@Nullable protected static HtmlScriptContentProvider findScriptContentProvider(@Nullable String mimeType) { if (StringUtil.isEmpty(mimeType)) { return ourDefaultLanguage != null ? LanguageHtmlScriptContentProvider.getScriptContentProvider(ourDefaultLanguage) : null; } Collection<Language> instancesByMimeType = Language.findInstancesByMimeType(mimeType.trim()); if (instancesByMimeType.isEmpty() && mimeType.contains("template")) { instancesByMimeType = Collections.<Language>singletonList(HTMLLanguage.INSTANCE); } for (Language language : instancesByMimeType) { HtmlScriptContentProvider scriptContentProvider = LanguageHtmlScriptContentProvider.getScriptContentProvider(language); if (scriptContentProvider != null) { return scriptContentProvider; } } return null; }
@Nullable protected HtmlScriptContentProvider findScriptContentProvider(@Nullable String mimeType) { if(StringUtil.isEmpty(mimeType)) { return ourDefaultLanguage != null ? LanguageHtmlScriptContentProvider.getScriptContentProvider(ourDefaultLanguage) : null; } Collection<Language> instancesByMimeType = Language.findInstancesByMimeType(mimeType.trim()); if(instancesByMimeType.isEmpty() && mimeType.contains("template")) { instancesByMimeType = Collections.singletonList(HTMLLanguage.INSTANCE); } for(Language language : instancesByMimeType) { HtmlScriptContentProvider scriptContentProvider = LanguageHtmlScriptContentProvider.getScriptContentProvider(language); if(scriptContentProvider != null) { return scriptContentProvider; } } return null; }
@Nullable protected static HtmlScriptContentProvider findScriptContentProvider(@Nullable String mimeType) { if (StringUtil.isEmpty(mimeType)) { return ourDefaultLanguage != null ? LanguageHtmlScriptContentProvider.getScriptContentProvider(ourDefaultLanguage) : null; } Collection<Language> instancesByMimeType = Language.findInstancesByMimeType(mimeType != null ? mimeType.trim() : null); for (Language language : instancesByMimeType) { HtmlScriptContentProvider scriptContentProvider = LanguageHtmlScriptContentProvider.getScriptContentProvider(language); if (scriptContentProvider != null) { return scriptContentProvider; } } return null; }
@Nullable protected IElementType getCurrentScriptElementType() { HtmlScriptContentProvider scriptContentProvider = findScriptContentProvider(scriptType); return scriptContentProvider == null ? null : scriptContentProvider.getScriptElementType(); }
private void setEmbeddedLexer() { Lexer newLexer = null; if (hasSeenStyle()) { if (styleLexer == null) { if (ourStyleFileType == null) { styleLexer = null; } else { SyntaxHighlighter highlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(ourStyleFileType, null, null); LOG.assertTrue(highlighter != null, ourStyleFileType); styleLexer = highlighter.getHighlightingLexer(); } } newLexer = styleLexer; } else if (hasSeenScript()) { Lexer scriptLexer = scriptLexers.get(scriptType); if (scriptLexer == null) { if (hasSeenTag()) { HtmlScriptContentProvider provider = findScriptContentProvider(scriptType); if (provider != null) { scriptLexer = provider.getHighlightingLexer(); } else { scriptLexer = SyntaxHighlighterFactory.getSyntaxHighlighter(PlainTextLanguage.INSTANCE, null, null).getHighlightingLexer(); } } else if (hasSeenAttribute()) { SyntaxHighlighter syntaxHighlighter = ourInlineScriptFileType != null ? SyntaxHighlighterFactory.getSyntaxHighlighter(ourInlineScriptFileType, null, null) : null; scriptLexer = syntaxHighlighter != null ? syntaxHighlighter.getHighlightingLexer() : null; } scriptLexers.put(scriptType, scriptLexer); } newLexer = scriptLexer; } else { newLexer = createELLexer(newLexer); } if (newLexer != null) { embeddedLexer = newLexer; } }