use of com.perl5.lang.perl.idea.completion.providers.processors.PerlVariableCompletionProcessor in project Perl5-IDEA by Camelcade.
the class PerlVariableCompletionUtil method fillWithLexicalVariables.
public static void fillWithLexicalVariables(@NotNull PerlVariableCompletionProcessor variableCompletionProcessor) {
PsiElement perlVariable = variableCompletionProcessor.getLeafParentElement();
Processor<PerlVariableDeclarationElement> lookupProcessor = createLexicalLookupProcessor(new PerlDelegatingVariableCompletionProcessor(variableCompletionProcessor) {
@Override
public boolean isLexical() {
return true;
}
});
PsiScopeProcessor processor = (element, __) -> {
if (!(element instanceof PerlVariableDeclarationElement)) {
return true;
}
PerlVariableDeclarationElement variable = (PerlVariableDeclarationElement) element;
PsiElement declarationStatement = PsiTreeUtil.getParentOfType(variable, PerlStatement.class);
if (PsiTreeUtil.isAncestor(declarationStatement, perlVariable, false)) {
return true;
}
if (StringUtil.isNotEmpty(variable.getName())) {
boolean processResult = lookupProcessor.process(variable);
if (processResult && variable.isGlobalDeclaration()) {
variableCompletionProcessor.register(variable.getCanonicalNameWithSigil());
}
return processResult;
}
return true;
};
PerlResolveUtil.treeWalkUp(variableCompletionProcessor.getLeafElement(), processor);
}
use of com.perl5.lang.perl.idea.completion.providers.processors.PerlVariableCompletionProcessor in project Perl5-IDEA by Camelcade.
the class PerlHandleCompletionProvider method addCompletions.
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, @NotNull ProcessingContext context, @NotNull CompletionResultSet result) {
PsiElement position = parameters.getPosition();
if (!isApplicable(position)) {
return;
}
PerlTimeLogger logger = PerlTimeLogger.create(LOG);
PerlSimpleCompletionProcessor completionProcessor = new PerlSimpleCompletionProcessor(parameters, result, position);
PerlPackageCompletionUtil.processAllNamespacesNames(completionProcessor, false, false);
logger.debug("Processed namespace names");
PerlSubCompletionUtil.processContextSubsLookupElements(completionProcessor);
logger.debug("Processed context subs lookups");
if (Experiments.getInstance().isFeatureEnabled("perl5.completion.var.without.sigil")) {
PerlVariableCompletionProcessor variableCompletionProcessor = new PerlVariableCompletionProcessorImpl(completionProcessor, null, false, false, false);
PerlVariableCompletionUtil.processVariables(variableCompletionProcessor, logger);
}
completionProcessor.logStatus(getClass());
}
Aggregations