Package org.eclipse.core.resources

Examples of org.eclipse.core.resources.IProject


    SourceIndexerRequestor requestor = new SourceIndexerRequestor(this);
    String documentPath = this.document.getPath();
    SourceElementParser parser = ((InternalSearchDocument) this.document).parser;
    if (parser == null) {
      IPath path = new Path(documentPath);
      IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(path.segment(0));
      parser = JavaModelManager.getJavaModelManager().indexManager.getSourceElementParser(JavaCore.create(project), requestor);
    } else {
      parser.requestor = requestor;
    }
   
View Full Code Here


    IPath path= new Path(pathString);
    IProject[] projects= ResourcesPlugin.getWorkspace().getRoot().getProjects();
    for (int i= 0, max= projects.length; i < max; i++) {
      try {
        IProject project = projects[i];
        if (!project.isAccessible()
          || !project.hasNature(JavaCore.NATURE_ID)) continue;
        IJavaProject javaProject= this.javaModel.getJavaProject(project);
        IPackageFragmentRoot[] roots= javaProject.getPackageFragmentRoots();
        for (int j= 0, rootCount= roots.length; j < rootCount; j++) {
          PackageFragmentRoot root= (PackageFragmentRoot)roots[j];
          if (root.getPath().isPrefixOf(path) && !Util.isExcluded(path, root.fullInclusionPatternChars(), root.fullExclusionPatternChars(), false)) {
View Full Code Here

    JavaModelManager.PerProjectInfo perProjectInfo;
    try {
      perProjectInfo = this.project.getPerProjectInfo();
    } catch (JavaModelException e) {
      // project doesn't exist
      IProject resource = this.project.getProject();
      if (resource.isAccessible()) {
        this.project.flushClasspathProblemMarkers(true/*flush cycle markers*/, true/*flush classpath format markers*/);
         
        // remove problems and tasks created  by the builder
        JavaBuilder.removeProblemsAndTasksFor(resource);
      }
View Full Code Here

  IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
  int length = projects.length;
  Object[] resources = null;
  int index = 0;
  for (int i = 0; i < length; i++) {
    IProject project = projects[i];
    if (!JavaProject.hasJavaNature(project)) {
      if (resources == null) {
        resources = new Object[length];
      }
      resources[index++] = project;
View Full Code Here

* @param visitedProjects Set to avoid infinite recursion
* @param referringEntry Project raw entry in referring project classpath
* @throws JavaModelException May happen while getting java model info
*/
void add(JavaProject javaProject, IPath pathToAdd, int includeMask, HashSet visitedProjects, IClasspathEntry referringEntry) throws JavaModelException {
  IProject project = javaProject.getProject();
  if (!project.isAccessible() || !visitedProjects.add(project)) return;

  IPath projectPath = project.getFullPath();
  String projectPathString = projectPath.toString();
  this.addEnclosingProjectOrJar(projectPath);

  IClasspathEntry[] entries = javaProject.getResolvedClasspath();
  IJavaModel model = javaProject.getJavaModel();
View Full Code Here

  IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
  int length = projects.length;
  IJavaElement[] children = new IJavaElement[length];
  int index = 0;
  for (int i = 0; i < length; i++) {
    IProject project = projects[i];
    if (JavaProject.hasJavaNature(project)) {
      children[index++] = getJavaProject(project);
    }
  }
  if (index < length)
View Full Code Here

        // so that there is no concurrency with the Java builder
        // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=96575
        IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
          public void run(IProgressMonitor progressMonitor) throws CoreException {
            for (int i = 0; i < length; i++) {
              IProject project = projectsToTouch[i];
             
              // touch to force a build of this project
              if (JavaBuilder.DEBUG)
                System.out.println("Touching project " + project.getName() + " due to external jar file change"); //$NON-NLS-1$ //$NON-NLS-2$
              project.touch(progressMonitor);
            }
          }
        };
        try {
          ResourcesPlugin.getWorkspace().run(runnable, monitor);
View Full Code Here

        break;
      case IResource.PROJECT :
        // NB: No need to check project's nature as if the project is not a java project:
        //     - if the project is added or changed this is a noop for projectsBeingDeleted
        //     - if the project is closed, it has already lost its java nature
        IProject project = (IProject)resource;
        JavaProject javaProject = (JavaProject)JavaCore.create(project);
        switch (delta.getKind()) {
          case IResourceDelta.ADDED :
            this.manager.batchContainerInitializations = true;
         
            // remember project and its dependents
            addToRootsToRefreshWithDependents(javaProject);
           
            // workaround for bug 15168 circular errors not reported
            if (JavaProject.hasJavaNature(project)) {
              addToParentInfo(javaProject);
              readRawClasspath(javaProject);
              // ensure project references are updated (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=121569)
              checkProjectReferenceChange(project, javaProject);
            }
           
            this.state.rootsAreStale = true;
            break;
           
          case IResourceDelta.CHANGED :
              if ((delta.getFlags() & IResourceDelta.OPEN) != 0) {
                this.manager.batchContainerInitializations = true;
   
                // project opened or closed: remember  project and its dependents
                addToRootsToRefreshWithDependents(javaProject);
               
                // workaround for bug 15168 circular errors not reported
                if (project.isOpen()) {
                  if (JavaProject.hasJavaNature(project)) {
                    addToParentInfo(javaProject);
                    readRawClasspath(javaProject);
                    // ensure project references are updated
                    checkProjectReferenceChange(project, javaProject);
                  }
                } else {
                  try {
                    javaProject.close();
                  } catch (JavaModelException e) {
                    // java project doesn't exist: ignore
                  }
                  this.removeFromParentInfo(javaProject);
                  this.manager.removePerProjectInfo(javaProject);
                  this.manager.containerRemove(javaProject);
                }
                this.state.rootsAreStale = true;
              } else if ((delta.getFlags() & IResourceDelta.DESCRIPTION) != 0) {
                boolean wasJavaProject = this.state.findJavaProject(project.getName()) != null;
                boolean isJavaProject = JavaProject.hasJavaNature(project);
                if (wasJavaProject != isJavaProject) {
                  this.manager.batchContainerInitializations = true;
                 
                  // java nature added or removed: remember  project and its dependents
View Full Code Here

          }
          if  (rootInfo != null && rootInfo.project.getProject().equals(resource)){
            element = rootInfo.project;
            break;
          }
          IProject proj = (IProject)resource;
          if (JavaProject.hasJavaNature(proj)) {
            element = JavaCore.create(proj);
          } else {
            // java project may have been been closed or removed (look for
            // element amongst old java project s list).
            element =  this.state.findJavaProject(proj.getName());
          }
        }
        break;
      case IJavaElement.PACKAGE_FRAGMENT_ROOT:
        element = rootInfo == null ? JavaCore.create(resource) : rootInfo.getPackageFragmentRoot(resource);
View Full Code Here

          break;
        case IJavaElement.JAVA_MODEL :
          Iterator projectNames = this.state.getOldJavaProjecNames().iterator();
          while (projectNames.hasNext()) {
            String projectName = (String) projectNames.next();
            IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
            if (!JavaProject.hasJavaNature(project)) {
              // project is not accessible or has lost its Java nature
              continue;
            }
            javaProject = (JavaProject) JavaCore.create(project);
            try {
              classpath = javaProject.getResolvedClasspath();
            } catch (JavaModelException e2) {
              // project doesn't exist -> ignore
              continue;
            }
            for (int k = 0, cpLength = classpath.length; k < cpLength; k++){
              if (classpath[k].getEntryKind() == IClasspathEntry.CPE_LIBRARY){
                archivePathsToRefresh.add(classpath[k].getPath());
              }
            }
          }
          break;
      }
    }
   
    // perform refresh
    Iterator projectNames = this.state.getOldJavaProjecNames().iterator();
    IWorkspaceRoot wksRoot = ResourcesPlugin.getWorkspace().getRoot();
    while (projectNames.hasNext()) {
     
      if (monitor != null && monitor.isCanceled()) break;
     
      String projectName = (String) projectNames.next();
      IProject project = wksRoot.getProject(projectName);
      if (!JavaProject.hasJavaNature(project)) {
        // project is not accessible or has lost its Java nature
        continue;
      }
      JavaProject javaProject = (JavaProject) JavaCore.create(project);
      IClasspathEntry[] entries;
      try {
        entries = javaProject.getResolvedClasspath();
      } catch (JavaModelException e1) {
        // project does not exist -> ignore
        continue;
      }
      for (int j = 0; j < entries.length; j++){
        if (entries[j].getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
         
          IPath entryPath = entries[j].getPath();
         
          if (!archivePathsToRefresh.contains(entryPath)) continue; // not supposed to be refreshed
         
          String status = (String)externalArchivesStatus.get(entryPath);
          if (status == null){
           
            // compute shared status
            Object targetLibrary = JavaModel.getTarget(wksRoot, entryPath, true);
   
            if (targetLibrary == null){ // missing JAR
              if (this.state.getExternalLibTimeStamps().remove(entryPath) != null){
                externalArchivesStatus.put(entryPath, EXTERNAL_JAR_REMOVED);
                // the jar was physically removed: remove the index
                this.manager.indexManager.removeIndex(entryPath);
              }
   
            } else if (targetLibrary instanceof File){ // external JAR
   
              File externalFile = (File)targetLibrary;
             
              // check timestamp to figure if JAR has changed in some way
              Long oldTimestamp =(Long) this.state.getExternalLibTimeStamps().get(entryPath);
              long newTimeStamp = getTimeStamp(externalFile);
              if (oldTimestamp != null){
   
                if (newTimeStamp == 0){ // file doesn't exist
                  externalArchivesStatus.put(entryPath, EXTERNAL_JAR_REMOVED);
                  this.state.getExternalLibTimeStamps().remove(entryPath);
                  // remove the index
                  this.manager.indexManager.removeIndex(entryPath);
   
                } else if (oldTimestamp.longValue() != newTimeStamp){
                  externalArchivesStatus.put(entryPath, EXTERNAL_JAR_CHANGED);
                  this.state.getExternalLibTimeStamps().put(entryPath, new Long(newTimeStamp));
                  // first remove the index so that it is forced to be re-indexed
                  this.manager.indexManager.removeIndex(entryPath);
                  // then index the jar
                  this.manager.indexManager.indexLibrary(entryPath, project.getProject());
                } else {
                  externalArchivesStatus.put(entryPath, EXTERNAL_JAR_UNCHANGED);
                }
              } else {
                if (newTimeStamp == 0){ // jar still doesn't exist
                  externalArchivesStatus.put(entryPath, EXTERNAL_JAR_UNCHANGED);
                } else {
                  externalArchivesStatus.put(entryPath, EXTERNAL_JAR_ADDED);
                  this.state.getExternalLibTimeStamps().put(entryPath, new Long(newTimeStamp));
                  // index the new jar
                  this.manager.indexManager.indexLibrary(entryPath, project.getProject());
                }
              }
            } else { // internal JAR
              externalArchivesStatus.put(entryPath, INTERNAL_JAR_IGNORE);
            }
View Full Code Here

TOP

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

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.