Package com.google.dart.engine.internal.cache

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


      htmlEntry.setModificationTime(getModificationStamp(source));
      htmlEntry.setExplicitlyAdded(explicitlyAdded);
      cache.put(source, htmlEntry);
      return htmlEntry;
    } else {
      DartEntryImpl dartEntry = new DartEntryImpl();
      dartEntry.setModificationTime(getModificationStamp(source));
      dartEntry.setExplicitlyAdded(explicitlyAdded);
      cache.put(source, dartEntry);
      return dartEntry;
    }
  }
View Full Code Here


          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(
              DartEntry.RESOLVED_UNIT,
              librarySource);
          if (resolvedUnitState == CacheState.INVALID
              || (isPriority && resolvedUnitState == CacheState.FLUSHED)) {
            //
            // The commented out lines below are an optimization that doesn't quite work yet. The
            // problem is that if the source was not resolved because it wasn't part of any library,
            // then there won't be any elements in the element model that we can use to resolve it.
            //
            //LibraryElement libraryElement = libraryEntry.getValue(DartEntry.ELEMENT);
            //if (libraryElement != null) {
            //  return new ResolveDartUnitTask(this, source, libraryElement);
            //}
            // Possibly replace with: return createResolveDartLibraryTask(librarySource, (DartEntry) libraryEntry);
            DartEntryImpl dartCopy = dartEntry.getWritableCopy();
            dartCopy.setStateInLibrary(
                DartEntry.RESOLVED_UNIT,
                librarySource,
                CacheState.IN_PROCESS);
            cache.put(source, dartCopy);
            return new TaskData(new ResolveDartLibraryTask(this, source, librarySource), false);
View Full Code Here

        iterator.setValue(htmlCopy);
        workManager.add(source, SourcePriority.HTML);
      } else if (sourceEntry instanceof DartEntry) {
        DartEntry dartEntry = (DartEntry) sourceEntry;
        oldPartMap.put(source, dartEntry.getValue(DartEntry.INCLUDED_PARTS));
        DartEntryImpl dartCopy = dartEntry.getWritableCopy();
        dartCopy.invalidateAllResolutionInformation(invalidateUris);
        iterator.setValue(dartCopy);
        workManager.add(source, computePriority(dartCopy));
      }
    }
    removeFromPartsUsingMap(oldPartMap);
View Full Code Here

    }
    // reset Dart sources
    Source[] oldElementSources = application.getElementSources();
    for (Source elementSource : oldElementSources) {
      DartEntry dartEntry = getReadableDartEntry(elementSource);
      DartEntryImpl dartCopy = dartEntry.getWritableCopy();
      dartCopy.setValue(DartEntry.ANGULAR_ERRORS, AnalysisError.NO_ERRORS);
      cache.put(elementSource, dartCopy);
      // notify about (disappeared) Angular errors
      ChangeNoticeImpl notice = getNotice(elementSource);
      notice.setErrors(dartCopy.getAllErrors(), dartEntry.getValue(SourceEntry.LINE_INFO));
    }
  }
View Full Code Here

    // if the public namespace hasn't changed, which will be a fairly common case. The question is
    // whether we can afford the time to compute the namespace to look for differences.
    DartEntry libraryEntry = getReadableDartEntry(librarySource);
    if (libraryEntry != null) {
      Source[] includedParts = libraryEntry.getValue(DartEntry.INCLUDED_PARTS);
      DartEntryImpl libraryCopy = libraryEntry.getWritableCopy();
      libraryCopy.invalidateAllResolutionInformation(false);
      cache.put(librarySource, libraryCopy);
      workManager.add(librarySource, SourcePriority.LIBRARY);
      for (Source partSource : includedParts) {
        SourceEntry partEntry = cache.get(partSource);
        if (partEntry instanceof DartEntry) {
          DartEntryImpl partCopy = ((DartEntry) partEntry).getWritableCopy();
          partCopy.invalidateAllResolutionInformation(false);
          cache.put(partSource, partCopy);
        }
      }
    }
    // invalidate Angular applications
View Full Code Here

      }
      // update Dart sources errors
      Source[] newElementSources = application.getElementSources();
      for (Source elementSource : newElementSources) {
        DartEntry dartEntry = getReadableDartEntry(elementSource);
        DartEntryImpl dartCopy = dartEntry.getWritableCopy();
        dartCopy.setValue(DartEntry.ANGULAR_ERRORS, task.getErrors(elementSource));
        cache.put(elementSource, dartCopy);
        // notify about Dart errors
        ChangeNoticeImpl notice = getNotice(elementSource);
        notice.setErrors(dartCopy.getAllErrors(), computeLineInfo(elementSource));
      }
    }
    // remember Angular entry point
    entry.setValue(HtmlEntry.ANGULAR_ENTRY, application);
  }
