private static boolean isBaseNameGenerated(JavaCodeStyleManager csManager, PsiType parameterType, String paramName) { if (Arrays.asList(csManager.suggestVariableName(VariableKind.PARAMETER, null, null, parameterType).names).contains(paramName)) { return true; } final String typeName = JavaCodeStyleManagerImpl.getTypeName(parameterType); return typeName != null && NameUtil.getSuggestionsByName(typeName, "", "", false, false, parameterType instanceof PsiArrayType).contains(paramName); }
protected String suggestInitialMethodName() { if (StringUtil.isEmpty(myInitialMethodName)) { final String initialMethodName; final JavaCodeStyleManagerImpl codeStyleManager = (JavaCodeStyleManagerImpl)JavaCodeStyleManager.getInstance(myProject); final String[] names = codeStyleManager.suggestVariableName(VariableKind.FIELD, null, myExpression, myReturnType).names; if (names.length > 0) { initialMethodName = codeStyleManager.variableNameToPropertyName(names[0], VariableKind.FIELD); } else { return myInitialMethodName; } if (myReturnType != null && !(myReturnType instanceof PsiPrimitiveType)) { return PropertyUtil.suggestGetterName(initialMethodName, myReturnType); } else if (myExpression != null) { if (myExpression instanceof PsiMethodCallExpression) { PsiExpression qualifierExpression = ((PsiMethodCallExpression)myExpression).getMethodExpression().getQualifierExpression(); if (qualifierExpression != null && PsiUtil.resolveGenericsClassInType(qualifierExpression.getType()) != myTargetClass) { return initialMethodName; } } else { return initialMethodName; } } PsiElement prevSibling = PsiTreeUtil.skipSiblingsBackward(myElements[0], PsiWhiteSpace.class); if (prevSibling instanceof PsiComment && ((PsiComment)prevSibling).getTokenType() == JavaTokenType.END_OF_LINE_COMMENT) { final String text = prevSibling.getText().trim().replaceAll(" ", "").substring(2); if (JavaPsiFacade.getInstance(myProject).getNameHelper().isIdentifier(text) && text.length() < 20) { return text; } } } return myInitialMethodName; }
private static boolean isBaseNameGenerated(JavaCodeStyleManager csManager, PsiType parameterType, String paramName) { if(Arrays.asList(csManager.suggestVariableName(VariableKind.PARAMETER, null, null, parameterType).names).contains(paramName)) { return true; } final String typeName = JavaCodeStyleManagerImpl.getTypeName(parameterType); return typeName != null && NameUtil.getSuggestionsByName(typeName, "", "", false, false, parameterType instanceof PsiArrayType).contains(paramName); }