Examples of DartEntry


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

     * @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;
      }
      Source[] exportedSources = getSources(librarySource, dartEntry, DartEntry.EXPORTED_LIBRARIES);
View Full Code Here

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

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

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

     */
    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));
        }
      }
      return pairs;
View Full Code Here

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

      }
      if (neededForResolution != null && neededForResolution.contains(source)) {
        return RetentionPriority.HIGH;
      }
      if (sourceEntry instanceof DartEntry) {
        DartEntry dartEntry = (DartEntry) sourceEntry;
        if (astIsNeeded(dartEntry)) {
          return RetentionPriority.MEDIUM;
        }
      }
      return RetentionPriority.LOW;
View Full Code Here

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

  private DartEntry recordGenerateDartErrorsTask(GenerateDartErrorsTask task)
      throws AnalysisException {
    Source source = task.getSource();
    Source librarySource = task.getLibraryElement().getSource();
    AnalysisException thrownException = task.getException();
    DartEntry dartEntry = null;
    synchronized (cacheLock) {
      SourceEntry sourceEntry = cache.get(source);
      if (sourceEntry == null) {
        throw new ObsoleteSourceAnalysisException(source);
      } else if (!(sourceEntry instanceof DartEntry)) {
        // 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 verify non-Dart file as a Dart file: "
                + source.getFullName());
      }
      dartEntry = (DartEntry) sourceEntry;
      long sourceTime = getModificationStamp(source);
      long resultTime = task.getModificationTime();
      if (sourceTime == resultTime) {
        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.setValueInLibrary(DartEntry.VERIFICATION_ERRORS, librarySource, task.getErrors());
          ChangeNoticeImpl notice = getNotice(source);
          notice.setErrors(dartCopy.getAllErrors(), dartCopy.getValue(SourceEntry.LINE_INFO));
        } else {
          dartCopy.recordVerificationErrorInLibrary(librarySource, thrownException);
        }
        cache.put(source, dartCopy);
        dartEntry = dartCopy;
      } else {
        logInformation("Generated errors discarded for " + debuggingString(source)
            + "; sourceTime = " + sourceTime + ", resultTime = " + resultTime + ", cacheTime = "
            + dartEntry.getModificationTime(), thrownException);
        DartEntryImpl dartCopy = dartEntry.getWritableCopy();
        if (thrownException == null || resultTime >= 0L) {
          //
          // The analysis was performed on out-of-date sources. Mark the cache so that the source
          // will be re-verified using the up-to-date sources.
          //
View Full Code Here

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

   */
  private DartEntry recordGenerateDartHintsTask(GenerateDartHintsTask task)
      throws AnalysisException {
    Source librarySource = task.getLibraryElement().getSource();
    AnalysisException thrownException = task.getException();
    DartEntry libraryEntry = null;
    HashMap<Source, TimestampedData<AnalysisError[]>> hintMap = task.getHintMap();
    if (hintMap == null) {
      synchronized (cacheLock) {
        // We don't have any information about which sources to mark as invalid other than the library
        // source.
        SourceEntry sourceEntry = cache.get(librarySource);
        if (sourceEntry == null) {
          throw new ObsoleteSourceAnalysisException(librarySource);
        } else if (!(sourceEntry instanceof DartEntry)) {
          // 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 generate hints for non-Dart file as a Dart file: "
                  + librarySource.getFullName());
        }
        if (thrownException == null) {
          thrownException = new AnalysisException(
              "GenerateDartHintsTask returned a null hint map without throwing an exception: "
                  + librarySource.getFullName());
        }
        DartEntryImpl dartCopy = ((DartEntry) sourceEntry).getWritableCopy();
        dartCopy.recordHintErrorInLibrary(librarySource, thrownException);
        cache.put(librarySource, dartCopy);
      }
      throw thrownException;
    }
    for (Map.Entry<Source, TimestampedData<AnalysisError[]>> entry : hintMap.entrySet()) {
      Source unitSource = entry.getKey();
      TimestampedData<AnalysisError[]> results = entry.getValue();
      synchronized (cacheLock) {
        SourceEntry sourceEntry = cache.get(unitSource);
        if (!(sourceEntry instanceof DartEntry)) {
          // 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 parse non-Dart file as a Dart file: "
                  + unitSource.getFullName());
        }
        DartEntry dartEntry = (DartEntry) sourceEntry;
        if (unitSource.equals(librarySource)) {
          libraryEntry = dartEntry;
        }
        long sourceTime = getModificationStamp(unitSource);
        long resultTime = results.getModificationTime();
        if (sourceTime == resultTime) {
          if (dartEntry.getModificationTime() != sourceTime) {
            // The source has changed without the context being notified. Simulate notification.
            sourceChanged(unitSource);
            dartEntry = getReadableDartEntry(unitSource);
            if (dartEntry == null) {
              throw new AnalysisException("A Dart file became a non-Dart file: "
                  + unitSource.getFullName());
            }
          }
          DartEntryImpl dartCopy = dartEntry.getWritableCopy();
          if (thrownException == null) {
            dartCopy.setValueInLibrary(DartEntry.HINTS, librarySource, results.getData());
            ChangeNoticeImpl notice = getNotice(unitSource);
            notice.setErrors(dartCopy.getAllErrors(), dartCopy.getValue(SourceEntry.LINE_INFO));
          } else {
            dartCopy.recordHintErrorInLibrary(librarySource, thrownException);
          }
          cache.put(unitSource, dartCopy);
          dartEntry = dartCopy;
        } else {
          logInformation("Generated hints discarded for " + debuggingString(unitSource)
              + "; sourceTime = " + sourceTime + ", resultTime = " + resultTime + ", cacheTime = "
              + dartEntry.getModificationTime(), thrownException);
          if (dartEntry.getStateInLibrary(DartEntry.HINTS, librarySource) == CacheState.IN_PROCESS) {
            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

   * @throws AnalysisException if the results could not be recorded
   */
  private DartEntry recordParseDartTaskResults(ParseDartTask task) throws AnalysisException {
    Source source = task.getSource();
    AnalysisException thrownException = task.getException();
    DartEntry dartEntry = null;
    synchronized (cacheLock) {
      SourceEntry sourceEntry = cache.get(source);
      if (sourceEntry == null) {
        throw new ObsoleteSourceAnalysisException(source);
      } else if (!(sourceEntry instanceof DartEntry)) {
        // 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 parse non-Dart file as a Dart file: "
                + source.getFullName());
      }
      dartEntry = (DartEntry) sourceEntry;
      long sourceTime = getModificationStamp(source);
      long resultTime = task.getModificationTime();
      if (sourceTime == resultTime) {
        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());
          }
        }
        removeFromParts(source, dartEntry);
        DartEntryImpl dartCopy = dartEntry.getWritableCopy();
        if (thrownException == null) {
          if (task.hasNonPartOfDirective()) {
            dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY);
            dartCopy.setContainingLibrary(source);
            workManager.add(source, SourcePriority.LIBRARY);
          } else if (task.hasPartOfDirective()) {
            dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.PART);
            dartCopy.removeContainingLibrary(source);
            workManager.add(source, SourcePriority.NORMAL_PART);
          } else {
            // The file contains no directives.
            List<Source> containingLibraries = dartCopy.getContainingLibraries();
            if (containingLibraries.size() > 1
                || (containingLibraries.size() == 1 && !containingLibraries.get(0).equals(source))) {
              dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.PART);
              dartCopy.removeContainingLibrary(source);
              workManager.add(source, SourcePriority.NORMAL_PART);
            } else {
              dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY);
              dartCopy.setContainingLibrary(source);
              workManager.add(source, SourcePriority.LIBRARY);
            }
          }
          Source[] newParts = task.getIncludedSources();
          for (int i = 0; i < newParts.length; i++) {
            Source partSource = newParts[i];
            DartEntry partEntry = getReadableDartEntry(partSource);
            if (partEntry != null && partEntry != dartEntry) {
              DartEntryImpl partCopy = partEntry.getWritableCopy();
              // TODO(brianwilkerson) Change the kind of the "part" if it was marked as a library
              // and it has no directives.
              partCopy.addContainingLibrary(source);
              cache.put(partSource, partCopy);
            }
View Full Code Here

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

  private DartEntry recordResolveDartUnitTaskResults(ResolveDartUnitTask task)
      throws AnalysisException {
    Source unitSource = task.getSource();
    Source librarySource = task.getLibrarySource();
    AnalysisException thrownException = task.getException();
    DartEntry dartEntry = null;
    synchronized (cacheLock) {
      SourceEntry sourceEntry = cache.get(unitSource);
      if (sourceEntry == null) {
        throw new ObsoleteSourceAnalysisException(unitSource);
      } else if (!(sourceEntry instanceof DartEntry)) {
        // 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: "
                + unitSource.getFullName());
      }
      dartEntry = (DartEntry) sourceEntry;
      long sourceTime = getModificationStamp(unitSource);
      long resultTime = task.getModificationTime();
      if (sourceTime == resultTime) {
        if (dartEntry.getModificationTime() != sourceTime) {
          // The source has changed without the context being notified. Simulate notification.
          sourceChanged(unitSource);
          dartEntry = getReadableDartEntry(unitSource);
          if (dartEntry == null) {
            throw new AnalysisException("A Dart file became a non-Dart file: "
                + unitSource.getFullName());
          }
        }
        DartEntryImpl dartCopy = dartEntry.getWritableCopy();
        if (thrownException == null) {
          dartCopy.setValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource, task.getResolvedUnit());
          cache.storedAst(unitSource);
        } else {
          dartCopy.recordResolutionErrorInLibrary(librarySource, thrownException);
          cache.removedAst(unitSource);
        }

        cache.put(unitSource, dartCopy);
        dartEntry = dartCopy;
      } else {
        logInformation("Resolution results discarded for " + debuggingString(unitSource)
            + "; sourceTime = " + sourceTime + ", resultTime = " + resultTime + ", cacheTime = "
            + dartEntry.getModificationTime(), thrownException);
        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

   * @throws AnalysisException if the results could not be recorded
   */
  private DartEntry recordScanDartTaskResults(ScanDartTask task) throws AnalysisException {
    Source source = task.getSource();
    AnalysisException thrownException = task.getException();
    DartEntry dartEntry = null;
    synchronized (cacheLock) {
      SourceEntry sourceEntry = cache.get(source);
      if (sourceEntry == null) {
        throw new ObsoleteSourceAnalysisException(source);
      } else if (!(sourceEntry instanceof DartEntry)) {
        // 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 parse non-Dart file as a Dart file: "
                + source.getFullName());
      }
      dartEntry = (DartEntry) sourceEntry;
      long sourceTime = getModificationStamp(source);
      long resultTime = task.getModificationTime();
      if (sourceTime == resultTime) {
        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) {
          LineInfo lineInfo = task.getLineInfo();
          dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo);
          dartCopy.setValue(DartEntry.TOKEN_STREAM, task.getTokenStream());
          dartCopy.setValue(DartEntry.SCAN_ERRORS, task.getErrors());
          cache.storedAst(source);

          ChangeNoticeImpl notice = getNotice(source);
          notice.setErrors(dartEntry.getAllErrors(), lineInfo);
        } else {
          removeFromParts(source, dartEntry);
          dartCopy.recordScanError(thrownException);
          cache.removedAst(source);
        }
        cache.put(source, dartCopy);
        dartEntry = dartCopy;
      } else {
        logInformation(
            "Scan results discarded for " + debuggingString(source) + "; sourceTime = "
                + sourceTime + ", resultTime = " + resultTime + ", cacheTime = "
                + dartEntry.getModificationTime(),
            thrownException);
        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 void removeFromParts(Source librarySource, DartEntry dartEntry) {
    Source[] oldParts = dartEntry.getValue(DartEntry.INCLUDED_PARTS);
    for (int i = 0; i < oldParts.length; i++) {
      Source partSource = oldParts[i];
      DartEntry partEntry = getReadableDartEntry(partSource);
      if (partEntry != null && partEntry != dartEntry) {
        DartEntryImpl partCopy = partEntry.getWritableCopy();
        partCopy.removeContainingLibrary(librarySource);
        if (partCopy.getContainingLibraries().size() == 0 && !exists(partSource)) {
          cache.remove(partSource);
        } else {
          cache.put(partSource, partCopy);
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.