View Full Code Here

          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.
          //
//          dartCopy.setState(DartEntry.VERIFICATION_ERRORS, librarySource, CacheState.INVALID);
          removeFromParts(source, dartEntry);
          dartCopy.invalidateAllInformation();
          dartCopy.setModificationTime(sourceTime);
          cache.removedAst(source);
          workManager.add(source, SourcePriority.UNKNOWN);
        } else {
          //
          // We could not determine whether the sources were up-to-date or out-of-date. Mark the
          // cache so that we won't attempt to re-verify the source until there's a good chance
          // that we'll be able to do so without error.
          //
          dartCopy.recordVerificationErrorInLibrary(librarySource, thrownException);
        }
        cache.put(source, dartCopy);
        dartEntry = dartCopy;
      }
    }
View Full Code Here

        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.
              //
//              dartCopy.setState(DartEntry.HINTS, librarySource, CacheState.INVALID);
              removeFromParts(unitSource, dartEntry);
              dartCopy.invalidateAllInformation();
              dartCopy.setModificationTime(sourceTime);
              cache.removedAst(unitSource);
              workManager.add(unitSource, SourcePriority.UNKNOWN);
            } else {
              //
              // We could not determine whether the sources were up-to-date or out-of-date. Mark the
              // cache so that we won't attempt to re-analyze the sources until there's a good chance
              // that we'll be able to do so without error.
              //
              dartCopy.recordHintErrorInLibrary(librarySource, thrownException);
            }
            cache.put(unitSource, dartCopy);
            dartEntry = dartCopy;
          }
        }
View Full Code Here

            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);
            }
          }
          dartCopy.setValue(DartEntry.PARSED_UNIT, task.getCompilationUnit());
          dartCopy.setValue(DartEntry.PARSE_ERRORS, task.getErrors());
          dartCopy.setValue(DartEntry.EXPORTED_LIBRARIES, task.getExportedSources());
          dartCopy.setValue(DartEntry.IMPORTED_LIBRARIES, task.getImportedSources());
          dartCopy.setValue(DartEntry.INCLUDED_PARTS, newParts);
          cache.storedAst(source);

          ChangeNoticeImpl notice = getNotice(source);
          notice.setErrors(dartCopy.getAllErrors(), task.getLineInfo());

          // Verify that the incrementally parsed and resolved unit in the incremental cache
          // is structurally equivalent to the fully parsed unit
          incrementalAnalysisCache = IncrementalAnalysisCache.verifyStructure(
              incrementalAnalysisCache,
              source,
              task.getCompilationUnit());
        } else {
          removeFromParts(source, dartEntry);
          dartCopy.recordParseError(thrownException);
          cache.removedAst(source);
        }
        cache.put(source, dartCopy);
        dartEntry = dartCopy;
      } else {
        logInformation(
            "Parse 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.
          //
//          dartCopy.recordParseNotInProcess();
          removeFromParts(source, dartEntry);
          dartCopy.invalidateAllInformation();
          dartCopy.setModificationTime(sourceTime);
          cache.removedAst(source);
          workManager.add(source, SourcePriority.UNKNOWN);
        } else {
          //
          // We could not determine whether the sources were up-to-date or out-of-date. Mark the
          // cache so that we won't attempt to re-analyze the sources until there's a good chance
          // that we'll be able to do so without error.
          //
          dartCopy.recordParseError(thrownException);
        }
        cache.put(source, dartCopy);
        dartEntry = dartCopy;
      }
    }
View Full Code Here

          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.
          //
//          if (dartCopy.getState(DartEntry.RESOLVED_UNIT) == CacheState.IN_PROCESS) {
//            dartCopy.setState(DartEntry.RESOLVED_UNIT, librarySource, CacheState.INVALID);
//          }
          removeFromParts(unitSource, dartEntry);
          dartCopy.invalidateAllInformation();
          dartCopy.setModificationTime(sourceTime);
          cache.removedAst(unitSource);
          workManager.add(unitSource, SourcePriority.UNKNOWN);
        } else {
          //
          // We could not determine whether the sources were up-to-date or out-of-date. Mark the
          // cache so that we won't attempt to re-analyze the sources until there's a good chance
          // that we'll be able to do so without error.
          //
          dartCopy.recordResolutionErrorInLibrary(librarySource, thrownException);
        }
        cache.put(unitSource, dartCopy);
        dartEntry = dartCopy;
      }
    }
View Full Code Here

TOP

Related Classes of com.google.dart.engine.internal.cache.DartEntryImpl

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.