use of com.perl5.lang.perl.idea.completion.providers.processors.PerlSimpleCompletionProcessor in project Perl5-IDEA by Camelcade.
the class PerlLabelCompletionProvider method addCompletions.
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, @NotNull ProcessingContext context, @NotNull final CompletionResultSet result) {
final PsiElement element = parameters.getOriginalPosition();
if (element == null) {
return;
}
PerlTimeLogger logger = PerlTimeLogger.create(LOG);
PerlSimpleCompletionProcessor completionProcessor = new PerlSimpleCompletionProcessor(parameters, result, element);
if (LABEL_DECLARATION_PATTERN.accepts(element)) {
// unresolved labels should be here
} else if (LABEL_IN_GOTO_PATTERN.accepts(element)) {
PerlPsiUtil.processGotoLabelDeclarations(element, perlLabelDeclaration -> {
if (perlLabelDeclaration != null) {
String labelName = perlLabelDeclaration.getName();
if (StringUtil.isNotEmpty(labelName) && completionProcessor.matches(labelName)) {
return completionProcessor.process(LookupElementBuilder.create(perlLabelDeclaration, labelName));
}
}
return completionProcessor.result();
});
logger.debug("Processed goto label declarations");
} else if (LABEL_IN_NEXT_LAST_REDO_PATTERN.accepts(element)) {
PerlPsiUtil.processNextRedoLastLabelDeclarations(element, perlLabelDeclaration -> {
if (perlLabelDeclaration != null) {
String labelName = perlLabelDeclaration.getName();
if (StringUtil.isNotEmpty(labelName) && completionProcessor.matches(labelName)) {
return completionProcessor.process(LookupElementBuilder.create(perlLabelDeclaration, labelName));
}
}
return completionProcessor.result();
});
logger.debug("Processed next redo label declarations");
}
completionProcessor.logStatus(getClass());
}
use of com.perl5.lang.perl.idea.completion.providers.processors.PerlSimpleCompletionProcessor in project Perl5-IDEA by Camelcade.
the class PerlPackageCompletionProvider method addCompletions.
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, @NotNull ProcessingContext context, @NotNull CompletionResultSet result) {
PsiElement element = parameters.getPosition();
PerlSimpleCompletionProcessor completionProcessor = new PerlSimpleCompletionProcessor(parameters, result, element);
PerlTimeLogger logger = PerlTimeLogger.create(LOG);
if (NAMESPACE_IN_DEFINITION_PATTERN.accepts(element)) {
// package Foo
PerlPackageCompletionUtil.fillWithNamespaceNameSuggestions(completionProcessor);
logger.debug("Filled with NS suggestions");
} else if (NAMESPACE_IN_VARIABLE_DECLARATION_PATTERN.accepts(element)) {
// my Foo::Bar
PerlPackageCompletionUtil.processAllNamespacesNames(completionProcessor);
logger.debug("Processed all namespace names");
} else if (NAMESPACE_IN_ANNOTATION_PATTERN.accepts(element)) {
// #@returns / #@type
completionProcessor.processSingle(LookupElementBuilder.create("ArrayRef").withInsertHandler(PerlInsertHandlers.ARRAY_ELEMENT_INSERT_HANDLER).withTailText("[]"));
completionProcessor.processSingle(LookupElementBuilder.create("HashRef").withInsertHandler(PerlInsertHandlers.ARRAY_ELEMENT_INSERT_HANDLER).withTailText("[]"));
PerlPackageCompletionUtil.processAllNamespacesNames(completionProcessor);
logger.debug("Processed all namespace names");
} else if (NAMESPACE_IN_USE_PATTERN.accepts(element)) {
// use/no/require
PerlPackageCompletionUtil.fillWithVersionNumbers(completionProcessor);
logger.debug("Processed all version numbers");
PerlPackageCompletionUtil.fillWithAllPackageFiles(completionProcessor);
logger.debug("Processed all package files");
} else {
// fallback
PerlPackageCompletionUtil.processAllNamespacesNames(completionProcessor);
logger.debug("Processed all namespace names");
}
completionProcessor.logStatus(getClass());
}
use of com.perl5.lang.perl.idea.completion.providers.processors.PerlSimpleCompletionProcessor in project Perl5-IDEA by Camelcade.
the class PerlSubCallCompletionProvider method addCompletions.
@Override
public void addCompletions(@NotNull CompletionParameters parameters, @NotNull ProcessingContext context, @NotNull CompletionResultSet resultSet) {
PsiElement position = parameters.getPosition();
PsiElement method = position.getParent();
assert method instanceof PsiPerlMethod;
PerlCallValue perlValue = PerlCallValue.from(method);
if (perlValue == null) {
return;
}
PerlSimpleCompletionProcessor completionProcessor = new PerlSimpleCompletionProcessor(parameters, resultSet, position);
PerlTimeLogger logger = PerlTimeLogger.create(LOG);
if (perlValue instanceof PerlCallStaticValue && !((PerlCallStaticValue) perlValue).hasExplicitNamespace()) {
PerlSubCompletionUtil.processBuiltInSubsLookupElements(completionProcessor);
logger.debug("Processed built-in subs");
}
PerlSubCompletionUtil.processSubsCompletionsForCallValue(completionProcessor, perlValue, perlValue instanceof PerlCallStaticValue);
logger.debug("Processed subs for call value");
completionProcessor.logStatus(getClass());
}
use of com.perl5.lang.perl.idea.completion.providers.processors.PerlSimpleCompletionProcessor in project Perl5-IDEA by Camelcade.
the class PerlSubNameElementCompletionProvider method addCompletions.
@Override
public void addCompletions(@NotNull CompletionParameters parameters, @NotNull ProcessingContext context, @NotNull CompletionResultSet resultSet) {
PsiElement element = parameters.getPosition();
if (!(element.getParent() instanceof PerlSubElement)) {
return;
}
PerlCompletionProcessor completionProcessor = new PerlSimpleCompletionProcessor(parameters, resultSet, element);
PerlTimeLogger logger = PerlTimeLogger.create(LOG);
PerlSubElement subDefinitionBase = (PerlSubElement) element.getParent();
PerlSubCompletionUtil.processUnresolvedSubsLookups(subDefinitionBase, completionProcessor);
logger.debug("Processed unresolved subs");
PerlSubCompletionUtil.processWithNotOverriddenSubs(subDefinitionBase, completionProcessor);
logger.debug("Processed not overriden subs");
completionProcessor.logStatus(getClass());
}
use of com.perl5.lang.perl.idea.completion.providers.processors.PerlSimpleCompletionProcessor in project Perl5-IDEA by Camelcade.
the class PerlUnicodeNamesCompletionProvider method addCompletions.
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, @NotNull ProcessingContext context, @NotNull CompletionResultSet result) {
PerlSimpleCompletionProcessor completionProcessor = new PerlSimpleCompletionProcessor(parameters, result.caseInsensitive(), parameters.getPosition());
Map<String, String> cache = myNamesCacheRef.get();
if (cache == null) {
LOG.debug("Cache been collected, re-init");
cache = new HashMap<>();
myCodePoint = 0;
myNamesCacheRef = new SoftReference<>(cache);
}
PerlTimeLogger logger = PerlTimeLogger.create(LOG);
fillCached(completionProcessor, cache);
logger.debug("Filled cached unicode names");
lazyCache(completionProcessor, cache);
logger.debug("Lazily populated cache of unicode names");
if (LOG.isDebugEnabled()) {
LOG.debug("Cached entries: ", cache.size(), "; data size, mb: ", (float) myDataSize / 1024 / 1024);
}
completionProcessor.logStatus(getClass());
}
Aggregations