Search in sources :

Example 11 with PerlTimeLogger

use of com.perl5.lang.perl.util.PerlTimeLogger 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());
}
Also used : PerlVariableCompletionProcessorImpl(com.perl5.lang.perl.idea.completion.providers.processors.PerlVariableCompletionProcessorImpl) PerlVariableCompletionProcessor(com.perl5.lang.perl.idea.completion.providers.processors.PerlVariableCompletionProcessor) PerlTimeLogger(com.perl5.lang.perl.util.PerlTimeLogger) PerlSimpleCompletionProcessor(com.perl5.lang.perl.idea.completion.providers.processors.PerlSimpleCompletionProcessor) PsiElement(com.intellij.psi.PsiElement)

Example 12 with PerlTimeLogger

use of com.perl5.lang.perl.util.PerlTimeLogger 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());
}
Also used : ProcessingContext(com.intellij.util.ProcessingContext) CompletionResultSet(com.intellij.codeInsight.completion.CompletionResultSet) LookupElementBuilder(com.intellij.codeInsight.lookup.LookupElementBuilder) StringUtil(com.intellij.openapi.util.text.StringUtil) CompletionParameters(com.intellij.codeInsight.completion.CompletionParameters) PsiElement(com.intellij.psi.PsiElement) PerlSimpleCompletionProcessor(com.perl5.lang.perl.idea.completion.providers.processors.PerlSimpleCompletionProcessor) PerlPsiUtil(com.perl5.lang.perl.psi.utils.PerlPsiUtil) PerlElementPatterns(com.perl5.lang.perl.idea.PerlElementPatterns) NotNull(org.jetbrains.annotations.NotNull) PerlTimeLogger(com.perl5.lang.perl.util.PerlTimeLogger) PerlTimeLogger(com.perl5.lang.perl.util.PerlTimeLogger) PerlSimpleCompletionProcessor(com.perl5.lang.perl.idea.completion.providers.processors.PerlSimpleCompletionProcessor) PsiElement(com.intellij.psi.PsiElement)

Example 13 with PerlTimeLogger

use of com.perl5.lang.perl.util.PerlTimeLogger 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());
}
Also used : PerlTimeLogger(com.perl5.lang.perl.util.PerlTimeLogger) PerlSimpleCompletionProcessor(com.perl5.lang.perl.idea.completion.providers.processors.PerlSimpleCompletionProcessor) PsiElement(com.intellij.psi.PsiElement)

Example 14 with PerlTimeLogger

use of com.perl5.lang.perl.util.PerlTimeLogger 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());
}
Also used : PerlCallStaticValue(com.perl5.lang.perl.idea.codeInsight.typeInference.value.PerlCallStaticValue) PsiPerlMethod(com.perl5.lang.perl.psi.PsiPerlMethod) PerlCallValue(com.perl5.lang.perl.idea.codeInsight.typeInference.value.PerlCallValue) PerlTimeLogger(com.perl5.lang.perl.util.PerlTimeLogger) PerlSimpleCompletionProcessor(com.perl5.lang.perl.idea.completion.providers.processors.PerlSimpleCompletionProcessor) PsiElement(com.intellij.psi.PsiElement)

Example 15 with PerlTimeLogger

use of com.perl5.lang.perl.util.PerlTimeLogger 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());
}
Also used : PerlSubElement(com.perl5.lang.perl.psi.PerlSubElement) PerlTimeLogger(com.perl5.lang.perl.util.PerlTimeLogger) PerlSimpleCompletionProcessor(com.perl5.lang.perl.idea.completion.providers.processors.PerlSimpleCompletionProcessor) PerlCompletionProcessor(com.perl5.lang.perl.idea.completion.providers.processors.PerlCompletionProcessor) PsiElement(com.intellij.psi.PsiElement)

Aggregations

PerlTimeLogger (com.perl5.lang.perl.util.PerlTimeLogger)17 PsiElement (com.intellij.psi.PsiElement)10 PerlSimpleCompletionProcessor (com.perl5.lang.perl.idea.completion.providers.processors.PerlSimpleCompletionProcessor)8 PerlVariableCompletionProcessorImpl (com.perl5.lang.perl.idea.completion.providers.processors.PerlVariableCompletionProcessorImpl)4 PsiPerlMethod (com.perl5.lang.perl.psi.PsiPerlMethod)3 NotNull (org.jetbrains.annotations.NotNull)3 PerlVariableCompletionProcessor (com.perl5.lang.perl.idea.completion.providers.processors.PerlVariableCompletionProcessor)2 CompletionParameters (com.intellij.codeInsight.completion.CompletionParameters)1 CompletionResultSet (com.intellij.codeInsight.completion.CompletionResultSet)1 LookupElementBuilder (com.intellij.codeInsight.lookup.LookupElementBuilder)1 Project (com.intellij.openapi.project.Project)1 TextRange (com.intellij.openapi.util.TextRange)1 StringUtil (com.intellij.openapi.util.text.StringUtil)1 PsiLanguageInjectionHost (com.intellij.psi.PsiLanguageInjectionHost)1 ProcessingContext (com.intellij.util.ProcessingContext)1 PerlElementPatterns (com.perl5.lang.perl.idea.PerlElementPatterns)1 PerlCallStaticValue (com.perl5.lang.perl.idea.codeInsight.typeInference.value.PerlCallStaticValue)1 PerlCallValue (com.perl5.lang.perl.idea.codeInsight.typeInference.value.PerlCallValue)1 PerlCompletionProcessor (com.perl5.lang.perl.idea.completion.providers.processors.PerlCompletionProcessor)1 PerlFormattingBlock (com.perl5.lang.perl.idea.formatter.blocks.PerlFormattingBlock)1