Examples of IClassFile


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

  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.IClassFile

      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.IClassFile

protected boolean computeChildren(OpenableElementInfo info, ArrayList entryNames) {
  if (entryNames != null && entryNames.size() > 0) {
    ArrayList vChildren = new ArrayList();
    for (Iterator iter = entryNames.iterator(); iter.hasNext();) {
      String child = (String) iter.next();
      IClassFile classFile = getClassFile(child);
      vChildren.add(classFile);
    }
    IJavaElement[] children= new IJavaElement[vChildren.size()];
    vChildren.toArray(children);
    info.setChildren(children);
View Full Code Here

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

  }
  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);
    }
View Full Code Here

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

  if (simpleTypeName.equals(binaryTypeQualifiedName))
    return binaryType; // answer only top-level types, sometimes the classFile is for a member/local type

  // type name may be null for anonymous (see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=164791)
  String classFileName = simpleTypeName.length() == 0 ? binaryTypeQualifiedName : simpleTypeName;
  IClassFile classFile = binaryType.getPackageFragment().getClassFile(classFileName + SuffixConstants.SUFFIX_STRING_class);
  return classFile.getType();
}
View Full Code Here

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

      char[][] parameterTypes = methodInfo.parameterTypes;
      if (parameterTypes != null && methodInfo.isConstructor && currentType.getDeclaringType() != null && !Flags.isStatic(currenTypeModifiers)) {
        IType declaringType = currentType.getDeclaringType();
        String declaringTypeName = declaringType.getElementName();
        if (declaringTypeName.length() == 0) {
          IClassFile classFile = declaringType.getClassFile();
          int length = parameterTypes.length;
          char[][] newParameterTypes = new char[length+1][];
          declaringTypeName = classFile.getElementName();
          declaringTypeName = declaringTypeName.substring(0, declaringTypeName.indexOf('.'));
          newParameterTypes[0] = declaringTypeName.toCharArray();
          System.arraycopy(parameterTypes, 0, newParameterTypes, 1, length);
          this.methodParameterTypes[typeDepth] = newParameterTypes;
        } else {
View Full Code Here

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

      }
      type = type.getType(simpleTypeName);
    }
    return type;
  } else {
    IClassFile classFile= pkgFragment.getClassFile(simpleName);
    return classFile.getType();
  }
View Full Code Here

Examples of org.eclipse.jdt.core.IClassFile

            IJavaElement ref = workingCopy.getElementAt(selection.getOffset());
            if (ref != null) {
                return ref;
            }
        } else if (input instanceof IClassFile) {
            IClassFile iClass = (IClassFile) input;
            IJavaElement ref = iClass.getElementAt(selection.getOffset());
            if (ref != null) {
                // If we are in the inner class, try to refine search result now
                if(ref instanceof IType){
                    IType type = (IType) ref;
                    IClassFile classFile = type.getClassFile();
                    if(classFile != iClass){
                        /*
                         * WORKAROUND it seems that source range for constructors from
                         * bytecode with source attached from zip files is not computed
                         * in Eclipse (SourceMapper returns nothing useful).
                         * Example: HashMap$Entry class with constructor
                         * <init>(ILjava/lang/Object;Ljava/lang/Object;Ljava/util/HashMap$Entry;)V
                         * We will get here at least the inner class...
                         * see https://bugs.eclipse.org/bugs/show_bug.cgi?id=137847
                         */
                        ref = classFile.getElementAt(selection.getOffset());
                    }
                }
                return ref;
            }
        }
View Full Code Here

Examples of org.eclipse.jdt.core.IClassFile

     * @param javaElement
     * @return new generated input stream for given element bytecode class file, or null
     * if class file cannot be found or this element is not from java source path
     */
    public static InputStream createInputStream(IJavaElement javaElement) {
        IClassFile classFile = (IClassFile) javaElement
            .getAncestor(IJavaElement.CLASS_FILE);
        InputStream is = null;

        // existing read-only class files
        if (classFile != null) {
            IJavaElement jarParent = classFile.getParent();
            // TODO dirty hack to be sure, that package is from jar -
            // because JarPackageFragment is not public class, we cannot
            // use instanceof here
            boolean isJar = jarParent != null
                && jarParent.getClass().getName()
View Full Code Here

Examples of org.eclipse.jdt.core.IClassFile

     */
    protected boolean setDocumentContent(IDocument document,
        IEditorInput editorInput, String encoding) throws CoreException {

        if (editorInput instanceof IClassFileEditorInput) {
            IClassFile classFile = ((IClassFileEditorInput) editorInput)
                .getClassFile();

            String source = null;
            try {
                source = classFile.getSource();
            } catch (JavaModelException e) {
                // ignore, this may happen if *class* file is not on class path but inside
                // of source tree without associated source
            }
            if (source == null) {
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.