Package org.eclipse.jdt.internal.core

Examples of org.eclipse.jdt.internal.core.ClassFile


                }
              }
            }else if(packInstance instanceof PackageFragment){
              //Current custom component is in jar files
              for(Object packo : ((PackageFragment) packInstance).getChildrenOfType(IJavaElement.CLASS_FILE)){
                ClassFile packi = (ClassFile) packo;
                String className = packi.getElementName().substring(0, packi.getElementName().indexOf('.'));
                if(className.indexOf('$') < 0 && (prefix + ":" + className.toLowerCase()).equals(nodeName)){
                  TapestryCoreComponents component = null;
                  try {
                    component = tapestryClassLoader.loadComponentAttributesFromClassFile(root, prefix, packi);
                  } catch (ClassFormatException e) {
View Full Code Here


          } else {
            // Load custom components from jar files
            for (IJavaElement pack : root.getChildren()) {
              if (pack != null && pack instanceof PackageFragment && pack.getElementName().equals(cp.getPath())) {
                for(Object packo : ((PackageFragment) pack).getChildrenOfType(IJavaElement.CLASS_FILE)){
                  ClassFile packi = (ClassFile) packo;
                  String itemName = packi.getElementName();
                  if(itemName.indexOf('$') < 0 && itemName.endsWith(".class"))
                    componentNameList.add(itemName.substring(0, itemName.length()-6));
                }
                break;
              }
View Full Code Here

          }
          // find the type declaration that corresponds to the original source type
          typeDeclaration = new ASTNodeFinder(parsedUnit).findType(context);
        }
      } else { // binary type
        ClassFile classFile = (ClassFile) context.getClassFile();
        ClassFileReader reader = (ClassFileReader) classFile.getBinaryTypeInfo((IFile) classFile.resource(), false/*don't fully initialize so as to keep constant pool (used below)*/);
        CompilationResult result = new CompilationResult(reader.getFileName(), 1, 1, this.compilerOptions.maxProblemsPerUnit);
        parsedUnit = new CompilationUnitDeclaration(this.parser.problemReporter(), result, 0);
        HashSetOfCharArrayArray typeNames = new HashSetOfCharArrayArray();

        BinaryTypeConverter converter = new BinaryTypeConverter(this.parser.problemReporter(), result, typeNames);
View Full Code Here

protected BinaryTypeBinding cacheBinaryType(IType type, IBinaryType binaryType) throws JavaModelException {
  IType enclosingType = type.getDeclaringType();
  if (enclosingType != null)
    cacheBinaryType(enclosingType, null); // cache enclosing types first, so that binary type can be found in lookup enviroment
  if (binaryType == null) {
    ClassFile classFile = (ClassFile) type.getClassFile();
    try {
      binaryType = getBinaryInfo(classFile, classFile.resource());
    } catch (CoreException e) {
      if (e instanceof JavaModelException) {
        throw (JavaModelException) e;
      } else {
        throw new JavaModelException(e);
View Full Code Here

  this.currentPossibleMatch = possibleMatch;
  CompilationUnitDeclaration unit = possibleMatch.parsedUnit;
  try {
    if (unit.isEmpty()) {
      if (this.currentPossibleMatch.openable instanceof ClassFile) {
        ClassFile classFile = (ClassFile) this.currentPossibleMatch.openable;
        IBinaryType info = null;
        try {
          info = getBinaryInfo(classFile, classFile.resource());
        }
        catch (CoreException ce) {
          // Do nothing
        }
        if (info != null) {
View Full Code Here

    }
  } while (token != TerminalTokens.TokenNameEOF);

}
protected void reportBinaryMemberDeclaration(IResource resource, IMember binaryMember, Binding binaryMemberBinding, IBinaryType info, int accuracy) throws CoreException {
  ClassFile classFile = (ClassFile) binaryMember.getClassFile();
  ISourceRange range = classFile.isOpen() ? binaryMember.getNameRange() : SourceMapper.UNKNOWN_RANGE;
  if (range.getOffset() == -1) {
    BinaryType type = (BinaryType) classFile.getType();
    String sourceFileName = type.sourceFileName(info);
    if (sourceFileName != null) {
      SourceMapper mapper = classFile.getSourceMapper();
      if (mapper != null) {
        char[] contents = mapper.findSource(type, sourceFileName);
        if (contents != null)
          range = mapper.mapSource(type, contents, info, binaryMember);
      }
View Full Code Here

        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, workingCopyOwner);
      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)
      try {
        int sourceStart = ((org.eclipse.jdt.internal.compiler.lookup.LocalTypeBinding) referenceBinding).sourceStart;
        return (JavaElement) cu.getElementAt(sourceStart);
      } catch (JavaModelException e) {
        // does not exist
        return null;
      }
    } else if (referenceBinding.isTypeVariable()) {
      // type parameter
      final String typeVariableName = new String(referenceBinding.sourceName());
      org.eclipse.jdt.internal.compiler.lookup.Binding declaringElement = ((org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding) referenceBinding).declaringElement;
      if (declaringElement instanceof MethodBinding) {
        IMethod declaringMethod = (IMethod) getUnresolvedJavaElement((MethodBinding) declaringElement, workingCopyOwner, bindingsToNodes);
        return (JavaElement) declaringMethod.getTypeParameter(typeVariableName);
      } else {
        IType declaringType = (IType) getUnresolvedJavaElement((TypeBinding) declaringElement, workingCopyOwner, bindingsToNodes);
        return (JavaElement) declaringType.getTypeParameter(typeVariableName);
      }
    } else {
      if (fileName == null) return null; // case of a WilCardBinding that doesn't have a corresponding Java element
      // member or top level type
      TypeBinding declaringTypeBinding = typeBinding.enclosingType();
      if (declaringTypeBinding == null) {
        // top level type
        if (org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(fileName)) {
          ClassFile classFile = (ClassFile) getClassFile(fileName);
          if (classFile == null) return null;
          return (JavaElement) classFile.getType();
        }
        ICompilationUnit cu = getCompilationUnit(fileName, workingCopyOwner);
        if (cu == null) return null;
        return (JavaElement) cu.getType(new String(referenceBinding.sourceName()));
      } else {
View Full Code Here

  public void testGetSupertypes() {
    long start = System.nanoTime();

    final List<Object> supertypes = TypeHelper.getSupertypes(javaFile);
    assertEquals(supertypes.size(), 19);
    final ClassFile clazz = (ClassFile) supertypes.get(0);
    assertEquals(clazz.getElementName(), "FormComponentPanel.class");

    System.out.println("testGetSupertypes:\t\t" + (System.nanoTime() - start));
  }
View Full Code Here

    String className = classFileName.substring(classFileName
        .lastIndexOf('/') + 1) + ".class";
    try {
      PackageFragment packInstance = (PackageFragment) root.getPackageFragment(packageName);
      for (Object packo : packInstance.getChildrenOfType(IJavaElement.CLASS_FILE)) {
        ClassFile packi = (ClassFile) packo;
        if (packi.getElementName().equals(className)) {
          ClassFileReader reader = null;
          try {
            reader = new ClassFileReader(packi.getBytes(),
                null);
          } catch (ClassFormatException e) {
            e.printStackTrace();
          }
View Full Code Here

      List<TapestryCoreComponents> list = new ArrayList<TapestryCoreComponents>();
      PackageFragment tapestryCorePackage = getTapestryCoreLibrary();
      try {
        if(tapestryCorePackage !=null)
          for(Object packo : tapestryCorePackage.getChildrenOfType(IJavaElement.CLASS_FILE)){
            ClassFile packi = (ClassFile) packo;
            if(packi.getElementName().indexOf('$') < 0){
              TapestryCoreComponents component = tapestryClassLoader.loadComponentAttributesFromClassFile(tapestryClassLoader.getTapestryCoreJar(project), "t", packi);
              if(component != null)
                list.add(component);
            }
          }
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.internal.core.ClassFile

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.