Skip to content

Commit

Permalink
False positive warning "Function ... is never used" #214 : more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xonixx committed Apr 17, 2024
1 parent 060dada commit 27cd90a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/main/java/intellij_awk/psi/AwkElementFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ public static AwkFunctionName createFunctionName(Project project, String name) {
return createAwkPsiElement(project, "function " + name + "(){}", AwkFunctionName.class);
}

public static AwkStr createString(Project project, String str) {
return createAwkPsiElement(
project, "{ a = \"" + str.replace("\"", "\\\"") + "\" }", AwkStr.class);
}

public static AwkItem createFunctionItem(Project project, String name) {
return createAwkPsiElement(project, "function " + name + "(){}", AwkItem.class);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/intellij_awk/psi/AwkStringMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static boolean canBeFunctionName(String s) {
}

public PsiElement setName(String newName) {
return replaceNameNode(AwkElementFactory.createFunctionCallName(getProject(), newName));
return replaceNameNode(AwkElementFactory.createString(getProject(), newName));
}

@Override
Expand Down
1 change: 1 addition & 0 deletions src/test/java/intellij_awk/AwkRenameTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class AwkRenameTests extends BasePlatformTestCase {
public void testVars6() { checkByFile(); }
public void testVars7() { checkByFile(); }
public void testFunc1() { checkByFile(); }
public void testFuncRef() { checkByFile(); }
public void testIndirect1() { checkByFile(); }

@Override
Expand Down
8 changes: 8 additions & 0 deletions src/test/testData/rename/funcRef.awk
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
BEGIN {
a = "fname"
b("fname")
substr("fname")
print "fname"
}
function b() {}
function fname<caret>() {}
8 changes: 8 additions & 0 deletions src/test/testData/rename/funcRefAfter.awk
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
BEGIN {
a = "newName"
b("newName")
substr("fname")
print "fname"
}
function b() {}
function newName<caret>() {}

0 comments on commit 27cd90a

Please sign in to comment.