当前位置: 首页>>代码示例>>Java>>正文


Java SyntaxHighlighterFactory类代码示例

本文整理汇总了Java中com.intellij.openapi.fileTypes.SyntaxHighlighterFactory的典型用法代码示例。如果您正苦于以下问题:Java SyntaxHighlighterFactory类的具体用法?Java SyntaxHighlighterFactory怎么用?Java SyntaxHighlighterFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SyntaxHighlighterFactory类属于com.intellij.openapi.fileTypes包,在下文中一共展示了SyntaxHighlighterFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: SoyLayeredHighlighter

import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory; //导入依赖的package包/类
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, ""));
}
 
开发者ID:google,项目名称:bamboo-soy,代码行数:23,代码来源:SoyLayeredHighlighter.java

示例2: JetLayeredSyntaxHighlighter

import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory; //导入依赖的package包/类
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, ""));
}
 
开发者ID:jhsx,项目名称:GoJetPlugin,代码行数:17,代码来源:JetLayeredSyntaxHighlighter.java

示例3: create

import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory; //导入依赖的package包/类
/**
 * SyntaxHighlighterProvider implementation (for .class files).
 */
@Nullable
@Override
public SyntaxHighlighter create(@NotNull FileType fileType, @Nullable Project project, @Nullable VirtualFile file) {
  if (project != null && file != null) {
    PsiFile psiFile = PsiManager.getInstance(project).findFile(file);

    if (fileType == JavaClassFileType.INSTANCE && psiFile != null) {
      Language language = psiFile.getLanguage();
      if (language != JavaLanguage.INSTANCE) {
        return SyntaxHighlighterFactory.getSyntaxHighlighter(language, project, file);
      }
    }

    if (psiFile instanceof ClsFileImpl) {
      LanguageLevel sourceLevel = ((ClsFileImpl)psiFile).getLanguageLevel();
      return new JavaFileHighlighter(sourceLevel);
    }
  }

  return new JavaFileHighlighter();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:JavaSyntaxHighlighterFactory.java

示例4: RestEditorHighlighter

import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory; //导入依赖的package包/类
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));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:RestEditorHighlighter.java

示例5: setHighlighters

import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory; //导入依赖的package包/类
private void setHighlighters(final Document oldDocument, final Document document,
                             List<BeforeAfter<TextRange>> ranges) {
  EditorHighlighterFactory editorHighlighterFactory = EditorHighlighterFactory.getInstance();
  final SyntaxHighlighter syntaxHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(myFileType, myProject, null);
  final EditorHighlighter highlighter =
    editorHighlighterFactory.createEditorHighlighter(syntaxHighlighter, EditorColorsManager.getInstance().getGlobalScheme());

  highlighter.setEditor(new LightHighlighterClient(oldDocument, myProject));
  highlighter.setText(oldDocument.getText());
  HighlighterIterator iterator = highlighter.createIterator(ranges.get(0).getBefore().getStartOffset());
  FragmentedEditorHighlighter beforeHighlighter =
    new FragmentedEditorHighlighter(iterator, getBeforeFragments(), 1, true);
  setBeforeHighlighter(beforeHighlighter);

  final EditorHighlighter highlighter1 =
    editorHighlighterFactory.createEditorHighlighter(syntaxHighlighter, EditorColorsManager.getInstance().getGlobalScheme());
  highlighter1.setEditor(new LightHighlighterClient(document, myProject));
  highlighter1.setText(document.getText());
  HighlighterIterator iterator1 = highlighter1.createIterator(ranges.get(0).getAfter().getStartOffset());
  FragmentedEditorHighlighter afterHighlighter =
    new FragmentedEditorHighlighter(iterator1, getAfterFragments(), 1, true);
  setAfterHighlighter(afterHighlighter);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:24,代码来源:PreparedFragmentedContent.java

示例6: createEditorHighlighter

import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory; //导入依赖的package包/类
@javax.annotation.Nullable
private static EditorHighlighter createEditorHighlighter(@Nullable Project project, @Nonnull DocumentContent content) {
  FileType type = content.getContentType();
  VirtualFile file = content.getHighlightFile();
  Language language = content.getUserData(DiffUserDataKeys.LANGUAGE);

  EditorHighlighterFactory highlighterFactory = EditorHighlighterFactory.getInstance();
  if (language != null) {
    SyntaxHighlighter syntaxHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(language, project, file);
    return highlighterFactory.createEditorHighlighter(syntaxHighlighter, EditorColorsManager.getInstance().getGlobalScheme());
  }
  if (file != null) {
    if ((type == null || type == PlainTextFileType.INSTANCE) || file.getFileType() == type || file instanceof LightVirtualFile) {
      return highlighterFactory.createEditorHighlighter(project, file);
    }
  }
  if (type != null) {
    return highlighterFactory.createEditorHighlighter(project, type);
  }
  return null;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:22,代码来源:DiffUtil.java

示例7: RythmLayeredSyntaxHighlighter

import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory; //导入依赖的package包/类
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, ""));
   */

}
 
