Package com.google.dart.engine.source

Examples of com.google.dart.engine.source.Source$ContentReceiver


     *
     * @param library the library to be processed to find libraries that have not yet been traversed
     * @throws AnalysisException if some portion of the library graph could not be traversed
     */
    private void computeLibraryDependencies(ResolvableLibrary library) {
      Source librarySource = library.getLibrarySource();
      DartEntry dartEntry = getReadableDartEntry(librarySource);
      Source[] importedSources = getSources(librarySource, dartEntry, DartEntry.IMPORTED_LIBRARIES);
      if (taskData != null) {
        return;
      }
View Full Code Here


      int importCount = importedSources.length;
      if (importCount > 0) {
        ArrayList<ResolvableLibrary> importedLibraries = new ArrayList<ResolvableLibrary>();
        boolean explicitlyImportsCore = false;
        for (int i = 0; i < importCount; i++) {
          Source importedSource = importedSources[i];
          if (importedSource.equals(coreLibrarySource)) {
            explicitlyImportsCore = true;
          }
          ResolvableLibrary importedLibrary = libraryMap.get(importedSource);
          if (importedLibrary == null) {
            importedLibrary = createLibraryOrNull(importedSource);
            if (importedLibrary != null) {
              computeLibraryDependencies(importedLibrary);
              if (taskData != null) {
                return;
              }
            }
          }
          if (importedLibrary != null) {
            importedLibraries.add(importedLibrary);
            dependencyGraph.addEdge(library, importedLibrary);
          }
        }

        library.setExplicitlyImportsCore(explicitlyImportsCore);
        if (!explicitlyImportsCore && !coreLibrarySource.equals(library.getLibrarySource())) {
          ResolvableLibrary importedLibrary = libraryMap.get(coreLibrarySource);
          if (importedLibrary == null) {
            importedLibrary = createLibraryOrNull(coreLibrarySource);
            if (importedLibrary != null) {
              computeLibraryDependencies(importedLibrary);
              if (taskData != null) {
                return;
              }
            }
          }
          if (importedLibrary != null) {
            importedLibraries.add(importedLibrary);
            dependencyGraph.addEdge(library, importedLibrary);
          }
        }

        library.setImportedLibraries(importedLibraries.toArray(new ResolvableLibrary[importedLibraries.size()]));
      } else {
        library.setExplicitlyImportsCore(false);
        ResolvableLibrary importedLibrary = libraryMap.get(coreLibrarySource);
        if (importedLibrary == null) {
          importedLibrary = createLibraryOrNull(coreLibrarySource);
          if (importedLibrary != null) {
            computeLibraryDependencies(importedLibrary);
            if (taskData != null) {
              return;
            }
          }
        }
        if (importedLibrary != null) {
          dependencyGraph.addEdge(library, importedLibrary);
          library.setImportedLibraries(new ResolvableLibrary[] {importedLibrary});
        }
      }

      int exportCount = exportedSources.length;
      if (exportCount > 0) {
        ArrayList<ResolvableLibrary> exportedLibraries = new ArrayList<ResolvableLibrary>(
            exportCount);
        for (int i = 0; i < exportCount; i++) {
          Source exportedSource = exportedSources[i];
          ResolvableLibrary exportedLibrary = libraryMap.get(exportedSource);
          if (exportedLibrary == null) {
            exportedLibrary = createLibraryOrNull(exportedSource);
            if (exportedLibrary != null) {
              computeLibraryDependencies(exportedLibrary);
View Full Code Here

      ArrayList<SourceEntryPair> entryPairs = libraryPair.entryPairs;
      int count = entryPairs.size();
      ResolvableCompilationUnit[] units = new ResolvableCompilationUnit[count];
      for (int i = 0; i < count; i++) {
        SourceEntryPair entryPair = entryPairs.get(i);
        Source source = entryPair.source;
        DartEntryImpl dartCopy = entryPair.entry.getWritableCopy();
        units[i] = new ResolvableCompilationUnit(
            dartCopy.getModificationTime(),
            dartCopy.getResolvableCompilationUnit(),
            source);
View Full Code Here

     * executed first in order to build the element model, that task is placed in {@link #taskData}.
     *
     * @param library the library which needs an element model.
     */
    private void ensureElementModel(ResolvableLibrary library) {
      Source librarySource = library.getLibrarySource();
      DartEntry libraryEntry = getReadableDartEntry(librarySource);
      if (libraryEntry != null && libraryEntry.getState(DartEntry.PARSED_UNIT) != CacheState.ERROR) {
        workManager.addFirst(librarySource, SourcePriority.LIBRARY);
        if (taskData == null) {
          taskData = createResolveDartLibraryTask(librarySource, libraryEntry);
View Full Code Here

     * @return a list of (source, entry) pairs for all of the compilation units in the library
     */
    private ArrayList<SourceEntryPair> ensurePartsInLibrary(ResolvableLibrary library)
        throws AnalysisException {
      ArrayList<SourceEntryPair> pairs = new ArrayList<SourceEntryPair>();
      Source librarySource = library.getLibrarySource();
      DartEntry libraryEntry = getReadableDartEntry(librarySource);
      if (libraryEntry == null) {
        throw new AnalysisException("Cannot find entry for " + librarySource.getFullName());
      } else if (libraryEntry.getState(DartEntry.PARSED_UNIT) == CacheState.ERROR) {
        String message = "Cannot compute parsed unit for " + librarySource.getFullName();
        AnalysisException exception = libraryEntry.getException();
        if (exception == null) {
          throw new AnalysisException(message);
        }
        throw new AnalysisException(message, exception);
      }
      ensureResolvableCompilationUnit(librarySource, libraryEntry);
      pairs.add(new SourceEntryPair(librarySource, libraryEntry));
      Source[] partSources = getSources(librarySource, libraryEntry, DartEntry.INCLUDED_PARTS);
      int count = partSources.length;
      for (int i = 0; i < count; i++) {
        Source partSource = partSources[i];
        DartEntry partEntry = getReadableDartEntry(partSource);
        if (partEntry != null && partEntry.getState(DartEntry.PARSED_UNIT) != CacheState.ERROR) {
          ensureResolvableCompilationUnit(partSource, partEntry);
          pairs.add(new SourceEntryPair(partSource, partEntry));
        }
View Full Code Here

  public static IncrementalAnalysisCache update(IncrementalAnalysisCache cache, Source source,
      String oldContents, String newContents, int offset, int oldLength, int newLength,
      SourceEntry sourceEntry) {

    // Determine the cache resolved unit
    Source librarySource = null;
    CompilationUnit unit = null;
    if (sourceEntry instanceof DartEntryImpl) {
      DartEntryImpl dartEntry = (DartEntryImpl) sourceEntry;
      Source[] librarySources = dartEntry.getLibrariesContaining();
      if (librarySources.length == 1) {
View Full Code Here

    }
  }

  @Override
  public void onError(AnalysisError error) {
    Source source = error.getSource();
    HashSet<AnalysisError> errorsForSource = errors.get(source);
    if (errors.get(source) == null) {
      errorsForSource = new HashSet<AnalysisError>();
      errors.put(source, errorsForSource);
    }
View Full Code Here

    ArrayList<Source> changedSources = new ArrayList<Source>();
    ArrayList<Source> missingSources = new ArrayList<Source>();
    synchronized (cacheLock) {
      MapIterator<Source, SourceEntry> iterator = cache.iterator();
      while (iterator.moveNext()) {
        Source source = iterator.getKey();
        SourceEntry sourceEntry = iterator.getValue();
        long sourceTime = getModificationStamp(source);
        if (sourceTime != sourceEntry.getModificationTime()) {
          changedSources.add(source);
        }
        if (sourceEntry.getException() != null) {
          if (!exists(source)) {
            missingSources.add(source);
          }
        }
      }
      int count = changedSources.size();
      for (int i = 0; i < count; i++) {
        sourceChanged(changedSources.get(i));
      }
    }
    long consistencyCheckEnd = System.nanoTime();
    if (changedSources.size() > 0 || missingSources.size() > 0) {
      @SuppressWarnings("resource")
      PrintStringWriter writer = new PrintStringWriter();
      writer.print("Consistency check took ");
      writer.print((consistencyCheckEnd - consistencyCheckStart) / 1000000.0);
      writer.println(" ms and found");
      writer.print("  ");
      writer.print(changedSources.size());
      writer.println(" inconsistent entries");
      writer.print("  ");
      writer.print(missingSources.size());
      writer.println(" missing sources");
      for (Source source : missingSources) {
        writer.print("    ");
        writer.println(source.getFullName());
      }
      logInformation(writer.toString());
    }
    return changedSources.size() > 0;
  }
View Full Code Here

  @Override
  public void applyAnalysisDelta(AnalysisDelta delta) {
    ChangeSet changeSet = new ChangeSet();
    for (Entry<Source, AnalysisLevel> entry : delta.getAnalysisLevels().entrySet()) {
      Source source = entry.getKey();
      if (entry.getValue() == AnalysisLevel.NONE) {
        changeSet.removedSource(source);
      } else {
        changeSet.addedSource(source);
      }
View Full Code Here

        // only re-analyze those libraries.
//        logInformation("Added Dart sources, invalidating all resolution information");
        ArrayList<Source> sourcesToInvalidate = new ArrayList<Source>();
        MapIterator<Source, SourceEntry> iterator = cache.iterator();
        while (iterator.moveNext()) {
          Source source = iterator.getKey();
          SourceEntry sourceEntry = iterator.getValue();
          if (!source.isInSystemLibrary()
              && (sourceEntry instanceof DartEntry || sourceEntry instanceof HtmlEntry)) {
            sourcesToInvalidate.add(source);
          }
        }
        int count = sourcesToInvalidate.size();
        for (int i = 0; i < count; i++) {
          Source source = sourcesToInvalidate.get(i);
          SourceEntry entry = getReadableSourceEntry(source);
          if (entry instanceof DartEntry) {
            DartEntry dartEntry = (DartEntry) entry;
            DartEntryImpl dartCopy = dartEntry.getWritableCopy();
            dartCopy.invalidateAllResolutionInformation(false);
View Full Code Here

TOP

Related Classes of com.google.dart.engine.source.Source$ContentReceiver

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.