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;
}
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;
}
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;
}
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;
}
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();
}
Aggregations