Package org.eclipse.jdt.internal.core.search.indexing

Examples of org.eclipse.jdt.internal.core.search.indexing.IndexManager


     * It is required to initialize all fields that depends on a headless environment
     * only if the platform is running. Otherwise this breaks the ability to use
     * ASTParser in a non-headless environment.
     */
    if (Platform.isRunning()) {
      this.indexManager = new IndexManager();
      this.nonChainingJars = loadClasspathListCache(NON_CHAINING_JARS_CACHE);
      this.invalidArchives = loadClasspathListCache(INVALID_ARCHIVES_CACHE);
      this.externalFiles = loadClasspathListCache(EXTERNAL_FILES_CACHE);
      this.assumedExternalFiles = loadClasspathListCache(ASSUMED_EXTERNAL_FILES_CACHE);
      String includeContainerReferencedLib = System.getProperty(RESOLVE_REFERENCED_LIBRARIES_FOR_CONTAINERS);
View Full Code Here


        // will need delta since this save (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=38658)
        context.needDelta();
 
        // clean up indexes on workspace full save
        // (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=52347)
        IndexManager manager = this.indexManager;
        if (manager != null
            // don't force initialization of workspace scope as we could be shutting down
            // (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=93941)
            && this.workspaceScope != null) {
          manager.cleanUpIndexes();
        }
      }
      //$FALL-THROUGH$
      case ISaveContext.SNAPSHOT : {
        // clean up external folders on full save or snapshot
View Full Code Here

   
    public void forgetExternalTimestampsAndIndexes() {
      IClasspathEntry[] classpath = this.resolvedClasspath;
      if (classpath == null) return;
      JavaModelManager manager = JavaModelManager.getJavaModelManager();
      IndexManager indexManager = manager.indexManager;
      Map externalTimeStamps = manager.deltaState.getExternalLibTimeStamps();
      HashMap rootInfos = JavaModelManager.getDeltaState().otherRoots;
      for (int i = 0, length = classpath.length; i < length; i++) {
        IClasspathEntry entry = classpath[i];
        if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
          IPath path = entry.getPath();
          if (rootInfos.get(path) == null) {
            externalTimeStamps.remove(path);
            indexManager.removeIndex(path); // force reindexing on next reference (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=250083 )
          }
        }
      }
    }
View Full Code Here

   *
   * @param indexLocation the location in the file system to the index
   * @since 3.2
   */
  public void removeIndex(IPath indexLocation){
    IndexManager manager = JavaModelManager.getIndexManager();
    manager.removeIndexPath(indexLocation);
  }
View Full Code Here

    if (file instanceof IResource) {
      containerPath = ((IResource)file).getProject().getFullPath();
    } else if (file == null) {
      containerPath = documentPath.removeLastSegments(1);
    }
    IndexManager manager = JavaModelManager.getIndexManager();
    // TODO (frederic) should not have to create index manually, should expose API that recreates index instead
    IndexLocation indexLocation;
    indexLocation = new FileIndexLocation(indexPath.toFile(), true);
    manager.ensureIndexExists(indexLocation, containerPath);
    manager.scheduleDocumentIndexing(document, containerPath, indexLocation, this);
    if (!indexPath.equals(this.lastIndexLocation)) {
      manager.updateParticipant(indexPath, containerPath);
      this.lastIndexLocation = indexPath;
    }
  }
