use of com.perl5.lang.perl.idea.completion.providers.processors.PerlSimpleCompletionProcessor in project Perl5-IDEA by Camelcade.
the class PerlAnnotationCompletionProvider method addCompletions.
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, @NotNull ProcessingContext context, @NotNull CompletionResultSet resultSet) {
PerlSimpleCompletionProcessor completionProcessor = new PerlSimpleCompletionProcessor(parameters, resultSet, parameters.getPosition());
for (String annotation : TOKENS_MAP.keySet()) {
if (completionProcessor.matches(annotation)) {
if (!completionProcessor.process(LookupElementBuilder.create(TOKENS_MAP.get(annotation), annotation).withInsertHandler(PerlAnnotationInsertHandler.INSTANCE).withIcon(PerlIcons.ANNOTATION_GUTTER_ICON))) {
break;
}
}
}
completionProcessor.logStatus(getClass());
}
use of com.perl5.lang.perl.idea.completion.providers.processors.PerlSimpleCompletionProcessor in project Perl5-IDEA by Camelcade.
the class PerlPackageSubCompletionProvider method addCompletions.
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, @NotNull ProcessingContext context, @NotNull CompletionResultSet result) {
PsiElement method = parameters.getPosition().getParent();
if (!(method instanceof PsiPerlMethod)) {
LOG.warn("Expected PsiPerlMethod, got psiElement=[" + method.getClass() + "]; text=[" + method.getText() + "]");
return;
}
String explicitNamespace = ((PsiPerlMethod) method).getExplicitNamespaceName();
String currentPrefixMatcher = result.getPrefixMatcher().getPrefix();
String newPrefixMathcer = explicitNamespace == null ? currentPrefixMatcher : PerlPackageUtil.join(explicitNamespace, currentPrefixMatcher);
result = result.withPrefixMatcher(newPrefixMathcer);
PerlSimpleCompletionProcessor completionProcessor = new PerlSimpleCompletionProcessor(parameters, result, parameters.getPosition());
PerlTimeLogger logger = PerlTimeLogger.create(LOG);
if (!((PsiPerlMethod) method).isObjectMethod()) {
PerlPackageCompletionUtil.processAllNamespacesNames(completionProcessor, false, false);
logger.debug("Processed all namespace names");
} else {
if (!StringUtil.equals(PerlPackageUtil.SUPER_NAMESPACE_FULL, newPrefixMathcer)) {
PerlPackageCompletionUtil.processPackageLookupElementWithAutocomplete(null, PerlPackageUtil.SUPER_NAMESPACE_FULL, null, completionProcessor);
logger.debug("Processed all package lookups with autocomplete");
}
}
completionProcessor.logStatus(getClass());
}
use of com.perl5.lang.perl.idea.completion.providers.processors.PerlSimpleCompletionProcessor in project Perl5-IDEA by Camelcade.
the class PerlStringContentCompletionProvider method addCompletions.
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, @NotNull ProcessingContext context, @NotNull final CompletionResultSet result) {
PsiElement element = parameters.getPosition();
PsiElement parent = element.getParent();
if (parent instanceof PsiLanguageInjectionHost && PerlInjectionUtil.hasInjections(parent)) {
return;
}
PerlTimeLogger logger = PerlTimeLogger.create(LOG);
PerlSimpleCompletionProcessor completionProcessor = new PerlSimpleCompletionProcessor(parameters, result, element);
if (EXPORT_ASSIGNED_STRING_CONTENT.accepts(element)) {
// exporter assignments
PerlStringCompletionUtil.fillWithExportableEntities(completionProcessor);
logger.debug("Filled with exportable entities");
} else if (SIMPLE_HASH_INDEX.accepts(element)) {
// hash indexes
PsiPerlHashIndex indexElement = PsiTreeUtil.getParentOfType(element, PsiPerlHashIndex.class);
if (indexElement != null && indexElement.getParent() instanceof PsiPerlGlobSlot) {
PerlStringCompletionUtil.fillWithRefTypes(completionProcessor);
logger.debug("Filled with ref types");
} else {
PerlStringCompletionUtil.fillWithHashIndexes(completionProcessor);
logger.debug("Filled with hash indexes");
PerlVariableCompletionUtil.processVariables(new PerlVariableCompletionProcessorImpl(completionProcessor, null, false, false, false), logger);
PerlSubCompletionUtil.processContextSubsLookupElements(completionProcessor);
logger.debug("Filled with context subs lookup elements");
PerlPackageCompletionUtil.processAllNamespacesNames(completionProcessor, false, false);
logger.debug("Filled with namespace names");
}
} else if (USE_PARAMETERS_PATTERN.accepts(element)) {
// use or no parameters
PerlStringCompletionUtil.fillWithUseParameters(completionProcessor);
logger.debug("Filled with use parameters");
} else if (parent != null && parent.getParent() instanceof PsiPerlAnnotationInject) {
// #@Inject some
PerlStringCompletionUtil.fillWithInjectableMarkers(completionProcessor);
result.stopHere();
logger.debug("Filled with injectable markers");
} else if (STRING_CONTENT_IN_HEREDOC_OPENER_PATTERN.accepts(element)) {
// HERE-DOC openers
PerlStringCompletionUtil.fillWithInjectableMarkers(completionProcessor);
logger.debug("Filled with injectable markers in opener");
PerlStringCompletionUtil.fillWithHeredocOpeners(completionProcessor);
logger.debug("Filled with heredoc openers");
} else if (STRING_CONTENT_IN_LIST_OR_STRING_START.accepts(element)) {
// begin of string or qw element
PerlStringCompletionUtil.fillWithRefTypes(completionProcessor);
logger.debug("Filled with ref types");
PerlPackageCompletionUtil.processAllNamespacesNames(completionProcessor);
logger.debug("Processed namespace names");
}
completionProcessor.logStatus(getClass());
}
use of com.perl5.lang.perl.idea.completion.providers.processors.PerlSimpleCompletionProcessor in project Perl5-IDEA by Camelcade.
the class PodLinkCompletionProvider method addCompletions.
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, @NotNull ProcessingContext context, @NotNull CompletionResultSet result) {
PsiElement element = parameters.getPosition();
PsiElement linkPart = element.getParent();
PodFormatterL linkElement = PsiTreeUtil.getParentOfType(element, PodFormatterL.class);
if (linkElement == null) {
return;
}
IElementType parentType = PsiUtilCore.getElementType(linkPart);
PerlSimpleCompletionProcessor completionProcessor = new PerlSimpleCompletionProcessor(parameters, result, linkElement);
if (parentType == LINK_TEXT && element.getPrevSibling() == null) {
processFilesCompletions(completionProcessor);
}
if (parentType == LINK_NAME) {
processFilesCompletions(completionProcessor);
}
if (parentType == LINK_SECTION) {
addSectionsCompletions(linkElement.getTargetFile(), completionProcessor);
}
completionProcessor.logStatus(getClass());
}
use of com.perl5.lang.perl.idea.completion.providers.processors.PerlSimpleCompletionProcessor 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