Search in sources :

Example 6 with PerlInjectionMarkersService

use of com.perl5.lang.perl.idea.intellilang.PerlInjectionMarkersService in project Perl5-IDEA by Camelcade.

the class PerlStringCompletionUtil method fillWithHeredocOpeners.

public static void fillWithHeredocOpeners(@NotNull PerlCompletionProcessor completionProcessor) {
    Project project = completionProcessor.getProject();
    Set<String> heredocOpenersCache = PerlStringCompletionCache.getInstance(project).getHeredocOpenersCache();
    // cached values
    for (String marker : heredocOpenersCache) {
        if (completionProcessor.matches(marker) && !completionProcessor.process(LookupElementBuilder.create(marker))) {
            return;
        }
    }
    PerlInjectionMarkersService injectionService = PerlInjectionMarkersService.getInstance(project);
    // collect new values
    PsiFile file = completionProcessor.getContainingFile();
    file.accept(new PerlCompletionRecursiveVisitor(completionProcessor) {

        @Override
        public void visitHeredocOpener(@NotNull PsiPerlHeredocOpener o) {
            String openerName = o.getName();
            if (StringUtil.isNotEmpty(openerName) && heredocOpenersCache.add(openerName) && injectionService.getLanguageByMarker(openerName) == null && !completionProcessor.process(LookupElementBuilder.create(o, openerName))) {
                return;
            }
            super.visitHeredocOpener(o);
        }
    });
}
Also used : Project(com.intellij.openapi.project.Project) PerlInjectionMarkersService(com.perl5.lang.perl.idea.intellilang.PerlInjectionMarkersService) PsiFile(com.intellij.psi.PsiFile)

Aggregations

PerlInjectionMarkersService (com.perl5.lang.perl.idea.intellilang.PerlInjectionMarkersService)6 Test (org.junit.Test)3 LookupElementBuilder (com.intellij.codeInsight.lookup.LookupElementBuilder)1 Language (com.intellij.lang.Language)1 Project (com.intellij.openapi.project.Project)1 PsiFile (com.intellij.psi.PsiFile)1