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

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


    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_INTERNAL);
              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

  /*
   * @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

          options.put(CompilerOptions.OPTION_ReportUnusedImport, CompilerOptions.IGNORE);
        }
      }
    }
  }
  INameEnvironment environment = null;
  try {
    this.context.evaluate(
      codeSnippet.toCharArray(),
      varTypeNames,
      varNames,
      localVariableModifiers,
      declaringType == null? null : declaringType.getFullyQualifiedName().toCharArray(),
      isStatic,
      isConstructorCall,
      environment = getBuildNameEnvironment(),
      options,
      getInfrastructureEvaluationRequestor(requestor),
      getProblemFactory());
  } catch (InstallException e) {
    handleInstallException(e);
  } finally {
    if (environment != null) environment.cleanup();
  }
}
View Full Code Here

* @see IEvaluationContext#evaluateCodeSnippet(String, ICodeSnippetRequestor, IProgressMonitor)
*/
public void evaluateCodeSnippet(String codeSnippet, ICodeSnippetRequestor requestor, IProgressMonitor progressMonitor) throws JavaModelException {

  checkBuilderState();
  INameEnvironment environment = null;
  try {
    this.context.evaluate(
      codeSnippet.toCharArray(),
      environment = getBuildNameEnvironment(),
      this.project.getOptions(true),
      getInfrastructureEvaluationRequestor(requestor),
      getProblemFactory());
  } catch (InstallException e) {
    handleInstallException(e);
  } finally {
    if (environment != null) environment.cleanup();
  }
}
View Full Code Here

* @see IEvaluationContext#evaluateVariable(IGlobalVariable, ICodeSnippetRequestor, IProgressMonitor)
*/
public void evaluateVariable(IGlobalVariable variable, ICodeSnippetRequestor requestor, IProgressMonitor progressMonitor) throws JavaModelException {

  checkBuilderState();
  INameEnvironment environment = null;
  try {
    this.context.evaluateVariable(
      ((GlobalVariableWrapper)variable).variable,
      environment = getBuildNameEnvironment(),
      this.project.getOptions(true),
      getInfrastructureEvaluationRequestor(requestor),
      getProblemFactory());
  } catch (InstallException e) {
    handleInstallException(e);
  } finally {
    if (environment != null) environment.cleanup();
  }
}
View Full Code Here

* @see IEvaluationContext#validateImports(ICodeSnippetRequestor)
*/
public void validateImports(ICodeSnippetRequestor requestor) {

  checkBuilderState();
  INameEnvironment environment = null;
  try {
    this.context.evaluateImports(
      environment = getBuildNameEnvironment(),
      getInfrastructureEvaluationRequestor(requestor),
      getProblemFactory());
  } finally {
    if (environment != null) environment.cleanup();
  }
}
View Full Code Here

      this.basicParser.reportOnlyOneSyntaxError = true;
      this.basicParser.scanner.taskTags = null;
      this.cud = this.basicParser.parse(this.compilationUnit, new CompilationResult(this.compilationUnit, 0, 0, this.options.maxProblemsPerUnit));

      // Use a non model name environment to avoid locks, monitors and such.
      INameEnvironment nameEnvironment = new JavaSearchNameEnvironment(javaProject, JavaModelManager.getJavaModelManager().getWorkingCopies(DefaultWorkingCopyOwner.PRIMARY, true/*add primary WCs*/));
      this.lookupEnvironment = new LookupEnvironment(this, this.options, problemReporter, nameEnvironment);
      reduceParseTree(this.cud);
      this.lookupEnvironment.buildTypeBindings(this.cud, null);
      this.lookupEnvironment.completeTypeBindings();
      this.cud.scope.faultInTypes();
View Full Code Here

        IProblemFactory problemFactory = new DefaultProblemFactory(Locale.ENGLISH);

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

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

    }

    public CompilationUnitDeclaration[] getUnits(List<CtFile> streams,Factory f)
            throws Exception {
        this.startTime = System.currentTimeMillis();
        INameEnvironment environment = this.environment;
        if(environment == null)
            environment = getLibraryAccess();
        this.batchCompiler = new Compiler(environment, getHandlingPolicy(),
                this.options, this, getProblemFactory(), this.out, false);
        return batchCompiler.compileUnits(getCompilationUnits(streams));
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.internal.compiler.env.INameEnvironment

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.