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

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


    DependencyVisitor trv = new DependencyVisitor(dependencies);

    // Find references to type in units that aren't any longer valid.
    //
    for (Iterator iter = cudsByFileName.values().iterator(); iter.hasNext();) {
      CompilationUnitDeclaration cud = (CompilationUnitDeclaration) iter.next();
      cud.traverse(trv, cud.scope);
    }

    Set toTraverse = new HashSet(changedFiles);
    for (Iterator iter = toTraverse.iterator(); iter.hasNext();) {
      String fileName = (String) iter.next();
View Full Code Here


            // in which case we already know it is invalid
            // or its something like GWT and it lives.
            continue;
          }
          String fileName = Util.findFileName(location);
          CompilationUnitDeclaration compilationUnitDeclaration = ((CompilationUnitDeclaration) cudsByFileName.get(location));
          if (compilationUnitDeclaration == null) {
            changedFiles.add(location);
            continue;
          }
          long srcLastModified = Long.MAX_VALUE;
View Full Code Here

  /* (non-Javadoc)
   * @see 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

* 2. Create the field bindings
* 3. Create the method bindings
*/
public void completeTypeBindings(CompilationUnitDeclaration[] parsedUnits, boolean[] buildFieldsAndMethods, int unitCount) {
  for (int i = 0; i < unitCount; i++) {
    CompilationUnitDeclaration parsedUnit = parsedUnits[i];
    if (parsedUnit.scope != null)
      (this.unitBeingCompleted = parsedUnit).scope.checkAndSetImports();
  }

  for (int i = 0; i < unitCount; i++) {
    CompilationUnitDeclaration parsedUnit = parsedUnits[i];
    if (parsedUnit.scope != null)
      (this.unitBeingCompleted = parsedUnit).scope.connectTypeHierarchy();
  }

  for (int i = 0; i < unitCount; i++) {
    CompilationUnitDeclaration parsedUnit = parsedUnits[i];
    if (parsedUnit.scope != null) {
      (this.unitBeingCompleted = parsedUnit).scope.checkParameterizedTypes();
      if (buildFieldsAndMethods[i])
        parsedUnit.scope.buildFieldsAndMethods();
    }
View Full Code Here

  return null;
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=372012
public void missingNonNullByDefaultAnnotation(TypeDeclaration type) {
  int severity;
  CompilationUnitDeclaration compUnitDecl = type.getCompilationUnitDeclaration();
  String[] arguments;
  if (compUnitDecl.currentPackage == null) {
    severity = computeSeverity(IProblem.MissingNonNullByDefaultAnnotationOnType);
    if (severity == ProblemSeverities.Ignore) return;
    // Default package
View Full Code Here

  // underlying resource is null in the case of a working copy on a class file in a jar
  if (underlyingResource != null)
    unitInfo.timestamp = ((IFile)underlyingResource).getModificationStamp();

  // compute other problems if needed
  CompilationUnitDeclaration compilationUnitDeclaration = null;
  CompilationUnit source = cloneCachingContents();
  try {
    if (computeProblems) {
      if (problems == null) {
        // report problems to the problem requestor
        problems = new HashMap();
        compilationUnitDeclaration = CompilationUnitProblemFinder.process(source, parser, this.owner, problems, createAST, reconcileFlags, pm);
        try {
          perWorkingCopyInfo.beginReporting();
          for (Iterator iteraror = problems.values().iterator(); iteraror.hasNext();) {
            CategorizedProblem[] categorizedProblems = (CategorizedProblem[]) iteraror.next();
            if (categorizedProblems == null) continue;
            for (int i = 0, length = categorizedProblems.length; i < length; i++) {
              perWorkingCopyInfo.acceptProblem(categorizedProblems[i]);
            }
          }
        } finally {
          perWorkingCopyInfo.endReporting();
        }
      } else {
        // collect problems
        compilationUnitDeclaration = CompilationUnitProblemFinder.process(source, parser, this.owner, problems, createAST, reconcileFlags, pm);
      }
    } else {
      compilationUnitDeclaration = parser.parseCompilationUnit(source, true /*full parse to find local elements*/, pm);
    }

    if (createAST) {
      int astLevel = ((ASTHolderCUInfo) info).astLevel;
      org.eclipse.jdt.core.dom.CompilationUnit cu = AST.convertCompilationUnit(astLevel, compilationUnitDeclaration, options, computeProblems, source, reconcileFlags, pm);
      ((ASTHolderCUInfo) info).ast = cu;
    }
  } finally {
      if (compilationUnitDeclaration != null) {
          compilationUnitDeclaration.cleanUp();
      }
  }

  return unitInfo.isStructureKnown();
}
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.INTERSECTION_TYPE:
            if (checkType(((WildcardBinding) binding).bound))
              return true;
            TypeBinding[] otherBounds = ((WildcardBinding) binding).otherBounds;
            // per construction, otherBounds is never null
            for (int i = 0, length = otherBounds.length; i < length; i++) {
              if (checkType(otherBounds[i]))
                return true;
            }
            break;
          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

        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, compilationUnitDeclaration.comments);
    }
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, compilationUnitDeclaration.comments);
    }
View Full Code Here

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

    CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, compilerOptions.maxProblemsPerUnit);
    CompilationUnitDeclaration unit = new CompilationUnitDeclaration(problemReporter, compilationResult, source.length);
    Expression result = parser.parseExpression(source, offset, length, unit);

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

TOP

Related Classes of 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.