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

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration


  DefaultBindingResolver(LookupEnvironment lookupEnvironment, WorkingCopyOwner workingCopyOwner, BindingTables bindingTables, boolean isRecoveredBinding) {
    this.newAstToOldAst = new HashMap();
    this.astNodesToBlockScope = new HashMap();
    this.bindingsToAstNodes = new HashMap();
    this.bindingTables = bindingTables;
    this.scope = new CompilationUnitScope(new CompilationUnitDeclaration(null, null, -1), lookupEnvironment);
    this.workingCopyOwner = workingCopyOwner;
    this.isRecoveredBinding = isRecoveredBinding;
  }
View Full Code Here


            return null;
          }
        }
      }
    } else if (node instanceof CompilationUnitDeclaration) {
      CompilationUnitDeclaration compilationUnitDeclaration = (CompilationUnitDeclaration) node;
      org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration[] types = compilationUnitDeclaration.types;
      if (types == null || types.length == 0) {
        return null;
      }
      org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration type = types[0];
View Full Code Here

      return this.ast;
    }
    if (this.ast != null)
      return this.ast; // no need to recompute AST if known already
   
    CompilationUnitDeclaration unit = null;
    char[] contents = null;
    try {
      // find problems if needed
      if (JavaProject.hasJavaNature(workingCopy.getJavaProject().getProject())
          && (this.reconcileFlags & ICompilationUnit.FORCE_PROBLEM_DETECTION) != 0) {
        this.resolveBindings = this.requestorIsActive;
        if (this.problems == null)
          this.problems = new HashMap();
        contents = workingCopy.getContents();
        unit =
          CompilationUnitProblemFinder.process(
            workingCopy,
            contents,
            this.workingCopyOwner,
            this.problems,
            this.astLevel != ICompilationUnit.NO_AST/*creating AST if level is not NO_AST */,
            reconcileFlags,
            this.progressMonitor);
        if (this.progressMonitor != null) this.progressMonitor.worked(1);
      }
     
      // create AST if needed
      if (this.astLevel != ICompilationUnit.NO_AST
          && unit !=null/*unit is null if working copy is consistent && (problem detection not forced || non-Java project) -> don't create AST as per API*/) {
        Map options = workingCopy.getJavaProject().getOptions(true);
        // convert AST
        this.ast =
          AST.convertCompilationUnit(
            this.astLevel,
            unit,
            contents,
            options,
            this.resolveBindings,
            workingCopy,
            reconcileFlags,
            this.progressMonitor);
        if (this.ast != null) {
          this.deltaBuilder.delta = new JavaElementDelta(workingCopy);
          this.deltaBuilder.delta.changedAST(this.ast);
        }
        if (this.progressMonitor != null) this.progressMonitor.worked(1);
      }
      } catch (JavaModelException e) {
        if (JavaProject.hasJavaNature(workingCopy.getJavaProject().getProject()))
          throw e;
        // else JavaProject has lost its nature (or most likely was closed/deleted) while reconciling -> ignore
        // (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=100919)
      } finally {
          if (unit != null) {
              unit.cleanUp();
          }
      }
    return this.ast;
  }
View Full Code Here

      this.typeBinding = baseTypeBinding;
    }
  }
 
  public void consumeCapture(final int position) {
    CompilationUnitDeclaration outerParsedUnit = this.outerMostParsedUnit == null ? this.parsedUnit : this.outerMostParsedUnit;
    if (outerParsedUnit == null) return;
    final Binding wildcardBinding = ((BindingKeyResolver) this.types.get(0)).compilerBinding;
    class CaptureFinder extends ASTVisitor {
      CaptureBinding capture;
      boolean checkType(TypeBinding binding) {
        if (binding == null)
          return false;
        switch (binding.kind()) {
          case Binding.PARAMETERIZED_TYPE:
            TypeBinding[] arguments = ((ParameterizedTypeBinding) binding).arguments;
            if (arguments == null) return false;
            for (int i = 0, length = arguments.length; i < length; i++) {
              if (checkType(arguments[i]))
                return true;
            }
            break;
          case Binding.WILDCARD_TYPE:
            return checkType(((WildcardBinding) binding).bound);
          case Binding.ARRAY_TYPE:
            return checkType(((ArrayBinding) binding).leafComponentType);
          case Binding.TYPE_PARAMETER:
            if (binding.isCapture()) {
              CaptureBinding captureBinding = (CaptureBinding) binding;
              if (captureBinding.position == position && captureBinding.wildcard == wildcardBinding) {
                this.capture = captureBinding;
                return true;
              }
            }
            break;
        }
        return false;
      }
      public boolean visit(SingleNameReference singleNameReference, BlockScope blockScope) {
        if (checkType(singleNameReference.resolvedType))
          return false;
        return super.visit(singleNameReference, blockScope);
      }
      public boolean visit(QualifiedNameReference qualifiedNameReference, BlockScope blockScope) {
        if (checkType(qualifiedNameReference.resolvedType))
          return false;
        return super.visit(qualifiedNameReference, blockScope);
      }
      public boolean visit(MessageSend messageSend, BlockScope blockScope) {
        if (checkType(messageSend.resolvedType))
          return false;
        return super.visit(messageSend, blockScope);
      }
      public boolean visit(FieldReference fieldReference, BlockScope blockScope) {
        if (checkType(fieldReference.resolvedType))
          return false;
        return super.visit(fieldReference, blockScope);
      }
      public boolean visit(ConditionalExpression conditionalExpression, BlockScope blockScope) {
        if (checkType(conditionalExpression.resolvedType))
          return false;
        return super.visit(conditionalExpression, blockScope);
      }
      public boolean visit(CastExpression castExpression, BlockScope blockScope) {
        if (checkType(castExpression.resolvedType))
          return false;
        return super.visit(castExpression, blockScope);
      }
      public boolean visit(Assignment assignment, BlockScope blockScope) {
        if (checkType(assignment.resolvedType))
          return false;
        return super.visit(assignment, blockScope);
      }
      public boolean visit(ArrayReference arrayReference, BlockScope blockScope) {
        if (checkType(arrayReference.resolvedType))
          return false;
        return super.visit(arrayReference, blockScope);
      }
    }
    CaptureFinder captureFinder = new CaptureFinder();
    outerParsedUnit.traverse(captureFinder, outerParsedUnit.scope);
    this.typeBinding = captureFinder.capture;
  }
