Examples of IPackageFragment


Examples of org.aspectj.org.eclipse.jdt.core.IPackageFragment

        } else {
          // try to return one that is a child of this project
          for (int i = 0, length = pkgFragments.length; i < length; i++) {

            IPackageFragment pkgFragment = pkgFragments[i];
            if (this.equals(pkgFragment.getParent().getParent())) {
              return pkgFragment;
            }
          }
          // default to the first one
          return pkgFragments[0];
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.core.IPackageFragment

    IPackageFragmentRoot root,
    ArrayList openables) {
    try {
      IJavaElement[] packFrags = root.getChildren();
      for (int k = 0; k < packFrags.length; k++) {
        IPackageFragment packFrag = (IPackageFragment) packFrags[k];
        injectAllOpenablesForPackageFragment(packFrag, openables);
      }
    } catch (JavaModelException e) {
      return;
    }
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.core.IPackageFragment

  // If the current type is an inner type, innerClasses returns
  // an extra entry for the current type.  This entry must be removed.
  // Can also return an entry for the enclosing type of an inner type.
  IBinaryNestedType[] innerTypes = typeInfo.getMemberTypes();
  if (innerTypes != null) {
    IPackageFragment pkg = (IPackageFragment) type.getAncestor(IJavaElement.PACKAGE_FRAGMENT);
    for (int i = 0, typeCount = innerTypes.length; i < typeCount; i++) {
      IBinaryNestedType binaryType = innerTypes[i];
      IClassFile parentClassFile= pkg.getClassFile(new String(ClassFile.unqualifiedName(binaryType.getName())) + SUFFIX_STRING_class);
      IType innerType = new BinaryType((JavaElement) parentClassFile, ClassFile.simpleName(binaryType.getName()));
      childrenHandles.add(innerType);
    }
  }
}
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.core.IPackageFragment

