Examples of INameEnvironment


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

    this.resolver = resolver;
  }

  public IAnnotationBinding[] getAnnotations() {
    try {
      INameEnvironment nameEnvironment = this.binding.environment.nameEnvironment;
      if (!(nameEnvironment instanceof SearchableEnvironment))
        return AnnotationBinding.NoAnnotations;
      NameLookup nameLookup = ((SearchableEnvironment) nameEnvironment).nameLookup;
      if (nameLookup == null)
        return AnnotationBinding.NoAnnotations;
      final String pkgName = getName();
      IPackageFragment[] pkgs = nameLookup.findPackageFragments(pkgName, false/*exact match*/);
      if (pkgs == null)
        return AnnotationBinding.NoAnnotations;

      for (int i = 0, len = pkgs.length; i < len; i++) {
        int fragType = pkgs[i].getKind();
        switch(fragType) {
          case IPackageFragmentRoot.K_SOURCE:
            String unitName = "package-info.java"; //$NON-NLS-1$
            ICompilationUnit unit = pkgs[i].getCompilationUnit(unitName);
            if (unit != null && unit.exists()) {
              ASTParser p = ASTParser.newParser(AST.JLS3);
              p.setSource(unit);
              p.setResolveBindings(true);
              p.setUnitName(unitName);
              p.setFocalPosition(0);
              p.setKind(ASTParser.K_COMPILATION_UNIT);
              CompilationUnit domUnit = (CompilationUnit) p.createAST(null);
              PackageDeclaration pkgDecl = domUnit.getPackage();
              if (pkgDecl != null) {
                List annos = pkgDecl.annotations();
                if (annos == null || annos.isEmpty())
                  return AnnotationBinding.NoAnnotations;
                IAnnotationBinding[] result = new IAnnotationBinding[annos.size()];
                int index=0;
                 for (Iterator it = annos.iterator(); it.hasNext(); index++) {
                  result[index] = ((Annotation) it.next()).resolveAnnotationBinding();
                  // not resolving bindings
                  if (result[index] == null)
                    return AnnotationBinding.NoAnnotations;
                }
                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();
              char[][][] missingTypeNames = type.getMissingTypeNames();
              IBinaryAnnotation[] binaryAnnotations = type.getAnnotations();
              org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding[] binaryInstances =
View Full Code Here

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

  /*
   * @see IBinding#getJavaElement()
   */
  public IJavaElement getJavaElement() {
    INameEnvironment nameEnvironment = this.binding.environment.nameEnvironment; // a package binding always has a LooupEnvironment set
    if (!(nameEnvironment instanceof SearchableEnvironment)) return null;
    // this is not true in standalone DOM/AST
    NameLookup nameLookup = ((SearchableEnvironment) nameEnvironment).nameLookup;
    if (nameLookup == null) return null;
    IJavaElement[] pkgs = nameLookup.findPackageFragments(getName(), false/*exact match*/);
 
View Full Code Here

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

            return new org.drools.commons.jci.compilers.CompilationResult(result);
        }
       
        final IErrorHandlingPolicy policy = DefaultErrorHandlingPolicies.proceedWithAllProblems();
        final IProblemFactory problemFactory = new DefaultProblemFactory(Locale.getDefault());
        final INameEnvironment nameEnvironment = new INameEnvironment() {

            public NameEnvironmentAnswer findType( final char[][] pCompoundTypeName ) {
                final StringBuilder result = new StringBuilder();
                for (int i = 0; i < pCompoundTypeName.length; i++) {
                    if (i != 0) {
View Full Code Here

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

            settings.put(OPTION_ReportDeprecation, IGNORE);
        }

        // Create a compiler
        List<CompilerError> compilerErrors = new ArrayList<CompilerError>();
        INameEnvironment nameEnvironment =
            new ClassLoaderNameEnvironment(classLoader, configuration.getSourceLocations());
        ICompilerRequestor requestor =
            new CompilerRequestor(configuration.getOutputLocation(), configuration.isShowWarnings(), compilerErrors);
        Compiler compiler =
            new Compiler(nameEnvironment, proceedWithAllProblems(), new CompilerOptions(settings), requestor,
View Full Code Here

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

            return new org.drools.compiler.commons.jci.compilers.CompilationResult(result);
        }

        final IErrorHandlingPolicy policy = DefaultErrorHandlingPolicies.proceedWithAllProblems();
        final IProblemFactory problemFactory = new DefaultProblemFactory(Locale.getDefault());
        final INameEnvironment nameEnvironment = new INameEnvironment() {

            public NameEnvironmentAnswer findType( final char[][] pCompoundTypeName ) {
                final StringBuilder result = new StringBuilder();
                for (int i = 0; i < pCompoundTypeName.length; i++) {
                    if (i != 0) {
View Full Code Here

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

        IProblemFactory problemFactory = new DefaultProblemFactory(Locale.ENGLISH);

        /**
         * To find types ...
         */
        INameEnvironment nameEnvironment = new INameEnvironment() {

            @Override
      public NameEnvironmentAnswer findType(final char[][] compoundTypeName) {
                final StringBuffer result = new StringBuffer();
                for (int i = 0; i < compoundTypeName.length; i++) {
View Full Code Here

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

            public boolean ignoreOptionalProblems() {
                return false;
            }
        }

        final INameEnvironment env = new INameEnvironment() {

                public NameEnvironmentAnswer
                    findType(char[][] compoundTypeName) {
                    String result = "";
                    String sep = "";
View Full Code Here

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

                return result;
            }
        }


        final INameEnvironment env = new INameEnvironment() {

                public NameEnvironmentAnswer findType(char[][] compoundTypeName) {
                    StringBuffer result = new StringBuffer();
                    for (int i = 0; i < compoundTypeName.length; i++) {
                        if (i > 0) {
View Full Code Here

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

                }
                return result;
            }
        }

        final INameEnvironment env = new INameEnvironment() {

                public NameEnvironmentAnswer
                    findType(char[][] compoundTypeName) {
                    String result = "";
                    String sep = "";
View Full Code Here

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

                }
                return result;
            }
        }

        final INameEnvironment env = new INameEnvironment() {

                public NameEnvironmentAnswer
                    findType(char[][] compoundTypeName) {
                    String result = "";
                    String sep = "";
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.