Package org.eclipse.core.resources

Examples of org.eclipse.core.resources.IResource


  }
  /* (non-Javadoc)
   * @see org.aspectj.org.eclipse.jdt.core.IJavaElement#getSchedulingRule()
   */
  public ISchedulingRule getSchedulingRule() {
    IResource resource = getResource();
    if (resource == null) {
      class NoResourceSchedulingRule implements ISchedulingRule {
        public IPath path;
        public NoResourceSchedulingRule(IPath path) {
          this.path = path;
View Full Code Here


    for (int i = 0, max = nonJavaResources.length; i < max; i++) {
      Object nonJavaResource = nonJavaResources[i];
      if (nonJavaResource instanceof IFile) {
        IFile file = (IFile) nonJavaResource;
        IPath path = file.getFullPath().removeFirstSegments(rootPathSegmentCounts);
        IResource member = container.findMember(path);
        if (member != null && member.exists()) {
          collector.add(member);
        }
      } else if (nonJavaResource instanceof IFolder) {
        IFolder folder = (IFolder) nonJavaResource;
        IResource[] members = null;
View Full Code Here

  private static void getGeneratedResource(ICompilationUnit unit,
      IContainer container,
      State state,
      int rootPathSegmentCounts,
      ArrayList collector) {
    IResource resource = unit.getResource();
    char[][] typeNames = state.getDefinedTypeNamesFor(resource.getProjectRelativePath().toString());
    if (typeNames != null) {
      IPath path = unit.getPath().removeFirstSegments(rootPathSegmentCounts).removeLastSegments(1);
      for (int j = 0, max2 = typeNames.length; j < max2; j++) {
        IPath localPath = path.append(new String(typeNames[j]) + ".class"); //$NON-NLS-1$
        IResource member = container.findMember(localPath);
        if (member != null && member.exists()) {
          collector.add(member);
        }
      }
    } else {
      IPath path = unit.getPath().removeFirstSegments(rootPathSegmentCounts).removeLastSegments(1);
      path = path.append(Util.getNameWithoutJavaLikeExtension(unit.getElementName()) + ".class"); //$NON-NLS-1$
      IResource member = container.findMember(path);
      if (member != null && member.exists()) {
        collector.add(member);
      }
    }
  }
View Full Code Here

    if (target == null)
      return null;

    // inside the workspace
    if (target instanceof IResource) {
      IResource resolvedResource = (IResource) target;
      switch (resolvedResource.getType()) {

        case IResource.PROJECT :
          // internal project
          return JavaCore.newProjectEntry(
              resolvedPath,
              entry.getAccessRules(),
              entry.combineAccessRules(),
              entry.getExtraAttributes(),
              entry.isExported());
        case IResource.FILE :
          if (org.aspectj.org.eclipse.jdt.internal.compiler.util.Util.isArchiveFileName(resolvedResource.getName())) {
            // internal binary archive
            return JavaCore.newLibraryEntry(
                resolvedPath,
                getResolvedVariablePath(entry.getSourceAttachmentPath()),
                getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
View Full Code Here

        ClasspathEntry combinedEntry = entry.combineWith(referringEntry);
        accumulatedEntries.add(combinedEntry);
       
        // recurse in project to get all its indirect exports (only consider exported entries from there on)       
        if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT) {
          IResource member = workspaceRoot.findMember(entry.getPath());
          if (member != null && member.getType() == IResource.PROJECT){ // double check if bound to project (23977)
            IProject projRsc = (IProject) member;
            if (JavaProject.hasJavaNature(projRsc)) {
              JavaProject javaProject = (JavaProject) JavaCore.create(projRsc);
              javaProject.computeExpandedClasspath(
                combinedEntry,
View Full Code Here

      case IClasspathEntry.CPE_PROJECT :

        if (!retrieveExportedRoots) return;
        if (referringEntry != null && !resolvedEntry.isExported()) return;

        IResource member = workspaceRoot.findMember(entryPath);
        if (member != null && member.getType() == IResource.PROJECT){// double check if bound to project (23977)
          IProject requiredProjectRsc = (IProject) member;
          if (JavaProject.hasJavaNature(requiredProjectRsc)){ // special builder binary output
            rootIDs.add(rootID);
            JavaProject requiredProject = (JavaProject)JavaCore.create(requiredProjectRsc);
            requiredProject.computePackageFragmentRoots(
View Full Code Here

        }
      default:
        // a path ending with .jar/.zip is still ambiguous and could still resolve to a source/lib folder
        // thus will try to guess based on existing resource
        if (org.aspectj.org.eclipse.jdt.internal.compiler.util.Util.isArchiveFileName(path.lastSegment())) {
          IResource resource = this.project.getWorkspace().getRoot().findMember(path);
          if (resource != null && resource.getType() == IResource.FOLDER){
            return getPackageFragmentRoot(resource);
          }
          return getPackageFragmentRoot0(path);
        } else if (segmentCount == 1) {
          // lib being another project
View Full Code Here

            for (int size = prereqChain.size(); index < size; index++) {
              cycleParticipants.add(prereqChain.get(index));
            }
          } else {
            if (!traversed.contains(prereqProjectPath)) {
              IResource member = workspaceRoot.findMember(prereqProjectPath);
              if (member != null && member.getType() == IResource.PROJECT){
                JavaProject javaProject = (JavaProject)JavaCore.create((IProject)member);
                javaProject.updateCycleParticipants(prereqChain, cycleParticipants, workspaceRoot, traversed, preferredClasspaths);
              }
            }
          }
View Full Code Here

            if (libraryJDK != 0 && libraryJDK > projectTargetJDK) {
              return new JavaModelStatus(IJavaModelStatusConstants.INCOMPATIBLE_JDK_LEVEL, project, path, CompilerOptions.versionFromJdkLevel(libraryJDK));
            }
          }
          if (target instanceof IResource){
            IResource resolvedResource = (IResource) target;
            switch(resolvedResource.getType()){
              case IResource.FILE :
                if (org.aspectj.org.eclipse.jdt.internal.compiler.util.Util.isArchiveFileName(resolvedResource.getName())) {
                  if (checkSourceAttachment
                    && sourceAttachment != null
                    && !sourceAttachment.isEmpty()
                    && JavaModel.getTarget(workspaceRoot, sourceAttachment, true) == null){
                    return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundSourceAttachment, new String [] {sourceAttachment.toString(), path.toString(), projectName}));
View Full Code Here

* (K_SOURCE or K_BINARY), and deletes the corresponding folder if it is then
* empty.
*/
private void deletePackageFragment(IPackageFragment frag)
  throws JavaModelException {
  IResource res = frag.getResource();
  if (res != null) {
    // collect the children to remove
    IJavaElement[] childrenOfInterest = frag.getChildren();
    if (childrenOfInterest.length > 0) {
      IResource[] resources = new IResource[childrenOfInterest.length];
      // remove the children
      for (int i = 0; i < childrenOfInterest.length; i++) {
        resources[i] = childrenOfInterest[i].getCorrespondingResource();
      }
      deleteResources(resources, force);
    }

    // Discard non-java resources
    Object[] nonJavaResources = frag.getNonJavaResources();
    int actualResourceCount = 0;
    for (int i = 0, max = nonJavaResources.length; i < max; i++){
      if (nonJavaResources[i] instanceof IResource) actualResourceCount++;
    }
    IResource[] actualNonJavaResources = new IResource[actualResourceCount];
    for (int i = 0, max = nonJavaResources.length, index = 0; i < max; i++){
      if (nonJavaResources[i] instanceof IResource) actualNonJavaResources[index++] = (IResource)nonJavaResources[i];
    }
    deleteResources(actualNonJavaResources, force);
   
    // delete remaining files in this package (.class file in the case where Proj=src=bin)
    IResource[] remainingFiles;
    try {
      remainingFiles = ((IContainer) res).members();
    } catch (CoreException ce) {
      throw new JavaModelException(ce);
    }
    boolean isEmpty = true;
    for (int i = 0, length = remainingFiles.length; i < length; i++) {
      IResource file = remainingFiles[i];
      if (file instanceof IFile && org.aspectj.org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(file.getName())) {
        this.deleteResource(file, IResource.FORCE | IResource.KEEP_HISTORY);
      } else {
        isEmpty = false;
      }
    }
    if (isEmpty && !frag.isDefaultPackage()/*don't delete default package's folder: see https://bugs.eclipse.org/bugs/show_bug.cgi?id=38450*/) {
      // delete recursively empty folders
      IResource fragResource =  frag.getResource();
      if (fragResource != null) {
        deleteEmptyPackageFragment(frag, false, fragResource.getParent());
      }
    }
  }
}
View Full Code Here

TOP

Related Classes of org.eclipse.core.resources.IResource

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.