コード例 #1
0
  public static String[] suggestVariableNames(
      @NotNull GrExpression expr, NameValidator validator, boolean forStaticVariable) {
    Set<String> possibleNames = new LinkedHashSet<String>();
    PsiType type = expr.getType();
    generateNameByExpr(expr, possibleNames, validator, forStaticVariable);
    if (type != null && !PsiType.VOID.equals(type)) {
      generateVariableNameByTypeInner(type, possibleNames, validator);
    }

    possibleNames.remove("");
    if (possibleNames.isEmpty()) {
      possibleNames.add(validator.validateName("var", true));
    }
    return ArrayUtil.toStringArray(possibleNames);
  }
コード例 #2
0
 public static String[] suggestVariableNameByType(PsiType type, NameValidator validator) {
   if (type == null) return ArrayUtil.EMPTY_STRING_ARRAY;
   Set<String> possibleNames = new LinkedHashSet<String>();
   generateVariableNameByTypeInner(type, possibleNames, validator);
   return ArrayUtil.toStringArray(possibleNames);
 }