Java 类com.intellij.psi.impl.source.codeStyle.JavaCodeStyleManagerImpl 实例源码

项目:intellij-ce-playground    文件:GenerateMembersUtil.java   
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);
}
项目:tools-idea    文件:ExtractMethodProcessor.java   
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;
}
项目:consulo-java    文件:GenerateMembersUtil.java   
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);
}