Skip to content

Commit

Permalink
Add intention to remove trailing semicolon #80
Browse files Browse the repository at this point in the history
  • Loading branch information
xonixx committed May 15, 2023
1 parent fa03659 commit 278cc0e
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/main/java/intellij_awk/Awk.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ statement ::= action
| EXIT expr_opt
| RETURN expr_opt
| statement_do
| semicolonPsi newlines_opt
| SEMICOLON newlines_opt
| simple_statement
| gawk_statement_switch

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiElementVisitor;
import intellij_awk.psi.AwkSemicolonPsi;
import intellij_awk.psi.AwkStatement;
import intellij_awk.psi.AwkTypes;
import intellij_awk.psi.AwkVisitor;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -47,13 +46,7 @@ private static class DeleteUnnecessarySemicolonQuickFix implements LocalQuickFix

@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
PsiElement psiElement = descriptor.getPsiElement();
PsiElement parent = psiElement.getParent();
if (parent instanceof AwkStatement) {
parent.delete();
} else {
psiElement.delete();
}
descriptor.getPsiElement().delete();
}
}
}
16 changes: 14 additions & 2 deletions src/test/java/intellij_awk/AwkInspectionTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,20 @@ public void testUnnecessarySemicolon3() {
checkByFile(unnecessarySemicolon);
}

public void testUnnecessarySemicolon4() {
checkByFile(unnecessarySemicolon);
public void testUnnecessarySemicolonNecessary1() {
checkByFileNoProblemAtCaret(unnecessarySemicolon);
}

public void testUnnecessarySemicolonNecessary2() {
checkByFileNoProblemAtCaret(unnecessarySemicolon);
}

public void testUnnecessarySemicolonNecessary3() {
checkByFileNoProblemAtCaret(unnecessarySemicolon);
}

public void testUnnecessarySemicolonNecessary4() {
checkByFileNoProblemAtCaret(unnecessarySemicolon);
}

@Override
Expand Down
2 changes: 0 additions & 2 deletions src/test/testData/inspection/unnecessarySemicolon4After.awk

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
function f() { while(1);<caret> }
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function f() {
for(;;);<caret>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
if(1) ;<caret>
}

0 comments on commit 278cc0e

Please sign in to comment.