Package org.aspectj.org.eclipse.jdt.internal.compiler.env

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer


        this.checkAccessRestrictions);
    if (answer != null) {
      // construct name env answer
      if (answer.type instanceof BinaryType) { // BinaryType
        try {
          return new NameEnvironmentAnswer((IBinaryType) ((BinaryType) answer.type).getElementInfo(), answer.restriction);
        } catch (JavaModelException npe) {
          return null;
        }
      } else { //SourceType
        try {
          // retrieve the requested type
          SourceTypeElementInfo sourceType = (SourceTypeElementInfo)((SourceType) answer.type).getElementInfo();
          ISourceType topLevelType = sourceType;
          while (topLevelType.getEnclosingType() != null) {
            topLevelType = topLevelType.getEnclosingType();
          }
          // find all siblings (other types declared in same unit, since may be used for name resolution)
          IType[] types = sourceType.getHandle().getCompilationUnit().getTypes();
          ISourceType[] sourceTypes = new ISourceType[types.length];
 
          // in the resulting collection, ensure the requested type is the first one
          sourceTypes[0] = sourceType;
          int length = types.length;
          for (int i = 0, index = 1; i < length; i++) {
            ISourceType otherType =
              (ISourceType) ((JavaElement) types[i]).getElementInfo();
            if (!otherType.equals(topLevelType) && index < length) // check that the index is in bounds (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=62861)
              sourceTypes[index++] = otherType;
          }
          return new NameEnvironmentAnswer(sourceTypes, answer.restriction);
        } catch (JavaModelException npe) {
          return null;
        }
      }
    }
View Full Code Here


private NameEnvironmentAnswer findClass(String qualifiedTypeName, char[] typeName) {
  String
    binaryFileName = null, qBinaryFileName = null,
    sourceFileName = null, qSourceFileName = null,
    qPackageName = null;
  NameEnvironmentAnswer suggestedAnswer = null;
  for (int i = 0, length = this.locations.length; i < length; i++) {
    ClasspathLocation location = this.locations[i];
    NameEnvironmentAnswer answer;
    if (location instanceof ClasspathSourceDirectory) {
      if (sourceFileName == null) {
        qSourceFileName = qualifiedTypeName; // doesn't include the file extension
        sourceFileName = qSourceFileName;
        qPackageName =  ""; //$NON-NLS-1$
        if (qualifiedTypeName.length() > typeName.length) {
          int typeNameStart = qSourceFileName.length() - typeName.length;
          qPackageName =  qSourceFileName.substring(0, typeNameStart - 1);
          sourceFileName = qSourceFileName.substring(typeNameStart);
        }
      }
      ICompilationUnit workingCopy = (ICompilationUnit) this.workingCopies.get(qualifiedTypeName);
      if (workingCopy != null) {
        answer = new NameEnvironmentAnswer(workingCopy, null /*no access restriction*/);
      } else {
        answer = location.findClass(
          sourceFileName, // doesn't include the file extension
          qPackageName,
          qSourceFileName)// doesn't include the file extension
      }
    } else {
      if (binaryFileName == null) {
        qBinaryFileName = qualifiedTypeName + SUFFIX_STRING_class;
        binaryFileName = qBinaryFileName;
        qPackageName =  ""; //$NON-NLS-1$
        if (qualifiedTypeName.length() > typeName.length) {
          int typeNameStart = qBinaryFileName.length() - typeName.length - 6; // size of ".class"
          qPackageName =  qBinaryFileName.substring(0, typeNameStart - 1);
          binaryFileName = qBinaryFileName.substring(typeNameStart);
        }
      }
      answer =
        location.findClass(
          binaryFileName,
          qPackageName,
          qBinaryFileName);
    }
    if (answer != null) {
      if (!answer.ignoreIfBetter()) {
        if (answer.isBetter(suggestedAnswer))
          return answer;
      } else if (answer.isBetter(suggestedAnswer))
        // remember suggestion and keep looking
        suggestedAnswer = answer;
    }
  }
  if (suggestedAnswer != null)
View Full Code Here

  try {
    ClassFileReader reader = ClassFileReader.read(this.zipFile, qualifiedBinaryFileName);
    if (reader != null) {
      if (this.accessRuleSet == null)
        return new NameEnvironmentAnswer(reader, null);
      String fileNameWithoutExtension = qualifiedBinaryFileName.substring(0, qualifiedBinaryFileName.length() - SuffixConstants.SUFFIX_CLASS.length);
      return new NameEnvironmentAnswer(reader, this.accessRuleSet.getViolatedRestriction(fileNameWithoutExtension.toCharArray()));
    }
  } catch (Exception e) { // treat as if class file is missing
  }
  return null;
}
View Full Code Here

                return result;
              }
            }
            break;
          case IPackageFragmentRoot.K_BINARY:
            NameEnvironmentAnswer answer =
              nameEnvironment.findType(TypeConstants.PACKAGE_INFO_NAME, this.binding.compoundName);
            if (answer != null && answer.isBinaryType()) {
              IBinaryType type = answer.getBinaryType();
              IBinaryAnnotation[] binaryAnnotations = type.getAnnotations();
              org.aspectj.org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding[] binaryInstances =
                BinaryTypeBinding.createAnnotations(binaryAnnotations, this.binding.environment);
              org.aspectj.org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding[] allInstances =
                org.aspectj.org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding.addStandardAnnotations(binaryInstances, type.getTagBits(), this.binding.environment);
View Full Code Here

  } catch (IOException e) {
    return null;
  }
  if (reader != null) {
    if (this.accessRuleSet == null)
      return new NameEnvironmentAnswer(reader, null);
    String fileNameWithoutExtension = qualifiedBinaryFileName.substring(0, qualifiedBinaryFileName.length() - SuffixConstants.SUFFIX_CLASS.length);
    return new NameEnvironmentAnswer(reader, this.accessRuleSet.getViolatedRestriction(fileNameWithoutExtension.toCharArray()));
  }
  return null;
}
View Full Code Here

