Package org.eclipse.jdt.core.refactoring

Examples of org.eclipse.jdt.core.refactoring.CompilationUnitChange


  /**
   * Adds {@link TextEdit}s into existing Java file {@link Change}.
   */
  private void addHandlerMethodChanges(CompositeChange compositeChange, IProgressMonitor pm)
      throws Exception {
    TextChange change = new CompilationUnitChange("(No matter)", m_field.getCompilationUnit());
    change.setEdit(new MultiTextEdit());
    // update handler methods
    String oldMethodPrefix = "on" + StringUtils.capitalize(m_oldName);
    String newMethodPrefix = "on" + StringUtils.capitalize(m_newName);
    IType type = (IType) m_field.getParent();
    for (IMethod method : type.getMethods()) {
      // prepare @UiHandler annotation
      IAnnotation annotation = getHandlerAnnotation(method);
      if (annotation == null) {
        continue;
      }
      // update @UiHandler name
      {
        ISourceRange annoRange = annotation.getSourceRange();
        ISourceRange nameRange = annotation.getNameRange();
        int nameEnd = nameRange.getOffset() + nameRange.getLength();
        int annoEnd = annoRange.getOffset() + annoRange.getLength();
        change.addEdit(new ReplaceEdit(nameEnd, annoEnd - nameEnd, "(\"" + m_newName + "\")"));
      }
      // rename method
      String methodName = method.getElementName();
      if (methodName.startsWith(oldMethodPrefix)) {
        String newName = newMethodPrefix + StringUtils.removeStart(methodName, oldMethodPrefix);
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.core.refactoring.CompilationUnitChange

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.