Examples of JavaProject


Examples of org.eclipse.jdt.internal.core.JavaProject

    if (monitor != null) monitor.beginTask("", size * 2/* 1 for build binding, 1 for connect hierarchy*/); //$NON-NLS-1$
    this.infoToHandle = new HashMap(size);
    Iterator javaProjects = allOpenablesInRegion.entrySet().iterator();
    while (javaProjects.hasNext()) {
      Map.Entry entry = (Map.Entry) javaProjects.next();
      JavaProject project = (JavaProject) entry.getKey();
      ArrayList allOpenables = (ArrayList) entry.getValue();
      Openable[] openables = new Openable[allOpenables.size()];
      allOpenables.toArray(openables);

      try {
        // resolve
        SearchableEnvironment searchableEnvironment = project.newSearchableNameEnvironment(this.hierarchy.workingCopies);
        this.nameLookup = searchableEnvironment.nameLookup;
        this.hierarchyResolver.resolve(openables, null, monitor);
      } catch (JavaModelException e) {
        // project doesn't exit: ignore
      }
View Full Code Here

Examples of org.eclipse.jdt.internal.core.JavaProject

    Collection<IProject> result = new HashSet<IProject>();
    IProject[] referencedProjects = proj.getReferencedProjects();
    result.addAll(Arrays.asList(referencedProjects));
    IProjectNature nature = proj.getNature(JAVANATURE);
    if(nature != null) {
      JavaProject javaProject = (JavaProject) JavaCore.create(proj);
      IClasspathEntry[] resolvedClasspath = javaProject.getResolvedClasspath();
      for (IClasspathEntry eachCPE : resolvedClasspath) {
        if(eachCPE.getEntryKind() == IClasspathEntry.CPE_PROJECT) {
         IProject project = getProject(eachCPE.getPath());
         result.add(project);
        }
View Full Code Here

Examples of org.eclipse.jdt.internal.core.JavaProject

  private void extendClasspathWithProject(Collection<String> result, IProject project,
          Collection<IProject> visited) throws CoreException, JavaModelException {
    IProjectNature nature = project.getNature(RutaProjectUtils.JAVANATURE);
    if (nature != null) {
      JavaProject javaProject = (JavaProject) JavaCore.create(project);

      // add output, e.g., target/classes
      IPath readOutputLocation = javaProject.readOutputLocation();
      IFolder folder = ResourcesPlugin.getWorkspace().getRoot().getFolder(readOutputLocation);
      result.add(folder.getLocation().toPortableString());

      IClasspathEntry[] rawClasspath = javaProject.getRawClasspath();
      for (IClasspathEntry each : rawClasspath) {
        int entryKind = each.getEntryKind();
        IPath path = each.getPath();
        if (entryKind == IClasspathEntry.CPE_PROJECT) {
          IProject p = RutaProjectUtils.getProject(path);
          if (!visited.contains(p)) {
            visited.add(p);
            extendClasspathWithProject(result, p, visited);
          }
        } else if (entryKind != IClasspathEntry.CPE_SOURCE) {
          String segment = path.segment(0);
          if (!segment.equals("org.eclipse.jdt.launching.JRE_CONTAINER")) {
            IClasspathEntry[] resolveClasspath = javaProject
                    .resolveClasspath(new IClasspathEntry[] { each });
            for (IClasspathEntry eachResolved : resolveClasspath) {
              if (eachResolved.getEntryKind() == IClasspathEntry.CPE_PROJECT) {
                IProject p = RutaProjectUtils.getProject(eachResolved.getPath());
                if (!visited.contains(p)) {
View Full Code Here

Examples of org.eclipse.jdt.internal.core.JavaProject

    if (monitor != null) monitor.beginTask("", size * 2/* 1 for build binding, 1 for connect hierarchy*/); //$NON-NLS-1$
    this.infoToHandle = new HashMap(size);
    Iterator javaProjects = allOpenablesInRegion.entrySet().iterator();
    while (javaProjects.hasNext()) {
      Map.Entry entry = (Map.Entry) javaProjects.next();
      JavaProject project = (JavaProject) entry.getKey();
      ArrayList allOpenables = (ArrayList) entry.getValue();
      Openable[] openables = new Openable[allOpenables.size()];
      allOpenables.toArray(openables);

      try {
        // resolve
        SearchableEnvironment searchableEnvironment = project.newSearchableNameEnvironment(this.hierarchy.workingCopies);
        this.nameLookup = searchableEnvironment.nameLookup;
        this.hierarchyResolver.resolve(openables, null, monitor);
      } catch (JavaModelException e) {
        // project doesn't exit: ignore
      }
View Full Code Here

Examples of org.eclipse.jdt.internal.core.JavaProject

  try {
    IJavaProject[] projects = JavaModelManager.getJavaModelManager().getJavaModel().getJavaProjects();
    // use a linked set to preserve the order during search: see bug 348507
    Set paths = new LinkedHashSet(projects.length * 2);
    for (int i = 0, length = projects.length; i < length; i++) {
      JavaProject javaProject = (JavaProject) projects[i];

      // Add project full path
      IPath projectPath = javaProject.getProject().getFullPath();
      paths.add(projectPath);
    }

    // add the project source paths first in a separate loop above
    // to ensure source files always get higher precedence during search.
    // see bug 348507

    for (int i = 0, length = projects.length; i < length; i++) {
      JavaProject javaProject = (JavaProject) projects[i];

      // Add project libraries paths
      IClasspathEntry[] entries = javaProject.getResolvedClasspath();
      for (int j = 0, eLength = entries.length; j < eLength; j++) {
        IClasspathEntry entry = entries[j];
        if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
          IPath path = entry.getPath();
          Object target = JavaModel.getTarget(path, false/*don't check existence*/);
 
View Full Code Here

Examples of org.eclipse.jdt.internal.core.JavaProject

        break;
      case IClasspathEntry.CPE_PROJECT:
        if ((includeMask & REFERENCED_PROJECTS) != 0) {
          IPath path = entry.getPath();
          if (pathToAdd == null || pathToAdd.equals(path)) {
            JavaProject referencedProject = (JavaProject) model.getJavaProject(path.lastSegment());
            if (!projectsToBeAdded.contains(referencedProject)) { // do not recurse if depending project was used to create the scope
              add(referencedProject, null, includeMask, projectsToBeAdded, visitedProjects, cpEntry);
            }
          }
        }
View Full Code Here

Examples of org.eclipse.jdt.internal.core.JavaProject

    }

    // initialize pattern for polymorphic search (i.e. method reference pattern)
    this.patternLocator.initializePolymorphicSearch(this);

    JavaProject previousJavaProject = null;
    PossibleMatchSet matchSet = new PossibleMatchSet();
    Util.sort(searchDocuments, new Util.Comparer() {
      public int compare(Object a, Object b) {
        return ((SearchDocument)a).getPath().compareTo(((SearchDocument)b).getPath());
      }
    });
    int displayed = 0; // progress worked displayed
    String previousPath = null;
    SearchParticipant searchParticipant = null;
    for (int i = 0; i < docsLength; i++) {
      if (this.progressMonitor != null && this.progressMonitor.isCanceled()) {
        throw new OperationCanceledException();
      }

      // skip duplicate paths
      SearchDocument searchDocument = searchDocuments[i];
      if (searchParticipant == null) {
        searchParticipant = searchDocument.getParticipant();
      }
      searchDocuments[i] = null; // free current document
      String pathString = searchDocument.getPath();
      if (i > 0 && pathString.equals(previousPath)) {
        if (this.progressMonitor != null) {
          this.progressWorked++;
          if ((this.progressWorked%this.progressStep)==0) this.progressMonitor.worked(this.progressStep);
        }
        displayed++;
        continue;
      }
      previousPath = pathString;

      Openable openable;
      org.eclipse.jdt.core.ICompilationUnit workingCopy = null;
      if (searchDocument instanceof WorkingCopyDocument) {
        workingCopy = ((WorkingCopyDocument)searchDocument).workingCopy;
        openable = (Openable) workingCopy;
      } else {
        openable = this.handleFactory.createOpenable(pathString, this.scope);
      }
      if (openable == null) {
        if (this.progressMonitor != null) {
          this.progressWorked++;
          if ((this.progressWorked%this.progressStep)==0) this.progressMonitor.worked(this.progressStep);
        }
        displayed++;
        continue; // match is outside classpath
      }

      // create new parser and lookup environment if this is a new project
      IResource resource = null;
      JavaProject javaProject = (JavaProject) openable.getJavaProject();
      resource = workingCopy != null ? workingCopy.getResource() : openable.getResource();
      if (resource == null)
        resource = javaProject.getProject(); // case of a file in an external jar or external folder
      if (!javaProject.equals(previousJavaProject)) {
        // locate matches in previous project
        if (previousJavaProject != null) {
          try {
            locateMatches(previousJavaProject, matchSet, i-displayed);
            displayed = i;
View Full Code Here

Examples of org.eclipse.jdt.internal.core.JavaProject

    if (!this.project.isAccessible()) return true; // nothing to do

    ReadWriteMonitor monitor = null;
    try {
      // Get source folder entries. Libraries are done as a separate job
      JavaProject javaProject = (JavaProject)JavaCore.create(this.project);
      // Do not create marker while getting raw classpath (see bug 41859)
      IClasspathEntry[] entries = javaProject.getRawClasspath();
      int length = entries.length;
      IClasspathEntry[] sourceEntries = new IClasspathEntry[length];
      int sourceEntriesNumber = 0;
      for (int i = 0; i < length; i++) {
        IClasspathEntry entry = entries[i];
        if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE)
          sourceEntries[sourceEntriesNumber++] = entry;
      }
      if (sourceEntriesNumber == 0) {
        IPath projectPath = javaProject.getPath();
        for (int i = 0; i < length; i++) {
          IClasspathEntry entry = entries[i];
          if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY && entry.getPath().equals(projectPath)) {
            // the project is also a library folder (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=89815)
            // ensure a job exists to index it as a binary folder
            this.manager.indexLibrary(projectPath, this.project, ((ClasspathEntry)entry).getLibraryIndexLocation());
            return true;
          }
        }

        // nothing to index but want to save an empty index file so its not 'rebuilt' when part of a search request
        Index index = this.manager.getIndexForUpdate(this.containerPath, true, /*reuse index file*/ true /*create if none*/);
        if (index != null)
          this.manager.saveIndex(index);
        return true;
      }
      if (sourceEntriesNumber != length)
        System.arraycopy(sourceEntries, 0, sourceEntries = new IClasspathEntry[sourceEntriesNumber], 0, sourceEntriesNumber);

      Index index = this.manager.getIndexForUpdate(this.containerPath, true, /*reuse index file*/ true /*create if none*/);
      if (index == null) return true;
      monitor = index.monitor;
      if (monitor == null) return true; // index got deleted since acquired

      monitor.enterRead(); // ask permission to read

      String[] paths = index.queryDocumentNames(""); // all file names //$NON-NLS-1$
      int max = paths == null ? 0 : paths.length;
      final SimpleLookupTable indexedFileNames = new SimpleLookupTable(max == 0 ? 33 : max + 11);
      final String OK = "OK"; //$NON-NLS-1$
      final String DELETED = "DELETED"; //$NON-NLS-1$
      if (paths != null) {
        for (int i = 0; i < max; i++)
          indexedFileNames.put(paths[i], DELETED);
      }
      final long indexLastModified = max == 0 ? 0L : index.getIndexLastModified();

      IWorkspaceRoot root = this.project.getWorkspace().getRoot();
      for (int i = 0; i < sourceEntriesNumber; i++) {
        if (this.isCancelled) return false;

        IClasspathEntry entry = sourceEntries[i];
        IResource sourceFolder = root.findMember(entry.getPath());
        if (sourceFolder != null) {

          // collect output locations if source is project (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=32041)
          final HashSet outputs = new HashSet();
          if (sourceFolder.getType() == IResource.PROJECT) {
            // Do not create marker while getting output location (see bug 41859)
            outputs.add(javaProject.getOutputLocation());
            for (int j = 0; j < sourceEntriesNumber; j++) {
              IPath output = sourceEntries[j].getOutputLocation();
              if (output != null) {
                outputs.add(output);
              }
View Full Code Here

Examples of org.eclipse.jdt.internal.core.JavaProject

    // projectOrJarPath is a jar
    // it can see the focus only if it is on the classpath of a project that can see the focus
    IJavaProject[] allProjects = model.getJavaProjects();
    for (int i = 0, length = allProjects.length; i < length; i++) {
      JavaProject otherProject = (JavaProject) allProjects[i];
      IClasspathEntry entry = otherProject.getClasspathEntryFor(projectOrJarPath);
      if (entry != null && entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
        if (canSeeFocus(focuses, otherProject, null)) {
          return true;
        }
      }
View Full Code Here

Examples of org.eclipse.jdt.internal.core.JavaProject

        focusQualifiedNames = getQualifiedNames(superTypes);
      }
      IJavaModel model = JavaModelManager.getJavaModelManager().getJavaModel();
      for (int i = 0; i < length; i++) {
        IPath path = projectsAndJars[i];
        JavaProject project = (JavaProject) getJavaProject(path, model);
        if (project != null) {
          visitedProjects.add(project);
          if (canSeeFocus(focuses, project, focusQualifiedNames)) {
            locations.add(manager.computeIndexLocation(path));
            projectsCanSeeFocus[projectIndex++] = project;
          }
        } else {
          externalLibsToCheck.add(path);
        }
      }
      for (int i = 0; i < projectIndex && externalLibsToCheck.elementSize > 0; i++) {
        IClasspathEntry[] entries = projectsCanSeeFocus[i].getResolvedClasspath();
        for (int j = entries.length; --j >= 0;) {
          IClasspathEntry entry = entries[j];
          if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
            IPath path = entry.getPath();
            if (externalLibsToCheck.remove(path) != null) {
              Object target = JavaModel.getTarget(path, false/*don't check existence*/);
              if (target instanceof IFolder) // case of an external folder
                path = ((IFolder) target).getFullPath();
              locations.add(manager.computeIndexLocation(path));
            }
          }
        }
      }
      // jar files can be included in the search scope without including one of the projects that references them, so scan all projects that have not been visited
      if (externalLibsToCheck.elementSize > 0) {
        IJavaProject[] allProjects = model.getJavaProjects();
        for (int i = 0, l = allProjects.length; i < l && externalLibsToCheck.elementSize > 0; i++) {
          JavaProject project = (JavaProject) allProjects[i];
          if (!visitedProjects.includes(project)) {
            IClasspathEntry[] entries = project.getResolvedClasspath();
            for (int j = entries.length; --j >= 0;) {
              IClasspathEntry entry = entries[j];
              if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
                IPath path = entry.getPath();
                if (externalLibsToCheck.remove(path) != null) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.