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

Examples of org.aspectj.org.eclipse.jdt.internal.core.index.Index


  public boolean execute(IProgressMonitor progressMonitor) {

    if (this.isCancelled || progressMonitor != null && progressMonitor.isCanceled()) return true;

    /* ensure no concurrent write access to index */
    Index index = this.manager.getIndex(this.containerPath, true, /*reuse index file*/ false /*create if none*/);
    if (index == null) return true;
    ReadWriteMonitor monitor = index.monitor;
    if (monitor == null) return true; // index got deleted since acquired

    try {
      monitor.enterRead(); // ask permission to read
      String containerRelativePath = Util.relativePath(this.folderPath, this.containerPath.segmentCount());
      String[] paths = index.queryDocumentNames(containerRelativePath);
      // all file names belonging to the folder or its subfolders and that are not excluded (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=32607)
      if (paths != null) {
        if (this.exclusionPatterns == null && this.inclusionPatterns == null) {
          for (int i = 0, max = paths.length; i < max; i++) {
            manager.remove(paths[i], this.containerPath); // write lock will be acquired by the remove operation
View Full Code Here


    if (this.isCancelled || progressMonitor != null && progressMonitor.isCanceled()) return true;

    try {
      // if index is already cached, then do not perform any check
      // MUST reset the IndexManager if a jar file is changed
      Index index = this.manager.getIndexForUpdate(this.containerPath, false, /*do not reuse index file*/ false /*do not create if none*/);
      if (index != null) {
        if (JobManager.VERBOSE)
          org.aspectj.org.eclipse.jdt.internal.core.util.Util.verbose("-> no indexing required (index already exists) for " + this.containerPath); //$NON-NLS-1$
        return true;
      }

      index = this.manager.getIndexForUpdate(this.containerPath, true, /*reuse index file*/ true /*create if none*/);
      if (index == null) {
        if (JobManager.VERBOSE)
          org.aspectj.org.eclipse.jdt.internal.core.util.Util.verbose("-> index could not be created for " + this.containerPath); //$NON-NLS-1$
        return true;
      }
      ReadWriteMonitor monitor = index.monitor;
      if (monitor == null) {
        if (JobManager.VERBOSE)
          org.aspectj.org.eclipse.jdt.internal.core.util.Util.verbose("-> index for " + this.containerPath + " just got deleted"); //$NON-NLS-1$//$NON-NLS-2$
        return true; // index got deleted since acquired
      }
      ZipFile zip = null;
      try {
        // this path will be a relative path to the workspace in case the zipfile in the workspace otherwise it will be a path in the
        // local file system
        Path zipFilePath = null;

        monitor.enterWrite(); // ask permission to write
        if (resource != null) {
          URI location = this.resource.getLocationURI();
          if (location == null) return false;
          if (JavaModelManager.ZIP_ACCESS_VERBOSE)
            System.out.println("(" + Thread.currentThread() + ") [AddJarFileToIndex.execute()] Creating ZipFile on " + location.getPath()); //$NON-NLS-1$  //$NON-NLS-2$
          File file = null;
          try {
            file = org.aspectj.org.eclipse.jdt.internal.core.util.Util.toLocalFile(location, progressMonitor);
          } catch (CoreException e) {
            if (JobManager.VERBOSE) {
              org.aspectj.org.eclipse.jdt.internal.core.util.Util.verbose("-> failed to index " + location.getPath() + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
              e.printStackTrace();
            }
          }
          if (file == null) {
            if (JobManager.VERBOSE)
              org.aspectj.org.eclipse.jdt.internal.core.util.Util.verbose("-> failed to index " + location.getPath() + " because the file could not be fetched"); //$NON-NLS-1$ //$NON-NLS-2$
            return false;
          }
          zip = new ZipFile(file);
          zipFilePath = (Path) this.resource.getFullPath().makeRelative();
          // absolute path relative to the workspace
        } else {
          if (JavaModelManager.ZIP_ACCESS_VERBOSE)
            System.out.println("(" + Thread.currentThread() + ") [AddJarFileToIndex.execute()] Creating ZipFile on " + this.containerPath); //$NON-NLS-1$  //$NON-NLS-2$
          // external file -> it is ok to use toFile()
          zip = new ZipFile(this.containerPath.toFile());
          zipFilePath = (Path) this.containerPath;
          // path is already canonical since coming from a library classpath entry
        }

        if (this.isCancelled) {
          if (JobManager.VERBOSE)
            org.aspectj.org.eclipse.jdt.internal.core.util.Util.verbose("-> indexing of " + zip.getName() + " has been cancelled"); //$NON-NLS-1$ //$NON-NLS-2$
          return false;
        }

        if (JobManager.VERBOSE)
          org.aspectj.org.eclipse.jdt.internal.core.util.Util.verbose("-> indexing " + zip.getName()); //$NON-NLS-1$
        long initialTime = System.currentTimeMillis();

        String[] paths = index.queryDocumentNames(""); // all file names //$NON-NLS-1$
        if (paths != null) {
          int max = paths.length;
          /* check integrity of the existing index file
           * if the length is equal to 0, we want to index the whole jar again
           * If not, then we want to check that there is no missing entry, if
View Full Code Here

  public boolean execute(IProgressMonitor progressMonitor) {

    if (this.isCancelled || progressMonitor != null && progressMonitor.isCanceled()) return true;

    /* ensure no concurrent write access to index */
    Index index = this.manager.getIndex(this.containerPath, true /*reuse index file*/, false /*don't create if none*/);
    if (index == null) return true;
    ReadWriteMonitor monitor = index.monitor;
    if (monitor == null) return true; // index got deleted since acquired

    try {
View Full Code Here

  public boolean execute(IProgressMonitor progressMonitor) {

    if (this.isCancelled || progressMonitor != null && progressMonitor.isCanceled()) return true;

    /* ensure no concurrent write access to index */
    Index index = this.manager.getIndex(this.containerPath, true, /*reuse index file*/ false /*create if none*/);
    if (index == null) return true;
    ReadWriteMonitor monitor = index.monitor;
    if (monitor == null) return true; // index got deleted since acquired

    try {
      monitor.enterWrite(); // ask permission to write
      index.remove(resourceName);
    } finally {
      monitor.exitWrite(); // free write lock
    }
    return true;
  }
View Full Code Here

            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;

View Full Code Here

    if (!project.isAccessible()) return true; // nothing to do
    IResource folder = this.project.getParent().findMember(this.folderPath);
    if (folder == null || folder.getType() == IResource.FILE) return true; // nothing to do, source folder was removed

    /* ensure no concurrent write access to index */
    Index index = this.manager.getIndex(this.containerPath, true, /*reuse index file*/ true /*create if none*/);
    if (index == null) return true;
    ReadWriteMonitor monitor = index.monitor;
    if (monitor == null) return true; // index got deleted since acquired

    try {
View Full Code Here

  public boolean execute(IProgressMonitor progressMonitor) {

    if (this.isCancelled || progressMonitor != null && progressMonitor.isCanceled()) return true;
    if (!this.folder.isAccessible()) return true; // nothing to do

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

    try {
      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) {
        this.folder.accept(new IResourceProxyVisitor() {
          public boolean visit(IResourceProxy proxy) {
            if (isCancelled) return false;
            if (proxy.getType() == IResource.FILE) {
              if (org.aspectj.org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(proxy.getName())) {
                IFile file = (IFile) proxy.requestResource();
                String containerRelativePath = Util.relativePath(file.getFullPath(), containerPath.segmentCount());
                indexedFileNames.put(containerRelativePath, file);
              }
              return false;
            }
            return true;
          }
        }, IResource.NONE);
      } else {
        for (int i = 0; i < max; i++) {
          indexedFileNames.put(paths[i], DELETED);
        }
        final long indexLastModified = index.getIndexFile().lastModified();
        this.folder.accept(
          new IResourceProxyVisitor() {
            public boolean visit(IResourceProxy proxy) throws CoreException {
              if (isCancelled) return false;
              if (proxy.getType() == IResource.FILE) {
View Full Code Here

  IndexManager indexManager = JavaModelManager.getJavaModelManager().getIndexManager();
  for (int i = 0; i < length; i++) {
    if (progressMonitor != null && progressMonitor.isCanceled()) throw new OperationCanceledException();
    // may trigger some index recreation work
    IPath indexLocation = indexLocations[i];
    Index index = indexManager.getIndex(indexLocation);
    if (index == null) {
      // only need containerPath if the index must be built
      IPath containerPath = (IPath) indexManager.indexLocations.keyForValue(indexLocation);
      if (containerPath != null) // sanity check
        index = indexManager.getIndex(containerPath, indexLocation, true /*reuse index file*/, false /*do not create if none*/);
 
View Full Code Here

TOP

Related Classes of org.aspectj.org.eclipse.jdt.internal.core.index.Index

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.