Skip to content

Commit

Permalink
[ fix #16 ] Improve tester logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ice1000 committed Apr 14, 2019
1 parent 782235a commit 9a06697
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/rs/pest/action/inline.kt
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,8 @@ class PestInlineProcessor(
.toTypedArray()

override fun performRefactoring(usages: Array<UsageInfo>) {
val grammarBody = rule.grammarBody
val expression = grammarBody?.expression ?: return
val newText = when (expression) {
val grammarBody = rule.grammarBody ?: return
val newText = when (val expression = grammarBody.expression ?: return) {
is PestString -> expression.text
is PestCharacter -> expression.text
is PestIdentifier -> expression.text
Expand Down
7 changes: 5 additions & 2 deletions src/rs/pest/action/ui/ui-impl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@ class PestIntroduceRulePopupImpl(
button.addActionListener {
val runnable = act@{
val document = myEditor.document
val grammarBody = elementToRename.grammarBody!!
val offset = newRuleStartOffset + grammarBody.startOffset
val grammarBody = elementToRename.grammarBody ?: return@act
val local = elementToRename.startOffset == 0
var offset = if (local) newRuleStartOffset + grammarBody.startOffset
else grammarBody.startOffset - 1
if (document.immutableCharSequence[offset] in "@!_$")
document.deleteString(offset, offset + 1)
else offset += 1
when (button) {
normal -> Unit
atomic -> document.insertString(offset, "@")
Expand Down

0 comments on commit 9a06697

Please sign in to comment.