mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'psicore'
This commit is contained in:
+2
-1
@@ -25,6 +25,7 @@ import com.intellij.openapi.editor.colors.EditorColorsScheme;
|
||||
import com.intellij.openapi.editor.highlighter.EditorHighlighter;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.FileTypeEditorHighlighterProviders;
|
||||
import com.intellij.openapi.fileTypes.LanguageFileType;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -162,7 +163,7 @@ public abstract class MultilanguageCodeStyleAbstractPanel extends CodeStyleAbstr
|
||||
@Nullable
|
||||
protected EditorHighlighter createHighlighter(final EditorColorsScheme scheme) {
|
||||
if (getFileType() instanceof LanguageFileType) {
|
||||
return ((LanguageFileType)getFileType()).getEditorHighlighter(getCurrentProject(), null, scheme);
|
||||
return FileTypeEditorHighlighterProviders.INSTANCE.forFileType(getFileType()).getEditorHighlighter(getCurrentProject(), null, scheme);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.openapi.fileTypes;
|
||||
|
||||
import com.intellij.openapi.editor.colors.EditorColorsScheme;
|
||||
import com.intellij.openapi.editor.highlighter.EditorHighlighter;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public interface EditorHighlighterProvider {
|
||||
/**
|
||||
* Lower level API for customizing language's file syntax highlighting in editor component.
|
||||
* @param project The project in which the highlighter will work, or null if the highlighter is not tied to any project.
|
||||
* @param virtualFile The file to be highlighted
|
||||
* @param colors color scheme highlighter shall be initialized with.
|
||||
* @return EditorHighlighter implementation
|
||||
*/
|
||||
|
||||
EditorHighlighter getEditorHighlighter(@Nullable Project project,
|
||||
@Nullable final VirtualFile virtualFile,
|
||||
@NotNull EditorColorsScheme colors);
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.openapi.fileTypes;
|
||||
|
||||
import com.intellij.openapi.editor.colors.EditorColorsScheme;
|
||||
import com.intellij.openapi.editor.highlighter.EditorHighlighter;
|
||||
import com.intellij.openapi.editor.highlighter.EditorHighlighterFactory;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class FileTypeEditorHighlighterProviders extends FileTypeExtension<EditorHighlighterProvider> {
|
||||
public static final FileTypeEditorHighlighterProviders INSTANCE = new FileTypeEditorHighlighterProviders();
|
||||
|
||||
private FileTypeEditorHighlighterProviders() {
|
||||
super("com.intellij.editorHighlighter");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<EditorHighlighterProvider> buildExtensions(String stringKey, final FileType key) {
|
||||
List<EditorHighlighterProvider> fromEP = super.buildExtensions(stringKey, key);
|
||||
if (fromEP.isEmpty()) {
|
||||
EditorHighlighterProvider defaultProvider = new EditorHighlighterProvider() {
|
||||
@Override
|
||||
public EditorHighlighter getEditorHighlighter(@Nullable Project project,
|
||||
@Nullable VirtualFile virtualFile,
|
||||
@NotNull EditorColorsScheme colors) {
|
||||
return EditorHighlighterFactory.getInstance().createEditorHighlighter(SyntaxHighlighter.PROVIDER.create(key, project, virtualFile), colors);
|
||||
}
|
||||
};
|
||||
return Collections.singletonList(defaultProvider);
|
||||
}
|
||||
return fromEP;
|
||||
}
|
||||
}
|
||||
@@ -50,19 +50,6 @@ public abstract class LanguageFileType implements FileType{
|
||||
return myLanguage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lower level API for customizing language's file syntax highlighting in editor component.
|
||||
* @param project The project in which the highlighter will work, or null if the highlighter is not tied to any project.
|
||||
* @param virtualFile The file to be highlighted
|
||||
* @param colors color scheme highlighter shall be initialized with.
|
||||
* @return EditorHighlighter implementation
|
||||
*/
|
||||
public EditorHighlighter getEditorHighlighter(@Nullable Project project,
|
||||
@Nullable final VirtualFile virtualFile,
|
||||
@NotNull EditorColorsScheme colors) {
|
||||
return EditorHighlighterFactory.getInstance().createEditorHighlighter(SyntaxHighlighter.PROVIDER.create(this, project, virtualFile), colors);
|
||||
}
|
||||
|
||||
public final boolean isBinary() {
|
||||
return false;
|
||||
}
|
||||
|
||||
+3
-3
@@ -39,7 +39,7 @@ public class EditorHighlighterFactoryImpl extends EditorHighlighterFactory {
|
||||
|
||||
public EditorHighlighter createEditorHighlighter(final FileType fileType, final EditorColorsScheme settings, final Project project) {
|
||||
if (fileType instanceof LanguageFileType) {
|
||||
return ((LanguageFileType)fileType).getEditorHighlighter(project, null, settings);
|
||||
return FileTypeEditorHighlighterProviders.INSTANCE.forFileType(fileType).getEditorHighlighter(project, null, settings);
|
||||
}
|
||||
|
||||
SyntaxHighlighter highlighter = SyntaxHighlighter.PROVIDER.create(fileType, project, null);
|
||||
@@ -55,14 +55,14 @@ public class EditorHighlighterFactoryImpl extends EditorHighlighterFactory {
|
||||
if (fileType instanceof LanguageFileType) {
|
||||
LanguageFileType substFileType = substituteFileType(((LanguageFileType)fileType).getLanguage(), vFile, project);
|
||||
if (substFileType != null) {
|
||||
final EditorHighlighter editorHighlighter = substFileType.getEditorHighlighter(project, vFile, settings);
|
||||
final EditorHighlighter editorHighlighter = FileTypeEditorHighlighterProviders.INSTANCE.forFileType(substFileType).getEditorHighlighter(project, vFile, settings);
|
||||
boolean isPlain = editorHighlighter.getClass() == LexerEditorHighlighter.class &&
|
||||
((LexerEditorHighlighter) editorHighlighter).isPlain();
|
||||
if (!isPlain) {
|
||||
return editorHighlighter;
|
||||
}
|
||||
}
|
||||
return ((LanguageFileType)fileType).getEditorHighlighter(project, vFile, settings);
|
||||
return FileTypeEditorHighlighterProviders.INSTANCE.forFileType(fileType).getEditorHighlighter(project, vFile, settings);
|
||||
}
|
||||
|
||||
final ContentBasedClassFileProcessor[] processors = Extensions.getExtensions(ContentBasedClassFileProcessor.EP_NAME);
|
||||
|
||||
@@ -116,4 +116,5 @@
|
||||
|
||||
<extensionPoint name="xmlRpcHandler" beanClass="com.intellij.ide.XmlRpcHandlerBean"/>
|
||||
|
||||
<extensionPoint name="editorHighlighterProvider" beanClass="com.intellij.openapi.fileTypes.FileTypeExtensionPoint"/>
|
||||
</extensionPoints>
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.jetbrains.plugins.groovy;
|
||||
|
||||
import com.intellij.openapi.fileTypes.EditorHighlighterProvider;
|
||||
import com.intellij.openapi.fileTypes.FileTypeEditorHighlighterProviders;
|
||||
import com.intellij.openapi.fileTypes.LanguageFileType;
|
||||
import com.intellij.openapi.editor.highlighter.EditorHighlighter;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsScheme;
|
||||
@@ -42,6 +44,14 @@ public class GroovyFileType extends LanguageFileType {
|
||||
|
||||
private GroovyFileType() {
|
||||
super(new GroovyLanguage());
|
||||
FileTypeEditorHighlighterProviders.INSTANCE.addExplicitExtension(this, new EditorHighlighterProvider() {
|
||||
@Override
|
||||
public EditorHighlighter getEditorHighlighter(@Nullable Project project,
|
||||
@Nullable VirtualFile virtualFile,
|
||||
@NotNull EditorColorsScheme colors) {
|
||||
return new GroovyEditorHighlighter(colors, project, virtualFile);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -69,8 +79,4 @@ public class GroovyFileType extends LanguageFileType {
|
||||
public boolean isJVMDebuggingSupported() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public EditorHighlighter getEditorHighlighter(@Nullable Project project, @Nullable VirtualFile virtualFile, @NotNull EditorColorsScheme colors) {
|
||||
return new GroovyEditorHighlighter(colors, project, virtualFile);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -23,7 +23,9 @@ import com.intellij.openapi.actionSystem.DataProvider;
|
||||
import com.intellij.openapi.actionSystem.LangDataKeys;
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.editor.highlighter.EditorHighlighter;
|
||||
import com.intellij.openapi.fileTypes.EditorHighlighterProvider;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.FileTypeEditorHighlighterProviders;
|
||||
import com.intellij.openapi.fileTypes.LanguageFileType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
@@ -51,7 +53,8 @@ public class HighlightingOutputConsole extends AdditionalTabComponent implements
|
||||
assert editorEx != null;
|
||||
|
||||
if (fileType != null) {
|
||||
final EditorHighlighter highlighter = ((LanguageFileType)fileType).getEditorHighlighter(project, null, editorEx.getColorsScheme());
|
||||
EditorHighlighterProvider provider = FileTypeEditorHighlighterProviders.INSTANCE.forFileType(fileType);
|
||||
final EditorHighlighter highlighter = provider.getEditorHighlighter(project, null, editorEx.getColorsScheme());
|
||||
editorEx.setHighlighter(highlighter);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user