public static boolean hasConflicts(String start, String end, PsiElement element) { final Language elementLanguage = element.getLanguage(); // JSP contains two roots that contain XmlText, don't inject anything in JSP root to prevent double injections if ("JSP".equals(elementLanguage.getDisplayName())) { return true; } PsiFile file = element.getContainingFile(); if (DEFAULT_START.equals(start) || DEFAULT_END.equals(end)) { // JSX attributes don't contain AngularJS injections, {{}} is JSX injection with object inside if (elementLanguage.isKindOf(JavascriptLanguage.INSTANCE)) return true; for (Language language : file.getViewProvider().getLanguages()) { if (DEFAULT_CONFLICTS.contains(language.getDisplayName())) { return true; } } } return false; }
public static @NotNull JavascriptLanguage getJSLang () { Language js = Language.findLanguageByID(JS_ID); if (js == null) { return JavascriptLanguage.INSTANCE; } return (JavascriptLanguage) js; }
@Test public void shouldBuildTranslationForJavascriptStringInJsFile() { //given when(typeResolver.isJsLiteral(psiElement)).thenReturn(true); when(typeResolver.getFileLanguage(psiElement)).thenReturn(JavascriptLanguage.INSTANCE); //when String content = contentCreator.buildTranslation("key", psiElement); //then assertEquals("t('key')", content); }
public MediaWikiJsPredefinedCodeStyle() { super("MediaWiki", JavascriptLanguage.INSTANCE); }
public LiveScriptLanguage() { super(JavascriptLanguage.INSTANCE, "LiveScript", new String[] { "text/ls" }); }