use of org.ballerinalang.plugins.idea.psi.scopes.RestrictedScope in project ballerina by ballerina-lang.
the class BallerinaPsiImplUtil method getAllLocalVariablesInResolvableScope.
/**
* Returns all local variables in provided scope and all parent contexts.
*
* @param scope
* @param caretOffset
* @return
*/
@NotNull
public static List<IdentifierPSINode> getAllLocalVariablesInResolvableScope(@NotNull ScopeNode scope, int caretOffset) {
List<IdentifierPSINode> results = new LinkedList<>();
if (scope instanceof VariableContainer || scope instanceof CodeBlockScope) {
results.addAll(getAllLocalVariablesInScope(scope, caretOffset));
ScopeNode context = scope.getContext();
if (context != null && !(scope instanceof RestrictedScope)) {
results.addAll(getAllLocalVariablesInResolvableScope(context, caretOffset));
}
} else if (scope instanceof ParameterContainer || scope instanceof LowerLevelDefinition) {
ScopeNode context = scope.getContext();
if (context != null) {
results.addAll(getAllLocalVariablesInResolvableScope(context, caretOffset));
}
}
return results;
}
Aggregations