Java 类com.intellij.openapi.editor.ex.util.LayerDescriptor 实例源码

项目:bamboo-soy    文件:SoyLayeredHighlighter.java   
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, ""));
}
项目:ApiDebugger    文件:ResponseBodyWidget.java   
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;
    }
项目:GoJetPlugin    文件:JetLayeredSyntaxHighlighter.java   
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, ""));
}
项目:intellij-ce-playground    文件:FileTemplateConfigurable.java   
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;
}
项目:intellij-ce-playground    文件:RestEditorHighlighter.java   
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));
}
项目:idea-doT    文件:DotTemplateHighlighter.java   
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, ""));
}
项目:consulo    文件:FileTemplateConfigurable.java   
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;
}
项目:consulo-apache-velocity    文件:VtlEditorHighlighter.java   
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);
        }
    }, ""));
}
项目:Intellij-Dust    文件:DustLayeredSyntaxHighlighter.java   
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, ""));
}
项目:rythm_plugin    文件:RythmLayeredSyntaxHighlighter.java   
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, ""));
   */

}
项目:intellij-latte    文件:LatteEditorHighlighter.java   
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);
        }
    }, ""));
}
项目:consulo-csharp    文件:CSharpEditorHighlighter.java   
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(), ""));
}
项目:consulo-play    文件:PlayBaseTemplateEditorHighlighter.java   
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);
}
项目:intellij-ce-playground    文件:TemplateEditorUtil.java   
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);
}
项目:intellij-ce-playground    文件:GroovyEditorHighlighter.java   
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);
}
项目:tools-idea    文件:GroovyEditorHighlighter.java   
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);
}