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

Examples of org.aspectj.org.eclipse.jdt.internal.core.JavaModelManager$PerWorkingCopyInfo


    super(hierarchy);
  }
 
public void build(boolean computeSubtypes) {
   
  JavaModelManager manager = JavaModelManager.getJavaModelManager();
  try {
    // optimize access to zip files while building hierarchy
    manager.cacheZipFiles();
       
    if (this.hierarchy.focusType == null || computeSubtypes) {
      IProgressMonitor typeInRegionMonitor =
        this.hierarchy.progressMonitor == null ?
          null :
          new SubProgressMonitor(this.hierarchy.progressMonitor, 30);
      HashMap allOpenablesInRegion = determineOpenablesInRegion(typeInRegionMonitor);
      this.hierarchy.initialize(allOpenablesInRegion.size());
      IProgressMonitor buildMonitor =
        this.hierarchy.progressMonitor == null ?
          null :
          new SubProgressMonitor(this.hierarchy.progressMonitor, 70);
      createTypeHierarchyBasedOnRegion(allOpenablesInRegion, buildMonitor);
      ((RegionBasedTypeHierarchy)this.hierarchy).pruneDeadBranches();
    } else {
      this.hierarchy.initialize(1);
      this.buildSupertypes();
    }
  } finally {
    manager.flushZipFiles();
  }
}
View Full Code Here


  return result;
}

public static ClassFileReader classFileReader(IType type) {
  IClassFile classFile = type.getClassFile();
  JavaModelManager manager = JavaModelManager.getJavaModelManager();
  if (classFile.isOpen())
    return (ClassFileReader) manager.getInfo(type);

  PackageFragment pkg = (PackageFragment) type.getPackageFragment();
  IPackageFragmentRoot root = (IPackageFragmentRoot) pkg.getParent();
  try {
    if (!root.isArchive())
      return Util.newClassFileReader(type.getResource());

    ZipFile zipFile = null;
    try {
      IPath zipPath = root.getPath();
      if (JavaModelManager.ZIP_ACCESS_VERBOSE)
        System.out.println("(" + Thread.currentThread() + ") [MatchLocator.classFileReader()] Creating ZipFile on " + zipPath); //$NON-NLS-1$  //$NON-NLS-2$
      zipFile = manager.getZipFile(zipPath);
      String classFileName = classFile.getElementName();
      String path = Util.concatWith(pkg.names, classFileName, '/');
      return ClassFileReader.read(zipFile, path);
    } finally {
      manager.closeZipFile(zipFile);
    }
  } catch (ClassFormatException e) {
    // invalid class file: return null
  } catch (CoreException e) {
    // cannot read class file: return null
View Full Code Here

  }
  int copiesLength = copies.size();
  this.workingCopies = new org.aspectj.org.eclipse.jdt.core.ICompilationUnit[copiesLength];
  copies.toArray(this.workingCopies);

  JavaModelManager manager = JavaModelManager.getJavaModelManager();
  this.bindings = new SimpleLookupTable();
  try {
    // optimize access to zip files during search operation
    manager.cacheZipFiles();

    // initialize handle factory (used as a cache of handles so as to optimize space)
    if (this.handleFactory == null)
      this.handleFactory = new HandleFactory();

    if (this.progressMonitor != null) {
      this.progressMonitor.beginTask("", searchDocuments.length); //$NON-NLS-1$
    }

    // 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;
          } catch (JavaModelException e) {
            // problem with classpath in this project -> skip it
          }
          matchSet.reset();
        }
        previousJavaProject = javaProject;
      }
      matchSet.add(new PossibleMatch(this, resource, openable, searchDocument, ((InternalSearchPattern) this.pattern).mustResolve));
    }

    // last project
    if (previousJavaProject != null) {
      try {
        locateMatches(previousJavaProject, matchSet, docsLength-displayed);
      } catch (JavaModelException e) {
        // problem with classpath in last project -> ignore
      }
    }

  } finally {
    if (this.progressMonitor != null)
      this.progressMonitor.done();
    if (this.nameEnvironment != null)
      this.nameEnvironment.cleanup();
    manager.flushZipFiles();
    this.bindings = null;
  }
}
View Full Code Here

    return;
  }
  int length = roots.length;
  ClasspathLocation[] cpLocations = new ClasspathLocation[length];
  int index = 0;
  JavaModelManager manager = JavaModelManager.getJavaModelManager();
  for (int i = 0; i < length; i++) {
    PackageFragmentRoot root = (PackageFragmentRoot) roots[i];
    IPath path = root.getPath();
    try {
      if (root.isArchive()) {
        ZipFile zipFile = manager.getZipFile(path);
        cpLocations[index++] = new ClasspathJar(zipFile, ((ClasspathEntry) root.getRawClasspathEntry()).getAccessRuleSet());
      } else {
        Object target = JavaModel.getTarget(workspaceRoot, path, false);
        if (target == null) {
          // target doesn't exist any longer
View Full Code Here

  for (int i = 0; i < length; i++) {
    char[] pattern = readName(in);
    int problemId = in.readInt();
    accessRules[i] = new ClasspathAccessRule(pattern, problemId);
  }
  JavaModelManager manager = JavaModelManager.getJavaModelManager();
  String[] messageTemplates = new String[AccessRuleSet.MESSAGE_TEMPLATES_LENGTH];
  for (int i = 0; i < AccessRuleSet.MESSAGE_TEMPLATES_LENGTH; i++) {
    messageTemplates[i] = manager.intern(in.readUTF());
  }
  AccessRuleSet accessRuleSet = new AccessRuleSet(accessRules, messageTemplates);
  return accessRuleSet;
}
View Full Code Here

TOP

Related Classes of org.aspectj.org.eclipse.jdt.internal.core.JavaModelManager$PerWorkingCopyInfo

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.