diff --git a/java/java-psi-api/src/com/intellij/psi/util/PropertyUtil.java b/java/java-psi-api/src/com/intellij/psi/util/PropertyUtil.java index c521e5f4720d..33d8b7063f13 100644 --- a/java/java-psi-api/src/com/intellij/psi/util/PropertyUtil.java +++ b/java/java-psi-api/src/com/intellij/psi/util/PropertyUtil.java @@ -508,6 +508,7 @@ public class PropertyUtil { return suggestPropertyName(field, field.getName()); } + @NotNull public static String suggestPropertyName(@NotNull PsiField field, @NotNull String fieldName) { JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance(field.getProject()); VariableKind kind = codeStyleManager.getVariableKind(field); diff --git a/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/PropertyGroup.java b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/PropertyGroup.java index cbe863b8933c..c29c04935211 100644 --- a/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/PropertyGroup.java +++ b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/PropertyGroup.java @@ -26,7 +26,6 @@ import com.intellij.openapi.editor.colors.CodeInsightColors; import com.intellij.openapi.editor.colors.TextAttributesKey; import com.intellij.openapi.project.IndexNotReadyException; import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.IconLoader; import com.intellij.psi.*; import com.intellij.psi.util.PropertyUtil; @@ -40,8 +39,8 @@ import java.util.ArrayList; import java.util.Collection; public class PropertyGroup implements Group, ColoredItemPresentation, AccessLevelProvider, WeighedItem { - private final String myPropertyName; - private final SmartTypePointer myPropertyType; + @NotNull private final String myPropertyName; + @NotNull private final String myTypeText; private SmartPsiElementPointer myFieldPointer; private SmartPsiElementPointer myGetterPointer; @@ -56,9 +55,9 @@ public class PropertyGroup implements Group, ColoredItemPresentation, AccessLeve private final Project myProject; private final Collection myChildren = new ArrayList<>(); - private PropertyGroup(String propertyName, PsiType propertyType, boolean isStatic, @NotNull Project project) { + private PropertyGroup(@NotNull String propertyName, @NotNull PsiType propertyType, boolean isStatic, @NotNull Project project) { myPropertyName = propertyName; - myPropertyType = SmartTypePointerManager.getInstance(project).createSmartTypePointer(propertyType); + myTypeText = propertyType.getPresentableText(); myIsStatic = isStatic; myProject = project; } @@ -143,8 +142,7 @@ public class PropertyGroup implements Group, ColoredItemPresentation, AccessLeve @Override public String getPresentableText() { - final PsiType type = getPropertyType(); - return myPropertyName + (type != null ? ": " + type.getPresentableText() : ""); + return myPropertyName + ": " + myTypeText; } public String toString() { @@ -156,32 +154,11 @@ public class PropertyGroup implements Group, ColoredItemPresentation, AccessLeve if (this == o) return true; if (!(o instanceof PropertyGroup)) return false; - final PropertyGroup propertyGroup = (PropertyGroup)o; - - if (myPropertyName != null ? !myPropertyName.equals(propertyGroup.myPropertyName) : propertyGroup.myPropertyName != null) return false; - - final PsiType propertyType = getPropertyType(); - final PsiType otherPropertyType = propertyGroup.getPropertyType(); - - if (!Comparing.equal(propertyType, otherPropertyType)) { - return false; - } - return true; + return myPropertyName.equals(((PropertyGroup)o).myPropertyName) && myTypeText.equals(((PropertyGroup)o).myTypeText); } public int hashCode() { - return myPropertyName != null ? myPropertyName.hashCode() : 0; - } - - public String getGetterName() { - return PropertyUtil.suggestGetterName(myPropertyName, getPropertyType()); - } - - private PsiType getPropertyType() { - if (myPropertyType == null) { - return null; - } - return myPropertyType.getType(); + return myPropertyName.hashCode() * 31 + myTypeText.hashCode(); } @Override