Package com.google.dart.engine.element

Examples of com.google.dart.engine.element.CompilationUnitElement


   */
  private Source getSource(AstNode node) {
    Source source = null;
    CompilationUnit unit = node.getAncestor(CompilationUnit.class);
    if (unit != null) {
      CompilationUnitElement element = unit.getElement();
      if (element != null) {
        source = element.getSource();
      }
    }
    return source;
  }
View Full Code Here


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

    }
  }

  @Override
  public Void visitCompilationUnit(CompilationUnit node) {
    CompilationUnitElement unitElement = node.getElement();
    if (unitElement != null) {
      elementStack.add(unitElement);
      libraryElement = unitElement.getEnclosingElement();
      if (libraryElement != null) {
        return super.visitCompilationUnit(node);
      }
    }
    return null;
View Full Code Here

    }
    return scope;
  }

  private Scope scopeForCompilationUnit(CompilationUnit node) throws AnalysisException {
    CompilationUnitElement unitElement = node.getElement();
    if (unitElement == null) {
      throw new AnalysisException("Cannot create scope: compilation unit is not resolved");
    }
    LibraryElement libraryElement = unitElement.getLibrary();
    if (libraryElement == null) {
      throw new AnalysisException("Cannot create scope: compilation unit is not part of a library");
    }
    return new LibraryScope(libraryElement, errorListener);
  }
View Full Code Here

  @Override
  public CompilationUnitElement getCompilationUnitElement(Source unitSource, Source librarySource) {
    LibraryElement libraryElement = getLibraryElement(librarySource);
    if (libraryElement != null) {
      // try defining unit
      CompilationUnitElement definingUnit = libraryElement.getDefiningCompilationUnit();
      if (definingUnit.getSource().equals(unitSource)) {
        return definingUnit;
      }
      // try parts
      for (CompilationUnitElement partUnit : libraryElement.getParts()) {
        if (partUnit.getSource().equals(unitSource)) {
View Full Code Here

          librarySource,
          librarySource,
          libraryEntry,
          DartEntry.ELEMENT);
      LibraryElement libraryElement = libraryEntry.getValue(DartEntry.ELEMENT);
      CompilationUnitElement definingUnit = libraryElement.getDefiningCompilationUnit();
      CompilationUnitElement[] parts = libraryElement.getParts();
      @SuppressWarnings("unchecked")
      TimestampedData<CompilationUnit>[] units = new TimestampedData[parts.length + 1];
      units[0] = getResolvedUnit(definingUnit, librarySource);
      if (units[0] == null) {
        Source source = definingUnit.getSource();
        units[0] = new TimestampedData<CompilationUnit>(
            getModificationStamp(source),
            resolveCompilationUnit(source, libraryElement));
      }
      for (int i = 0; i < parts.length; i++) {
View Full Code Here

      Source librarySource, DartEntry libraryEntry) {
    if (libraryEntry.getState(DartEntry.ELEMENT) != CacheState.VALID) {
      return createResolveDartLibraryTask(librarySource, libraryEntry);
    }
    LibraryElement libraryElement = libraryEntry.getValue(DartEntry.ELEMENT);
    CompilationUnitElement definingUnit = libraryElement.getDefiningCompilationUnit();
    CompilationUnitElement[] parts = libraryElement.getParts();
    @SuppressWarnings("unchecked")
    TimestampedData<CompilationUnit>[] units = new TimestampedData[parts.length + 1];
    units[0] = getResolvedUnit(definingUnit, librarySource);
    if (units[0] == null) {
View Full Code Here

  public void generateForLibrary() throws AnalysisException {
    TimeCounterHandle timeCounter = PerformanceStatistics.hints.start();
    try {
      for (int i = 0; i < compilationUnits.length; i++) {
        CompilationUnitElement element = compilationUnits[i].getElement();
        if (element != null) {
          if (i == 0) {
            importsVerifier.setInDefiningCompilationUnit(true);
            generateForCompilationUnit(compilationUnits[i], element.getSource());
            importsVerifier.setInDefiningCompilationUnit(false);
          } else {
            generateForCompilationUnit(compilationUnits[i], element.getSource());
          }
        }
      }
      ErrorReporter definingCompilationUnitErrorReporter = new ErrorReporter(
          errorListener,
View Full Code Here

   * @param libraryElement the element representing the library being searched through
   * @param unitSource the source for the compilation unit whose element is to be returned
   * @return the element representing the compilation unit
   */
  private CompilationUnitElement find(LibraryElement libraryElement, Source unitSource) {
    CompilationUnitElement element = libraryElement.getDefiningCompilationUnit();
    if (element.getSource().equals(unitSource)) {
      return element;
    }
    for (CompilationUnitElement partElement : libraryElement.getParts()) {
      if (partElement.getSource().equals(unitSource)) {
        return partElement;
View Full Code Here

    }
    LibraryElement libraryElement = unitElement.getLibrary();
    if (libraryElement == null) {
      return false;
    }
    CompilationUnitElement definingUnitElement = libraryElement.getDefiningCompilationUnit();
    if (definingUnitElement == null) {
      return false;
    }
    // prepare sources
    Source library = definingUnitElement.getSource();
    Source unit = unitElement.getSource();
    // special handling for the defining library unit
    if (unit.equals(library)) {
      // prepare new parts
      Set<Source> newParts = Sets.newHashSet();
View Full Code Here

TOP

Related Classes of com.google.dart.engine.element.CompilationUnitElement

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.