public NameEnvironmentAnswer findClass(String sourceFileWithoutExtension, String qualifiedPackageName, String qualifiedSourceFileWithoutExtension) {
  SimpleLookupTable dirTable = directoryTable(qualifiedPackageName);
  if (dirTable != null && dirTable.elementSize > 0) {
    IFile file = (IFile) dirTable.get(sourceFileWithoutExtension);
    if (file != null) {
      return new NameEnvironmentAnswer(new ResourceCompilationUnit(file, file.getLocationURI()), null /* no access restriction */);
    }
  }
  return null;
}
View Full Code Here

   
    if (cf == null) return null;

    try {
      //System.out.println("from cache: " + name);
      return new NameEnvironmentAnswer(
          new ClassFileReader(cf.getBytes(), cf.getFilename().toCharArray()),
          null /* no access restriction */);
    } catch (ClassFormatException e) {
      return null; //!!! seems to match FileSystem behavior
    }
View Full Code Here

  public NameEnvironmentAnswer findType(
    char[] typeName,
    char[][] packageName)
  {
    NameEnvironmentAnswer ret = findType(new String(CharOperation.concatWith(packageName, typeName, '.')));
    if (ret != null) return ret;
    return baseEnvironment.findType(typeName, packageName);
  }
View Full Code Here

    if (ret != null) return ret;
    return baseEnvironment.findType(typeName, packageName);
  }

  public NameEnvironmentAnswer findType(char[][] compoundName) {
    NameEnvironmentAnswer ret = findType(new String(CharOperation.concatWith(compoundName, '.')));
    if (ret != null) return ret;
    return baseEnvironment.findType(compoundName);
  }
View Full Code Here

    String name = type.getName();
    if (name.endsWith(".class")) {
      name = name.substring(0,name.length() - ".class".length());
    }
    char[][] cname = CharOperation.splitOn('.',name.toCharArray());
    NameEnvironmentAnswer answer = nameEnv.findType(cname);
    if (answer == null || !answer.isBinaryType()) {
      return null;
    } else {
      IBinaryType binType = answer.getBinaryType();
      // XXX - but better than the alternative hacks
      if (binType instanceof ClassFileReader) {
        ClassFileReader cfr = (ClassFileReader) binType;
        cf = new ClassFileReaderBackedClassFile(cfr);
      } else {
View Full Code Here

TOP

Related Classes of org.aspectj.org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer

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.