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; }
@NotNull @Override public SyntaxHighlighter getSyntaxHighlighter(Project project, VirtualFile virtualFile) { final boolean schema = virtualFile != null && virtualFile.getFileType() == JSGraphQLSchemaFileType.INSTANCE; if(project == null) { Project[] openProjects = ProjectManager.getInstance().getOpenProjects(); if(openProjects.length > 0) { project = openProjects[0]; } else { // can't syntax highlight GraphQL without a project to associate the language service instance to return new PlainSyntaxHighlighter(); } } return new JSGraphQLSyntaxHighlighter(project, schema); }
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 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 boolean isPlain() { return myHighlighter instanceof PlainSyntaxHighlighter; }
@NotNull public SyntaxHighlighter getHighlighter() { return new PlainSyntaxHighlighter(); }
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); }
@NotNull @Override public SyntaxHighlighter getHighlighter() { return new PlainSyntaxHighlighter(); }
@Override @NotNull public SyntaxHighlighter getHighlighter() { return new PlainSyntaxHighlighter(); }
/** * Gets the syntax highlighter for the specified project and file. * * @param project The project. * @param virtualFile The file. * @return The syntax highlighter. */ @Override public SyntaxHighlighter getSyntaxHighlighter( final Project project, final VirtualFile virtualFile) { @Nullable ILanguageImpl implementation = null; @Nullable final FileObject file = this.resourceService.resolve(virtualFile); if (file != null) { try { implementation = this.identifierService.identify(file); } catch (IllegalStateException ex) { // Multiple possible languages identified // (e.g. when different languages have the same extension, // such as TypeScript and TS both having .ts extension) // TODO: Better error message, // but to do that the exception needs to have its own class (derived from IllegalStateException) // that contains a list of languages. Notification notification = NotificationUtils.METABORG_NOTIFICATIONS.createNotification(ex.getMessage(), NotificationType.ERROR); NotificationUtils.INSTANCE.notify(project, notification); implementation = null; } } else if (virtualFile instanceof LightVirtualFile) { final com.intellij.lang.Language ideaLanguage = ((LightVirtualFile)virtualFile).getLanguage(); if (ideaLanguage instanceof MetaborgIdeaLanguage) { final ILanguage language = this.languageManager.getLanguage((MetaborgIdeaLanguage)ideaLanguage); implementation = language.activeImpl(); } } if (implementation == null){ // We don't know the language, so // let's return the plain syntax highlighter instead. return new PlainSyntaxHighlighter(); } @Nullable final IProject metaborgProject = null; // FIXME: Get IProject from Project final SpoofaxTokenTypeManager tokenTypesManager = this.bindingManager.getTokenTypeManager(implementation.belongsTo()); final Lexer lexer = this.highlightingLexerFactory .create(file, metaborgProject, implementation, tokenTypesManager); return new SpoofaxSyntaxHighlighter(lexer); }
@Override @Nonnull public SyntaxHighlighter getHighlighter() { return new PlainSyntaxHighlighter(); }
@Nonnull @Override public SyntaxHighlighter getHighlighter() { return new PlainSyntaxHighlighter(); }