Examples of NameEnvironmentAnswer


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

  boolean binaryExists = ((this.mode & BINARY) != 0) && doesFileExist(fileName + SUFFIX_STRING_class, qualifiedPackageName);
  boolean sourceExists = ((this.mode & SOURCE) != 0) && doesFileExist(fileName + SUFFIX_STRING_java, qualifiedPackageName);
  if (sourceExists && !asBinaryOnly) {
    String fullSourcePath = this.path + qualifiedBinaryFileName.substring(0, qualifiedBinaryFileName.length() - 6+ SUFFIX_STRING_java;
    if (!binaryExists)
      return new NameEnvironmentAnswer(new CompilationUnit(null,
          fullSourcePath, this.encoding, destinationPath),
          fetchAccessRestriction(qualifiedBinaryFileName));
    String fullBinaryPath = this.path + qualifiedBinaryFileName;
    long binaryModified = new File(fullBinaryPath).lastModified();
    long sourceModified = new File(fullSourcePath).lastModified();
    if (sourceModified > binaryModified)
      return new NameEnvironmentAnswer(new CompilationUnit(null,
          fullSourcePath, this.encoding, destinationPath),
          fetchAccessRestriction(qualifiedBinaryFileName));
  }
  if (binaryExists) {
    try {
      ClassFileReader reader = ClassFileReader.read(this.path + qualifiedBinaryFileName);
      if (reader != null)
        return new NameEnvironmentAnswer(
            reader,
            fetchAccessRestriction(qualifiedBinaryFileName));
    } catch (Exception e) {
      // treat as if file is missing
    }
View Full Code Here

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

}
/**
* @see INameEnvironment#findType(char[][])
*/
public NameEnvironmentAnswer findType(char[][] compoundTypeName) {
  NameEnvironmentAnswer result = this.env.findType(compoundTypeName);
  if (result != null) {
    return result;
  }
  if (CharOperation.equals(compoundTypeName, ROOT_COMPOUND_NAME)) {
    IBinaryType binary = this.context.getRootCodeSnippetBinary();
    if (binary == null) {
      return null;
    } else {
      return new NameEnvironmentAnswer(binary, null /*no access restriction*/);
    }
  }
  VariablesInfo installedVars = this.context.installedVars;
  ClassFile[] classFiles = installedVars.classFiles;
  for (int i = 0; i < classFiles.length; i++) {
    ClassFile classFile = classFiles[i];
    if (CharOperation.equals(compoundTypeName, classFile.getCompoundName())) {
      ClassFileReader binary = null;
      try {
        binary = new ClassFileReader(classFile.getBytes(), null);
      } catch (ClassFormatException e) {
        e.printStackTrace()// Should never happen since we compiled this type
        return null;
      }
      return new NameEnvironmentAnswer(binary, null /*no access restriction*/);
    }
  }
  return null;
}
View Full Code Here

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

}
/**
* @see INameEnvironment#findType(char[], char[][])
*/
public NameEnvironmentAnswer findType(char[] typeName, char[][] packageName) {
  NameEnvironmentAnswer result = this.env.findType(typeName, packageName);
  if (result != null) {
    return result;
  }
  return findType(CharOperation.arrayConcat(packageName, typeName));
}
View Full Code Here

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

  try {
      ensureOpen(); // AspectJ Extension
    ClassFileReader reader = ClassFileReader.read(this.zipFile, qualifiedBinaryFileName);
    if (reader != null)
      return new NameEnvironmentAnswer(reader, fetchAccessRestriction(qualifiedBinaryFileName));
  } catch(ClassFormatException e) {
    // treat as if class file is missing
  } catch (IOException e) {
    // treat as if class file is missing
  }
View Full Code Here

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

      return null; // most common case

    ZipEntry sourceEntry = this.zipFile.getEntry(qualifiedBinaryFileName.substring(0, qualifiedBinaryFileName.length() - 6+ SUFFIX_STRING_java);
    if (sourceEntry != null) {
      try {
        return new NameEnvironmentAnswer(
            new CompilationUnit(
                Util.getInputStreamAsCharArray(this.zipFile.getInputStream(sourceEntry),
                    -1, this.encoding),
            qualifiedBinaryFileName.substring(0, qualifiedBinaryFileName.length() - 6+ SUFFIX_STRING_java,
            this.encoding, this.destinationPath),
View Full Code Here

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

  String qualifiedPackageName =
    qualifiedTypeName.length() == typeName.length
      ? Util.EMPTY_STRING
      : qualifiedBinaryFileName.substring(0, qualifiedTypeName.length() - typeName.length - 1);
  String qp2 = File.separatorChar == '/' ? qualifiedPackageName : qualifiedPackageName.replace('/', File.separatorChar);
  NameEnvironmentAnswer suggestedAnswer = null;
  if (qualifiedPackageName == qp2) {
    for (int i = 0, length = this.classpaths.length; i < length; i++) {
      NameEnvironmentAnswer answer = this.classpaths[i].findClass(typeName, qualifiedPackageName, qualifiedBinaryFileName, asBinaryOnly);
      if (answer != null) {
        if (!answer.ignoreIfBetter()) {
          if (answer.isBetter(suggestedAnswer))
            return answer;
        } else if (answer.isBetter(suggestedAnswer))
          // remember suggestion and keep looking
          suggestedAnswer = answer;
      }
    }
  } else {
    String qb2 = qualifiedBinaryFileName.replace('/', File.separatorChar);
    for (int i = 0, length = this.classpaths.length; i < length; i++) {
      Classpath p = this.classpaths[i];
      NameEnvironmentAnswer answer = (p instanceof ClasspathJar)
        ? p.findClass(typeName, qualifiedPackageName, qualifiedBinaryFileName, asBinaryOnly)
        : p.findClass(typeName, qp2, qb2, asBinaryOnly);
      if (answer != null) {
        if (!answer.ignoreIfBetter()) {
          if (answer.isBetter(suggestedAnswer))
            return answer;
        } else if (answer.isBetter(suggestedAnswer))
          // remember suggestion and keep looking
          suggestedAnswer = answer;
      }
    }
  }
View Full Code Here

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

  private NameEnvironmentAnswer findType(String name) {
    // pr133532 - ask the state for the type first
    IBinaryType seenOnPreviousBuild = state.checkPreviousBuild(name);
    if (seenOnPreviousBuild != null) {
      return new NameEnvironmentAnswer(seenOnPreviousBuild, null);
    }
    if (this.inflatedClassFilesCache.containsKey(name)) {
      return (NameEnvironmentAnswer) this.inflatedClassFilesCache.get(name);
    } else {
      File fileOnDisk = (File) classesFromName.get(name);
      // System.err.println("find: " + name + " found: " + cf);

      if (fileOnDisk == null)
        return null;

      try {
        // System.out.println("from cache: " + name);
        byte[] bytes = FileUtil.readAsByteArray(fileOnDisk);
        NameEnvironmentAnswer ret = new NameEnvironmentAnswer(new ClassFileReader(bytes, fileOnDisk.getAbsolutePath()
            .toCharArray()), null /* no access restriction */);
        this.inflatedClassFilesCache.put(name, ret);
        return ret;
      } catch (ClassFormatException e) {
        return null; // !!! seems to match FileSystem behavior
View Full Code Here

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

      }
    }
  }

  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

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

      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

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

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