开发者ID:scireum-incubator,项目名称:rythm_plugin,代码行数:33,代码来源:RythmLayeredSyntaxHighlighter.java

示例8: RtplLanguage

import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory; //导入依赖的package包/类
protected RtplLanguage() {
    super(NAME);
    SyntaxHighlighterFactory.LANGUAGE_FACTORY.addExplicitExtension(this,
            new SingleLazyInstanceSyntaxHighlighterFactory() {
                @NotNull
                protected SyntaxHighlighter createHighlighter() {
                    return new RtplSyntaxHighlighter();
                }
            }
    );
}
 
开发者ID:LichFaker,项目名称:RtplPlugin,代码行数:12,代码来源:RtplLanguage.java

示例9: ChunkExtractor

import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory; //导入依赖的package包/类
private ChunkExtractor(@NotNull PsiFile file) {
  myColorsScheme = UsageTreeColorsScheme.getInstance().getScheme();

  Project project = file.getProject();
  myDocument = PsiDocumentManager.getInstance(project).getDocument(file);
  LOG.assertTrue(myDocument != null);
  final FileType fileType = file.getFileType();
  SyntaxHighlighter highlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(fileType, project, file.getVirtualFile());
  highlighter = highlighter == null ? new PlainSyntaxHighlighter() : highlighter;
  myHighlighter = new SyntaxHighlighterOverEditorHighlighter(highlighter, file.getVirtualFile(), project);
  myDocumentStamp = -1;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:ChunkExtractor.java

示例10: printAsFileType

import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory; //导入依赖的package包/类
public static void printAsFileType(@NotNull ConsoleView console, @NotNull String text, @NotNull FileType fileType) {
  SyntaxHighlighter highlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(fileType, null, null);
  if (highlighter != null) {
    printWithHighlighting(console, text, highlighter);
  }
  else {
    console.print(text, ConsoleViewContentType.NORMAL_OUTPUT);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:ConsoleViewUtil.java

示例11: BuildoutCfgLanguage

import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory; //导入依赖的package包/类
private BuildoutCfgLanguage() {
  super("BuildoutCfg");
  SyntaxHighlighterFactory.LANGUAGE_FACTORY.addExplicitExtension(this, new SingleLazyInstanceSyntaxHighlighterFactory() {
    @NotNull
    protected SyntaxHighlighter createHighlighter() {
      return new BuildoutCfgSyntaxHighlighter();
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:BuildoutCfgLanguage.java

示例12: ApplicationEnvironment

import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory; //导入依赖的package包/类
public ApplicationEnvironment(CoreApplicationEnvironment appEnvironment) {
  appEnvironment.registerFileType(HtmlFileType.INSTANCE, "html;htm;sht;shtm;shtml");
  appEnvironment.registerFileType(XHtmlFileType.INSTANCE, "xhtml");
  appEnvironment.registerFileType(DTDFileType.INSTANCE, "dtd;ent;mod;elt");

  appEnvironment.registerFileType(XmlFileType.INSTANCE, "xml;xsd;tld;xsl;jnlp;wsdl;jhm;ant;xul;xslt;rng;fxml");

  SyntaxHighlighterFactory.LANGUAGE_FACTORY.addExplicitExtension(XMLLanguage.INSTANCE, new XmlSyntaxHighlighterFactory());
  SyntaxHighlighterFactory.LANGUAGE_FACTORY.addExplicitExtension(DTDLanguage.INSTANCE, new DtdSyntaxHighlighterFactory());
  SyntaxHighlighterFactory.LANGUAGE_FACTORY.addExplicitExtension(HTMLLanguage.INSTANCE, new HtmlSyntaxHighlighterFactory());
  SyntaxHighlighterFactory.LANGUAGE_FACTORY.addExplicitExtension(XHTMLLanguage.INSTANCE, new XhtmlSyntaxHighlighterFactory());

  appEnvironment.addExplicitExtension(LanguageParserDefinitions.INSTANCE, XMLLanguage.INSTANCE, new XMLParserDefinition());
  appEnvironment.addExplicitExtension(LanguageParserDefinitions.INSTANCE, DTDLanguage.INSTANCE, new DTDParserDefinition());
  appEnvironment.addExplicitExtension(LanguageParserDefinitions.INSTANCE, HTMLLanguage.INSTANCE, new HTMLParserDefinition());
  appEnvironment.addExplicitExtension(LanguageParserDefinitions.INSTANCE, XHTMLLanguage.INSTANCE, new XHTMLParserDefinition());

  appEnvironment.addExplicitExtension(IdIndexers.INSTANCE, XmlFileType.INSTANCE, new XmlIdIndexer());
  appEnvironment.addExplicitExtension(IdIndexers.INSTANCE, DTDFileType.INSTANCE, new XmlIdIndexer());
  appEnvironment.addExplicitExtension(TodoIndexers.INSTANCE, XmlFileType.INSTANCE, new XmlTodoIndexer());
  appEnvironment.addExplicitExtension(TodoIndexers.INSTANCE, DTDFileType.INSTANCE, new XmlTodoIndexer());
  appEnvironment.addExplicitExtension(TodoIndexers.INSTANCE, XHtmlFileType.INSTANCE, new XHtmlTodoIndexer());

  appEnvironment.addExtension(MetaDataContributor.EP_NAME, new XmlApplicationComponent());
  appEnvironment.addExtension(FileBasedIndexExtension.EXTENSION_POINT_NAME, new XmlNamespaceIndex());
  appEnvironment.addExtension(FileBasedIndexExtension.EXTENSION_POINT_NAME, new SchemaTypeInheritanceIndex());
  appEnvironment.addExtension(FileBasedIndexExtension.EXTENSION_POINT_NAME, new XmlTagNamesIndex());
  appEnvironment.addExtension(StandardResourceProvider.EP_NAME, new InternalResourceProvider());

  appEnvironment.registerApplicationComponent(PathMacros.class, new PathMacrosImpl());
  appEnvironment.registerApplicationService(ExternalResourceManager.class, new ExternalResourceManagerExImpl());
  appEnvironment.registerApplicationService(XmlFoldingSettings.class, new XmlFoldingSettings());
  Language[] myLanguages = new Language[]{XMLLanguage.INSTANCE, HTMLLanguage.INSTANCE, XHTMLLanguage.INSTANCE, DTDLanguage.INSTANCE};
  for (Language myLanguage : myLanguages) {
    appEnvironment.addExplicitExtension(LanguageFolding.INSTANCE, myLanguage, new XmlFoldingBuilder());
    appEnvironment.addExplicitExtension(LanguageFindUsages.INSTANCE, myLanguage, new XmlFindUsagesProvider());
    appEnvironment.addExplicitExtension(LanguageASTFactory.INSTANCE, myLanguage, new XmlASTFactory());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:40,代码来源:XmlCoreEnvironment.java

示例13: ByteCodeViewerComponent

import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory; //导入依赖的package包/类
public ByteCodeViewerComponent(Project project, AnAction[] additionalActions) {
  super(new BorderLayout());
  final EditorFactory factory = EditorFactory.getInstance();
  final Document doc = ((EditorFactoryImpl)factory).createDocument("", true, false);
  doc.setReadOnly(true);
  myEditor = factory.createEditor(doc, project);
  EditorHighlighterFactory editorHighlighterFactory = EditorHighlighterFactory.getInstance();
  final SyntaxHighlighter syntaxHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(StdFileTypes.JAVA, project, null);
  ((EditorEx)myEditor).setHighlighter(editorHighlighterFactory.createEditorHighlighter(syntaxHighlighter, EditorColorsManager.getInstance().getGlobalScheme()));
  ((EditorEx)myEditor).setCaretVisible(true);

  final EditorSettings settings = myEditor.getSettings();
  settings.setLineMarkerAreaShown(false);
  settings.setIndentGuidesShown(false);
  settings.setLineNumbersShown(false);
  settings.setFoldingOutlineShown(false);

  myEditor.setBorder(null);
  add(myEditor.getComponent(), BorderLayout.CENTER);
  final ActionManager actionManager = ActionManager.getInstance();
  final DefaultActionGroup actions = new DefaultActionGroup();
  if (additionalActions != null) {
    for (final AnAction action : additionalActions) {
      actions.add(action);
    }
  }
  add(actionManager.createActionToolbar(ActionPlaces.JAVADOC_TOOLBAR, actions, true).getComponent(), BorderLayout.NORTH);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:ByteCodeViewerComponent.java

示例14: ApplicationEnvironment

import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory; //导入依赖的package包/类
public ApplicationEnvironment(CoreApplicationEnvironment appEnvironment) {
  appEnvironment.registerFileType(PropertiesFileType.INSTANCE, "properties");
  appEnvironment.addExplicitExtension(SyntaxHighlighterFactory.LANGUAGE_FACTORY, PropertiesLanguage.INSTANCE,
                                      new PropertiesSyntaxHighlighterFactory());
  appEnvironment.addExplicitExtension(LanguageParserDefinitions.INSTANCE, PropertiesLanguage.INSTANCE, new PropertiesParserDefinition());
  appEnvironment.addExtension(FileBasedIndexExtension.EXTENSION_POINT_NAME, new XmlPropertiesIndex());
  appEnvironment.addExtension(StubIndexExtension.EP_NAME, new PropertyKeyIndex());

  appEnvironment.registerApplicationService(PropertiesQuickFixFactory.class, new EmptyPropertiesQuickFixFactory());
  appEnvironment.registerApplicationService(PropertiesRefactoringSettings.class, new PropertiesRefactoringSettings());
  appEnvironment.addExplicitExtension(LanguageAnnotators.INSTANCE, PropertiesLanguage.INSTANCE, new PropertiesAnnotator());
  appEnvironment.addExplicitExtension(LanguageFindUsages.INSTANCE, PropertiesLanguage.INSTANCE, new PropertiesFindUsagesProvider());

  appEnvironment.addExplicitExtension(LanguageASTFactory.INSTANCE, PropertiesLanguage.INSTANCE, new PropertiesASTFactory());
  appEnvironment.addExplicitExtension(LanguageFolding.INSTANCE, PropertiesLanguage.INSTANCE, new PropertiesFoldingBuilder());
  appEnvironment.addExplicitExtension(ElementManipulators.INSTANCE, PropertyImpl.class, new PropertyManipulator());
  appEnvironment.addExplicitExtension(ElementManipulators.INSTANCE, PropertyKeyImpl.class, new PropertyKeyManipulator());
  appEnvironment.addExplicitExtension(ElementManipulators.INSTANCE, PropertyValueImpl.class, new PropertyValueManipulator());

  final StubElementTypeHolderEP stubElementTypeHolderBean = new StubElementTypeHolderEP();
  stubElementTypeHolderBean.holderClass = PropertiesElementTypes.class.getName();
  appEnvironment.addExtension(StubElementTypeHolderEP.EP_NAME, stubElementTypeHolderBean);

  appEnvironment.addExplicitExtension(LanguageCommenters.INSTANCE, PropertiesLanguage.INSTANCE, new PropertiesCommenter());
  appEnvironment.addExplicitExtension(IdIndexers.INSTANCE, PropertiesFileType.INSTANCE, new PropertiesIdIndexer());
  appEnvironment.addExplicitExtension(TodoIndexers.INSTANCE, PropertiesFileType.INSTANCE, new PropertiesTodoIndexer());

  appEnvironment.addExtension(IconProvider.EXTENSION_POINT_NAME, new XmlPropertiesIconProvider());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:PropertiesCoreEnvironment.java

示例15: PropertiesLanguage

import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory; //导入依赖的package包/类
public PropertiesLanguage() {
  super("Properties", "text/properties");
  SyntaxHighlighterFactory.LANGUAGE_FACTORY.addExplicitExtension(this, new SingleLazyInstanceSyntaxHighlighterFactory() {
    @NotNull
    protected SyntaxHighlighter createHighlighter() {
      return new PropertiesHighlighter();
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:PropertiesLanguage.java


注:本文中的com.intellij.openapi.fileTypes.SyntaxHighlighterFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。