use of org.intellij.plugins.markdown.injection.CodeFenceLanguageProvider in project intellij-plugins by JetBrains.
the class LanguageListCompletionTest method testCustomCompletionProvider.
public void testCustomCompletionProvider() {
try {
PlatformTestUtil.registerExtension(CodeFenceLanguageProvider.EP_NAME, new CodeFenceLanguageProvider() {
@Nullable
@Override
public Language getLanguageByInfoString(@NotNull String infoString) {
return null;
}
@NotNull
@Override
public List<LookupElement> getCompletionVariantsForInfoString(@NotNull CompletionParameters parameters) {
return Collections.singletonList(LookupElementBuilder.create("{js is a great ecma}").withInsertHandler((context, item) -> {
context.getDocument().insertString(context.getEditor().getCaretModel().getOffset(), "Customized insertion");
context.getEditor().getCaretModel().moveCaretRelatively("Customized insertion".length(), 0, true, false, true);
}));
}
}, myFixture.getTestRootDisposable());
LanguageGuesser.INSTANCE.resetCodeFenceLanguageProviders();
configure();
myFixture.completeBasic();
assertContainsElements(myFixture.getLookupElementStrings(), "js", "javascript", "{js is a great ecma}");
myFixture.type("ecm\t");
checkResult();
} finally {
LanguageGuesser.INSTANCE.resetCodeFenceLanguageProviders();
}
}
Aggregations