Skip to content

Commit

Permalink
Fix completion within functions (#439)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusAmshove authored Dec 1, 2023
2 parents 59a49d2 + cfc68e0 commit d931fd9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -310,4 +310,20 @@ void filterVariableCompletionBasedOnTypedQualificationOnTriggerCharWhenVariables
""")
.assertContainsVariableCompleting("#VARIABLE :(A10) (SUB)", "#VARIABLE");
}

@Test
void containAFunctionsImplicitReturnVariable()
{
assertCompletions("LIBONE", "FUNC.NS7", """
DEFINE FUNCTION FUNC RETURNS (A1)
DEFINE DATA LOCAL
1 #VAR (A10)
END-DEFINE
${}$
END-FUNCTION
END
""")
.assertContainsVariable("FUNC :(A1) (FUNC)")
.assertContainsVariable("#VAR :(A10) (FUNC)");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,14 @@ protected void nodeAdded(BaseSyntaxNode node)
}
}

/**
* Do not use this, exists temporarly for functions
*/
void addVariable(IVariableNode variable)
{
variables.add(variable);
}

private void addAllVariablesFromUsing(IUsingNode usingNode)
{
if (usingNode.defineData() == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ private NaturalModule parseModule(NaturalFile file, IModuleProvider moduleProvid
topLevelNodes.add(parseDefineData(tokens, moduleProvider, naturalModule));
if (file.getFiletype() == NaturalFileType.FUNCTION && naturalModule.defineData() != null && functionReturnVariable != null)
{
((DefineDataNode) naturalModule.defineData()).addNode(functionReturnVariable);
var defineData = (DefineDataNode) naturalModule.defineData();
defineData.addVariable(functionReturnVariable);
naturalModule.addReferencableNodes(List.of(functionReturnVariable));
}
}

Expand Down

0 comments on commit d931fd9

Please sign in to comment.