View Full Code Here

    CompilationResult result =
      new CompilationResult(sourceTypes[0].getFileName(), 1, 1, this.options.maxProblemsPerUnit);

    // need to hold onto this
    CompilationUnitDeclaration unit =
      SourceTypeConverter.buildCompilationUnit(
        sourceTypes,//sourceTypes[0] is always toplevel here
        SourceTypeConverter.FIELD_AND_METHOD // need field and methods
        | SourceTypeConverter.MEMBER_TYPE // need member types
        | SourceTypeConverter.FIELD_INITIALIZATION, // need field initialization
View Full Code Here

        source,
        "", //$NON-NLS-1$
        compilerOptions.defaultEncoding);

    CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, compilerOptions.maxProblemsPerUnit);
    final CompilationUnitDeclaration compilationUnitDeclaration = new CompilationUnitDeclaration(problemReporter, compilationResult, source.length);
    ASTNode[] result = parser.parseClassBodyDeclarations(source, offset, length, compilationUnitDeclaration);
   
    if (recordParsingInformation) {
      this.recordedParsingInformation = getRecordedParsingInformation(compilationResult, parser);
    }
View Full Code Here

      new CompilationUnit(
        source,
        "", //$NON-NLS-1$
        compilerOptions.defaultEncoding);
    final CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, compilerOptions.maxProblemsPerUnit);
    CompilationUnitDeclaration compilationUnitDeclaration = parser.dietParse(sourceUnit, compilationResult);

    if (recordParsingInformation) {
      this.recordedParsingInformation = getRecordedParsingInformation(compilationResult, parser);
    }
   
View Full Code Here

        source,
        "", //$NON-NLS-1$
        compilerOptions.defaultEncoding);

    CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, compilerOptions.maxProblemsPerUnit);
    Expression result = parser.parseExpression(source, offset, length, new CompilationUnitDeclaration(problemReporter, compilationResult, source.length));
   
    if (recordParsingInformation) {
      this.recordedParsingInformation = getRecordedParsingInformation(compilationResult, parser);
    }
    return result;
View Full Code Here

        source,
        "", //$NON-NLS-1$
        compilerOptions.defaultEncoding);

    final CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, compilerOptions.maxProblemsPerUnit);
    CompilationUnitDeclaration compilationUnitDeclaration = new CompilationUnitDeclaration(problemReporter, compilationResult, length);   

    ConstructorDeclaration constructorDeclaration = new ConstructorDeclaration(compilationResult);
    constructorDeclaration.sourceEnd  = -1;
    constructorDeclaration.declarationSourceEnd = offset + length - 1;
    constructorDeclaration.bodyStart = offset;
View Full Code Here

  /* (non-Javadoc)
   * @see org.aspectj.org.eclipse.jdt.internal.compiler.parser.Parser#endParse(int)
   */
  protected CompilationUnitDeclaration endParse(int act) {
    CompilationUnitDeclaration unit = super.endParse(act);
    if (unit.comments == null) {
      pushOnCommentsStack(0, this.scanner.commentPtr);
      unit.comments = getCommentsPositions();
    }
    return unit;
View Full Code Here

TOP

Related Classes of org.aspectj.org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration

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.