Package org.eclipse.jdt.internal.core

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


            } else {
              // Load custom components from jar files
              for (IJavaElement pack : root.getChildren()) {
                if (pack != null && pack instanceof PackageFragment && pack.getElementName().equals(pi.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")){
                      ComponentInstance ci = new ComponentInstance();
                      String componentName = itemName.substring(0, itemName.length()-6);
                      ci.setId(componentName);
                      ci.setName(pi.getPrefix() + ":" + componentName);
View Full Code Here


    /**
     * Override super implementation to set the WOJ source mapper on the Jar containing the classfile
     */
    protected IEditorInput transformEditorInput(IEditorInput input) {
        IClassFileEditorInput iClassFileEditorInput = (IClassFileEditorInput) super.transformEditorInput(input);
        ClassFile classFile = (ClassFile) iClassFileEditorInput.getClassFile();
        if(wojKnowThisModule(classFile)) {
          JavaSourceHook.installSourceMapper(classFile.getPackageFragmentRoot());
        }
        return iClassFileEditorInput;
    }
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

        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

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

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

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.