Package org.eclipse.ltk.core.refactoring

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


  public void testShouldConvertEjbCreateMethodToAConstructor() throws Exception {
    fixture.addClassToProject("org.superbiz.ProductBean", fixture.getStreamContent(getClass().getResourceAsStream("Ejb21ProductBean.txt"))); //$NON-NLS-1$ //$NON-NLS-2$
    JDTFacade facade = new JDTFacade(fixture.getProject());
    facade.convertMethodToConstructor("org.superbiz.ProductBean", "ejbCreate", new String[] { "java.lang.Integer", "java.lang.String", "java.lang.String", "java.lang.String"}); //$NON-NLS-1$
   
    Change change = facade.getChange();
    change.perform(new NullProgressMonitor());

    assertEquals(fixture.getStreamContent(getClass().getResourceAsStream("Expected30ProductBean.txt")), fixture.getClassContents("org.superbiz.ProductBean")); //$NON-NLS-1$ //$NON-NLS-2$
  }
View Full Code Here


   
    JDTFacade facade = new JDTFacade(fixture.getProject());
    String[] signature = new String[] { "java.lang.Integer", "java.lang.String", "java.lang.String", "java.lang.String" };
    facade.changeInvocationsToConstructor("org.superbiz.ProductHome", "create", signature, "org.superbiz.ProductBean");

    Change change = facade.getChange();
    change.perform(new NullProgressMonitor());

    assertEquals(fixture.getStreamContent(getClass().getResourceAsStream("ExpectedSessionBean.txt")), fixture.getClassContents("org.superbiz.SessionBean")); //$NON-NLS-1$ //$NON-NLS-2$
  }
View Full Code Here

    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);
      }
View Full Code Here

        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

      }
      // rename method
      String methodName = method.getElementName();
      if (methodName.startsWith(oldMethodPrefix)) {
        String newName = newMethodPrefix + StringUtils.removeStart(methodName, oldMethodPrefix);
        Change renameChange = createRenameChange(method, newName, pm);
        compositeChange.add(renameChange);
        RefactoringUtils.mergeTextChange(this, renameChange);
      }
    }
    // merge edits into existing (rename) change
View Full Code Here

    RefactoringStatus refactoringStatus = new RefactoringStatus();
    return refactoringStatus;
  }

  public Change createChange(IProgressMonitor _pm) throws CoreException, OperationCanceledException {
    Change change = null;
    if (myProject != null) {
      String principalClass = myProject.getBuildProperties().getPrincipalClass(true);
      int nameIndex = principalClass.lastIndexOf('$');
      if (nameIndex == -1) {
        nameIndex = principalClass.lastIndexOf('.');
View Full Code Here

    RefactoringStatus refactoringStatus = new RefactoringStatus();
    return refactoringStatus;
  }

  public Change createChange(IProgressMonitor _pm) throws CoreException, OperationCanceledException {
    Change change = null;
    if (myProject != null) {
      // String newName = myJavaDestination.getElementName();
      String newFullyQualifiedName;
      if (myJavaDestination instanceof IType) {
        newFullyQualifiedName = ((IType) myJavaDestination).getFullyQualifiedName() + '$' + myName;
View Full Code Here

          if (!added) {
            newEntries.add(entry);
          }

          final IClasspathEntry[] newCPEntries= (IClasspathEntry[]) newEntries.toArray(new IClasspathEntry[newEntries.size()]);
          Change newClasspathChange= newClasspathChange(project, newCPEntries, project.getOutputLocation());
          if (newClasspathChange != null) {
            return newClasspathChange;
          }
        return new NullChange();
View Full Code Here

          if (monitor == null) {
            monitor = new NullProgressMonitor();
          }
          monitor.beginTask(WizardMessages.NewTestCaseCreationWizard_create_progress, 4);
          try {
            Change change = fix.createChange(new SubProgressMonitor(monitor, 1));
            new PerformChangeOperation(change).run(new SubProgressMonitor(monitor, 1));

            runnable.run(new SubProgressMonitor(monitor, 2));
          } catch (OperationCanceledException e) {
            throw new InterruptedException();
View Full Code Here

        RefactoringStatus result = refactoring.checkAllConditions(monitor);

        assertTrue("Refactoring is not ok: " + result.getMessageMatchingSeverity(RefactoringStatus.WARNING),
                result.isOK());

        Change change = refactoring.createChange(monitor);
        change.perform(monitor);

        assertEquals(data.result, document.get());

        FileUtilsFileBuffer.IN_TESTS = false;
    }
View Full Code Here

TOP

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

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.