Package com.google.dart.engine.ast

Examples of com.google.dart.engine.ast.CompilationUnit


   *
   * @param identifier the identifier whose source is to be returned
   * @return the source that contains the given identifier
   */
  protected final Source getSource(AstNode node) {
    CompilationUnit unit = node.getAncestor(CompilationUnit.class);
    if (unit != null) {
      CompilationUnitElement unitElement = unit.getElement();
      if (unitElement != null) {
        return unitElement.getSource();
      }
    }
    return null;
View Full Code Here


    // Validate the directives
    //
    unit.accept(new RecursiveXmlVisitor<Void>() {
      @Override
      public Void visitHtmlScriptTagNode(HtmlScriptTagNode node) {
        CompilationUnit script = node.getScript();
        if (script != null) {
          GenerateDartErrorsTask.validateDirectives(getContext(), source, script, errorListener);
        }
        return null;
      }
View Full Code Here

    // check if Angular at all
    if (!hasAngularAnnotation(unit)) {
      return null;
    }
    // prepare resolved Dart unit
    CompilationUnit dartUnit = getDartUnit(context, unit);
    if (dartUnit == null) {
      return null;
    }
    // prepare accessible Angular elements
    LibraryElement libraryElement = dartUnit.getElement().getLibrary();
    Set<LibraryElement> libraries = Sets.newHashSet();
    AngularElement[] angularElements = getAngularElements(libraries, libraryElement);
    // resolve AngularComponentElement template URIs
    // TODO(scheglov) resolve to HtmlElement to allow F3 ?
    Set<Source> angularElementsSources = Sets.newHashSet();
View Full Code Here

  @Override
  protected void internalPerform() throws AnalysisException {
    TypeProvider typeProvider = ((InternalAnalysisContext) libraryElement.getContext()).getTypeProvider();
    ResolvableCompilationUnit resolvableUnit = getContext().computeResolvableCompilationUnit(source);
    modificationTime = resolvableUnit.getModificationTime();
    CompilationUnit unit = resolvableUnit.getCompilationUnit();
    if (unit == null) {
      throw new AnalysisException(
          "Internal error: computeResolvableCompilationUnit returned a value without a parsed Dart unit");
    }
    //
    // Resolve names in declarations.
    //
    new DeclarationResolver().resolve(unit, find(libraryElement, source));
    //
    // Resolve the type names.
    //
    RecordingErrorListener errorListener = new RecordingErrorListener();
    TypeResolverVisitor typeResolverVisitor = new TypeResolverVisitor(
        libraryElement,
        source,
        typeProvider,
        errorListener);
    unit.accept(typeResolverVisitor);
    //
    // Resolve the rest of the structure
    //
    InheritanceManager inheritanceManager = new InheritanceManager(libraryElement);
    ResolverVisitor resolverVisitor = new ResolverVisitor(
        libraryElement,
        source,
        typeProvider,
        inheritanceManager,
        errorListener);
    unit.accept(resolverVisitor);
    //
    // Perform additional error checking.
    //
    TimeCounterHandle counterHandleErrors = PerformanceStatistics.errors.start();
    try {
      ErrorReporter errorReporter = new ErrorReporter(errorListener, source);
      ErrorVerifier errorVerifier = new ErrorVerifier(
          errorReporter,
          libraryElement,
          typeProvider,
          inheritanceManager);
      unit.accept(errorVerifier);

      ConstantVerifier constantVerifier = new ConstantVerifier(
          errorReporter,
          libraryElement,
          typeProvider);
      unit.accept(constantVerifier);
    } finally {
      counterHandleErrors.stop();
    }
    //
    // Capture the results.
View Full Code Here

          new SubSequenceReader(contents, contentOffset),
          errorListener);
      scanner.setSourceStart(location.getLineNumber(), location.getColumnNumber());
      com.google.dart.engine.scanner.Token firstToken = scanner.tokenize();
      Parser parser = new Parser(getSource(), errorListener);
      CompilationUnit unit = parser.parseCompilationUnit(firstToken);
      unit.setLineInfo(lineInfo);
      tagNode.setScript(unit);
      return tagNode;
    }
    return new XmlTagNode(
        nodeStart,
View Full Code Here

    Scanner scanner = new Scanner(
        source,
        new CharSequenceReader(libraryFileContents),
        errorListener);
    Parser parser = new Parser(source, errorListener);
    CompilationUnit unit = parser.parseCompilationUnit(scanner.tokenize());
    LibraryBuilder libraryBuilder = new LibraryBuilder(useDart2jsPaths);
    // If any syntactic errors were found then don't try to visit the AST structure.
    if (!errorListener.getErrorReported()) {
      unit.accept(libraryBuilder);
    }
    return libraryBuilder.getLibrariesMap();
  }
View Full Code Here

  public CompilationUnit getResolvableCompilationUnit() {
    if (parsedUnitState == CacheState.VALID) {
      if (parsedUnitAccessed) {
        return (CompilationUnit) parsedUnit.accept(new AstCloner());
      }
      CompilationUnit unit = parsedUnit;
      parsedUnitState = CacheState.FLUSHED;
      parsedUnitAccessed = false;
      parsedUnit = null;
      return unit;
    }
View Full Code Here

      launchableState = state;
    } else if (descriptor == PARSE_ERRORS) {
      parseErrors = updatedValue(state, parseErrors, AnalysisError.NO_ERRORS);
      parseErrorsState = state;
    } else if (descriptor == PARSED_UNIT) {
      CompilationUnit newUnit = updatedValue(state, parsedUnit, null);
      if (newUnit != parsedUnit) {
        parsedUnitAccessed = false;
      }
      parsedUnit = newUnit;
      parsedUnitState = state;
View Full Code Here

   */
  public static ImportElementInfo getImportElementInfo(SimpleIdentifier prefixNode) {
    ImportElementInfo info = new ImportElementInfo();
    // prepare environment
    AstNode parent = prefixNode.getParent();
    CompilationUnit unit = prefixNode.getAncestor(CompilationUnit.class);
    LibraryElement libraryElement = unit.getElement().getLibrary();
    // prepare used element
    Element usedElement = null;
    if (parent instanceof PrefixedIdentifier) {
      PrefixedIdentifier prefixed = (PrefixedIdentifier) parent;
      if (prefixed.getPrefix() == prefixNode) {
View Full Code Here

          typeProvider,
          analysisContext.getDeclaredVariables());
      for (Library library : librariesInCycles) {
        for (Source source : library.getCompilationUnitSources()) {
          try {
            CompilationUnit unit = library.getAST(source);
            if (unit != null) {
              computer.add(unit);
            }
          } catch (AnalysisException exception) {
            AnalysisEngine.getInstance().getLogger().logError(
View Full Code Here

TOP

Related Classes of com.google.dart.engine.ast.CompilationUnit

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.