Package org.eclipse.jdt.internal.compiler

Examples of org.eclipse.jdt.internal.compiler.CompilationResult


      new ProblemReporter(
          DefaultErrorHandlingPolicies.proceedWithAllProblems(),
          compilerOptions,
          new DefaultProblemFactory()),
      false);
    CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, compilerOptions.maxProblemsPerUnit);
    CompilationUnitDeclaration compilationUnitDeclaration = parser.dietParse(sourceUnit, compilationResult);

    if (compilationUnitDeclaration.ignoreMethodBodies) {
      compilationUnitDeclaration.ignoreFurtherInvestigation = true;
      // if initial diet parse did not work, no need to dig into method bodies.
View Full Code Here


          // requested AST
          char[] fileName = unit.compilationResult.getFileName();
          ICompilationUnit source = (ICompilationUnit) this.requestedSources.get(fileName);
          if (source != null) {
            // convert AST
            CompilationResult compilationResult = unit.compilationResult;
            org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit = compilationResult.compilationUnit;
            char[] contents = sourceUnit.getContents();
            AST ast = AST.newAST(apiLevel);
            ast.setFlag(flags | AST.RESOLVED_BINDINGS);
            ast.setDefaultNodeFlag(ASTNode.ORIGINAL);
            ASTConverter converter = new ASTConverter(compilerOptions, true/*need to resolve bindings*/, this.monitor);
            BindingResolver resolver = new DefaultBindingResolver(unit.scope, owner, this.bindingTables, (flags & ICompilationUnit.ENABLE_BINDINGS_RECOVERY) != 0, this.fromJavaProject);
            ast.setBindingResolver(resolver);
            converter.setAST(ast);
            CompilationUnit compilationUnit = converter.convert(unit, contents);
            compilationUnit.setTypeRoot(source);
            compilationUnit.setLineEndTable(compilationResult.getLineSeparatorPositions());
            ast.setDefaultNodeFlag(0);
            ast.setOriginalModificationCount(ast.modificationCount());

            // pass it to requestor
            astRequestor.acceptAST(source, compilationUnit);
View Full Code Here

          // requested AST
          char[] fileName = unit.compilationResult.getFileName();
          org.eclipse.jdt.internal.compiler.env.ICompilationUnit source = (org.eclipse.jdt.internal.compiler.env.ICompilationUnit) this.requestedSources.get(fileName);
          if (source != null) {
            // convert AST
            CompilationResult compilationResult = unit.compilationResult;
            org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit = compilationResult.compilationUnit;
            char[] contents = sourceUnit.getContents();
            AST ast = AST.newAST(apiLevel);
            ast.setFlag(flags | AST.RESOLVED_BINDINGS);
            ast.setDefaultNodeFlag(ASTNode.ORIGINAL);
            ASTConverter converter = new ASTConverter(compilerOptions, true/*need to resolve bindings*/, this.monitor);
            BindingResolver resolver = new DefaultBindingResolver(unit.scope, null, this.bindingTables, (flags & ICompilationUnit.ENABLE_BINDINGS_RECOVERY) != 0, this.fromJavaProject);
            ast.setBindingResolver(resolver);
            converter.setAST(ast);
            CompilationUnit compilationUnit = converter.convert(unit, contents);
            compilationUnit.setTypeRoot(null);
            compilationUnit.setLineEndTable(compilationResult.getLineSeparatorPositions());
            ast.setDefaultNodeFlag(0);
            ast.setOriginalModificationCount(ast.modificationCount());

            // pass it to requestor
            astRequestor.acceptAST(new String(source.getFileName()), compilationUnit);
View Full Code Here

  ISourceType sourceType = sourceTypes[0];
  while (sourceType.getEnclosingType() != null)
    sourceType = sourceType.getEnclosingType();

  // build corresponding compilation unit
  CompilationResult result = new CompilationResult(sourceType.getFileName(), 1, 1, this.options.maxProblemsPerUnit);
  CompilationUnitDeclaration unit =
    SourceTypeConverter.buildCompilationUnit(
      new ISourceType[] {sourceType}, // ignore secondary types, to improve laziness
      SourceTypeConverter.MEMBER_TYPE, // need member types
      // no need for field initialization
View Full Code Here

        // build parsed unit
        CompilationUnitDeclaration parsedUnit = null;
        if (cu.isOpen()) {
          // create parsed unit from source element infos
          CompilationResult result = new CompilationResult((ICompilationUnit)cu, i, openablesLength, this.options.maxProblemsPerUnit);
          SourceTypeElementInfo[] typeInfos = null;
          try {
            IType[] topLevelTypes = cu.getTypes();
            int topLevelLength = topLevelTypes.length;
            if (topLevelLength == 0) continue; // empty cu: no need to parse (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=65677)
            typeInfos = new SourceTypeElementInfo[topLevelLength];
            for (int j = 0; j < topLevelLength; j++) {
              IType topLevelType = topLevelTypes[j];
              typeInfos[j] = (SourceTypeElementInfo)((JavaElement)topLevelType).getElementInfo();
            }
          } catch (JavaModelException e) {
            // types/cu exist since cu is opened
          }
          int flags = !containsLocalType
            ? SourceTypeConverter.MEMBER_TYPE
            : SourceTypeConverter.FIELD_AND_METHOD | SourceTypeConverter.MEMBER_TYPE | SourceTypeConverter.LOCAL_TYPE;
          parsedUnit =
            SourceTypeConverter.buildCompilationUnit(
              typeInfos,
              flags,
              this.lookupEnvironment.problemReporter,
              result);
         
          // We would have got all the necessary local types by now and hence there is no further need
          // to parse the method bodies. Parser.getMethodBodies, which is called latter in this function,
          // will not parse the method statements if ASTNode.HasAllMethodBodies is set.
          if (containsLocalType)   parsedUnit.bits |= ASTNode.HasAllMethodBodies;
        } else {
          // create parsed unit from file
          IFile file = (IFile) cu.getResource();
          ICompilationUnit sourceUnit = this.builder.createCompilationUnitFromPath(openable, file);

          CompilationResult unitResult = new CompilationResult(sourceUnit, i, openablesLength, this.options.maxProblemsPerUnit);
          parsedUnit = parser.dietParse(sourceUnit, unitResult);
        }

        if (parsedUnit != null) {
          hasLocalType[unitsIndex] = containsLocalType;
View Full Code Here

*/
protected CompilationUnitDeclaration buildBindings(ICompilationUnit compilationUnit, boolean isTopLevelOrMember) throws JavaModelException {
  // source unit
  org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit = (org.eclipse.jdt.internal.compiler.env.ICompilationUnit) compilationUnit;

  CompilationResult compilationResult = new CompilationResult(sourceUnit, 1, 1, 0);
  CompilationUnitDeclaration unit =
    isTopLevelOrMember ?
      this.locator.basicParser().dietParse(sourceUnit, compilationResult) :
      this.locator.basicParser().parse(sourceUnit, compilationResult);
  if (unit != null) {
View Full Code Here

* Add an additional compilation unit into the loop
*  ->  build compilation unit declarations, their bindings and record their results.
*/
public void accept(ICompilationUnit sourceUnit, AccessRestriction accessRestriction) {
  // Switch the current policy and compilation result for this unit to the requested one.
  CompilationResult unitResult = new CompilationResult(sourceUnit, 1, 1, this.options.maxProblemsPerUnit);
  try {
    CompilationUnitDeclaration parsedUnit = basicParser().dietParse(sourceUnit, unitResult);
    this.lookupEnvironment.buildTypeBindings(parsedUnit, accessRestriction);
    this.lookupEnvironment.completeTypeBindings(parsedUnit, true);
  } catch (AbortCompilationUnit e) {
View Full Code Here

    SourceTypeElementInfo elementInfo = (SourceTypeElementInfo) sourceType;
    IType type = elementInfo.getHandle();
    ICompilationUnit sourceUnit = (ICompilationUnit) type.getCompilationUnit();
    accept(sourceUnit, accessRestriction);
  } else {
    CompilationResult result = new CompilationResult(sourceType.getFileName(), 1, 1, 0);
    CompilationUnitDeclaration unit =
      SourceTypeConverter.buildCompilationUnit(
        sourceTypes,
        SourceTypeConverter.FIELD_AND_METHOD // need field and methods
        | SourceTypeConverter.MEMBER_TYPE, // need member types
View Full Code Here

  // see bug 47079 for more details
  int[] oldLineEnds = this.parser.scanner.lineEnds;
  int oldLinePtr = this.parser.scanner.linePtr;

  try {
    CompilationResult compilationResult = unit.compilationResult;
    this.parser.scanner.setSource(compilationResult);

    if (this.parser.javadocParser.checkDocComment) {
      char[] contents = compilationResult.compilationUnit.getContents();
      this.parser.javadocParser.scanner.setSource(contents);
View Full Code Here

  }
  this.bindings.put(methodPattern, new ProblemMethodBinding(methodPattern.selector, null, ProblemReasons.NotFound));
  return null;
}
protected boolean hasAlreadyDefinedType(CompilationUnitDeclaration parsedUnit) {
  CompilationResult result = parsedUnit.compilationResult;
  if (result == null) return false;
  for (int i = 0; i < result.problemCount; i++)
    if (result.problems[i].getID() == IProblem.DuplicateTypes)
      return true;
  return false;
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.internal.compiler.CompilationResult

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.