mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
JavaLanguage to OpenAPI; register SyntaxHighlighterFactory for Java in XML
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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.lang.java;
|
||||
|
||||
import com.intellij.ide.highlighter.JavaFileHighlighter;
|
||||
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
|
||||
import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory;
|
||||
import com.intellij.openapi.module.LanguageLevelUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class JavaSyntaxHighlighterFactory extends SyntaxHighlighterFactory {
|
||||
@NotNull
|
||||
public SyntaxHighlighter getSyntaxHighlighter(final Project project, final VirtualFile virtualFile) {
|
||||
return new JavaFileHighlighter(
|
||||
virtualFile != null ? LanguageLevelUtil.getLanguageLevelForFile(virtualFile) : LanguageLevel.HIGHEST);
|
||||
}
|
||||
}
|
||||
-15
@@ -15,15 +15,7 @@
|
||||
*/
|
||||
package com.intellij.lang.java;
|
||||
|
||||
import com.intellij.ide.highlighter.JavaFileHighlighter;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
|
||||
import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory;
|
||||
import com.intellij.openapi.module.LanguageLevelUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author max
|
||||
@@ -34,13 +26,6 @@ public class JavaLanguage extends Language {
|
||||
|
||||
public JavaLanguage() {
|
||||
super("JAVA", "text/java", "application/x-java", "text/x-java");
|
||||
SyntaxHighlighterFactory.LANGUAGE_FACTORY.addExplicitExtension(this, new SyntaxHighlighterFactory() {
|
||||
@NotNull
|
||||
public SyntaxHighlighter getSyntaxHighlighter(final Project project, final VirtualFile virtualFile) {
|
||||
return new JavaFileHighlighter(
|
||||
virtualFile != null ? LanguageLevelUtil.getLanguageLevelForFile(virtualFile) : LanguageLevel.HIGHEST);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.intellij.psi.tree.java;
|
||||
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.lang.java.JavaLanguage;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
@@ -27,7 +27,7 @@ public class IJavaElementType extends IElementType {
|
||||
}
|
||||
|
||||
public IJavaElementType(@NonNls final String debugName, final boolean leftBound) {
|
||||
super(debugName, StdFileTypes.JAVA != null ? StdFileTypes.JAVA.getLanguage() : null);
|
||||
super(debugName, JavaLanguage.INSTANCE);
|
||||
myLeftBound = leftBound;
|
||||
}
|
||||
|
||||
|
||||
@@ -138,6 +138,7 @@
|
||||
</extensionPoints>
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<lang.syntaxHighlighterFactory key="JAVA" implementationClass="com.intellij.lang.java.JavaSyntaxHighlighterFactory"/>
|
||||
|
||||
<constantExpressionEvaluator language="JAVA" implementationClass="com.intellij.psi.impl.PsiExpressionEvaluator" />
|
||||
<annotationSupport language="JAVA" implementationClass="com.intellij.psi.impl.source.tree.java.JavaAnnotationSupport" />
|
||||
|
||||
Reference in New Issue
Block a user