Package org.eclipse.jdt.internal.core.util

Examples of org.eclipse.jdt.internal.core.util.HashtableOfArrayToObject


      resourcePath = resource.getLocation();

    try {
      JavaProjectElementInfo projectInfo = (JavaProjectElementInfo) getJavaModelManager().getInfo(project);
      ProjectCache projectCache = projectInfo == null ? null : projectInfo.projectCache;
      HashtableOfArrayToObject allPkgFragmentsCache = projectCache == null ? null : projectCache.allPkgFragmentsCache;
      boolean isJavaLike = org.eclipse.jdt.internal.core.util.Util.isJavaLikeFileName(resourcePath.lastSegment());
      IClasspathEntry[] entries = isJavaLike ? project.getRawClasspath() // JAVA file can only live inside SRC folder (on the raw path)
          : ((JavaProject)project).getResolvedClasspath();

      int length  = entries.length;
      if (length > 0) {
        String sourceLevel = project.getOption(JavaCore.COMPILER_SOURCE, true);
        String complianceLevel = project.getOption(JavaCore.COMPILER_COMPLIANCE, true);
        for (int i = 0; i < length; i++) {
          IClasspathEntry entry = entries[i];
          if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT) continue;
          IPath rootPath = entry.getPath();
          if (rootPath.equals(resourcePath)) {
            if (isJavaLike)
              return null;
            return project.getPackageFragmentRoot(resource);
          } else if (rootPath.isPrefixOf(resourcePath)) {
            // allow creation of package fragment if it contains a .java file that is included
            if (!Util.isExcluded(resource, ((ClasspathEntry)entry).fullInclusionPatternChars(), ((ClasspathEntry)entry).fullExclusionPatternChars())) {
              // given we have a resource child of the root, it cannot be a JAR pkg root
              PackageFragmentRoot root =
                isExternal ?
                  new ExternalPackageFragmentRoot(rootPath, (JavaProject) project) :
                  (PackageFragmentRoot) ((JavaProject) project).getFolderPackageFragmentRoot(rootPath);
              if (root == null) return null;
              IPath pkgPath = resourcePath.removeFirstSegments(rootPath.segmentCount());

              if (resource.getType() == IResource.FILE) {
                // if the resource is a file, then remove the last segment which
                // is the file name in the package
                pkgPath = pkgPath.removeLastSegments(1);
              }
              String[] pkgName = pkgPath.segments();

              // if package name is in the cache, then it has already been validated
              // (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=133141)
              if (allPkgFragmentsCache != null && allPkgFragmentsCache.containsKey(pkgName))
                return root.getPackageFragment(pkgName);

              if (pkgName.length != 0 && JavaConventions.validatePackageName(Util.packageName(pkgPath, sourceLevel, complianceLevel), sourceLevel, complianceLevel).getSeverity() == IStatus.ERROR) {
                return null;
              }
View Full Code Here


   * Compute the package fragment children of this package fragment root.
   * These are all of the directory zip entries, and any directories implied
   * by the path of class files contained in the jar of this package fragment root.
   */
  protected boolean computeChildren(OpenableElementInfo info, IResource underlyingResource) throws JavaModelException {
    HashtableOfArrayToObject rawPackageInfo = new HashtableOfArrayToObject();
    IJavaElement[] children;
    ZipFile jar = null;
    try {
      IJavaProject project = getJavaProject();
      String sourceLevel = project.getOption(JavaCore.COMPILER_SOURCE, true);
      String compliance = project.getOption(JavaCore.COMPILER_COMPLIANCE, true);
      jar = getJar();

      // always create the default package
      rawPackageInfo.put(CharOperation.NO_STRINGS, new ArrayList[] { EMPTY_LIST, EMPTY_LIST });

      for (Enumeration e= jar.entries(); e.hasMoreElements();) {
        ZipEntry member= (ZipEntry) e.nextElement();
        initRawPackageInfo(rawPackageInfo, member.getName(), member.isDirectory(), sourceLevel, compliance);
      }

      // loop through all of referenced packages, creating package fragments if necessary
      // and cache the entry names in the rawPackageInfo table
      children = new IJavaElement[rawPackageInfo.size()];
      int index = 0;
      for (int i = 0, length = rawPackageInfo.keyTable.length; i < length; i++) {
        String[] pkgName = (String[]) rawPackageInfo.keyTable[i];
        if (pkgName == null) continue;
        children[index++] = getPackageFragment(pkgName);
View Full Code Here

public class WojNameLookup32 extends NameLookup{

    private NameLookup _nameLookup;

    public WojNameLookup32(NameLookup nameLookup) {
        super(null, new HashtableOfArrayToObject(), null, null, null);
        _nameLookup = nameLookup;
    }
View Full Code Here

public class WojNameLookup extends NameLookup{

    private NameLookup _nameLookup;

    public WojNameLookup(NameLookup nameLookup) {
        super(null, new HashtableOfArrayToObject(), null, null);
        _nameLookup = nameLookup;
    }
View Full Code Here

      resourcePath = resource.getLocation();

    try {
      JavaProjectElementInfo projectInfo = (JavaProjectElementInfo) getJavaModelManager().getInfo(project);
      ProjectCache projectCache = projectInfo == null ? null : projectInfo.projectCache;
      HashtableOfArrayToObject allPkgFragmentsCache = projectCache == null ? null : projectCache.allPkgFragmentsCache;
      boolean isJavaLike = org.eclipse.jdt.internal.core.util.Util.isJavaLikeFileName(resourcePath.lastSegment());
      IClasspathEntry[] entries = isJavaLike ? project.getRawClasspath() // JAVA file can only live inside SRC folder (on the raw path)
          : ((JavaProject)project).getResolvedClasspath();

      int length  = entries.length;
      if (length > 0) {
        String sourceLevel = project.getOption(JavaCore.COMPILER_SOURCE, true);
        String complianceLevel = project.getOption(JavaCore.COMPILER_COMPLIANCE, true);
        for (int i = 0; i < length; i++) {
          IClasspathEntry entry = entries[i];
          if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT) continue;
          IPath rootPath = entry.getPath();
          if (rootPath.equals(resourcePath)) {
            if (isJavaLike)
              return null;
            return project.getPackageFragmentRoot(resource);
          } else if (rootPath.isPrefixOf(resourcePath)) {
            // allow creation of package fragment if it contains a .java file that is included
            if (!Util.isExcluded(resource, ((ClasspathEntry)entry).fullInclusionPatternChars(), ((ClasspathEntry)entry).fullExclusionPatternChars())) {
              // given we have a resource child of the root, it cannot be a JAR pkg root
              PackageFragmentRoot root =
                isExternal ?
                  new ExternalPackageFragmentRoot(rootPath, (JavaProject) project) :
                  (PackageFragmentRoot) ((JavaProject) project).getFolderPackageFragmentRoot(rootPath);
              if (root == null) return null;
              IPath pkgPath = resourcePath.removeFirstSegments(rootPath.segmentCount());

              if (resource.getType() == IResource.FILE) {
                // if the resource is a file, then remove the last segment which
                // is the file name in the package
                pkgPath = pkgPath.removeLastSegments(1);
              }
              String[] pkgName = pkgPath.segments();

              // if package name is in the cache, then it has already been validated
              // (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=133141)
              if (allPkgFragmentsCache != null && allPkgFragmentsCache.containsKey(pkgName))
                return root.getPackageFragment(pkgName);

              if (pkgName.length != 0 && JavaConventions.validatePackageName(Util.packageName(pkgPath, sourceLevel, complianceLevel), sourceLevel, complianceLevel).getSeverity() == IStatus.ERROR) {
                return null;
              }
View Full Code Here

   * The given project is assumed to be the handle of this info.
   * This name lookup first looks in the given working copies.
   */
  NameLookup newNameLookup(JavaProject project, ICompilationUnit[] workingCopies) {
    ProjectCache cache = getProjectCache(project);
    HashtableOfArrayToObject allPkgFragmentsCache = cache.allPkgFragmentsCache;
    if (allPkgFragmentsCache == null) {
      HashMap rootInfos = JavaModelManager.getJavaModelManager().deltaState.roots;
      IPackageFragmentRoot[] allRoots = cache.allPkgFragmentRootsCache;
      int length = allRoots.length;
      allPkgFragmentsCache = new HashtableOfArrayToObject();
      for (int i = 0; i < length; i++) {
        IPackageFragmentRoot root = allRoots[i];
        DeltaProcessor.RootInfo rootInfo = (DeltaProcessor.RootInfo) rootInfos.get(root.getPath());
        JavaProject rootProject = rootInfo == null ? project : rootInfo.project;
        HashSetOfArray fragmentsCache;
        if (rootProject.equals(project)) {
          // retrieve package fragments cache from this project
          fragmentsCache = (HashSetOfArray) cache.pkgFragmentsCaches.get(root);
        } else {
          // retrieve package fragments  cache from the root's project
          ProjectCache rootProjectCache;
          try {
            rootProjectCache = rootProject.getProjectCache();
          } catch (JavaModelException e) {
            // project doesn't exit
            continue;
          }
          fragmentsCache = (HashSetOfArray) rootProjectCache.pkgFragmentsCaches.get(root);
        }
        if (fragmentsCache == null) { // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=183833
          fragmentsCache = new HashSetOfArray();
          initializePackageNames(root, fragmentsCache);
        }
        Object[][] set = fragmentsCache.set;
        for (int j = 0, length2 = set.length; j < length2; j++) {
          String[] pkgName = (String[]) set[j];
          if (pkgName == null)
            continue;
          Object existing = allPkgFragmentsCache.get(pkgName);
          if (existing == null || existing == NO_ROOTS) {
            allPkgFragmentsCache.put(pkgName, root);
            // ensure super packages (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=119161)
            // are also in the map
            addSuperPackageNames(pkgName, allPkgFragmentsCache);
          } else {
            if (existing instanceof PackageFragmentRoot) {
              allPkgFragmentsCache.put(pkgName, new IPackageFragmentRoot[] {(PackageFragmentRoot) existing, root});
            } else {
              IPackageFragmentRoot[] roots = (IPackageFragmentRoot[]) existing;
              int rootLength = roots.length;
              System.arraycopy(roots, 0, roots = new IPackageFragmentRoot[rootLength+1], 0, rootLength);
              roots[rootLength] = root;
              allPkgFragmentsCache.put(pkgName, roots);
            }
          }
        }
      }
      cache.allPkgFragmentsCache = allPkgFragmentsCache;
View Full Code Here

      resourcePath = resource.getLocation();

    try {
      JavaProjectElementInfo projectInfo = (JavaProjectElementInfo) getJavaModelManager().getInfo(project);
      ProjectCache projectCache = projectInfo == null ? null : projectInfo.projectCache;
      HashtableOfArrayToObject allPkgFragmentsCache = projectCache == null ? null : projectCache.allPkgFragmentsCache;
      boolean isJavaLike = org.eclipse.jdt.internal.core.util.Util.isJavaLikeFileName(resourcePath.lastSegment());
      IClasspathEntry[] entries = isJavaLike ? project.getRawClasspath() // JAVA file can only live inside SRC folder (on the raw path)
          : ((JavaProject)project).getResolvedClasspath();

      int length  = entries.length;
      if (length > 0) {
        String sourceLevel = project.getOption(JavaCore.COMPILER_SOURCE, true);
        String complianceLevel = project.getOption(JavaCore.COMPILER_COMPLIANCE, true);
        for (int i = 0; i < length; i++) {
          IClasspathEntry entry = entries[i];
          if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT) continue;
          IPath rootPath = entry.getPath();
          if (rootPath.equals(resourcePath)) {
            if (isJavaLike)
              return null;
            return project.getPackageFragmentRoot(resource);
          } else if (rootPath.isPrefixOf(resourcePath)) {
            // allow creation of package fragment if it contains a .java file that is included
            if (!Util.isExcluded(resource, ((ClasspathEntry)entry).fullInclusionPatternChars(), ((ClasspathEntry)entry).fullExclusionPatternChars())) {
              // given we have a resource child of the root, it cannot be a JAR pkg root
              PackageFragmentRoot root =
                isExternal ?
                  new ExternalPackageFragmentRoot(rootPath, (JavaProject) project) :
                  (PackageFragmentRoot) ((JavaProject) project).getFolderPackageFragmentRoot(rootPath);
              if (root == null) return null;
              IPath pkgPath = resourcePath.removeFirstSegments(rootPath.segmentCount());

              if (resource.getType() == IResource.FILE) {
                // if the resource is a file, then remove the last segment which
                // is the file name in the package
                pkgPath = pkgPath.removeLastSegments(1);
              }
              String[] pkgName = pkgPath.segments();

              // if package name is in the cache, then it has already been validated
              // (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=133141)
              if (allPkgFragmentsCache != null && allPkgFragmentsCache.containsKey(pkgName))
                return root.getPackageFragment(pkgName);

              if (pkgName.length != 0 && JavaConventions.validatePackageName(Util.packageName(pkgPath, sourceLevel, complianceLevel), sourceLevel, complianceLevel).getSeverity() == IStatus.ERROR) {
                return null;
              }
View Full Code Here

   * Compute the package fragment children of this package fragment root.
   * These are all of the directory zip entries, and any directories implied
   * by the path of class files contained in the jar of this package fragment root.
   */
  protected boolean computeChildren(OpenableElementInfo info, IResource underlyingResource) throws JavaModelException {
    HashtableOfArrayToObject rawPackageInfo = new HashtableOfArrayToObject();
    IJavaElement[] children;
    ZipFile jar = null;
    try {
      IJavaProject project = getJavaProject();
      String sourceLevel = project.getOption(JavaCore.COMPILER_SOURCE, true);
      String compliance = project.getOption(JavaCore.COMPILER_COMPLIANCE, true);
      jar = getJar();

      // always create the default package
      rawPackageInfo.put(CharOperation.NO_STRINGS, new ArrayList[] { EMPTY_LIST, EMPTY_LIST });

      for (Enumeration e= jar.entries(); e.hasMoreElements();) {
        ZipEntry member= (ZipEntry) e.nextElement();
        initRawPackageInfo(rawPackageInfo, member.getName(), member.isDirectory(), sourceLevel, compliance);
      }

      // loop through all of referenced packages, creating package fragments if necessary
      // and cache the entry names in the rawPackageInfo table
      children = new IJavaElement[rawPackageInfo.size()];
      int index = 0;
      for (int i = 0, length = rawPackageInfo.keyTable.length; i < length; i++) {
        String[] pkgName = (String[]) rawPackageInfo.keyTable[i];
        if (pkgName == null) continue;
        children[index++] = getPackageFragment(pkgName);
View Full Code Here

   * Compute the package fragment children of this package fragment root.
   * These are all of the directory zip entries, and any directories implied
   * by the path of class files contained in the jar of this package fragment root.
   */
  protected boolean computeChildren(OpenableElementInfo info, IResource underlyingResource) throws JavaModelException {
    HashtableOfArrayToObject rawPackageInfo = new HashtableOfArrayToObject();
    IJavaElement[] children;
    ZipFile jar = null;
    try {
      jar = getJar();

      // always create the default package
      rawPackageInfo.put(CharOperation.NO_STRINGS, new ArrayList[] { EMPTY_LIST, EMPTY_LIST });

      for (Enumeration e= jar.entries(); e.hasMoreElements();) {
        ZipEntry member= (ZipEntry) e.nextElement();
        initRawPackageInfo(rawPackageInfo, member.getName(), member.isDirectory());
      }

      // loop through all of referenced packages, creating package fragments if necessary
      // and cache the entry names in the rawPackageInfo table
      children = new IJavaElement[rawPackageInfo.size()];
      int index = 0;
      for (int i = 0, length = rawPackageInfo.keyTable.length; i < length; i++) {
        String[] pkgName = (String[]) rawPackageInfo.keyTable[i];
        if (pkgName == null) continue;
        children[index++] = getPackageFragment(pkgName);
View Full Code Here

    String jarPath= resourcePath.substring(0, separatorIndex);
    IPackageFragmentRoot root= ((AbstractJavaSearchScope)this.scope).packageFragmentRoot(resourcePath, separatorIndex, jarPath);
    if (root == null) return null;
    this.lastPkgFragmentRootPath= jarPath;
    this.lastPkgFragmentRoot= root;
    this.packageHandles= new HashtableOfArrayToObject(5);
  }
  // create handle
  String classFilePath= resourcePath.substring(separatorIndex + 1);
  String[] simpleNames = new Path(classFilePath).segments();
  String[] pkgName;
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.internal.core.util.HashtableOfArrayToObject

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.