private GrTypeComboBox createTypeComboBox(
      GrVariable var, GrExpression expr, StringPartInfo stringPartInfo) {
    GrTypeComboBox box;
    if (var != null) {
      box = GrTypeComboBox.createTypeComboBoxWithDefType(var.getDeclaredType(), var);
    } else if (expr != null) {
      box = GrTypeComboBox.createTypeComboBoxFromExpression(expr);
    } else if (stringPartInfo != null) {
      box = GrTypeComboBox.createTypeComboBoxFromExpression(stringPartInfo.getLiteral());
    } else {
      box = GrTypeComboBox.createEmptyTypeComboBox();
    }

    box.addClosureTypesFrom(inferClosureReturnType(), myInfo.getContext());
    if (expr == null && var == null && stringPartInfo == null) {
      box.setSelectedIndex(box.getItemCount() - 1);
    }
    return box;
  }
コード例 #2
0
  @NotNull
  public LinkedHashSet<String> suggestNames() {
    final GrExpression expression = myContext.getExpression();
    final GrVariable var = myContext.getVar();
    final StringPartInfo stringPart = myContext.getStringPart();

    if (expression != null) {
      return new LinkedHashSet<String>(
          Arrays.asList(
              GroovyNameSuggestionUtil.suggestVariableNames(expression, myValidator, myForStatic)));
    } else if (stringPart != null) {
      return new LinkedHashSet<String>(
          Arrays.asList(
              GroovyNameSuggestionUtil.suggestVariableNames(
                  stringPart.getLiteral(), myValidator, myForStatic)));
    } else {
      assert var != null;
      return new LinkedHashSet<String>(
          Arrays.asList(
              GroovyNameSuggestionUtil.suggestVariableNameByType(var.getType(), myValidator)));
    }
  }