com.intellij.lang.javascript.JavascriptLanguage Java Examples

The following examples show how to use com.intellij.lang.javascript.JavascriptLanguage. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RTJSBracesUtil.java    From react-templates-plugin with MIT License 6 votes vote down vote up
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;
}
 
Example #2
Source File: RTJSBracesUtil.java    From react-templates-plugin with MIT License 6 votes vote down vote up
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;
}
 
Example #3
Source File: BlazeTypescriptGotoDeclarationHandler.java    From intellij with Apache License 2.0 5 votes vote down vote up
private static boolean isJsIdentifier(PsiElement sourceElement) {
  return Optional.of(sourceElement)
      .filter(e -> e.getLanguage().is(JavascriptLanguage.INSTANCE))
      .filter(LeafPsiElement.class::isInstance)
      .map(LeafPsiElement.class::cast)
      .filter(e -> e.getElementType().equals(JSTokenTypes.IDENTIFIER))
      .isPresent();
}
 
Example #4
Source File: JavaScriptInjector.java    From idea-php-typo3-plugin with MIT License 4 votes vote down vote up
@Override
public void getLanguagesToInject(@NotNull PsiLanguageInjectionHost host, @NotNull InjectedLanguagePlaces injectionPlacesRegistrar) {
    if (getXmlFAssetJsContentPattern().accepts(host)) {
        injectionPlacesRegistrar.addPlace(JavascriptLanguage.INSTANCE, new TextRange(0, host.getTextLength()-1), null, null);
    }
}