Package com.google.dart.engine.source

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


  }

  @Override
  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);
View Full Code Here


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

  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);
View Full Code Here

   * @param container the source container containing the sources to be added to the list
   */
  private void addSourcesInContainer(ArrayList<Source> sources, SourceContainer container) {
    MapIterator<Source, SourceEntry> iterator = cache.iterator();
    while (iterator.moveNext()) {
      Source source = iterator.getKey();
      if (container.contains(source)) {
        sources.add(source);
      }
    }
  }
View Full Code Here

      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();
        units[0] = new TimestampedData<CompilationUnit>(
            getModificationStamp(source),
            resolveCompilationUnit(source, libraryElement));
      }
      for (int i = 0; i < parts.length; i++) {
        units[i + 1] = getResolvedUnit(parts[i], librarySource);
        if (units[i + 1] == null) {
          Source source = parts[i].getSource();
          units[i + 1] = new TimestampedData<CompilationUnit>(
              getModificationStamp(source),
              resolveCompilationUnit(source, libraryElement));
        }
      }
View Full Code Here

      //
      // Look for a priority source that needs to be analyzed.
      //
      int priorityCount = priorityOrder.length;
      for (int i = 0; i < priorityCount; i++) {
        Source source = priorityOrder[i];
        TaskData taskData = getNextAnalysisTaskForSource(
            source,
            cache.get(source),
            true,
            hintsEnabled);
        AnalysisTask task = taskData.getTask();
        if (task != null) {
          return task;
        } else if (taskData.isBlocked()) {
          hasBlockedTask = true;
        }
      }
      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) {
                  return task;
                } else if (taskData.isBlocked()) {
                  hasBlockedTask = true;
                }
              }
            }
          }
        }
        int count = sourcesToRemove.size();
        for (int i = 0; i < count; i++) {
          neededForResolution.remove(sourcesToRemove.get(i));
        }
      }
      //
      // Look for a non-priority source that needs to be analyzed.
      //
      ArrayList<Source> sourcesToRemove = new ArrayList<Source>();
      WorkManager.WorkIterator sources = workManager.iterator();
      try {
        while (sources.hasNext()) {
          Source source = sources.next();
          TaskData taskData = getNextAnalysisTaskForSource(
              source,
              cache.get(source),
              false,
              hintsEnabled);
View Full Code Here

   */
  private void invalidateAllLocalResolutionInformation(boolean invalidateUris) {
    HashMap<Source, Source[]> oldPartMap = new HashMap<Source, Source[]>();
    MapIterator<Source, SourceEntry> iterator = privatePartition.iterator();
    while (iterator.moveNext()) {
      Source source = iterator.getKey();
      SourceEntry sourceEntry = iterator.getValue();
      if (sourceEntry instanceof HtmlEntry) {
        HtmlEntryImpl htmlCopy = ((HtmlEntry) sourceEntry).getWritableCopy();
        htmlCopy.invalidateAllResolutionInformation(invalidateUris);
        iterator.setValue(htmlCopy);
View Full Code Here

    // reset HTML sources
    AngularElement[] oldAngularElements = application.getElements();
    for (AngularElement angularElement : oldAngularElements) {
      if (angularElement instanceof AngularHasTemplateElement) {
        AngularHasTemplateElement hasTemplate = (AngularHasTemplateElement) angularElement;
        Source templateSource = hasTemplate.getTemplateSource();
        if (templateSource != null) {
          HtmlEntry htmlEntry = getReadableHtmlEntry(templateSource);
          HtmlEntryImpl htmlCopy = htmlEntry.getWritableCopy();
          htmlCopy.setValue(HtmlEntry.ANGULAR_APPLICATION, null);
          htmlCopy.setValue(HtmlEntry.ANGULAR_COMPONENT, null);
View Full Code Here

    }
    // invalidate Angular applications
    List<AngularApplication> angularApplicationsCopy = Lists.newArrayList(angularApplications);
    for (AngularApplication application : angularApplicationsCopy) {
      if (application.dependsOn(librarySource)) {
        Source entryPointSource = application.getEntryPoint();
        HtmlEntry entry = getReadableHtmlEntry(entryPointSource);
        HtmlEntryImpl entryCopy = entry.getWritableCopy();
        invalidateAngularResolution(entryCopy);
        cache.put(entryPointSource, entryCopy);
        workManager.add(entryPointSource, SourcePriority.HTML);
View Full Code Here

      // schedule HTML templates analysis
      AngularElement[] newAngularElements = application.getElements();
      for (AngularElement angularElement : newAngularElements) {
        if (angularElement instanceof AngularHasTemplateElement) {
          AngularHasTemplateElement hasTemplate = (AngularHasTemplateElement) angularElement;
          Source templateSource = hasTemplate.getTemplateSource();
          if (templateSource != null) {
            HtmlEntry htmlEntry = getReadableHtmlEntry(templateSource);
            HtmlEntryImpl htmlCopy = htmlEntry.getWritableCopy();
            htmlCopy.setValue(HtmlEntry.ANGULAR_APPLICATION, application);
            if (hasTemplate instanceof AngularComponentElement) {
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.