Examples of NameEnvironmentAnswer


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

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

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

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

  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

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

                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

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

  } 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

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

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

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

        public NameEnvironmentAnswer findType(char[][] compoundTypeName) {
            // check 1st if type corresponds with any of current compilation units
            String fqn = CharOperation.toString(compoundTypeName);
            ICompilationUnit cu = compUnits.get(fqn);
            if (cu != null) {
                return new NameEnvironmentAnswer(cu, null);
            }

            // locate the class through the class loader
            try {
                byte[] bytes = this.findClass(CharOperation.toString(compoundTypeName));
                if (bytes == null) {
                    return null;
                }
                ClassFileReader classFileReader =
                        new ClassFileReader(bytes, fqn.toCharArray(), true);
                return new NameEnvironmentAnswer(classFileReader, null);
            } catch (Exception e) {
                return null;
            }
        }
View Full Code Here

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

                    try {
                        if (className.equals(targetClassName)) {
                            ICompilationUnit compilationUnit =
                                new CompilationUnit(sourceFile, className);
                            return
                                new NameEnvironmentAnswer(compilationUnit);
                        }
                        String resourceName =
                            className.replace('.', '/') + ".class";
                        InputStream is =
                            classLoader.getResourceAsStream(resourceName);
                        if (is != null) {
                            byte[] classBytes;
                            byte[] buf = new byte[8192];
                            ByteArrayOutputStream baos =
                                new ByteArrayOutputStream(buf.length);
                            int count;
                            while ((count = is.read(buf, 0, buf.length)) > 0) {
                                baos.write(buf, 0, count);
                            }
                            baos.flush();
                            classBytes = baos.toByteArray();
                            char[] fileName = className.toCharArray();
                            ClassFileReader classFileReader =
                                new ClassFileReader(classBytes, fileName,
                                                    true);
                            return
                                new NameEnvironmentAnswer(classFileReader);
                        }
                    } catch (IOException exc) {
                        log.error("Compilation error", exc);
                    } catch (org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException exc) {
                        log.error("Compilation error", exc);
View Full Code Here

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

    try {
      if (!name.startsWith("japidviews.")) {
        // let super class loader to load the bytecode
//        byte[] bytes = this.rendererCompiler.crlr.getClassDefinition(name);
        byte[] bytes = this.rendererCompiler.crlr.getClassDefinition(name);
        return bytes == null? null : new NameEnvironmentAnswer(new ClassFileReader(bytes, name.toCharArray(), true), null);
      } else {
        char[] fileName = name.toCharArray();
        RendererClass applicationClass = this.rendererCompiler.japidClasses.get(name);

        // ApplicationClass exists
        if (applicationClass != null) {

          byte[] bytecode = applicationClass.getBytecode();
          if (bytecode != null) {
            ClassFileReader classFileReader = new ClassFileReader(bytecode, fileName, true);
            return new NameEnvironmentAnswer(classFileReader, null);
          }
          // Cascade compilation
          ICompilationUnit compilationUnit = new CompilationUnit(this.rendererCompiler, name);
          return new NameEnvironmentAnswer(compilationUnit, null);
        }
        return null;
      }
    } catch (ClassFormatException e) {
      // Something very very bad
View Full Code Here

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

            }

            private NameEnvironmentAnswer createNameEnvironmentAnswer(final String pClazzName, final byte[] clazzBytes) throws ClassFormatException {               
                final char[] fileName = pClazzName.toCharArray();
                final ClassFileReader classFileReader = new ClassFileReader(clazzBytes, fileName, true);
                return new NameEnvironmentAnswer(classFileReader, null);
            }

            private boolean isSourceAvailable(final String pClazzName, final ResourceReader pReader) {
                // FIXME: this should not be tied to the extension
                final String javaSource = pClazzName.replace('.', '/') + ".java";
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.