protected void executeOperation() throws JavaModelException {
  try {
    beginTask(Messages.operation_createUnitProgress, 2);
    JavaElementDelta delta = newJavaElementDelta();
    ICompilationUnit unit = getCompilationUnit();
    IPackageFragment pkg = (IPackageFragment) getParentElement();
    IContainer folder = (IContainer) pkg.getResource();
    worked(1);
    IFile compilationUnitFile = folder.getFile(new Path(fName));
    if (compilationUnitFile.exists()) {
      // update the contents of the existing unit if fForce is true
      if (force) {
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.core.IPackageFragment

      this.nameLookup = ((JavaProject) projects[i]).newNameLookup(this.workingCopies);
      IPackageFragment[] packageFragments = this.nameLookup.findPackageFragments(new String(pkgPattern.pkgName), false, true);
      int pLength = packageFragments == null ? 0 : packageFragments.length;
      // Report matches avoiding duplicate names
      for (int p=0; p<pLength; p++) {
        IPackageFragment fragment = packageFragments[p];
        if (packages.addIfNotIncluded(fragment) == null) continue;
        if (encloses(fragment)) {
          IResource resource = fragment.getResource();
          if (resource == null) // case of a file in an external jar
            resource = javaProject.getProject();
          try {
            if (encloses(fragment)) {
              SearchMatch match = new PackageDeclarationMatch(fragment, SearchMatch.A_ACCURATE, -1, -1, participant, resource);
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.core.IPackageFragment

      pkgEnd = CharOperation.lastIndexOf(File.separatorChar, fileName);
    if (jarSeparator != -1 && pkgEnd < jarSeparator) // if in a jar and no slash, it is a default package -> pkgEnd should be equal to jarSeparator
      pkgEnd = jarSeparator;
    if (pkgEnd == -1)
      return null;
    IPackageFragment pkg = getPackageFragment(fileName, pkgEnd, jarSeparator);
    if (pkg == null) return null;
    int start;
    return pkg.getClassFile(new String(fileName, start = pkgEnd + 1, fileName.length - start));
  }
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.core.IPackageFragment

  private ICompilationUnit getCompilationUnit(char[] fileName) {
    char[] slashSeparatedFileName = CharOperation.replaceOnCopy(fileName, File.separatorChar, '/');
    int pkgEnd = CharOperation.lastIndexOf('/', slashSeparatedFileName); // pkgEnd is exclusive
    if (pkgEnd == -1)
      return null;
    IPackageFragment pkg = getPackageFragment(slashSeparatedFileName, pkgEnd, -1/*no jar separator for .java files*/);
    if (pkg == null) return null;
    int start;
    ICompilationUnit cu = pkg.getCompilationUnit(new String(slashSeparatedFileName, start =  pkgEnd+1, slashSeparatedFileName.length - start));
    if (this.resolver instanceof DefaultBindingResolver) {
      ICompilationUnit workingCopy = cu.findWorkingCopy(((DefaultBindingResolver) this.resolver).workingCopyOwner);
      if (workingCopy != null)
        return workingCopy;
    }
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.core.IPackageFragment

          pkgEnd = CharOperation.lastIndexOf(File.separatorChar, fileName);
        if (jarSeparator != -1 && pkgEnd < jarSeparator) // if in a jar and no slash, it is a default package -> pkgEnd should be equal to jarSeparator
          pkgEnd = jarSeparator;
        if (pkgEnd == -1)
          return null;
        IPackageFragment pkg = getPackageFragment(fileName, pkgEnd, jarSeparator);
        char[] constantPoolName = referenceBinding.constantPoolName();
        if (constantPoolName == null) {
          ClassFile classFile = (ClassFile) getClassFile(fileName);
          return classFile == null ? null : (JavaElement) classFile.getType();
        }
        pkgEnd = CharOperation.lastIndexOf('/', constantPoolName);
        char[] classFileName = CharOperation.subarray(constantPoolName, pkgEnd+1, constantPoolName.length);
        ClassFile classFile = (ClassFile) pkg.getClassFile(new String(classFileName) + SuffixConstants.SUFFIX_STRING_class);
        return (JavaElement) classFile.getType();
      }
      ICompilationUnit cu = getCompilationUnit(fileName);
      if (cu == null) return null;
      // must use getElementAt(...) as there is no back pointer to the defining method (scope is null after resolution has ended)
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.core.IPackageFragment

        pkgName = new String[length];
        System.arraycopy(simpleNames, 0, pkgName, 0, length);
      } else {
        pkgName = CharOperation.NO_STRINGS;
      }
      IPackageFragment pkgFragment= (IPackageFragment) this.packageHandles.get(pkgName);
      if (pkgFragment == null) {
        pkgFragment= ((PackageFragmentRoot) this.lastPkgFragmentRoot).getPackageFragment(pkgName);
        this.packageHandles.put(pkgName, pkgFragment);
      }
      IClassFile classFile= pkgFragment.getClassFile(simpleNames[length]);
      return (Openable) classFile;
    } else {
      // path to a file in a directory
      // Optimization: cache package fragment root handle and package handles
      int rootPathLength = -1;
      if (this.lastPkgFragmentRootPath == null
        || !(resourcePath.startsWith(this.lastPkgFragmentRootPath)
          && (rootPathLength = this.lastPkgFragmentRootPath.length()) > 0
          && resourcePath.charAt(rootPathLength) == '/')) {
        IPackageFragmentRoot root= this.getPkgFragmentRoot(resourcePath);
        if (root == null)
          return null; // match is outside classpath
        this.lastPkgFragmentRoot = root;
        this.lastPkgFragmentRootPath = this.lastPkgFragmentRoot.getPath().toString();
        this.packageHandles = new HashtableOfArrayToObject(5);
      }
      // create handle
      resourcePath = resourcePath.substring(this.lastPkgFragmentRootPath.length() + 1);
      String[] simpleNames = new Path(resourcePath).segments();
      String[] pkgName;
      int length = simpleNames.length-1;
      if (length > 0) {
        pkgName = new String[length];
        System.arraycopy(simpleNames, 0, pkgName, 0, length);
      } else {
        pkgName = CharOperation.NO_STRINGS;
      }
      IPackageFragment pkgFragment= (IPackageFragment) this.packageHandles.get(pkgName);
      if (pkgFragment == null) {
        pkgFragment= ((PackageFragmentRoot) this.lastPkgFragmentRoot).getPackageFragment(pkgName);
        this.packageHandles.put(pkgName, pkgFragment);
      }
      String simpleName= simpleNames[length];
      if (org.aspectj.org.eclipse.jdt.internal.core.util.Util.isJavaLikeFileName(simpleName)) {
        ICompilationUnit unit= pkgFragment.getCompilationUnit(simpleName);
        return (Openable) unit;
      } else {
        IClassFile classFile= pkgFragment.getClassFile(simpleName);
        return (Openable) classFile;
      }
    }
  } 
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.core.IPackageFragment

          int segments = path.segmentCount();
          while (elements.hasNext()) {
            IFolder f = (IFolder) elements.next();
            IPath relativePath = f.getFullPath().removeFirstSegments(segments);
            String[] pkgName = relativePath.segments();
            IPackageFragment pkg = root.getPackageFragment(pkgName);
            if (!Util.isExcluded(pkg))
              fragments.add(pkg);
          }
        }
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.