Search in sources :

Example 6 with PerlTimeLogger

use of com.perl5.lang.perl.util.PerlTimeLogger in project Perl5-IDEA by Camelcade.

the class PerlEnterHandler method preprocessEnter.

@Override
public final Result preprocessEnter(@NotNull PsiFile file, @NotNull Editor editor, @NotNull Ref<Integer> caretOffset, @NotNull Ref<Integer> caretAdvance, @NotNull DataContext dataContext, EditorActionHandler originalHandler) {
    PerlTimeLogger logger = PerlTimeLogger.create(LOG);
    Result result = doPreprocessEnter(file, editor, caretOffset, caretAdvance, dataContext, originalHandler);
    logger.debug("Pre processed enter with " + getClass().getSimpleName());
    return result;
}
Also used : PerlTimeLogger(com.perl5.lang.perl.util.PerlTimeLogger)

Example 7 with PerlTimeLogger

use of com.perl5.lang.perl.util.PerlTimeLogger in project Perl5-IDEA by Camelcade.

the class PerlPackageProcessorBase method getImports.

@Override
@NotNull
public List<PerlExportDescriptor> getImports(@NotNull PerlUseStatementElement useStatement) {
    String packageName = useStatement.getPackageName();
    if (packageName == null) {
        return Collections.emptyList();
    }
    PerlTimeLogger logger = PerlTimeLogger.create(LOG);
    List<PerlExportDescriptor> result = new ArrayList<>();
    List<String> importParameters = getImportParameters(useStatement);
    Set<String> exportNames = new HashSet<>();
    Set<String> exportOkNames = new HashSet<>();
    addExports(useStatement, exportNames, exportOkNames);
    if (importParameters == null) {
        exportNames.forEach(name -> result.add(createDescriptor(packageName, name)));
    } else {
        importParameters.stream().filter(exportOkNames::contains).forEach(name -> result.add(createDescriptor(packageName, name)));
    }
    logger.debug("Collected imports for ", packageName);
    return result;
}
Also used : PerlTimeLogger(com.perl5.lang.perl.util.PerlTimeLogger) NotNull(org.jetbrains.annotations.NotNull)

Example 8 with PerlTimeLogger

use of com.perl5.lang.perl.util.PerlTimeLogger in project Perl5-IDEA by Camelcade.

the class PerlEnterHandler method postProcessEnter.

@Override
public final Result postProcessEnter(@NotNull PsiFile file, @NotNull Editor editor, @NotNull DataContext dataContext) {
    PerlTimeLogger logger = PerlTimeLogger.create(LOG);
    Result result = doPostProcessEnter(file, editor, dataContext);
    logger.debug("Post processed enter with " + getClass().getSimpleName());
    return result;
}
Also used : PerlTimeLogger(com.perl5.lang.perl.util.PerlTimeLogger)

Example 9 with PerlTimeLogger

use of com.perl5.lang.perl.util.PerlTimeLogger in project Perl5-IDEA by Camelcade.

the class PerlFormattingModelBuilder method createModel.

@Override
@NotNull
public FormattingModel createModel(@NotNull FormattingContext formattingContext) {
    var element = formattingContext.getPsiElement();
    var range = formattingContext.getFormattingRange();
    var settings = formattingContext.getCodeStyleSettings();
    var mode = formattingContext.getFormattingMode();
    PerlTimeLogger logger = PerlTimeLogger.create(LOG);
    TextRange computedRange = COMPUTED_RANGE_KEY.get(element);
    COMPUTED_RANGE_KEY.set(element, null);
    if (computedRange != null && range.contains(computedRange)) {
        LOG.debug("Got pre-computed range: ", computedRange);
        range = computedRange;
    } else {
        LOG.debug("No pre-computed range, trying to reduce provided:", range);
        range = computeFormattingRange(element.getContainingFile(), range);
    }
    PerlFormattingBlock rootBlock = new PerlFormattingBlock(element.getNode(), new PurePerlFormattingContext(formattingContext, range));
    PerlDocumentBasedFormattingModel model = new PerlDocumentBasedFormattingModel(rootBlock, element, settings);
    if (LOG.isDebugEnabled()) {
        logger.debug("Created model for: ", element.getNode(), "; range: ", range, "; settings: ", settings, "; mode: ", mode);
        if (LOG.isTraceEnabled()) {
            LOG.trace("Tree size: " + computeTreeSize(rootBlock));
        }
    }
    return model;
}
Also used : PerlTimeLogger(com.perl5.lang.perl.util.PerlTimeLogger) TextRange(com.intellij.openapi.util.TextRange) PerlFormattingBlock(com.perl5.lang.perl.idea.formatter.blocks.PerlFormattingBlock) NotNull(org.jetbrains.annotations.NotNull)

Example 10 with PerlTimeLogger

use of com.perl5.lang.perl.util.PerlTimeLogger in project Perl5-IDEA by Camelcade.

the class PerlPackageCompletionUtil method processFirstNamespaceForEachName.

/**
 * Iterates all namespaces in {@code project} and {@code searchScope}, and processes the first element with each name with
 * {@code namespaceProcessor}
 */
public static boolean processFirstNamespaceForEachName(@NotNull PerlCompletionProcessor completionProcessor, @NotNull Project project, @NotNull GlobalSearchScope searchScope, @NotNull Processor<PerlNamespaceDefinitionElement> namespaceProcessor) {
    PerlTimeLogger logger = PerlTimeLogger.create(LOG);
    Collection<String> names = PerlPackageUtil.getKnownNamespaceNames(searchScope);
    logger.debug("Collected all namespaces names: ", names.size());
    for (String packageName : names) {
        if (!completionProcessor.matches(packageName)) {
            continue;
        }
        PerlPackageUtil.processNamespaces(packageName, project, searchScope, namespace -> {
            String name = namespace.getNamespaceName();
            if (StringUtil.isNotEmpty(name)) {
                char firstChar = name.charAt(0);
                if (firstChar == '_' || Character.isLetterOrDigit(firstChar)) {
                    namespaceProcessor.process(namespace);
                    completionProcessor.register(namespace.getNamespaceName());
                    return false;
                }
            }
            return false;
        });
        if (!completionProcessor.result()) {
            LOG.debug("Processor is full");
            return false;
        }
    }
    logger.debug("Collected namespaces from indexes");
    return completionProcessor.result();
}
Also used : PerlTimeLogger(com.perl5.lang.perl.util.PerlTimeLogger)

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