Search in sources :

Example 1 with PerlInjectionMarkersService

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

the class PerlStringCompletionUtil method fillWithInjectableMarkers.

public static void fillWithInjectableMarkers(@NotNull PerlCompletionProcessor completionProcessor) {
    // injectable markers
    PerlInjectionMarkersService injectionService = PerlInjectionMarkersService.getInstance(completionProcessor.getProject());
    for (String marker : injectionService.getSupportedMarkers()) {
        if (!completionProcessor.matches(marker)) {
            continue;
        }
        Language language = injectionService.getLanguageByMarker(marker);
        if (language == null) {
            continue;
        }
        LookupElementBuilder newItem = LookupElementBuilder.create(marker).withTypeText("inject with " + language.getDisplayName(), true);
        if (language.getAssociatedFileType() != null) {
            newItem = newItem.withIcon(language.getAssociatedFileType().getIcon());
        }
        if (!completionProcessor.process(newItem)) {
            return;
        }
    }
}
Also used : Language(com.intellij.lang.Language) PerlInjectionMarkersService(com.perl5.lang.perl.idea.intellilang.PerlInjectionMarkersService) LookupElementBuilder(com.intellij.codeInsight.lookup.LookupElementBuilder)

Example 2 with PerlInjectionMarkersService

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

the class PerlInjectionMarkersTest method doFileTest.

private void doFileTest() {
    PerlInjectionMarkersService markersService = PerlInjectionMarkersService.getInstance(getProject());
    initWithFileSmartWithoutErrors();
    assertNotInjected();
    markersService.setCustomMarkersMap(ContainerUtil.newHashMap(Pair.create(TEST_MARKER, HTMLLanguage.INSTANCE.getID())));
    FileContentUtil.reparseOpenedFiles();
    initWithFileSmartWithoutErrors();
    assertInjected();
}
Also used : PerlInjectionMarkersService(com.perl5.lang.perl.idea.intellilang.PerlInjectionMarkersService)

Example 3 with PerlInjectionMarkersService

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

the class PerlInjectionMarkersTest method testCustomMarkerAddition.

@Test
public void testCustomMarkerAddition() {
    PerlInjectionMarkersService markersService = PerlInjectionMarkersService.getInstance(getProject());
    assertNull(markersService.getLanguageByMarker(TEST_MARKER));
    markersService.setCustomMarkersMap(ContainerUtil.newHashMap(Pair.create(TEST_MARKER, HTMLLanguage.INSTANCE.getID())));
    assertEquals(HTMLLanguage.INSTANCE, markersService.getLanguageByMarker(TEST_MARKER));
}
Also used : PerlInjectionMarkersService(com.perl5.lang.perl.idea.intellilang.PerlInjectionMarkersService) Test(org.junit.Test)

Example 4 with PerlInjectionMarkersService

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

the class PerlInjectionMarkersTest method testMarkerOverride.

@Test
public void testMarkerOverride() {
    PerlInjectionMarkersService markersService = PerlInjectionMarkersService.getInstance(getProject());
    assertEquals(PerlLanguage.INSTANCE, markersService.getLanguageByMarker(PERL5_MARKER));
    markersService.setCustomMarkersMap(ContainerUtil.newHashMap(Pair.create(PERL5_MARKER, HTMLLanguage.INSTANCE.getID())));
    assertEquals(HTMLLanguage.INSTANCE, markersService.getLanguageByMarker(PERL5_MARKER));
    markersService.setCustomMarkersMap(Collections.emptyMap());
    assertEquals(PerlLanguage.INSTANCE, markersService.getLanguageByMarker(PERL5_MARKER));
}
Also used : PerlInjectionMarkersService(com.perl5.lang.perl.idea.intellilang.PerlInjectionMarkersService) Test(org.junit.Test)

Example 5 with PerlInjectionMarkersService

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

the class PerlInjectionMarkersTest method testMarkerCompletion.

@Test
public void testMarkerCompletion() {
    PerlInjectionMarkersService markersService = PerlInjectionMarkersService.getInstance(getProject());
    markersService.setCustomMarkersMap(ContainerUtil.newHashMap(Pair.create(TEST_MARKER, HTMLLanguage.INSTANCE.getID())));
    doTestCompletion();
}
Also used : PerlInjectionMarkersService(com.perl5.lang.perl.idea.intellilang.PerlInjectionMarkersService) Test(org.junit.Test)

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