From 43e81e2450e4fb688eeadd127521e281ba83dd62 Mon Sep 17 00:00:00 2001 From: greg Date: Fri, 27 Mar 2009 21:10:49 +0300 Subject: [PATCH] allow "is" getters java.lang.Boolean. Against spec, but allowed every-other-where. Sun claims it was too late to change the spec. --- openapi/src/com/intellij/psi/util/PropertyUtil.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/openapi/src/com/intellij/psi/util/PropertyUtil.java b/openapi/src/com/intellij/psi/util/PropertyUtil.java index 8f364f80eb..2da284e202 100644 --- a/openapi/src/com/intellij/psi/util/PropertyUtil.java +++ b/openapi/src/com/intellij/psi/util/PropertyUtil.java @@ -62,7 +62,7 @@ public class PropertyUtil { if (returnType != null && returnType == PsiType.VOID) return false; } else if (methodName.startsWith("is")) { - if (returnType != null && returnType != PsiType.BOOLEAN) return false; + return isBoolean(returnType); } else { return false; @@ -297,7 +297,7 @@ public class PropertyUtil { public static String suggestGetterName(@NotNull String propertyName, @Nullable PsiType propertyType, @NonNls String existingGetterName) { @NonNls StringBuffer name = new StringBuffer(StringUtil.capitalize(propertyName)); - if (propertyType == PsiType.BOOLEAN) { + if (isBoolean(propertyType)) { if (existingGetterName == null || !existingGetterName.startsWith("get")) { name.insert(0, "is"); } @@ -312,6 +312,10 @@ public class PropertyUtil { return name.toString(); } + private static boolean isBoolean(@Nullable PsiType propertyType) { + return propertyType == PsiType.BOOLEAN || propertyType != null && CommonClassNames.JAVA_LANG_BOOLEAN.equals(propertyType.getCanonicalText()); + } + @NonNls public static String[] suggestGetterNames(String propertyName) { final String str = StringUtil.capitalize(propertyName); -- 2.11.4.GIT