Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve auto complete for this case #186 #217

Merged
merged 3 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions src/main/java/intellij_awk/Awk.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -502,15 +502,11 @@ lvalue ::= gawk_var_name | DOLLAR expr

// XXX this covers a[1][2][3] like in Gawk
// XXX awk only supports a[1]
private gawk_var_name ::= var_name (LBRACKET expr_lst RBRACKET)*

// XXX for some reason the below makes it terribly slow or hanging on profile5.awk
/*private gawk_var_name ::= var_name (subscript_start RBRACKET)*
private subscript_start ::= LBRACKET expr_lst {
private gawk_var_name ::= var_name (subscript_start RBRACKET)*
private subscript_start ::= LBRACKET expr_lst
{
pin=1
recoverWhile=recover_on_rbracket
}
private recover_on_rbracket ::= !RBRACKET*/

private var_name ::= builtin_var_name | user_var_name

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/intellij_awk/AwkParserDefinition.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class AwkParserDefinition implements ParserDefinition {
new IStubFileElementType<>(AwkLanguage.INSTANCE) {
@Override
public int getStubVersion() {
return 16;
return 17;
}

@Override
Expand Down
15 changes: 13 additions & 2 deletions src/test/java/intellij_awk/AwkCompletionTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -430,21 +430,32 @@ public void testLocalVariableInAction3() {
}

public void testGlobalVariableInAction1() {
checkCompletionAuto("{ Xxx=1 } function f(){ Xx<caret> }", "{ Xxx=1 } function f(){ Xxx<caret> }");
checkCompletionAuto(
"{ Xxx=1 } function f(){ Xx<caret> }", "{ Xxx=1 } function f(){ Xxx<caret> }");
}

public void testGlobalVariableInAction2() {
checkCompletionAuto("{ Xxx=1 }\nXx<caret>", "{ Xxx=1 }\nXxx<caret>");
}

public void testGlobalVariableInAction3() {
checkCompletionAuto("/a/{ xxx=1 } /b/{ xx<caret> }", "/a/{ xxx=1 } /b/{ xxx<caret> }");
}

public void testGlobalVariableInAction4() {
checkCompletionAuto("function f(){ Xxx=1 } { Xx<caret> }", "function f(){ Xxx=1 } { Xxx<caret> }");
checkCompletionAuto(
"function f(){ Xxx=1 } { Xx<caret> }", "function f(){ Xxx=1 } { Xxx<caret> }");
}

public void testGlobalVariableInAction5_NotLocal() {
checkCompletionEmpty("function f(Xxx){ Xxx=1 } { Xx<caret> }");
}

public void testMustCompleteInsideEmptySubscript() {
checkCompletion(
Set.of("q1q2q3"), Set.of(), "BEGIN {\n a[<caret>]\n}\n\nfunction q1q2q3() {\n}");
}

private void checkFunctionArgs(String code, String fName, String expectedArgs) {
setupCode(code);
LookupElement[] variants = myFixture.completeBasic();
Expand Down
Loading