Пример #1
0
 public static void appendName(@NotNull final StringBuilder buffer, @NotNull final String name) {
   if (GroovyNamesUtil.isIdentifier(name)) {
     buffer.append(name);
   } else {
     buffer.append("'");
     buffer.append(GrStringUtil.escapeSymbolsForString(name, true, false));
     buffer.append("'");
   }
 }
  @Override
  protected ValidationInfo doValidate() {
    final String text = getEnteredName();
    if (!GroovyNamesUtil.isIdentifier(text)) {
      return new ValidationInfo(
          GroovyRefactoringBundle.message("name.is.wrong", text), myNameSuggestionsField);
    }

    if (myTypeComboBox.isClosureSelected()) {
      final Ref<ValidationInfo> info = new Ref<ValidationInfo>();
      toRemoveCBs.forEachEntry(
          new TObjectIntProcedure<JCheckBox>() {
            @Override
            public boolean execute(JCheckBox checkbox, int index) {
              if (!checkbox.isSelected()) return true;

              final GrParameter param = myInfo.getToReplaceIn().getParameters()[index];
              final ParameterInfo pinfo = findParamByOldName(param.getName());
              if (pinfo == null || !pinfo.passAsParameter()) return true;

              final String message =
                  GroovyRefactoringBundle.message(
                      "you.cannot.pass.as.parameter.0.because.you.remove.1.from.base.method",
                      pinfo.getName(),
                      param.getName());
              info.set(new ValidationInfo(message));
              return false;
            }
          });
      if (info.get() != null) {
        return info.get();
      }
    }

    return null;
  }