Package org.eclipse.ltk.core.refactoring

Examples of org.eclipse.ltk.core.refactoring.CompositeChange


  }

  @Override
  public Change createChange(IProgressMonitor pm) throws CoreException,
      OperationCanceledException {
    CompositeChange rootChange = new CompositeChange("CompositeChange");
    try {
      pm.beginTask( CoreTexts.renameRefactor_collectingChanges, 100 );
     
      IFile file = getFile(info.getAtgEditor());
      TextFileChange textFileChange = new TextFileChange( file.getName(), file );
      rootChange.add(textFileChange);
     
      //a file change contains a tree of edits, first add the root of them
      final MultiTextEdit fileChangeRootEdit = new MultiTextEdit();
      textFileChange.setEdit(fileChangeRootEdit);   
     
View Full Code Here


  }

  @Override
  public Change createChange(IProgressMonitor pm) throws CoreException,
      OperationCanceledException {
    CompositeChange rootChange = new CompositeChange("CompositeChange");
    try {
      pm.beginTask( CoreTexts.renameRefactor_collectingChanges, 100 );
     
      IFile file = getFile(info.getAtgEditor());
      TextFileChange textFileChange = new TextFileChange( file.getName(), file );
      rootChange.add(textFileChange);
     
      //a file change contains a tree of edits, first add the root of them
      final MultiTextEdit fileChangeRootEdit = new MultiTextEdit();
      textFileChange.setEdit(fileChangeRootEdit);   
     
View Full Code Here

  }

  @Override
  public Change createChange(IProgressMonitor pm) throws CoreException,
      OperationCanceledException {
    CompositeChange rootChange = new CompositeChange("CompositeChange");
    try {
      pm.beginTask( CoreTexts.renameRefactor_collectingChanges, 100 );
     
      IFile file = getFile(info.getAtgEditor());
      TextFileChange textFileChange = new TextFileChange( file.getName(), file );
      rootChange.add(textFileChange);
     
      //a file change contains a tree of edits, first add the root of them
      final MultiTextEdit fileChangeRootEdit = new MultiTextEdit();
      textFileChange.setEdit(fileChangeRootEdit);   
     
View Full Code Here

  public Change createChange(IProgressMonitor monitor) throws CoreException,
      OperationCanceledException {
    try {
      monitor.beginTask(Messages.ConvertConstantsToEnumRefactoring_CreatingChange, 1);
      final Collection changes = this.changes.values();
      final CompositeChange change = new CompositeChange(this.getName(),
          (Change[]) changes.toArray(new Change[changes.size()])) {
        public ChangeDescriptor getDescriptor() {
          String project = ConvertConstantsToEnumRefactoring.this
              .getJavaProject().getElementName();
          String description = Messages.ConvertConstantsToEnum_Name;
View Full Code Here

  // Change
  //
  ////////////////////////////////////////////////////////////////////////////
  @Override
  public Change createChangeEx(IProgressMonitor pm) throws Exception {
    CompositeChange compositeChange = new CompositeChange("Remote service rename");
    // prepare types
    IType serviceType = m_type;
    IType asyncType = GwtRefactoringUtils.getServiceAsyncType(serviceType, pm);
    IType implType = GwtRefactoringUtils.getServiceImplType(serviceType, pm);
    // prepare names
    String oldServiceName = serviceType.getElementName();
    String newServiceName = getArguments().getNewName();
    // rename Async
    if (!Utils.hasGPE()) {
      if (asyncType != null) {
        String newAsyncName = newServiceName + "Async";
        Change renameChange = RefactoringUtils.createRenameTypeChange(asyncType, newAsyncName, pm);
        // renameChange also changes serviceType compilation unit, so merge changes for its file
        RefactoringUtils.mergeTextChange(this, renameChange);
        // after merge add remainder to the composite change
        compositeChange.add(renameChange);
      }
    }
    // Impl
    if (implType != null) {
      compositeChange.add(createImplChange(
          serviceType,
          implType,
          oldServiceName,
          newServiceName,
          pm));
View Full Code Here

  private CompositeChange createImplChange(IType serviceType,
      IType implType,
      String oldServiceName,
      String newServiceName,
      IProgressMonitor pm) throws Exception, CoreException {
    CompositeChange implChange = new CompositeChange("Implementation change");
    String newImplName = newServiceName + "Impl";
    // change module XML
    {
      String oldServletPath = "/" + oldServiceName;
      String newServletPath = "/" + newServiceName;
      implChange.add(GwtRefactoringUtils.module_replaceServletPath(
          implType,
          oldServletPath,
          newServletPath));
    }
    // change name in remote service
    implChange.add(replaceServiceNameInAST(serviceType, oldServiceName, newServiceName));
    // change web.xml
    implChange.add(GwtRefactoringUtils.web_replaceServletPath(
        implType,
        oldServiceName,
        newServiceName));
    // rename Impl (participant for Impl rename will modify module)
    {
      Change implRenameChange = RefactoringUtils.createRenameTypeChange(implType, newImplName, pm);
      RefactoringUtils.mergeTextChanges(implChange, implRenameChange);
      implChange.add(implRenameChange);
    }
    // final change
    return implChange;
  }
View Full Code Here

*/
public class RemoteServiceImplMoveParticipant extends AbstractMoveParticipant {
  @Override
  protected Change createChange(IPackageFragment targetPackage, IProgressMonitor pm)
      throws Exception {
    CompositeChange compositeChange = new CompositeChange("Remote service Impl rename");
    // prepare context
    String newTypeName = targetPackage.getElementName() + "." + m_type.getElementName();
    // add changes
    compositeChange.add(GwtRefactoringUtils.module_replaceServletClass(m_type, newTypeName));
    compositeChange.add(GwtRefactoringUtils.web_replaceServletClass(m_type, newTypeName));
    return compositeChange;
  }
View Full Code Here

  //
  ////////////////////////////////////////////////////////////////////////////
  @Override
  protected Change createChange(IPackageFragment targetPackage, IProgressMonitor pm)
      throws Exception {
    CompositeChange compositeChange = new CompositeChange("Remote service move");
    // add Async changes
    IType asyncType = GwtRefactoringUtils.getServiceAsyncType(m_type, pm);
    if (asyncType != null) {
      String asyncTypeName = asyncType.getFullyQualifiedName();
      // when we move service, Eclipse adds import for Async type,
      // but we don't need it, so remove this import from text change
      {
        TextChange textChange = getTextChange(m_type.getUnderlyingResource());
        if (textChange != null) {
          removeInsertEdits_forSubString(textChange.getEdit(), "import " + asyncTypeName);
          removeInsertEdits_forNewLine(textChange.getEdit());
        }
      }
      // remove Async type, our builder will regenerate it near to moved service type
      compositeChange.add(RefactoringUtils.createDeleteTypeChange(asyncType));
    }
    // final change
    return compositeChange;
  }
View Full Code Here

  // Change
  //
  ////////////////////////////////////////////////////////////////////////////
  @Override
  public Change createChangeEx(IProgressMonitor pm) throws Exception {
    CompositeChange compositeChange = new CompositeChange("Remote service Impl rename");
    // prepare context
    String packageName = m_type.getPackageFragment().getElementName();
    String newSimpleName = getArguments().getNewName();
    String newTypeName = packageName + "." + newSimpleName;
    // add changes
    compositeChange.add(GwtRefactoringUtils.module_replaceServletClass(m_type, newTypeName));
    compositeChange.add(GwtRefactoringUtils.web_replaceServletClass(m_type, newTypeName));
    return compositeChange;
  }
View Full Code Here

* @coverage gwt.refactoring.participants
*/
public class RemoteServiceDeleteParticipant extends AbstractDeleteParticipant {
  @Override
  protected Change createChangeEx(IProgressMonitor pm) throws Exception {
    CompositeChange compositeChange = new CompositeChange("Remote service delete");
    // prepare Interface/Async/Impl types for service
    IType serviceType = m_type;
    IType asyncType = GwtRefactoringUtils.getServiceAsyncType(serviceType, pm);
    IType implType = GwtRefactoringUtils.getServiceImplType(serviceType, pm);
    // add changes
    if (asyncType != null) {
      compositeChange.add(RefactoringUtils.createDeleteTypeChange(asyncType));
    }
    if (implType != null) {
      compositeChange.add(GwtRefactoringUtils.module_removeServlet(implType));
      compositeChange.add(GwtRefactoringUtils.web_removeServlet(implType));
      compositeChange.add(RefactoringUtils.createDeleteTypeChange(implType));
    }
    // done
    return compositeChange;
  }
View Full Code Here

TOP

Related Classes of org.eclipse.ltk.core.refactoring.CompositeChange

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.