Package org.aspectj.org.eclipse.jdt.internal.core

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


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.getResource());
    } 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 = getBinaryInfo(classFile, this.currentPossibleMatch.resource);
        if (info != null) {
          boolean mayBeGeneric = this.patternLocator.mayBeGeneric;
          this.patternLocator.mayBeGeneric = false; // there's no longer generics in class files
          try {
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);
      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 = ((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());
      Binding declaringElement = ((TypeVariableBinding) referenceBinding).declaringElement;
      IBinding declaringTypeBinding = null;
      if (declaringElement instanceof MethodBinding) {
        declaringTypeBinding = this.resolver.getMethodBinding((MethodBinding) declaringElement);
        IMethod declaringMethod = (IMethod) declaringTypeBinding.getJavaElement();
        return (JavaElement) declaringMethod.getTypeParameter(typeVariableName);
      } else {
        ITypeBinding typeBinding2 = this.resolver.getTypeBinding((org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding) declaringElement);
        if (typeBinding2 == null) return null;
        declaringTypeBinding = typeBinding2;
        IType declaringType = (IType) declaringTypeBinding.getJavaElement();
        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
      ITypeBinding declaringTypeBinding = null;
      if (this.isArray()) {
        declaringTypeBinding = this.getElementType().getDeclaringClass();
      } else {
        declaringTypeBinding = this.getDeclaringClass();
      }
      if (declaringTypeBinding == null) {
        // top level type
        if (Util.isClassFileName(fileName)) {
          ClassFile classFile = (ClassFile) getClassFile(fileName);
          if (classFile == null) return null;
          return (JavaElement) classFile.getType();
        }
        ICompilationUnit cu = getCompilationUnit(fileName);
        if (cu == null) return null;
        return (JavaElement) cu.getType(new String(referenceBinding.sourceName()));
      } else {
View Full Code Here

TOP

Related Classes of org.aspectj.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.