View Full Code Here

      };
     
      int matchRule = SearchPattern.R_PREFIX_MATCH;
      if (camelCaseMatch) matchRule |= SearchPattern.R_CAMELCASE_MATCH;
      if (monitor != null) {
        IndexManager indexManager = JavaModelManager.getIndexManager();
        if (indexManager.awaitingJobsCount() == 0) {
          // indexes were already there, so perform an immediate search to avoid any index rebuilt
          new BasicSearchEngine(this.workingCopies).searchAllTypeNames(
            qualification,
            SearchPattern.R_EXACT_MATCH,
            simpleName,
            matchRule, // not case sensitive
            searchFor,
            getSearchScope(),
            typeRequestor,
            FORCE_IMMEDIATE_SEARCH,
            progressMonitor);
        } else {
          // indexes were not ready, give the indexing a chance to finish small jobs by sleeping 100ms...
          try {
            Thread.sleep(100);
          } catch (InterruptedException e) {
            // Do nothing
          }
          if (monitor.isCanceled()) {
            throw new OperationCanceledException();
          }
          if (indexManager.awaitingJobsCount() == 0) {
            // indexes are now ready, so perform an immediate search to avoid any index rebuilt
            new BasicSearchEngine(this.workingCopies).searchAllTypeNames(
              qualification,
              SearchPattern.R_EXACT_MATCH,
              simpleName,
View Full Code Here

      };
     
      int matchRule = SearchPattern.R_PREFIX_MATCH;
      if (camelCaseMatch) matchRule |= SearchPattern.R_CAMELCASE_MATCH;
      if (monitor != null) {
        IndexManager indexManager = JavaModelManager.getIndexManager();
        while (indexManager.awaitingJobsCount() > 0) {
          try {
            Thread.sleep(50); // indexes are not ready,  sleep 50ms...
          } catch (InterruptedException e) {
            // Do nothing
          }
View Full Code Here

      // project doesn't exist
      return;
    }

    JavaModelManager manager = JavaModelManager.getJavaModelManager();
    IndexManager indexManager = manager.indexManager;
    if (indexManager == null)
      return;
    DeltaProcessingState state = manager.deltaState;

    int newLength = newResolvedClasspath.length;
    int oldLength = this.oldResolvedClasspath == null ? 0 : this.oldResolvedClasspath.length;
    for (int i = 0; i < oldLength; i++) {
      int index = classpathContains(newResolvedClasspath, this.oldResolvedClasspath[i]);
      if (index == -1) {
        // remote projects are not indexed in this project
        if (this.oldResolvedClasspath[i].getEntryKind() == IClasspathEntry.CPE_PROJECT){
          continue;
        }

        // Remove the .java files from the index for a source folder
        // For a lib folder or a .jar file, remove the corresponding index if not shared.
        IClasspathEntry oldEntry = this.oldResolvedClasspath[i];
        final IPath path = oldEntry.getPath();
        int changeKind = this.oldResolvedClasspath[i].getEntryKind();
        switch (changeKind) {
          case IClasspathEntry.CPE_SOURCE:
            char[][] inclusionPatterns = ((ClasspathEntry)oldEntry).fullInclusionPatternChars();
            char[][] exclusionPatterns = ((ClasspathEntry)oldEntry).fullExclusionPatternChars();
            indexManager.removeSourceFolderFromIndex(this.project, path, inclusionPatterns, exclusionPatterns);
            break;
          case IClasspathEntry.CPE_LIBRARY:
            if (state.otherRoots.get(path) == null) { // if root was not shared
              indexManager.discardJobs(path.toString());
              indexManager.removeIndex(path);
              // TODO (kent) we could just remove the in-memory index and have the indexing check for timestamps
            }
            break;
        }
      }
    }

    for (int i = 0; i < newLength; i++) {
      int index = classpathContains(this.oldResolvedClasspath, newResolvedClasspath[i]);
      if (index == -1 || newResolvedClasspath[i].getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
        // remote projects are not indexed in this project
        if (newResolvedClasspath[i].getEntryKind() == IClasspathEntry.CPE_PROJECT){
          continue;
        }

        // Request indexing
        int entryKind = newResolvedClasspath[i].getEntryKind();
        URL newurl = ((ClasspathEntry)newResolvedClasspath[i]).getLibraryIndexLocation();
        switch (entryKind) {
          case IClasspathEntry.CPE_LIBRARY:
            boolean pathHasChanged = true;
            IPath newPath = newResolvedClasspath[i].getPath();
            for (int j = 0; j < oldLength; j++) {
              IClasspathEntry oldEntry = this.oldResolvedClasspath[j];
              if (oldEntry.getPath().equals(newPath)) {
                URL oldurl = ((ClasspathEntry)oldEntry).getLibraryIndexLocation();
                if (oldurl == null && newurl == null) {
                  pathHasChanged = false;
                } else if (oldurl != null && newurl != null) {
                  pathHasChanged = !(newurl.equals(oldurl));
                } else if (oldurl != null) {
                  indexManager.removeIndex(newPath);
                }
                break;
              }
            }
            if (pathHasChanged) {
              indexManager.indexLibrary(newPath, this.project.getProject(), newurl);
            }
            break;
          case IClasspathEntry.CPE_SOURCE:
            IClasspathEntry entry = newResolvedClasspath[i];
            IPath path = entry.getPath();
            char[][] inclusionPatterns = ((ClasspathEntry)entry).fullInclusionPatternChars();
            char[][] exclusionPatterns = ((ClasspathEntry)entry).fullExclusionPatternChars();
            indexManager.indexSourceFolder(this.project, path, inclusionPatterns, exclusionPatterns);
            break;
        }
      }
    }
  }
View Full Code Here

   *
   * @param indexLocation the location in the file system to the index
   * @since 3.2
   */
  public void removeIndex(IPath indexLocation){
    IndexManager manager = JavaModelManager.getIndexManager();
    manager.removeIndexPath(indexLocation);
  }
View Full Code Here

    if (file instanceof IResource) {
      containerPath = ((IResource)file).getProject().getFullPath();
    } else if (file == null) {
      containerPath = documentPath.removeLastSegments(1);
    }
    IndexManager manager = JavaModelManager.getIndexManager();
    // TODO (frederic) should not have to create index manually, should expose API that recreates index instead
    IndexLocation indexLocation;
    indexLocation = new FileIndexLocation(indexPath.toFile(), true);
    manager.ensureIndexExists(indexLocation, containerPath);
    manager.scheduleDocumentIndexing(document, containerPath, indexLocation, this);
    if (!indexPath.equals(this.lastIndexLocation)) {
      manager.updateParticipant(indexPath, containerPath);
      this.lastIndexLocation = indexPath;
    }
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.internal.core.search.indexing.IndexManager

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.