/**
   * Removes contents of {@link #getPackageP()}, of {@link #getRoot()} (except for p) and of the
   * Java project (except for src and the JRE library).
   *
   * @throws Exception in case of errors
   */
  protected void tearDown() throws Exception {
    refreshFromLocal();
    performDummySearch();

    final boolean pExists = getPackageP().exists();
    if (pExists) {
      tryDeletingAllJavaChildren(getPackageP());
      tryDeletingAllNonJavaChildResources(getPackageP());
    }

    if (getRoot().exists()) {
      IJavaElement[] packages = getRoot().getChildren();
      for (int i = 0; i < packages.length; i++) {
        IPackageFragment pack = (IPackageFragment) packages[i];
        if (!pack.equals(getPackageP()) && pack.exists() && !pack.isReadOnly())
          if (pack.isDefaultPackage()) pack.delete(true, null);
          else
            JavaProjectHelper.delete(pack.getResource()); // also delete packages with subpackages
      }
      // Restore package 'p'
      if (!pExists) getRoot().createPackageFragment("p", true, null);

      tryDeletingAllNonJavaChildResources(getRoot());
    }

    restoreTestProject();
  }
 public RenamePackageChange(IPackageFragment pack, String newName, boolean renameSubpackages) {
   this(
       pack.getPath(),
       pack.getElementName(),
       newName,
       IResource.NULL_STAMP,
       null,
       renameSubpackages);
   Assert.isTrue(!pack.isReadOnly(), "package must not be read only"); // $NON-NLS-1$
 }
Ejemplo n.º 3
0
 private void collectPrivateMethods(IPackageFragment packageFragment, Set<IMethod> collector) {
   if (!packageFragment.isReadOnly()) {
     try {
       for (ICompilationUnit cu : packageFragment.getCompilationUnits()) {
         collectPrivateMethods(cu, collector);
       }
     } catch (JavaModelException jamox) {
       trace(jamox, packageFragment.getElementName());
     }
   }
 }