Examples of DartEntry


Examples of com.google.dart.engine.internal.cache.DartEntry

   */
  protected DartEntry recordResolveDartLibraryCycleTaskResults(ResolveDartLibraryCycleTask task)
      throws AnalysisException {
    LibraryResolver2 resolver = task.getLibraryResolver();
    AnalysisException thrownException = task.getException();
    DartEntry unitEntry = null;
    Source unitSource = task.getUnitSource();
    if (resolver != null) {
      //
      // The resolver should only be null if an exception was thrown before (or while) it was
      // being created.
      //
      List<ResolvableLibrary> resolvedLibraries = resolver.getResolvedLibraries();
      synchronized (cacheLock) {
        if (resolvedLibraries == null) {
          //
          // The resolved libraries should only be null if an exception was thrown during resolution.
          //
          unitEntry = getReadableDartEntry(unitSource);
          if (unitEntry == null) {
            throw new AnalysisException("A Dart file became a non-Dart file: "
                + unitSource.getFullName());
          }
          DartEntryImpl dartCopy = unitEntry.getWritableCopy();
          if (thrownException == null) {
            dartCopy.recordResolutionError(new AnalysisException(
                "In recordResolveDartLibraryCycleTaskResults, resolvedLibraries was null and there was no thrown exception"));
          } else {
            dartCopy.recordResolutionError(thrownException);
          }
          cache.put(unitSource, dartCopy);
          cache.remove(unitSource);
          if (thrownException != null) {
            throw thrownException;
          }
          return dartCopy;
        }
        if (allModificationTimesMatch(resolvedLibraries)) {
          Source htmlSource = getSourceFactory().forUri(DartSdk.DART_HTML);
          RecordingErrorListener errorListener = resolver.getErrorListener();
          for (ResolvableLibrary library : resolvedLibraries) {
            Source librarySource = library.getLibrarySource();
            for (Source source : library.getCompilationUnitSources()) {
              CompilationUnit unit = library.getAST(source);
              AnalysisError[] errors = errorListener.getErrorsForSource(source);
              LineInfo lineInfo = getLineInfo(source);
              DartEntryImpl dartCopy = (DartEntryImpl) cache.get(source).getWritableCopy();
              if (thrownException == null) {
                dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED);
                dartCopy.setValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource, unit);
                dartCopy.setValueInLibrary(DartEntry.RESOLUTION_ERRORS, librarySource, errors);
                if (source.equals(librarySource)) {
                  recordElementData(
                      dartCopy,
                      library.getLibraryElement(),
                      librarySource,
                      htmlSource);
                }
                cache.storedAst(source);
              } else {
                dartCopy.recordResolutionErrorInLibrary(librarySource, thrownException);
                cache.remove(source);
              }
              cache.put(source, dartCopy);
              if (!source.equals(librarySource)) {
                workManager.add(source, SourcePriority.PRIORITY_PART);
              }
              if (source.equals(unitSource)) {
                unitEntry = dartCopy;
              }

              ChangeNoticeImpl notice = getNotice(source);
              notice.setCompilationUnit(unit);
              notice.setErrors(dartCopy.getAllErrors(), lineInfo);
            }
          }
        } else {
          @SuppressWarnings("resource")
          PrintStringWriter writer = new PrintStringWriter();
          writer.println("Library resolution results discarded for");
          for (ResolvableLibrary library : resolvedLibraries) {
            for (Source source : library.getCompilationUnitSources()) {
              DartEntry dartEntry = getReadableDartEntry(source);
              if (dartEntry != null) {
                long resultTime = library.getModificationTime(source);
                writer.println("  " + debuggingString(source) + "; sourceTime = "
                    + getModificationStamp(source) + ", resultTime = " + resultTime
                    + ", cacheTime = " + dartEntry.getModificationTime());
                DartEntryImpl dartCopy = dartEntry.getWritableCopy();
                if (thrownException == null || resultTime >= 0L) {
                  //
                  // The analysis was performed on out-of-date sources. Mark the cache so that the
                  // sources will be re-analyzed using the up-to-date sources.
                  //
View Full Code Here

Examples of com.google.dart.engine.internal.cache.DartEntry

   */
  protected DartEntry recordResolveDartLibraryTaskResults(ResolveDartLibraryTask task)
      throws AnalysisException {
    LibraryResolver resolver = task.getLibraryResolver();
    AnalysisException thrownException = task.getException();
    DartEntry unitEntry = null;
    Source unitSource = task.getUnitSource();
    if (resolver != null) {
      //
      // The resolver should only be null if an exception was thrown before (or while) it was
      // being created.
      //
      Set<Library> resolvedLibraries = resolver.getResolvedLibraries();
      synchronized (cacheLock) {
        if (resolvedLibraries == null) {
          //
          // The resolved libraries should only be null if an exception was thrown during resolution.
          //
          unitEntry = getReadableDartEntry(unitSource);
          if (unitEntry == null) {
            throw new AnalysisException("A Dart file became a non-Dart file: "
                + unitSource.getFullName());
          }
          DartEntryImpl dartCopy = unitEntry.getWritableCopy();
          if (thrownException == null) {
            dartCopy.recordResolutionError(new AnalysisException(
                "In recordResolveDartLibraryTaskResults, resolvedLibraries was null and there was no thrown exception"));
          } else {
            dartCopy.recordResolutionError(thrownException);
          }
          cache.put(unitSource, dartCopy);
          cache.remove(unitSource);
          if (thrownException != null) {
            throw thrownException;
          }
          return dartCopy;
        }
        if (allModificationTimesMatch(resolvedLibraries)) {
          Source htmlSource = getSourceFactory().forUri(DartSdk.DART_HTML);
          RecordingErrorListener errorListener = resolver.getErrorListener();
          for (Library library : resolvedLibraries) {
            Source librarySource = library.getLibrarySource();
            for (Source source : library.getCompilationUnitSources()) {
              CompilationUnit unit = library.getAST(source);
              AnalysisError[] errors = errorListener.getErrorsForSource(source);
              LineInfo lineInfo = getLineInfo(source);
              DartEntry dartEntry = (DartEntry) cache.get(source);
              long sourceTime = getModificationStamp(source);
              if (dartEntry.getModificationTime() != sourceTime) {
                // The source has changed without the context being notified. Simulate notification.
                sourceChanged(source);
                dartEntry = getReadableDartEntry(source);
                if (dartEntry == null) {
                  throw new AnalysisException("A Dart file became a non-Dart file: "
                      + source.getFullName());
                }
              }
              DartEntryImpl dartCopy = dartEntry.getWritableCopy();
              if (thrownException == null) {
                dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo);
                dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED);
                dartCopy.setValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource, unit);
                dartCopy.setValueInLibrary(DartEntry.RESOLUTION_ERRORS, librarySource, errors);
                if (source.equals(librarySource)) {
                  recordElementData(
                      dartCopy,
                      library.getLibraryElement(),
                      librarySource,
                      htmlSource);
                }
                cache.storedAst(source);
              } else {
                dartCopy.recordResolutionErrorInLibrary(librarySource, thrownException);
                cache.remove(source);
              }
              cache.put(source, dartCopy);
              if (!source.equals(librarySource)) {
                workManager.add(source, SourcePriority.PRIORITY_PART);
              }
              if (source.equals(unitSource)) {
                unitEntry = dartCopy;
              }

              ChangeNoticeImpl notice = getNotice(source);
              notice.setCompilationUnit(unit);
              notice.setErrors(dartCopy.getAllErrors(), lineInfo);
            }
          }
        } else {
          @SuppressWarnings("resource")
          PrintStringWriter writer = new PrintStringWriter();
          writer.println("Library resolution results discarded for");
          for (Library library : resolvedLibraries) {
            for (Source source : library.getCompilationUnitSources()) {
              DartEntry dartEntry = getReadableDartEntry(source);
              if (dartEntry != null) {
                long resultTime = library.getModificationTime(source);
                writer.println("  " + debuggingString(source) + "; sourceTime = "
                    + getModificationStamp(source) + ", resultTime = " + resultTime
                    + ", cacheTime = " + dartEntry.getModificationTime());
                DartEntryImpl dartCopy = dartEntry.getWritableCopy();
                if (thrownException == null || resultTime >= 0L) {
                  //
                  // The analysis was performed on out-of-date sources. Mark the cache so that the
                  // sources will be re-analyzed using the up-to-date sources.
                  //
View Full Code Here

Examples of com.google.dart.engine.internal.cache.DartEntry

  private boolean allModificationTimesMatch(List<ResolvableLibrary> resolvedLibraries)
      throws AnalysisException {
    boolean allTimesMatch = true;
    for (ResolvableLibrary library : resolvedLibraries) {
      for (Source source : library.getCompilationUnitSources()) {
        DartEntry dartEntry = getReadableDartEntry(source);
        if (dartEntry == null) {
          // This shouldn't be possible because we should never have performed the task if the
          // source didn't represent a Dart file, but check to be safe.
          throw new AnalysisException(
              "Internal error: attempting to resolve non-Dart file as a Dart file: "
View Full Code Here

Examples of com.google.dart.engine.internal.cache.DartEntry

  private boolean allModificationTimesMatch(Set<Library> resolvedLibraries)
      throws AnalysisException {
    boolean allTimesMatch = true;
    for (Library library : resolvedLibraries) {
      for (Source source : library.getCompilationUnitSources()) {
        DartEntry dartEntry = getReadableDartEntry(source);
        if (dartEntry == null) {
          // This shouldn't be possible because we should never have performed the task if the
          // source didn't represent a Dart file, but check to be safe.
          throw new AnalysisException(
              "Internal error: attempting to resolve non-Dart file as a Dart file: "
View Full Code Here

Examples of com.google.dart.engine.internal.cache.DartEntry

    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.
      //
      DartEntry libraryEntry = getReadableDartEntry(librarySource);
      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);
View Full Code Here

Examples of com.google.dart.engine.internal.cache.DartEntry

   * @return the requested data about the given source
   * @throws AnalysisException if data could not be returned because the source could not be parsed
   */
  private <E> E getDartParseData(Source source, DataDescriptor<E> descriptor, E defaultValue)
      throws AnalysisException {
    DartEntry dartEntry = getReadableDartEntry(source);
    if (dartEntry == null) {
      return defaultValue;
    }
    try {
      return getDartParseData(source, dartEntry, descriptor);
View Full Code Here

Examples of com.google.dart.engine.internal.cache.DartEntry

   * @throws AnalysisException if data could not be returned because the source could not be
   *           resolved
   */
  private <E> E getDartResolutionData(Source unitSource, Source librarySource,
      DataDescriptor<E> descriptor, E defaultValue) throws AnalysisException {
    DartEntry dartEntry = getReadableDartEntry(unitSource);
    if (dartEntry == null) {
      return defaultValue;
    }
    try {
      return getDartResolutionData(unitSource, librarySource, dartEntry, descriptor);
View Full Code Here

Examples of com.google.dart.engine.internal.cache.DartEntry

   * @return the requested data about the given source
   * @throws AnalysisException if data could not be returned because the source could not be scanned
   */
  private <E> E getDartScanData(Source source, DataDescriptor<E> descriptor, E defaultValue)
      throws AnalysisException {
    DartEntry dartEntry = getReadableDartEntry(source);
    if (dartEntry == null) {
      return defaultValue;
    }
    try {
      return getDartScanData(source, dartEntry, descriptor);
View Full Code Here

Examples of com.google.dart.engine.internal.cache.DartEntry

      if (neededForResolution != null) {
        ArrayList<Source> sourcesToRemove = new ArrayList<Source>();
        for (Source source : neededForResolution) {
          SourceEntry sourceEntry = cache.get(source);
          if (sourceEntry instanceof DartEntry) {
            DartEntry dartEntry = (DartEntry) sourceEntry;
            if (!dartEntry.hasResolvableCompilationUnit()) {
              if (dartEntry.getState(DartEntry.PARSED_UNIT) == CacheState.ERROR) {
                sourcesToRemove.add(source);
              } else {
                TaskData taskData = createParseDartTask(source, dartEntry);
                AnalysisTask task = taskData.getTask();
                if (task != null) {
View Full Code Here

Examples of com.google.dart.engine.internal.cache.DartEntry

      // We have done all of the analysis we can for this source because we cannot get its content.
      return new TaskData(null, false);
    }

    if (sourceEntry instanceof DartEntry) {
      DartEntry dartEntry = (DartEntry) sourceEntry;

      CacheState scanErrorsState = dartEntry.getState(DartEntry.SCAN_ERRORS);
      if (scanErrorsState == CacheState.INVALID
          || (isPriority && scanErrorsState == CacheState.FLUSHED)) {
        return createScanDartTask(source, dartEntry);
      }

      CacheState parseErrorsState = dartEntry.getState(DartEntry.PARSE_ERRORS);
      if (parseErrorsState == CacheState.INVALID
          || (isPriority && parseErrorsState == CacheState.FLUSHED)) {
        return createParseDartTask(source, dartEntry);
      }
      if (isPriority && parseErrorsState != CacheState.ERROR) {
        if (!dartEntry.hasResolvableCompilationUnit()) {
          return createParseDartTask(source, dartEntry);
        }
      }

      SourceKind kind = dartEntry.getValue(DartEntry.SOURCE_KIND);
      if (kind == SourceKind.UNKNOWN) {
        return createParseDartTask(source, dartEntry);
      } else if (kind == SourceKind.LIBRARY) {
        CacheState elementState = dartEntry.getState(DartEntry.ELEMENT);
        if (elementState == CacheState.INVALID) {
          return createResolveDartLibraryTask(source, dartEntry);
        }
      }

      Source[] librariesContaining = dartEntry.getValue(DartEntry.CONTAINING_LIBRARIES);
      for (Source librarySource : librariesContaining) {
        SourceEntry librarySourceEntry = cache.get(librarySource);
        if (librarySourceEntry instanceof DartEntry) {
          DartEntry libraryEntry = (DartEntry) librarySourceEntry;
          CacheState elementState = libraryEntry.getState(DartEntry.ELEMENT);
          if (elementState == CacheState.INVALID
              || (isPriority && elementState == CacheState.FLUSHED)) {
            //return createResolveDartLibraryTask(librarySource, (DartEntry) libraryEntry);
            DartEntryImpl libraryCopy = libraryEntry.getWritableCopy();
            libraryCopy.setState(DartEntry.ELEMENT, CacheState.IN_PROCESS);
            cache.put(librarySource, libraryCopy);
            return new TaskData(new ResolveDartLibraryTask(this, source, librarySource), false);
          }
          CacheState resolvedUnitState = dartEntry.getStateInLibrary(
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.