本文整理汇总了Java中com.intellij.openapi.fileTypes.SyntaxHighlighterFactory.getSyntaxHighlighter方法的典型用法代码示例。如果您正苦于以下问题:Java SyntaxHighlighterFactory.getSyntaxHighlighter方法的具体用法?Java SyntaxHighlighterFactory.getSyntaxHighlighter怎么用?Java SyntaxHighlighterFactory.getSyntaxHighlighter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.fileTypes.SyntaxHighlighterFactory
的用法示例。
在下文中一共展示了SyntaxHighlighterFactory.getSyntaxHighlighter方法的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, ""));
}
示例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, ""));
}
示例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();
}
示例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));
}
示例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);
}
示例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;
}
示例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, ""));
*/
}
示例8: 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;
}
示例9: 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);
}
}
示例10: 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);
}
示例11: 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();
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();
}
示例12: setEmbeddedLexer
import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory; //导入方法依赖的package包/类
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;
}
}
示例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 = 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);
}
示例14: PlayBaseTemplateEditorHighlighter
import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory; //导入方法依赖的package包/类
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);
}
示例15: ChunkExtractor
import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory; //导入方法依赖的package包/类
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;
}