Package com.google.dart.engine.element

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


  /**
   * When we inject variable, we give access to the library of its type.
   */
  private void recordTypeLibraryInjected(LocalVariableElementImpl variable) {
    LibraryElement typeLibrary = variable.getType().getElement().getLibrary();
    injectedLibraries.add(typeLibrary);
  }
View Full Code Here


   *
   * @param element the export element whose export namespace is to be created
   * @return the export namespace that was created
   */
  public Namespace createExportNamespaceForDirective(ExportElement element) {
    LibraryElement exportedLibrary = element.getExportedLibrary();
    if (exportedLibrary == null) {
      //
      // The exported library will be null if the URI does not reference a valid library.
      //
      return Namespace.EMPTY;
View Full Code Here

    return null;
  }

  @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)) {
          return partUnit;
        }
      }
    }
View Full Code Here

  public TypeProvider getTypeProvider() throws AnalysisException {
    Source coreSource = getSourceFactory().forUri(DartSdk.DART_CORE);
    if (coreSource == null) {
      throw new AnalysisException("Could not create a source for dart:core");
    }
    LibraryElement coreElement = computeLibraryElement(coreSource);
    if (coreElement == null) {
      throw new AnalysisException("Could not create an element for dart:core");
    }
    return new TypeProviderImpl(coreElement);
  }
View Full Code Here

  public void recordLibraryElements(Map<Source, LibraryElement> elementMap) {
    synchronized (cacheLock) {
      Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML);
      for (Map.Entry<Source, LibraryElement> entry : elementMap.entrySet()) {
        Source librarySource = entry.getKey();
        LibraryElement library = entry.getValue();
        //
        // Cache the element in the library's info.
        //
        DartEntry dartEntry = getReadableDartEntry(librarySource);
        if (dartEntry != null) {
          DartEntryImpl dartCopy = dartEntry.getWritableCopy();
          recordElementData(dartCopy, library, library.getSource(), htmlSource);
          dartCopy.setState(SourceEntry.CONTENT, CacheState.FLUSHED);
          dartCopy.setValue(SourceEntry.LINE_INFO, new LineInfo(new int[] {0}));
          dartCopy.setValue(DartEntry.ANGULAR_ERRORS, AnalysisError.NO_ERRORS);
          // DartEntry.ELEMENT - set in recordElementData
          dartCopy.setValue(DartEntry.EXPORTED_LIBRARIES, Source.EMPTY_ARRAY);
View Full Code Here

      libraryEntry = cacheDartResolutionData(
          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();
View Full Code Here

    while (state != CacheState.ERROR && state != CacheState.VALID) {
      //
      // If not, compute the information. Unless the modification date of the source continues to
      // change, this loop will eventually terminate.
      //
      LibraryElement library = computeLibraryElement(librarySource);
      CompilationUnit unit = resolveCompilationUnit(unitSource, library);
      if (unit == null) {
        throw new AnalysisException("Could not resolve compilation unit "
            + unitSource.getFullName() + " in " + librarySource.getFullName());
      }
View Full Code Here

      DartEntryImpl dartCopy = unitEntry.getWritableCopy();
      dartCopy.recordResolutionError(exception);
      cache.put(unitSource, dartCopy);
      return new TaskData(null, false);
    }
    LibraryElement libraryElement = libraryEntry.getValue(DartEntry.ELEMENT);
    DartEntryImpl dartCopy = unitEntry.getWritableCopy();
    dartCopy.setStateInLibrary(DartEntry.VERIFICATION_ERRORS, librarySource, CacheState.IN_PROCESS);
    cache.put(unitSource, dartCopy);
    return new TaskData(new GenerateDartErrorsTask(
        this,
View Full Code Here

  private TaskData createGenerateDartHintsTask(Source source, DartEntry dartEntry,
      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) {
      // TODO(brianwilkerson) We should return a ResolveDartUnitTask (unless there are multiple ASTs
View Full Code Here

          CacheState resolvedUnitState = dartEntry.getStateInLibrary(
              DartEntry.RESOLVED_UNIT,
              librarySource);
          if (resolvedUnitState == CacheState.INVALID
              || (isPriority && resolvedUnitState == CacheState.FLUSHED)) {
            LibraryElement libraryElement = libraryEntry.getValue(DartEntry.ELEMENT);
            if (libraryElement != null) {
              sources.add(source);
              return;
            }
          }
          if (generateSdkErrors || !source.isInSystemLibrary()) {
            CacheState verificationErrorsState = dartEntry.getStateInLibrary(
                DartEntry.VERIFICATION_ERRORS,
                librarySource);
            if (verificationErrorsState == CacheState.INVALID
                || (isPriority && verificationErrorsState == CacheState.FLUSHED)) {
              LibraryElement libraryElement = libraryEntry.getValue(DartEntry.ELEMENT);
              if (libraryElement != null) {
                sources.add(source);
                return;
              }
            }
            if (hintsEnabled) {
              CacheState hintsState = dartEntry.getStateInLibrary(DartEntry.HINTS, librarySource);
              if (hintsState == CacheState.INVALID
                  || (isPriority && hintsState == CacheState.FLUSHED)) {
                LibraryElement libraryElement = libraryEntry.getValue(DartEntry.ELEMENT);
                if (libraryElement != null) {
                  sources.add(source);
                  return;
                }
              }
View Full Code Here

TOP

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

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.