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, "")); }
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, "")); }
/** * 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(); }
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)); }
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); }
@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; }
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, "")); */ }
protected RtplLanguage() { super(NAME); SyntaxHighlighterFactory.LANGUAGE_FACTORY.addExplicitExtension(this, new SingleLazyInstanceSyntaxHighlighterFactory() { @NotNull protected SyntaxHighlighter createHighlighter() { return new RtplSyntaxHighlighter(); } } ); }
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; }
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); } }
private BuildoutCfgLanguage() { super("BuildoutCfg"); SyntaxHighlighterFactory.LANGUAGE_FACTORY.addExplicitExtension(this, new SingleLazyInstanceSyntaxHighlighterFactory() { @NotNull protected SyntaxHighlighter createHighlighter() { return new BuildoutCfgSyntaxHighlighter(); } }); }
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()); } }
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); }
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()); }
public PropertiesLanguage() { super("Properties", "text/properties"); SyntaxHighlighterFactory.LANGUAGE_FACTORY.addExplicitExtension(this, new SingleLazyInstanceSyntaxHighlighterFactory() { @NotNull protected SyntaxHighlighter createHighlighter() { return new PropertiesHighlighter(); } }); }
public PerlLanguage() { super(Constants.LANGUAGE_NAME); SyntaxHighlighterFactory.LANGUAGE_FACTORY.addExplicitExtension(this, new PerlSyntaxHighlighterFactory() { @NotNull protected SyntaxHighlighter createHighlighter() { return new PerlSyntaxHighlighter(); } }); }
/** * Initializes a new instance of the {@link InstanceLanguageExtensionPoint} class. * * @param language The language. * @param instance The instance. */ public InstanceSyntaxHighlighterFactoryExtensionPoint( final Language language, final SyntaxHighlighterFactory instance) { super(); this.instance = instance; this.language = language.getID(); this.implementationClass = null; }
public JFlexLanguage() { super(ID); //somehow lang.syntaxHighlighterFactory extension won't work for me SyntaxHighlighterFactory.LANGUAGE_FACTORY.addExplicitExtension(this, new SingleLazyInstanceSyntaxHighlighterFactory() { @NotNull protected SyntaxHighlighter createHighlighter() { return new JFlexSyntaxHighlighter(); } }); }
private RobotLanguage() { super(ID); SyntaxHighlighterFactory.LANGUAGE_FACTORY.addExplicitExtension(this, new SingleLazyInstanceSyntaxHighlighterFactory() { @NotNull protected SyntaxHighlighter createHighlighter() { return new RobotSyntaxHighlighter(); } }); }
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(); final SyntaxHighlighter highlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(fileType, project, file.getVirtualFile()); myHighlighter = highlighter == null ? new PlainSyntaxHighlighter() : highlighter; myLexer = myHighlighter.getHighlightingLexer(); myLexer.start(myDocument.getCharsSequence()); myDocumentStamp = myDocument.getModificationStamp(); }
private void setEmbeddedLexer() { Lexer newLexer = null; if (hasSeenStyle()) { if (styleLexer==null) { styleLexer = (ourStyleFileType!=null)? SyntaxHighlighterFactory.getSyntaxHighlighter(ourStyleFileType, null, null).getHighlightingLexer():null; } newLexer = styleLexer; } else if (hasSeenScript()) { if (scriptLexer == null) { if (hasSeenTag()) { HtmlScriptContentProvider provider = findScriptContentProvider(scriptType); if (provider != null) { scriptLexer = provider.getHighlightingLexer(); } else { scriptLexer = SyntaxHighlighterFactory.getSyntaxHighlighter(StdLanguages.TEXT, null, null).getHighlightingLexer(); } } else if (hasSeenAttribute()) { SyntaxHighlighter syntaxHighlighter = (ourInlineScriptFileType != null) ? SyntaxHighlighterFactory.getSyntaxHighlighter(ourInlineScriptFileType, null, null) : null; scriptLexer = syntaxHighlighter != null ? syntaxHighlighter.getHighlightingLexer() : null; } } newLexer = scriptLexer; } else { newLexer = createELLexer(newLexer); } if (newLexer!=null) { embeddedLexer = newLexer; } }
public ByteCodeViewerComponent(Project project, AnAction[] additionalActions) { super(new BorderLayout()); final EditorFactory factory = EditorFactory.getInstance(); final Document doc = factory.createDocument(""); 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).setBackgroundColor(EditorFragmentComponent.getBackgroundColor(myEditor)); myEditor.getColorsScheme().setColor(EditorColors.CARET_ROW_COLOR, LightColors.SLIGHTLY_GRAY); ((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); }
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 AsciiDocLanguage() { super(LANGUAGE_NAME); SyntaxHighlighterFactory.LANGUAGE_FACTORY.addExplicitExtension(this, new SingleLazyInstanceSyntaxHighlighterFactory() { @NotNull protected SyntaxHighlighter createHighlighter() { return new AsciiDocHighlighter(); } }); }
private ChunkExtractor(@Nonnull 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; }
public static void printAsFileType(@Nonnull ConsoleView console, @Nonnull String text, @Nonnull FileType fileType) { SyntaxHighlighter highlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(fileType, null, null); if (highlighter != null) { printWithHighlighting(console, text, highlighter); } else { console.print(text, ConsoleViewContentType.NORMAL_OUTPUT); } }
@Nonnull static EditorHighlighter getLazyParsableHighlighterIfAny(Project project, Editor editor, PsiFile psiFile) { if (!PsiDocumentManager.getInstance(project).isCommitted(editor.getDocument())) { return ((EditorEx)editor).getHighlighter(); } PsiElement elementAt = psiFile.findElementAt(editor.getCaretModel().getOffset()); for (PsiElement e : SyntaxTraverser.psiApi().parents(elementAt).takeWhile(Conditions.notEqualTo(psiFile))) { if (!(PsiUtilCore.getElementType(e) instanceof ILazyParseableElementType)) continue; Language language = ILazyParseableElementType.LANGUAGE_KEY.get(e.getNode()); if (language == null) continue; TextRange range = e.getTextRange(); final int offset = range.getStartOffset(); SyntaxHighlighter syntaxHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(language, project, psiFile.getVirtualFile()); LexerEditorHighlighter highlighter = new LexerEditorHighlighter(syntaxHighlighter, editor.getColorsScheme()) { @Nonnull @Override public HighlighterIterator createIterator(int startOffset) { return new HighlighterIteratorWrapper(super.createIterator(Math.max(startOffset - offset, 0))) { @Override public int getStart() { return super.getStart() + offset; } @Override public int getEnd() { return super.getEnd() + offset; } }; } }; highlighter.setText(editor.getDocument().getText(range)); return highlighter; } return ((EditorEx)editor).getHighlighter(); }
@Nonnull @Override public EditorHighlighter getHighlighter() { EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme(); SyntaxHighlighter syntaxHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(myInjectedFile.getLanguage(), getProject(), myInjectedFile.getVirtualFile()); EditorHighlighter highlighter = HighlighterFactory.createHighlighter(syntaxHighlighter, scheme); highlighter.setText(getDocument().getText()); highlighter.setEditor(new LightHighlighterClient(getDocument(), getProject())); return highlighter; }
@SuppressWarnings({"UseOfObsoleteCollectionType"}) private static Vector<FileType> getFileTypes(Project project) { final Vector<FileType> v = new Vector<FileType>(); final FileType[] fileTypes = FileTypeManager.getInstance().getRegisteredFileTypes(); for (FileType fileType : fileTypes) { try { if (fileType instanceof LanguageFileType) { final SyntaxHighlighter sh = SyntaxHighlighterFactory.getSyntaxHighlighter(((LanguageFileType)fileType).getLanguage(), project, null); if (sh != null) { v.add(fileType); } } } catch (Throwable e) { Logger.getInstance(XsltRunSettingsEditor.class.getName()).info("Encountered incompatible FileType: " + fileType.getName(), e); } } Collections.sort(v, new Comparator<FileType>() { public int compare(FileType o1, FileType o2) { return o1.getDescription().compareTo(o2.getDescription()); } }); // off v.insertElementAt(null, 0); return v; }
public ByteCodeViewerComponent(Project project, AnAction[] additionalActions) { super(new BorderLayout()); final EditorFactory factory = EditorFactory.getInstance(); final Document doc = factory.createDocument(""); doc.setReadOnly(true); myEditor = factory.createEditor(doc, project); EditorHighlighterFactory editorHighlighterFactory = EditorHighlighterFactory.getInstance(); final SyntaxHighlighter syntaxHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(PlainTextFileType.INSTANCE, project, null); ((EditorEx) myEditor).setHighlighter(editorHighlighterFactory.createEditorHighlighter(syntaxHighlighter, EditorColorsManager.getInstance().getGlobalScheme())); ((EditorEx) myEditor).setBackgroundColor(EditorFragmentComponent.getBackgroundColor(myEditor)); myEditor.getColorsScheme().setColor(EditorColors.CARET_ROW_COLOR, LightColors.SLIGHTLY_GRAY); ((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); }
@Override public SyntaxHighlighter createHighlighter() { return SyntaxHighlighterFactory.getSyntaxHighlighter(AppleScriptFileType.INSTANCE, null, null); }
@NotNull @Override public SyntaxHighlighter getHighlighter() { return SyntaxHighlighterFactory.getSyntaxHighlighter(SwiftLanguage.INSTANCE, null, null); }
@Override public SyntaxHighlighter createHighlighter() { return SyntaxHighlighterFactory.getSyntaxHighlighter(myFileType, null, null); }
@NotNull @Override public SyntaxHighlighter getHighlighter() { return SyntaxHighlighterFactory.getSyntaxHighlighter(JsonLanguage.INSTANCE, null, null); }
public PythonEditorHighlighter(@NotNull EditorColorsScheme scheme, @Nullable Project project, @Nullable VirtualFile file) { super(SyntaxHighlighterFactory.getSyntaxHighlighter(file != null ? file.getFileType() : PythonFileType.INSTANCE, project, file), scheme); }
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; } }
@NotNull public SyntaxHighlighter getHighlighter() { return SyntaxHighlighterFactory.getSyntaxHighlighter(XPathFileType.XPATH.getLanguage(), null, null); }
/** * {@inheritDoc} */ @Override public final SyntaxHighlighterFactory getInstance() { return this.instance; }
/** * {@inheritDoc} */ @Override public String getId() { return ExtensionIds.SyntaxHighlighterFactory; }