mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
optimization: retrieve PsiElement when problem occurs only
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.codeInspection.reference;
|
||||
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.psi.PsiField;
|
||||
|
||||
/**
|
||||
@@ -24,6 +25,7 @@ import com.intellij.psi.PsiField;
|
||||
* @since 6.0
|
||||
*/
|
||||
public interface RefField extends RefJavaElement {
|
||||
Key<Boolean> ENUM_CONSTANT = Key.create("ENUM_CONSTANT");
|
||||
/**
|
||||
* Checks if the field is used for reading.
|
||||
*
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.intellij.codeInspection.reference;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.ClassUtil;
|
||||
import com.intellij.psi.util.PsiFormatUtil;
|
||||
@@ -43,6 +44,9 @@ public class RefFieldImpl extends RefJavaElementImpl implements RefField {
|
||||
setIsStatic(true);
|
||||
setIsFinal(true);
|
||||
}
|
||||
if (field instanceof PsiEnumConstant) {
|
||||
putUserData(ENUM_CONSTANT, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
-1
@@ -160,7 +160,10 @@ public class VisibilityInspection extends GlobalJavaBatchInspectionTool {
|
||||
//ignore implicit constructors. User should not be able to see them.
|
||||
if (refElement instanceof RefImplicitConstructor) return null;
|
||||
|
||||
if (refElement instanceof RefField && ((RefField)refElement).getElement() instanceof PsiEnumConstant) return null;
|
||||
if (refElement instanceof RefField) {
|
||||
final Boolean isEnumConstant = refElement.getUserData(RefField.ENUM_CONSTANT);
|
||||
if (isEnumConstant != null && isEnumConstant.booleanValue()) return null;
|
||||
}
|
||||
|
||||
//ignore library override methods.
|
||||
if (refElement instanceof RefMethod) {
|
||||
|
||||
Reference in New Issue
Block a user