Package org.aspectj.org.eclipse.jdt.internal.core

Examples of org.aspectj.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


    }

    // initialize pattern for polymorphic search (ie. 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;
    for (int i = 0; i < docsLength; i++) {
      if (this.progressMonitor != null && this.progressMonitor.isCanceled()) {
        throw new OperationCanceledException();
      }

      // skip duplicate paths
      SearchDocument searchDocument = searchDocuments[i];
      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.aspectj.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
      if (!javaProject.equals(previousJavaProject)) {
        // locate matches in previous project
        if (previousJavaProject != null) {
          try {
            locateMatches(previousJavaProject, matchSet, i-displayed);
            displayed = i;
View Full Code Here

    if (!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);
            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.getIndexFile().lastModified();

      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

    if (target instanceof IFile) {
      // internal jar: is it on the classpath of its project?
      //  e.g. org.eclipse.swt.win32/ws/win32/swt.jar
      //        is NOT on the classpath of org.eclipse.swt.win32
      IFile jarFile = (IFile)target;
      JavaProject javaProject = (JavaProject) this.javaModel.getJavaProject(jarFile);
      try {
        IClasspathEntry entry = javaProject.getClasspathEntryFor(jarPath);
        if (entry != null) {
          return javaProject.getPackageFragmentRoot(jarFile);
        }
      } catch (JavaModelException e) {
        // ignore and try to find another project
      }
    }
View Full Code Here

    IPath jarPath,
    Object target,
    IJavaProject[] projects) {
    for (int i= 0, projectCount= projects.length; i < projectCount; i++) {
      try {
        JavaProject javaProject= (JavaProject)projects[i];
        IClasspathEntry classpathEnty = javaProject.getClasspathEntryFor(jarPath);
        if (classpathEnty != null) {
          if (target instanceof IFile) {
            // internal jar
            return javaProject.getPackageFragmentRoot((IFile)target);
          } else {
            // external jar
            return javaProject.getPackageFragmentRoot0(jarPath);
          }
        }
      } catch (JavaModelException e) {
        // JavaModelException from getResolvedClasspath - a problem occured while accessing project: nothing we can do, ignore
      }
View Full Code Here

*/
public static boolean canSeeFocus(IJavaElement focus, boolean isPolymorphicSearch, IPath projectOrJarPath) {
  try {
    IClasspathEntry[] focusEntries = null;
    if (isPolymorphicSearch) {
      JavaProject focusProject = focus instanceof JarPackageFragmentRoot ? (JavaProject) focus.getParent() : (JavaProject) focus;
      focusEntries = focusProject.getExpandedClasspath();
    }
    IJavaModel model = focus.getJavaModel();
    IJavaProject project = getJavaProject(projectOrJarPath, model);
    if (project != null)
      return canSeeFocus(focus, (JavaProject) project, focusEntries);

    // 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
          && canSeeFocus(focus, otherProject, focusEntries))
        return true;
    }
View Full Code Here

      SimpleSet visitedProjects = new SimpleSet(length);
      int projectIndex = 0;
      SimpleSet jarsToCheck = new SimpleSet(length);
      IClasspathEntry[] focusEntries = null;
      if (this.pattern instanceof MethodPattern) { // should consider polymorphic search for method patterns
        JavaProject focusProject = focus instanceof JarPackageFragmentRoot ? (JavaProject) focus.getParent() : (JavaProject) focus;
        focusEntries = focusProject.getExpandedClasspath();
      }
      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(focus, project, focusEntries)) {
            locations.add(manager.computeIndexLocation(path));
            projectsCanSeeFocus[projectIndex++] = project;
          }
        } else {
          jarsToCheck.add(path);
        }
      }
      for (int i = 0; i < projectIndex && jarsToCheck.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 (jarsToCheck.includes(path)) {
              locations.add(manager.computeIndexLocation(entry.getPath()));
              jarsToCheck.remove(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 (jarsToCheck.elementSize > 0) {
        IJavaProject[] allProjects = model.getJavaProjects();
        for (int i = 0, l = allProjects.length; i < l && jarsToCheck.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 (jarsToCheck.includes(path)) {
View Full Code Here

TOP

Related Classes of org.aspectj.org.eclipse.jdt.internal.core.JavaProject

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.