mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-06 06:21:16 +07:00
[Parameter Name Hints] do not show hints for single param methods if return type is not void
Just testing this new approach: generally single param methods acts like getters "get(int index), charAt(int index), indexOf(int index)"
This commit is contained in:
+11
-5
@@ -44,9 +44,7 @@ public class ParameterNameHintsManager {
|
||||
|
||||
private static final Set<Character> ALLOWED_PARAMETER_NAME_CHARS = ContainerUtil.newHashSet('x', 'y', 'z', 'w', 'h');
|
||||
|
||||
private static final Set<String> COMMON_METHOD_NAMES = ContainerUtil.newHashSet(
|
||||
"get", "set", "contains", "append", "print", "println", "charAt", "startsWith", "endsWith", "indexOf"
|
||||
);
|
||||
private static final Set<String> COMMON_METHOD_NAMES = ContainerUtil.newHashSet("set", "print", "println");
|
||||
|
||||
@NotNull
|
||||
private final List<InlayInfo> myDescriptors;
|
||||
@@ -72,18 +70,26 @@ public class ParameterNameHintsManager {
|
||||
PsiElement element = resolveResult.getElement();
|
||||
if (element instanceof PsiMethod) {
|
||||
PsiMethod method = (PsiMethod)element;
|
||||
return !isSetter(method) && !isCommonMethod(method);
|
||||
if (isSetter(method)) return false;
|
||||
if (hasSingleParameter(method)) {
|
||||
return PsiType.VOID.equals(method.getReturnType());
|
||||
}
|
||||
return !isCommonMethod(method);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean hasSingleParameter(PsiMethod method) {
|
||||
return method.getParameterList().getParametersCount() == 1;
|
||||
}
|
||||
|
||||
private static boolean isCommonMethod(PsiMethod method) {
|
||||
return COMMON_METHOD_NAMES.contains(method.getName());
|
||||
}
|
||||
|
||||
private static boolean isSetter(PsiMethod method) {
|
||||
String methodName = method.getName();
|
||||
if (method.getParameterList().getParametersCount() == 1
|
||||
if (hasSingleParameter(method)
|
||||
&& methodName.startsWith("set")
|
||||
&& methodName.length() > 3 && Character.isUpperCase(methodName.charAt(3))) {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user