@Override
 public RefactoringStatus checkNewName(String newName) {
   RefactoringStatus result = new RefactoringStatus();
   result.merge(super.checkNewName(newName));
   if (element instanceof LocalVariableElement) {
     LocalVariableElement variableElement = (LocalVariableElement) element;
     if (variableElement.isConst()) {
       result.merge(NamingConventions.validateConstantName(newName));
     } else {
       result.merge(NamingConventions.validateVariableName(newName));
     }
   } else if (element instanceof ParameterElement) {
     result.merge(NamingConventions.validateParameterName(newName));
   } else if (element instanceof FunctionElement) {
     result.merge(NamingConventions.validateFunctionName(newName));
   }
   return result;
 }
Ejemplo n.º 2
0
 public boolean isEnabled() {
   try {
     String newName = fNamePosition.getContent();
     if (fOriginalName.equals(newName)) {
       return false;
     }
     // TODO(scheglov) we may be rename not only variable, but also method, type, etc
     return NamingConventions.validateVariableName(newName).isOK();
   } catch (BadLocationException e) {
     return false;
   }
 }