use of com.perl5.lang.perl.util.PerlTimeLogger 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.util.PerlTimeLogger 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.util.PerlTimeLogger in project Perl5-IDEA by Camelcade.
the class PerlVariableCompletionProvider method addCompletions.
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, @NotNull ProcessingContext context, @NotNull CompletionResultSet resultSet) {
if (!Experiments.getInstance().isFeatureEnabled("perl5.completion.var.without.sigil")) {
return;
}
PsiElement subName = parameters.getPosition();
PsiElement method = subName.getParent();
String namespaceName = null;
if (!(method instanceof PsiPerlMethod) || ((PsiPerlMethod) method).isObjectMethod()) {
return;
}
namespaceName = ((PsiPerlMethod) method).getExplicitNamespaceName();
if (StringUtil.isNotEmpty(namespaceName)) {
resultSet = resultSet.withPrefixMatcher(PerlPackageUtil.join(namespaceName, resultSet.getPrefixMatcher().getPrefix()));
}
PerlVariableCompletionProcessor variableCompletionProcessor = new PerlVariableCompletionProcessorImpl(parameters, resultSet, subName, namespaceName, false, false, false);
PerlTimeLogger logger = PerlTimeLogger.create(LOG);
PerlVariableCompletionUtil.processVariables(variableCompletionProcessor, logger);
variableCompletionProcessor.logStatus(getClass());
}
use of com.perl5.lang.perl.util.PerlTimeLogger in project Perl5-IDEA by Camelcade.
the class PerlVariableNameCompletionProvider method addCompletions.
@Override
public void addCompletions(@NotNull CompletionParameters parameters, @NotNull ProcessingContext context, @NotNull CompletionResultSet resultSet) {
PsiElement variableNameElement = parameters.getPosition();
String namespaceName = null;
if (variableNameElement instanceof PerlVariableNameElement) {
resultSet = resultSet.withPrefixMatcher(getVariableNamePrefix(variableNameElement, parameters.getOffset()));
PsiElement variable = variableNameElement.getParent();
if (variable instanceof PerlVariable) {
namespaceName = ((PerlVariable) variable).getExplicitNamespaceName();
}
}
boolean isDeclaration = VARIABLE_NAME_IN_DECLARATION_PATTERN.accepts(variableNameElement);
boolean hasBraces = VARIABLE_OPEN_BRACES.contains(PsiUtilCore.getElementType(variableNameElement.getPrevSibling()));
boolean isCapped = StringUtil.startsWithChar(resultSet.getPrefixMatcher().getPrefix(), '^');
PerlVariableCompletionProcessorImpl variableCompletionProcessor = new PerlVariableCompletionProcessorImpl(parameters, resultSet, variableNameElement, namespaceName, hasBraces, isDeclaration, false);
PerlTimeLogger timeLogger = new PerlTimeLogger(LOG);
// declaration helper
if (isDeclaration) {
PerlVariableCompletionUtil.fillWithUnresolvedVars(variableCompletionProcessor);
timeLogger.debug("Filled with unresolved variables");
} else if (!variableCompletionProcessor.isFullQualified()) {
if (!isCapped) {
PerlVariableCompletionUtil.fillWithLexicalVariables(variableCompletionProcessor);
timeLogger.debug("Filled with lexical variables");
}
PerlVariableCompletionUtil.fillWithBuiltInVariables(variableCompletionProcessor);
timeLogger.debug("Filled with built in variables");
}
// built ins
if (VARIABLE_NAME_IN_LOCAL_DECLARATION_PATTERN.accepts(variableNameElement)) {
PerlVariableCompletionUtil.fillWithBuiltInVariables(variableCompletionProcessor);
timeLogger.debug("Filled with built in variables");
}
// imports
if (!isCapped && !isDeclaration && !variableCompletionProcessor.isFullQualified()) {
PerlVariableCompletionUtil.fillWithImportedVariables(variableCompletionProcessor);
timeLogger.debug("Filled with imported variables");
}
// fqn names
if (!isCapped && !isDeclaration) {
PerlPackageCompletionUtil.processAllNamespacesNames(variableCompletionProcessor, true, false);
timeLogger.debug("Filled with namespace names");
PerlVariableCompletionUtil.processFullQualifiedVariables(variableCompletionProcessor);
timeLogger.debug("Filled with full qualified variables");
}
variableCompletionProcessor.logStatus(getClass());
}
use of com.perl5.lang.perl.util.PerlTimeLogger in project Perl5-IDEA by Camelcade.
the class PerlReparseableElementType method parseContents.
@Override
public ASTNode parseContents(@NotNull ASTNode chameleon) {
PerlTimeLogger logger = PerlTimeLogger.create(LOG);
PsiElement parentElement = chameleon.getTreeParent().getPsi();
Project project = parentElement.getProject();
CharSequence newChars = chameleon.getChars();
PsiBuilder builder = PsiBuilderFactory.getInstance().createBuilder(project, chameleon, createLexer(chameleon), getLanguage(), newChars);
ASTNode result = PerlParserImpl.INSTANCE.parse(this, builder).getFirstChildNode();
logger.trace("Parsed: ", PerlTimeLogger.kb(newChars.length()), " kb of ", this);
return result;
}
Aggregations