This commit is contained in:
Roman Shevchenko
2011-03-07 22:01:52 +01:00
parent a39faeffca
commit a9c8cd157b
8 changed files with 143 additions and 132 deletions
@@ -0,0 +1,35 @@
/*
* Copyright 2000-2009 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.codeInsight.daemon.impl;
import com.intellij.codeInsight.daemon.HighlightDisplayKey;
import com.intellij.codeInspection.unusedImport.UnusedImportLocalInspection;
import com.intellij.lang.annotation.HighlightSeverity;
import com.intellij.openapi.editor.SyntaxHighlighterColors;
import com.intellij.openapi.editor.colors.CodeInsightColors;
/**
* @author anna
* Date: 01-Feb-2008
*/
public interface JavaHighlightInfoTypes extends HighlightInfoType {
HighlightInfoType UNUSED_IMPORT = new HighlightInfoType.HighlightInfoTypeSeverityByKey(
HighlightDisplayKey.findOrRegister(UnusedImportLocalInspection.SHORT_NAME, UnusedImportLocalInspection.DISPLAY_NAME),
CodeInsightColors.NOT_USED_ELEMENT_ATTRIBUTES);
HighlightInfoType JAVA_KEYWORD = new HighlightInfoType.HighlightInfoTypeImpl(
HighlightSeverity.INFORMATION, SyntaxHighlighterColors.KEYWORD);
}
@@ -1,43 +0,0 @@
/*
* Copyright 2000-2009 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.
*/
/*
* User: anna
* Date: 01-Feb-2008
*/
package com.intellij.codeInsight.daemon.impl;
import com.intellij.codeInsight.daemon.HighlightDisplayKey;
import com.intellij.codeInspection.javaDoc.JavaDocReferenceInspection;
import com.intellij.codeInspection.uncheckedWarnings.UncheckedWarningLocalInspection;
import com.intellij.codeInspection.unusedImport.UnusedImportLocalInspection;
import com.intellij.openapi.editor.colors.CodeInsightColors;
public class JavaHightlightInfoTypes {
public static final HighlightInfoType UNUSED_IMPORT = new HighlightInfoType.HighlightInfoTypeSeverityByKey(
HighlightDisplayKey.find(UnusedImportLocalInspection.SHORT_NAME) == null ?
HighlightDisplayKey.register(UnusedImportLocalInspection.SHORT_NAME, UnusedImportLocalInspection.DISPLAY_NAME) : HighlightDisplayKey.find(UnusedImportLocalInspection.SHORT_NAME), CodeInsightColors.NOT_USED_ELEMENT_ATTRIBUTES);
public static final HighlightInfoType JAVADOC_WRONG_REF = new HighlightInfoType.HighlightInfoTypeSeverityByKey(HighlightDisplayKey.find(
JavaDocReferenceInspection.SHORT_NAME) == null ?
HighlightDisplayKey.register(JavaDocReferenceInspection.SHORT_NAME, JavaDocReferenceInspection.DISPLAY_NAME) : HighlightDisplayKey.find(JavaDocReferenceInspection.SHORT_NAME), CodeInsightColors.WRONG_REFERENCES_ATTRIBUTES);
public static final HighlightInfoType UNCHECKED_WARNING = new HighlightInfoType.HighlightInfoTypeSeverityByKeyAttrBySeverity(HighlightDisplayKey.find(
UncheckedWarningLocalInspection.SHORT_NAME) == null ?
HighlightDisplayKey.register(UncheckedWarningLocalInspection.SHORT_NAME, UncheckedWarningLocalInspection.DISPLAY_NAME, UncheckedWarningLocalInspection.ID) : HighlightDisplayKey.find(UncheckedWarningLocalInspection.SHORT_NAME));
private JavaHightlightInfoTypes() {
}
}
@@ -674,7 +674,7 @@ public class PostHighlightingPass extends TextEditorHighlightingPass {
}
private HighlightInfo registerRedundantImport(PsiImportStatementBase importStatement, HighlightDisplayKey unusedImportKey) {
HighlightInfo info = HighlightInfo.createHighlightInfo(JavaHightlightInfoTypes.UNUSED_IMPORT, importStatement, InspectionsBundle.message("unused.import.statement"));
HighlightInfo info = HighlightInfo.createHighlightInfo(JavaHighlightInfoTypes.UNUSED_IMPORT, importStatement, InspectionsBundle.message("unused.import.statement"));
QuickFixAction.registerQuickFixAction(info, new OptimizeImportsFix(), unusedImportKey);
QuickFixAction.registerQuickFixAction(info, new EnableOptimizeImportsOnTheFlyFix(), unusedImportKey);
@@ -533,7 +533,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
if (!myHolder.hasErrorResults()) myHolder.add(HighlightUtil.checkIllegalVoidType(keyword));
if (PsiTreeUtil.getParentOfType(keyword, PsiDocTagValue.class) != null) {
myHolder.add(HighlightInfo.createHighlightInfo(HighlightInfoType.JAVA_KEYWORD, keyword, null));
myHolder.add(HighlightInfo.createHighlightInfo(JavaHighlightInfoTypes.JAVA_KEYWORD, keyword, null));
}
}
@@ -79,21 +79,21 @@ public class AdvHighlightingTest extends DaemonAnalyzerTestCase {
public void testImportDefaultPackage2() throws Exception { doTest(BASE_PATH+"/importDefaultPackage/x/ImportOnDemandUsage.java", BASE_PATH+"/importDefaultPackage", false, false); }
public void testScopeBased() throws Exception {
NamedScope xscope = new NamedScope("xxx", new PatternPackageSet("x..*", PatternPackageSet.SCOPE_SOURCE, null));
NamedScope utilscope = new NamedScope("util", new PatternPackageSet("java.util.*", PatternPackageSet.SCOPE_LIBRARY, null));
NamedScope xScope = new NamedScope("xxx", new PatternPackageSet("x..*", PatternPackageSet.SCOPE_SOURCE, null));
NamedScope utilScope = new NamedScope("util", new PatternPackageSet("java.util.*", PatternPackageSet.SCOPE_LIBRARY, null));
NamedScopeManager scopeManager = NamedScopeManager.getInstance(getProject());
scopeManager.addScope(xscope);
scopeManager.addScope(utilscope);
scopeManager.addScope(xScope);
scopeManager.addScope(utilScope);
EditorColorsManager manager = EditorColorsManager.getInstance();
EditorColorsScheme scheme = (EditorColorsScheme)manager.getGlobalScheme().clone();
manager.addColorsScheme(scheme);
EditorColorsManager.getInstance().setGlobalScheme(scheme);
TextAttributesKey xKey = ColorAndFontOptions.getScopeTextAttributeKey(xscope.getName());
TextAttributesKey xKey = ColorAndFontOptions.getScopeTextAttributeKey(xScope.getName());
TextAttributes xAttributes = new TextAttributes(Color.cyan, Color.darkGray, Color.blue, EffectType.BOXED, Font.ITALIC);
scheme.setAttributes(xKey, xAttributes);
TextAttributesKey utilKey = ColorAndFontOptions.getScopeTextAttributeKey(utilscope.getName());
TextAttributesKey utilKey = ColorAndFontOptions.getScopeTextAttributeKey(utilScope.getName());
TextAttributes utilAttributes = new TextAttributes(Color.gray, Color.magenta, Color.orange, EffectType.STRIKEOUT, Font.BOLD);
scheme.setAttributes(utilKey, utilAttributes);
@@ -105,21 +105,21 @@ public class AdvHighlightingTest extends DaemonAnalyzerTestCase {
}
}
public void testSharedScopeBased() throws Exception {
NamedScope xscope = new NamedScope("xxx", new PatternPackageSet("x..*", PatternPackageSet.SCOPE_ANY, null));
NamedScope utilscope = new NamedScope("util", new PatternPackageSet("java.util.*", PatternPackageSet.SCOPE_LIBRARY, null));
NamedScope xScope = new NamedScope("xxx", new PatternPackageSet("x..*", PatternPackageSet.SCOPE_ANY, null));
NamedScope utilScope = new NamedScope("util", new PatternPackageSet("java.util.*", PatternPackageSet.SCOPE_LIBRARY, null));
NamedScopesHolder scopeManager = DependencyValidationManager.getInstance(getProject());
scopeManager.addScope(xscope);
scopeManager.addScope(utilscope);
scopeManager.addScope(xScope);
scopeManager.addScope(utilScope);
EditorColorsManager manager = EditorColorsManager.getInstance();
EditorColorsScheme scheme = (EditorColorsScheme)manager.getGlobalScheme().clone();
manager.addColorsScheme(scheme);
EditorColorsManager.getInstance().setGlobalScheme(scheme);
TextAttributesKey xKey = ColorAndFontOptions.getScopeTextAttributeKey(xscope.getName());
TextAttributesKey xKey = ColorAndFontOptions.getScopeTextAttributeKey(xScope.getName());
TextAttributes xAttributes = new TextAttributes(Color.cyan, Color.darkGray, Color.blue, null, Font.ITALIC);
scheme.setAttributes(xKey, xAttributes);
TextAttributesKey utilKey = ColorAndFontOptions.getScopeTextAttributeKey(utilscope.getName());
TextAttributesKey utilKey = ColorAndFontOptions.getScopeTextAttributeKey(utilScope.getName());
TextAttributes utilAttributes = new TextAttributes(Color.gray, Color.magenta, Color.orange, EffectType.STRIKEOUT, Font.BOLD);
scheme.setAttributes(utilKey, utilAttributes);
@@ -158,6 +158,7 @@ public class AdvHighlightingTest extends DaemonAnalyzerTestCase {
}
});
assert root != null;
configureByExistingFile(root.findFileByRelativePath("moduleJava5/com/Java5.java"));
Collection<HighlightInfo> infos = highlightErrors();
assertEmpty(infos);
@@ -168,6 +169,7 @@ public class AdvHighlightingTest extends DaemonAnalyzerTestCase {
VirtualFile root = LocalFileSystem.getInstance().findFileByIoFile(new File(path));
loadAllModulesUnder(root);
assert root != null;
configureByExistingFile(root.findFileByRelativePath("client/src/BugTest.java"));
Collection<HighlightInfo> infos = highlightErrors();
assertEmpty(infos);
@@ -178,12 +180,18 @@ public class AdvHighlightingTest extends DaemonAnalyzerTestCase {
VirtualFile root = LocalFileSystem.getInstance().findFileByIoFile(new File(path));
loadAllModulesUnder(root);
assert root != null;
configureByExistingFile(root.findFileByRelativePath("src/ppp/SomeClass.java"));
PsiField field = ((PsiJavaFile)myFile).getClasses()[0].findFieldByName("f", false);
assert field != null;
PsiClass aClass = ((PsiClassType)field.getType()).resolve();
assert aClass != null;
assertEquals("ppp.BadClass", aClass.getQualifiedName());
//lies in source
assertEquals(myFile.getVirtualFile().getParent(), aClass.getContainingFile().getVirtualFile().getParent());
final VirtualFile vFile1 = myFile.getVirtualFile();
final VirtualFile vFile2 = aClass.getContainingFile().getVirtualFile();
assert vFile1 != null;
assert vFile2 != null;
assertEquals(vFile1.getParent(), vFile2.getParent());
}
}
@@ -4,8 +4,6 @@ import com.intellij.JavaTestUtil;
import com.intellij.codeInspection.LocalInspectionTool;
import com.intellij.codeInspection.javaDoc.JavaDocLocalInspection;
import com.intellij.codeInspection.javaDoc.JavaDocReferenceInspection;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
import com.intellij.pom.java.LanguageLevel;
@@ -47,9 +45,7 @@ public class JavadocHighlightingTest extends LightDaemonAnalyzerTestCase {
doTest();
}
public void testInlineTagAsDescription() throws Exception {
doTest();
}
public void testInlineTagAsDescription() throws Exception { doTest(); }
public void testParam0() throws Exception { doTestWithLangLevel(LanguageLevel.HIGHEST); }
public void testParam1() throws Exception { doTest(); }
@@ -62,8 +58,8 @@ public class JavadocHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testSee3() throws Exception { doTest(); }
public void testSee4() throws Exception { doTest(); }
public void testSee5() throws Exception { doTest(); }
public void testSee6() throws Exception {doTest();}
public void testSeeConstants() throws Exception { doTest();}
public void testSee6() throws Exception { doTest(); }
public void testSeeConstants() throws Exception { doTest(); }
public void testReturn0() throws Exception { doTest(); }
public void testException0() throws Exception { doTest(); }
public void testException1() throws Exception { doTest(); }
@@ -73,7 +69,7 @@ public class JavadocHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testMultipleThrows() throws Exception { doTest(); }
public void testInheritJavaDoc() throws Exception {doTestWithLangLevel(LanguageLevel.JDK_1_3);}
public void testLink0() throws Exception { doTest(); }
public void testLinkFromInnerClassToSelfMethod() throws Exception {doTest();}
public void testLinkFromInnerClassToSelfMethod() throws Exception { doTest(); }
public void testValueBadReference() throws Exception { doTestWithLangLevel(LanguageLevel.HIGHEST); }
public void testValueGoodReference() throws Exception { doTestWithLangLevel(LanguageLevel.HIGHEST); }
@@ -83,20 +79,18 @@ public class JavadocHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testValueNotOnStaticField() throws Exception { doTestWithLangLevel(LanguageLevel.HIGHEST); }
public void testValueOnNotInitializedField() throws Exception { doTestWithLangLevel(LanguageLevel.HIGHEST); }
public void testUnknownInlineTag() throws Exception {doTest();}
public void testUnknownTags() throws Exception {doTest();}
public void testUnknownInlineTag() throws Exception { doTest(); }
public void testUnknownTags() throws Exception { doTest(); }
public void testBadCharacters() throws Exception {doTest();}
public void testBadCharacters() throws Exception { doTest(); }
public void testVararg() throws Exception {doTest();}
public void testVararg() throws Exception { doTest(); }
public void testInnerClassReferenceInSignature() throws Exception {doTest();}
public void testInnerClassReferenceInSignature() throws Exception { doTest(); }
public void testBadReference() throws Exception{
doTest();
}
public void testBadReference() throws Exception { doTest(); }
public void testMissingReturnDescription() throws Exception {doTest();}
public void testMissingReturnDescription() throws Exception { doTest(); }
private void doTestWithLangLevel(final LanguageLevel langLevel) throws Exception {
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(langLevel);
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.codeInsight.daemon;
import com.intellij.openapi.diagnostic.Logger;
@@ -36,11 +35,12 @@ public class HighlightDisplayKey {
private final String myName;
private final String myID;
public static HighlightDisplayKey find(@NonNls @NotNull String name){
public static HighlightDisplayKey find(@NonNls @NotNull final String name) {
return ourNameToKeyMap.get(name);
}
public static HighlightDisplayKey findById(@NonNls @NotNull String id){
@Nullable
public static HighlightDisplayKey findById(@NonNls @NotNull final String id) {
HighlightDisplayKey key = ourIdToKeyMap.get(id);
if (key != null) return key;
key = ourNameToKeyMap.get(id);
@@ -49,7 +49,7 @@ public class HighlightDisplayKey {
}
@Nullable
public static HighlightDisplayKey register(@NonNls @NotNull String name) {
public static HighlightDisplayKey register(@NonNls @NotNull final String name) {
if (find(name) != null) {
LOG.info("Key with name \'" + name + "\' already registered");
return null;
@@ -58,7 +58,14 @@ public class HighlightDisplayKey {
}
@Nullable
public static HighlightDisplayKey register(@NonNls @NotNull String name, @NotNull String displayName, @NotNull @NonNls String id){
public static HighlightDisplayKey register(@NonNls @NotNull final String name, @NotNull final String displayName) {
return register(name, displayName, name);
}
@Nullable
public static HighlightDisplayKey register(@NonNls @NotNull final String name,
@NotNull final String displayName,
@NotNull @NonNls final String id) {
if (find(name) != null) {
LOG.info("Key with name \'" + name + "\' already registered");
return null;
@@ -69,19 +76,49 @@ public class HighlightDisplayKey {
}
@Nullable
public static HighlightDisplayKey register(@NonNls @NotNull String name, @NotNull String displayName) {
return register(name, displayName, name);
public static HighlightDisplayKey register(@NonNls @NotNull final String name,
@NonNls @NotNull final String displayName,
@NonNls @NotNull final String id,
@NonNls @Nullable final String alternativeID) {
final HighlightDisplayKey key = register(name, displayName, id);
if (alternativeID != null) {
ourKeyToAlternativeIDMap.put(key, alternativeID);
}
return key;
}
public static String getDisplayNameByKey(@Nullable HighlightDisplayKey key){
@NotNull
public static HighlightDisplayKey findOrRegister(@NonNls @NotNull String name, @NotNull final String displayName) {
return findOrRegister(name, displayName, null);
}
@NotNull
public static HighlightDisplayKey findOrRegister(@NonNls @NotNull final String name,
@NotNull final String displayName,
@NonNls @Nullable final String id) {
HighlightDisplayKey key = find(name);
if (key == null) {
key = register(name, displayName, id != null ? id : name);
assert key != null : name;
}
return key;
}
@Nullable
public static String getDisplayNameByKey(@Nullable HighlightDisplayKey key) {
return key == null ? null : ourKeyToDisplayNameMap.get(key);
}
private HighlightDisplayKey(@NotNull String name) {
public static String getAlternativeID(@NotNull HighlightDisplayKey key) {
return ourKeyToAlternativeIDMap.get(key);
}
private HighlightDisplayKey(@NonNls @NotNull final String name) {
this(name, name);
}
public HighlightDisplayKey(@NonNls @NotNull final String name, @NotNull @NonNls final String ID) {
public HighlightDisplayKey(@NonNls @NotNull final String name, @NonNls @NotNull final String ID) {
myName = name;
myID = ID;
ourNameToKeyMap.put(myName, this);
@@ -97,16 +134,4 @@ public class HighlightDisplayKey {
public String getID(){
return myID;
}
public static HighlightDisplayKey register(@NotNull String shortName, @NotNull String displayName, @NotNull String id, String alternativeID) {
final HighlightDisplayKey key = register(shortName, displayName, id);
if (alternativeID != null) {
ourKeyToAlternativeIDMap.put(key, alternativeID);
}
return key;
}
public static String getAlternativeID(@NotNull HighlightDisplayKey key) {
return ourKeyToAlternativeIDMap.get(key);
}
}
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.codeInsight.daemon.impl;
import com.intellij.codeHighlighting.HighlightDisplayLevel;
@@ -22,7 +21,6 @@ import com.intellij.codeInspection.InspectionProfile;
import com.intellij.codeInspection.InspectionsBundle;
import com.intellij.lang.annotation.HighlightSeverity;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.SyntaxHighlighterColors;
import com.intellij.openapi.editor.colors.CodeInsightColors;
import com.intellij.openapi.editor.colors.TextAttributesKey;
import com.intellij.openapi.util.Comparing;
@@ -42,34 +40,36 @@ public interface HighlightInfoType {
@NonNls String UNUSED_SYMBOL_ID = "UnusedDeclaration";
@NonNls String DEPRECATION_SHORT_NAME = "Deprecation";
@NonNls String DEPRECATION_ID = "deprecation";
@NonNls String DEPRECATION_DISPLAY_NAME = InspectionsBundle.message("inspection.deprecated.display.name");
@NonNls String DEPRECATION_ID = "deprecation";
HighlightInfoType ERROR = new HighlightInfoTypeImpl(HighlightSeverity.ERROR, CodeInsightColors.ERRORS_ATTRIBUTES);
HighlightInfoType WARNING = new HighlightInfoTypeImpl(HighlightSeverity.WARNING, CodeInsightColors.WARNINGS_ATTRIBUTES);
/** @deprecated use {@link #WEAK_WARNING} instead */
HighlightInfoType INFO = new HighlightInfoTypeImpl(HighlightSeverity.INFO, CodeInsightColors.INFO_ATTRIBUTES);
HighlightInfoType WEAK_WARNING = new HighlightInfoTypeImpl(HighlightSeverity.WEAK_WARNING, CodeInsightColors.WEAK_WARNING_ATTRIBUTES);
HighlightInfoType INFORMATION = new HighlightInfoTypeImpl(HighlightSeverity.INFORMATION, CodeInsightColors.INFORMATION_ATTRIBUTES);
HighlightInfoType WRONG_REF = new HighlightInfoTypeImpl(HighlightSeverity.ERROR, CodeInsightColors.WRONG_REFERENCES_ATTRIBUTES);
HighlightInfoType ERROR = new HighlightInfoTypeImpl(HighlightSeverity.ERROR, CodeInsightColors.ERRORS_ATTRIBUTES);
HighlightInfoType GENERIC_WARNINGS_OR_ERRORS_FROM_SERVER = new HighlightInfoTypeImpl(HighlightSeverity.GENERIC_SERVER_ERROR_OR_WARNING, CodeInsightColors.GENERIC_SERVER_ERROR_OR_WARNING);
HighlightInfoType GENERIC_WARNINGS_OR_ERRORS_FROM_SERVER = new HighlightInfoTypeImpl(
HighlightSeverity.GENERIC_SERVER_ERROR_OR_WARNING, CodeInsightColors.GENERIC_SERVER_ERROR_OR_WARNING);
HighlightInfoType DUPLICATE_FROM_SERVER = new HighlightInfoTypeImpl(HighlightSeverity.INFORMATION, CodeInsightColors.DUPLICATE_FROM_SERVER);
HighlightInfoType UNUSED_SYMBOL = new HighlightInfoTypeSeverityByKey(HighlightDisplayKey.find(UNUSED_SYMBOL_SHORT_NAME) == null ?
HighlightDisplayKey.register(UNUSED_SYMBOL_SHORT_NAME,
UNUSED_SYMBOL_DISPLAY_NAME,
UNUSED_SYMBOL_ID) : HighlightDisplayKey.find(UNUSED_SYMBOL_SHORT_NAME),
CodeInsightColors.NOT_USED_ELEMENT_ATTRIBUTES);
HighlightInfoType UNUSED_SYMBOL = new HighlightInfoTypeSeverityByKey(
HighlightDisplayKey.findOrRegister(UNUSED_SYMBOL_SHORT_NAME, UNUSED_SYMBOL_DISPLAY_NAME, UNUSED_SYMBOL_ID),
CodeInsightColors.NOT_USED_ELEMENT_ATTRIBUTES);
HighlightInfoType DEPRECATED = new HighlightInfoTypeSeverityByKey(
HighlightDisplayKey.find(DEPRECATION_SHORT_NAME) == null ? HighlightDisplayKey
.register(DEPRECATION_SHORT_NAME, DEPRECATION_DISPLAY_NAME, DEPRECATION_ID) : HighlightDisplayKey.find(DEPRECATION_SHORT_NAME),
HighlightDisplayKey.findOrRegister(DEPRECATION_SHORT_NAME, DEPRECATION_DISPLAY_NAME, DEPRECATION_ID),
CodeInsightColors.DEPRECATED_ATTRIBUTES);
HighlightInfoType LOCAL_VARIABLE = new HighlightInfoTypeImpl(HighlightSeverity.INFORMATION, CodeInsightColors.LOCAL_VARIABLE_ATTRIBUTES);
HighlightInfoType INSTANCE_FIELD = new HighlightInfoTypeImpl(HighlightSeverity.INFORMATION, CodeInsightColors.INSTANCE_FIELD_ATTRIBUTES);
HighlightInfoType STATIC_FIELD = new HighlightInfoTypeImpl(HighlightSeverity.INFORMATION, CodeInsightColors.STATIC_FIELD_ATTRIBUTES);
HighlightInfoType PARAMETER = new HighlightInfoTypeImpl(HighlightSeverity.INFORMATION, CodeInsightColors.PARAMETER_ATTRIBUTES);
// t.o.d.o attributes depend on the t.o.d.o text
HighlightInfoType TODO = new HighlightInfoTypeImpl(HighlightSeverity.INFORMATION, null);
HighlightInfoType TODO = new HighlightInfoTypeImpl(HighlightSeverity.INFORMATION, null); // t.o.d.o attributes depend on the t.o.d.o text
HighlightInfoType METHOD_CALL = new HighlightInfoTypeImpl(HighlightSeverity.INFORMATION, CodeInsightColors.METHOD_CALL_ATTRIBUTES);
HighlightInfoType METHOD_DECLARATION = new HighlightInfoTypeImpl(HighlightSeverity.INFORMATION, CodeInsightColors.METHOD_DECLARATION_ATTRIBUTES);
HighlightInfoType CONSTRUCTOR_CALL = new HighlightInfoTypeImpl(HighlightSeverity.INFORMATION, CodeInsightColors.CONSTRUCTOR_CALL_ATTRIBUTES);
@@ -84,21 +84,11 @@ public interface HighlightInfoType {
HighlightInfoType REASSIGNED_LOCAL_VARIABLE = new HighlightInfoTypeImpl(HighlightSeverity.INFORMATION, CodeInsightColors.REASSIGNED_LOCAL_VARIABLE_ATTRIBUTES);
HighlightInfoType REASSIGNED_PARAMETER = new HighlightInfoTypeImpl(HighlightSeverity.INFORMATION, CodeInsightColors.REASSIGNED_PARAMETER_ATTRIBUTES);
HighlightInfoType IMPLICIT_ANONYMOUS_CLASS_PARAMETER = new HighlightInfoTypeImpl(HighlightSeverity.INFORMATION, CodeInsightColors.IMPLICIT_ANONYMOUS_CLASS_PARAMETER_ATTRIBUTES);
HighlightInfoType UNHANDLED_EXCEPTION = new HighlightInfoTypeImpl(HighlightSeverity.ERROR, CodeInsightColors.ERRORS_ATTRIBUTES);
HighlightInfoType WARNING = new HighlightInfoTypeImpl(HighlightSeverity.WARNING, CodeInsightColors.WARNINGS_ATTRIBUTES);
/**
* use #WEAK_WARNING instead
*/
@Deprecated
HighlightInfoType INFO = new HighlightInfoTypeImpl(HighlightSeverity.INFO, CodeInsightColors.INFO_ATTRIBUTES);
HighlightInfoType WEAK_WARNING = new HighlightInfoTypeImpl(HighlightSeverity.WEAK_WARNING, CodeInsightColors.WEAK_WARNING_ATTRIBUTES);
HighlightInfoType INFORMATION = new HighlightInfoTypeImpl(HighlightSeverity.INFORMATION, CodeInsightColors.INFORMATION_ATTRIBUTES);
HighlightSeverity INJECTED_FRAGMENT_SEVERITY = new HighlightSeverity("INJECTED_FRAGMENT_SEVERITY", HighlightSeverity.INFORMATION.myVal-1);
HighlightInfoType INJECTED_LANGUAGE_FRAGMENT = new HighlightInfoTypeImpl(INJECTED_FRAGMENT_SEVERITY, CodeInsightColors.INFORMATION_ATTRIBUTES);
HighlightInfoType UNHANDLED_EXCEPTION = new HighlightInfoTypeImpl(HighlightSeverity.ERROR, CodeInsightColors.ERRORS_ATTRIBUTES);
HighlightInfoType JAVA_KEYWORD = new HighlightInfoTypeImpl(HighlightSeverity.INFORMATION, SyntaxHighlighterColors.KEYWORD);
@NotNull
HighlightSeverity getSeverity(PsiElement psiElement);
@@ -199,8 +189,7 @@ public interface HighlightInfoType {
}
class HighlightInfoTypeSeverityByKeyAttrBySeverity implements HighlightInfoType {
static final Logger LOG = Logger.getInstance(
"#com.intellij.codeInsight.daemon.impl.HighlightInfoType.HighlightInfoTypeSeverityByKeyAttrBySeverity");
static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.daemon.impl.HighlightInfoType.HighlightInfoTypeSeverityByKeyAttrBySeverity");
private final HighlightDisplayKey mySeverityKey;
@@ -210,9 +199,10 @@ public interface HighlightInfoType {
@NotNull
public HighlightSeverity getSeverity(final PsiElement psiElement) {
HighlightDisplayLevel level = psiElement != null ? InspectionProjectProfileManager.getInstance(psiElement.getProject()).getInspectionProfile().getErrorLevel(mySeverityKey,
psiElement) : ((InspectionProfile)InspectionProfileManager.getInstance().getRootProfile()).getErrorLevel(mySeverityKey,
psiElement);
InspectionProfile profile = psiElement == null
? (InspectionProfile)InspectionProfileManager.getInstance().getRootProfile()
: InspectionProjectProfileManager.getInstance(psiElement.getProject()).getInspectionProfile();
HighlightDisplayLevel level = profile.getErrorLevel(mySeverityKey, psiElement);
LOG.assertTrue(level != HighlightDisplayLevel.DO_NOT_SHOW);
return level.getSeverity();
}
@@ -224,14 +214,16 @@ public interface HighlightInfoType {
? infoType.getAttributesKey()
: severity == HighlightSeverity.ERROR
? CodeInsightColors.ERRORS_ATTRIBUTES
: severity == HighlightSeverity.WARNING ? CodeInsightColors.WARNINGS_ATTRIBUTES
: severity == HighlightSeverity.WEAK_WARNING ? CodeInsightColors.WEAK_WARNING_ATTRIBUTES : CodeInsightColors.INFO_ATTRIBUTES;
: severity == HighlightSeverity.WARNING
? CodeInsightColors.WARNINGS_ATTRIBUTES
: severity == HighlightSeverity.WEAK_WARNING
? CodeInsightColors.WEAK_WARNING_ATTRIBUTES
: CodeInsightColors.INFO_ATTRIBUTES;
}
@SuppressWarnings({"HardCodedStringLiteral"})
public String toString() {
return "HighlightInfoTypeSeverityByKeyAttrBySeverity[severity=" + mySeverityKey + "]";
}
}
}