public SoyLayeredHighlighter( @Nullable Project project, @Nullable VirtualFile virtualFile, @NotNull EditorColorsScheme colors) { // Creating main highlighter. super(new SoySyntaxHighlighter(), colors); // Highlighter for the outer language. FileType type = null; if (project == null || virtualFile == null) { type = StdFileTypes.PLAIN_TEXT; } else { Language language = TemplateDataLanguageMappings.getInstance(project).getMapping(virtualFile); if (language != null) type = language.getAssociatedFileType(); if (type == null) type = SoyLanguage.getDefaultTemplateLang(); } SyntaxHighlighter outerHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(type, project, virtualFile); registerLayer(OTHER, new LayerDescriptor(outerHighlighter, "")); }
private EditorHighlighter createHighlighter(LanguageFileType fileType) { // FileType fileType = FileTypeManager.getInstance().getFileTypeByExtension(""); // if (fileType == null) { // fileType = FileTypes.PLAIN_TEXT; // } SyntaxHighlighter originalHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(fileType, null, null); if (originalHighlighter == null) { originalHighlighter = new PlainSyntaxHighlighter(); } EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme(); LayeredLexerEditorHighlighter highlighter = new LayeredLexerEditorHighlighter(getFileHighlighter(fileType), scheme);// TODO: 2017/8/3 HTML highlighter.registerLayer(TextElementType, new LayerDescriptor(originalHighlighter, "")); return highlighter; }
public JetLayeredSyntaxHighlighter(Project project, EditorColorsScheme scheme, FileType ptype, VirtualFile virtualFile) { super(new JetSyntaxHighlighter(), scheme); // highlighter for outer ide FileType type = null; if (project == null || virtualFile == null) { type = StdFileTypes.PLAIN_TEXT; } else { Language language = TemplateDataLanguageMappings.getInstance(project).getMapping(virtualFile); if (language != null) type = language.getAssociatedFileType(); if (type == null) type = JetLanguage.getDefaultTemplateLang(); } SyntaxHighlighter outerHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(type, project, virtualFile); registerLayer(TEXT, new LayerDescriptor(outerHighlighter, "")); }
private EditorHighlighter createHighlighter() { if (myTemplate != null && myVelocityFileType != FileTypes.UNKNOWN) { return EditorHighlighterFactory.getInstance().createEditorHighlighter(myProject, new LightVirtualFile("aaa." + myTemplate.getExtension() + ".ft")); } FileType fileType = null; if (myTemplate != null) { fileType = FileTypeManager.getInstance().getFileTypeByExtension(myTemplate.getExtension()); } if (fileType == null) { fileType = FileTypes.PLAIN_TEXT; } SyntaxHighlighter originalHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(fileType, null, null); if (originalHighlighter == null) { originalHighlighter = new PlainSyntaxHighlighter(); } final EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme(); LayeredLexerEditorHighlighter highlighter = new LayeredLexerEditorHighlighter(new TemplateHighlighter(), scheme); highlighter.registerLayer(FileTemplateTokenType.TEXT, new LayerDescriptor(originalHighlighter, "")); return highlighter; }
public RestEditorHighlighter(@NotNull EditorColorsScheme scheme, @Nullable Project project, @Nullable VirtualFile file) { super(SyntaxHighlighterFactory.getSyntaxHighlighter(RestLanguage.INSTANCE, project, file), scheme); registerLayer(RestTokenTypes.PYTHON_LINE, new LayerDescriptor( SyntaxHighlighterFactory.getSyntaxHighlighter(PythonFileType.INSTANCE, project, file), "", EditorColors.INJECTED_LANGUAGE_FRAGMENT)); FileType djangoTemplateFileType = FileTypeManager.getInstance().findFileTypeByName("DjangoTemplate"); if (djangoTemplateFileType != null) { registerLayer(RestTokenTypes.DJANGO_LINE, new LayerDescriptor( SyntaxHighlighterFactory.getSyntaxHighlighter(djangoTemplateFileType, project, file), "", EditorColors.INJECTED_LANGUAGE_FRAGMENT)); } registerLayer(RestTokenTypes.JAVASCRIPT_LINE, new LayerDescriptor( SyntaxHighlighterFactory.getSyntaxHighlighter(StdFileTypes.JS, project, file), "", EditorColors.INJECTED_LANGUAGE_FRAGMENT)); }
public DotTemplateHighlighter(@Nullable Project project, @Nullable VirtualFile virtualFile, @NotNull EditorColorsScheme colors) { // create main highlighter super(new DotHighlighter(), colors); // highlighter for outer lang FileType type = null; if(project == null || virtualFile == null) { type = StdFileTypes.PLAIN_TEXT; } else { Language language = TemplateDataLanguageMappings.getInstance(project).getMapping(virtualFile); if(language != null) type = language.getAssociatedFileType(); if(type == null) type = DotLanguage.getDefaultTemplateLang(); } @SuppressWarnings ("deprecation") // deprecated in IDEA 12, still needed in IDEA 11 TODO remove when IDEA 11 support is dropped SyntaxHighlighter outerHighlighter = SyntaxHighlighter.PROVIDER.create(type, project, virtualFile); registerLayer(DotTokenTypes.CONTENT, new LayerDescriptor(outerHighlighter, "")); }
private EditorHighlighter createHighlighter() { if (myTemplate != null && myVelocityFileType != UnknownFileType.INSTANCE) { return EditorHighlighterFactory.getInstance().createEditorHighlighter(myProject, new LightVirtualFile("aaa." + myTemplate.getExtension() + ".ft")); } FileType fileType = null; if (myTemplate != null) { fileType = FileTypeManager.getInstance().getFileTypeByExtension(myTemplate.getExtension()); } if (fileType == null) { fileType = PlainTextFileType.INSTANCE; } SyntaxHighlighter originalHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(fileType, null, null); if (originalHighlighter == null) { originalHighlighter = new PlainSyntaxHighlighter(); } final EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme(); LayeredLexerEditorHighlighter highlighter = new LayeredLexerEditorHighlighter(new TemplateHighlighter(), scheme); highlighter.registerLayer(FileTemplateTokenType.TEXT, new LayerDescriptor(originalHighlighter, "")); return highlighter; }
public VtlEditorHighlighter(@Nullable final Project project, @Nullable final VirtualFile virtualFile, @NotNull final EditorColorsScheme colors) { super(new VtlSyntaxHighlighter(), colors); final SyntaxHighlighter highlighter = getTemplateDataLanguageHighlighter(project, virtualFile); registerLayer(TEMPLATE_TEXT, new LayerDescriptor(new SyntaxHighlighter() { @Override @NotNull public Lexer getHighlightingLexer() { return highlighter.getHighlightingLexer(); } @Override @NotNull public TextAttributesKey[] getTokenHighlights(final IElementType tokenType) { return highlighter.getTokenHighlights(tokenType); } }, "")); }
public DustLayeredSyntaxHighlighter(@Nullable Project project, @Nullable VirtualFile virtualFile, @NotNull EditorColorsScheme colors) { // create main highlighter super(new DustSyntaxHighlighter(), colors); // highlighter for outer lang FileType type = null; if(project == null || virtualFile == null) { type = StdFileTypes.PLAIN_TEXT; } else { Language language = TemplateDataLanguageMappings.getInstance(project).getMapping(virtualFile); if(language != null) type = language.getAssociatedFileType(); if(type == null) type = StdFileTypes.HTML; } SyntaxHighlighter outerHighlighter = SyntaxHighlighter.PROVIDER.create(type, project, virtualFile); registerLayer(DustTypes.HTML, new LayerDescriptor(outerHighlighter, "")); }
public RythmLayeredSyntaxHighlighter(Project project, EditorColorsScheme scheme, FileType ptype, VirtualFile virtualFile) { super(new RythmSyntaxHighlighter(), scheme); FileType type = null; //Test for Java implementation FileType type1 = null; if (project == null || virtualFile == null) { type = StdFileTypes.PLAIN_TEXT; } else { Language language = TemplateDataLanguageMappings.getInstance(project).getMapping(virtualFile); if (language != null) type = language.getAssociatedFileType(); if (type == null) { type = RythmLanguage.getDefaultTemplateLang(); //Test for Java implementation //type1 = RythmLanguage.getLanguage(); } } SyntaxHighlighter outerHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(type, project, virtualFile); registerLayer(TEXT, new LayerDescriptor(outerHighlighter, "")); //Test for Java implementation /* SyntaxHighlighter middleHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(type1, project, virtualFile); registerLayer(TEXT, new LayerDescriptor(middleHighlighter, "")); */ }
public LatteEditorHighlighter(@Nullable Project project, @Nullable VirtualFile virtualFile, @NotNull EditorColorsScheme colors) { super(new LatteSyntaxHighlighter(), colors); final SyntaxHighlighter highlighter = getHighlighter(project, virtualFile); this.registerLayer(LatteTypes.T_TEXT, new LayerDescriptor(new SyntaxHighlighter() { @NotNull public Lexer getHighlightingLexer() { return highlighter.getHighlightingLexer(); } @NotNull public TextAttributesKey[] getTokenHighlights(IElementType tokenType) { return highlighter.getTokenHighlights(tokenType); } }, "")); }
public CSharpEditorHighlighter(@Nullable final VirtualFile virtualFile, @NotNull final EditorColorsScheme colors) { super(new CSharpSyntaxHighlighter(), colors); registerLayer(CSharpTokens.STRING_LITERAL, new LayerDescriptor(new CSharpSyntaxHighlighter() { @NotNull @Override public Lexer getHighlightingLexer() { return new StringLiteralLexer('\"', CSharpTokens.STRING_LITERAL); } }, "")); registerLayer(CSharpTokensImpl.LINE_DOC_COMMENT, new LayerDescriptor(new CSharpDocSyntaxHighlighter(), "")); registerLayer(CSharpTokens.CHARACTER_LITERAL, new LayerDescriptor(new CSharpSyntaxHighlighter() { @NotNull @Override public Lexer getHighlightingLexer() { return new StringLiteralLexer('\'', CSharpTokens.CHARACTER_LITERAL); } }, "")); registerLayer(CSharpTokensImpl.INTERPOLATION_STRING_LITERAL, new LayerDescriptor(new CfsSyntaxHighlighter(CSharpCfsLanguageVersion .getInstance()) { @NotNull @Override public TextAttributesKey[] getTokenHighlights(IElementType elementType) { if(elementType == CfsTokens.TEXT) { return pack(CSharpHighlightKey.STRING); } return super.getTokenHighlights(elementType); } }, "")); registerLayer(CSharpTemplateTokens.PREPROCESSOR_FRAGMENT, new LayerDescriptor(new CSharpPreprocessorSyntaxHighlighter(), "")); }
public PlayBaseTemplateEditorHighlighter(@NotNull EditorColorsScheme scheme, @Nullable Project project, @Nullable VirtualFile virtualFile) { super(new PlayBaseTemplateSyntaxHighlighter(), scheme); SyntaxHighlighter htmlHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(HTMLLanguage.INSTANCE, project, virtualFile); LayerDescriptor htmlLayer = new LayerDescriptor(new TemplateDataHighlighterWrapper(htmlHighlighter), "\n"); registerLayer(PlayBaseTemplateTokens.TEMPLATE_TEXT, htmlLayer); SyntaxHighlighter groovyHighlighter = new GroovySyntaxHighlighter(); LayerDescriptor groovyLayer = new LayerDescriptor(groovyHighlighter, "\n", DefaultLanguageHighlighterColors.TEMPLATE_LANGUAGE_COLOR); registerLayer(PlayBaseTemplateTokens.GROOVY_EXPRESSION_OLD, groovyLayer); }
private static void setHighlighter(EditorEx editor, @Nullable SyntaxHighlighter highlighter) { EditorColorsScheme editorColorsScheme = EditorColorsManager.getInstance().getGlobalScheme(); LayeredLexerEditorHighlighter layeredHighlighter = new LayeredLexerEditorHighlighter(new TemplateHighlighter(), editorColorsScheme); layeredHighlighter.registerLayer(TemplateTokenType.TEXT, new LayerDescriptor(ObjectUtils.notNull(highlighter, new PlainSyntaxHighlighter()), "")); editor.setHighlighter(layeredHighlighter); }
private void registerGroovydocHighlighter() { // Register GroovyDoc Highlighter SyntaxHighlighter groovyDocHighlighter = new GroovyDocSyntaxHighlighter(); final LayerDescriptor groovyDocLayer = new LayerDescriptor(groovyDocHighlighter, "\n", GroovySyntaxHighlighter.DOC_COMMENT_CONTENT); registerLayer(GroovyDocElementTypes.GROOVY_DOC_COMMENT, groovyDocLayer); }
private void registerGroovydocHighlighter() { // Register GroovyDoc Highlighter SyntaxHighlighter groovyDocHighlighter = new GroovyDocSyntaxHighlighter(); final LayerDescriptor groovyDocLayer = new LayerDescriptor(groovyDocHighlighter, "\n", DefaultHighlighter.DOC_COMMENT_CONTENT); registerLayer(GroovyDocElementTypes.GROOVY_DOC_COMMENT, groovyDocLayer); }