Package com.google.dart.engine.context

Examples of com.google.dart.engine.context.AnalysisContext


      return;
    }

    setIndicatorText("Analyzing " + virtualFile.getName() + "...");

    final AnalysisContext analysisContext = annotator.doAnnotate(annotatorInfo);
    if (analysisContext == null) return;


    libraryRoot2Errors.put(virtualFile, analysisContext.getErrors(DartFileBasedSource.getSource(project, virtualFile)).getErrors());
  }
View Full Code Here


  private static boolean safeIsUpToDate(LibraryElement library, long timeStamp,
      Set<LibraryElement> visitedLibraries) {
    if (!visitedLibraries.contains(library)) {
      visitedLibraries.add(library);

      AnalysisContext context = library.getContext();
      // Check the defining compilation unit.
      if (timeStamp < context.getModificationStamp(library.getDefiningCompilationUnit().getSource())) {
        return false;
      }

      // Check the parted compilation units.
      for (CompilationUnitElement element : library.getParts()) {
        if (timeStamp < context.getModificationStamp(element.getSource())) {
          return false;
        }
      }

      // Check the imported libraries.
View Full Code Here

    this.nameOffset = nameOffset;
  }

  @Override
  public String computeDocumentationComment() throws AnalysisException {
    AnalysisContext context = getContext();
    if (context == null) {
      return null;
    }
    return context.computeDocumentationComment(this);
  }
View Full Code Here

                  + " found.");
            }
          }
          // context
          int contextId = stream.readInt();
          AnalysisContext context = contextCodec.decode(contextId);
          if (context == null) {
            return null;
          }
          // relations
          Map<RelationKeyData, List<LocationData>> relations = Maps.newHashMap();
View Full Code Here

    DataOutputStream stream = new DataOutputStream(outputStream);
    // version
    stream.writeInt(VERSION);
    // context
    {
      AnalysisContext context = node.getContext();
      int contextId = contextCodec.encode(context);
      stream.writeInt(contextId);
    }
    // relations
    Map<RelationKeyData, List<LocationData>> relations = node.getRelations();
View Full Code Here

    if (element instanceof Member) {
      element = ((Member) element).getBaseElement();
    }
//    System.out.println(element + " " + relationship + " " + location);
    // prepare information
    AnalysisContext elementContext = element.getContext();
    AnalysisContext locationContext = location.getElement().getContext();
    Source elementSource = element.getSource();
    Source locationSource = location.getElement().getSource();
    Source elementLibrarySource = getLibrarySourceOrNull(element);
    Source locationLibrarySource = getLibrarySourceOrNull(location.getElement());
    // sanity check
    if (locationContext == null) {
      return;
    }
    if (locationSource == null) {
      return;
    }
    if (elementContext == null && !(element instanceof NameElementImpl)
        && !(element instanceof UniverseElementImpl)) {
      return;
    }
    if (elementSource == null && !(element instanceof NameElementImpl)
        && !(element instanceof UniverseElementImpl)) {
      return;
    }
    // may be already disposed in other thread
    if (elementContext != null && elementContext.isDisposed()) {
      return;
    }
    if (locationContext.isDisposed()) {
      return;
    }
    // record: key -> location(s)
    ElementRelationKey key = getCanonicalKey(element, relationship);
    {
View Full Code Here

  private Location[] getRelationshipsUniverse(Relationship relationship) {
    List<Location> locations = Lists.newArrayList();
    for (Entry<Integer, Map<Integer, Map<Relationship, List<LocationData>>>> contextEntry : contextNodeRelations.entrySet()) {
      int contextId = contextEntry.getKey();
      AnalysisContext context = contextCodec.decode(contextId);
      if (context != null) {
        for (Map<Relationship, List<LocationData>> nodeRelations : contextEntry.getValue().values()) {
          List<LocationData> nodeLocations = nodeRelations.get(relationship);
          if (nodeLocations != null) {
            for (LocationData locationData : nodeLocations) {
View Full Code Here

   */
  private void resolveScriptDirectives(CompilationUnit script, AnalysisErrorListener errorListener) {
    if (script == null) {
      return;
    }
    AnalysisContext analysisContext = getContext();
    for (Directive directive : script.getDirectives()) {
      if (directive instanceof UriBasedDirective) {
        ParseDartTask.resolveDirective(
            analysisContext,
            source,
View Full Code Here

      parser.setParseAsync(options.getEnableAsync());
      parser.setParseDeferredLibraries(options.getEnableDeferredLoading());
      parser.setParseEnum(options.getEnableEnum());
      unit = parser.parseCompilationUnit(tokenStream);
      unit.setLineInfo(lineInfo);
      AnalysisContext analysisContext = getContext();
      for (Directive directive : unit.getDirectives()) {
        if (directive instanceof PartOfDirective) {
          containsPartOfDirective = true;
        } else {
          containsNonPartOfDirective = true;
View Full Code Here

  }

  @NotNull
  public AnalysisContext getAnalysisContext(final @NotNull VirtualFile annotatedFile,
                                            final @NotNull String sdkPath) {
    AnalysisContext analysisContext = SoftReference.dereference(myAnalysisContextRef);

    final DartUrlResolver dartUrlResolver = DartUrlResolver.getInstance(myProject, annotatedFile);
    final VirtualFile yamlFile = dartUrlResolver.getPubspecYamlFile();
    final Document cachedDocument = yamlFile == null ? null : FileDocumentManager.getInstance().getCachedDocument(yamlFile);
    final long pubspecYamlTimestamp = yamlFile == null ? -1
                                                       : cachedDocument == null ? yamlFile.getModificationCount()
                                                                                : cachedDocument.getModificationStamp();

    final VirtualFile[] packageRoots = dartUrlResolver.getPackageRoots();

    final VirtualFile contentRoot = ProjectRootManager.getInstance(myProject).getFileIndex().getContentRootForFile(annotatedFile);
    final Module module = ModuleUtilCore.findModuleForFile(annotatedFile, myProject);

    final boolean useExplicitPackageUriResolver = !ApplicationManager.getApplication().isUnitTestMode() &&
                                                  contentRoot != null &&
                                                  module != null &&
                                                  !DartConfigurable.isCustomPackageRootSet(module) &&
                                                  yamlFile == null;

    final boolean sameContext = analysisContext != null &&
                                Comparing.equal(sdkPath, mySdkPath) &&
                                pubspecYamlTimestamp == myPubspecYamlTimestamp &&
                                Comparing.haveEqualElements(packageRoots, myDartPackageRoots) &&
                                (!useExplicitPackageUriResolver || Comparing.equal(contentRoot, myContentRoot));

    if (sameContext) {
      applyChangeSet(analysisContext, annotatedFile);
      myCreatedFiles.clear();
    }
    else {
      final DirectoryBasedDartSdk dirBasedSdk = getDirectoryBasedDartSdkSdk(sdkPath);
      final DartUriResolver dartUriResolver = new DartUriResolver(dirBasedSdk);
      final DartFileAndPackageUriResolver fileAndPackageUriResolver = new DartFileAndPackageUriResolver(myProject, dartUrlResolver);

      final SourceFactory sourceFactory = useExplicitPackageUriResolver
                                          ? new SourceFactory(dartUriResolver, fileAndPackageUriResolver,
                                                              new ExplicitPackageUriResolver(dirBasedSdk, new File(contentRoot.getPath())))
                                          : new SourceFactory(dartUriResolver, fileAndPackageUriResolver);

      analysisContext = AnalysisEngine.getInstance().createAnalysisContext();
      analysisContext.setSourceFactory(sourceFactory);

      final AnalysisOptionsImpl contextOptions = new AnalysisOptionsImpl();
      contextOptions.setEnableAsync(true);
      analysisContext.setAnalysisOptions(contextOptions);

      mySdkPath = sdkPath;
      myPubspecYamlTimestamp = pubspecYamlTimestamp;
      myDartPackageRoots = packageRoots;
      myContentRoot = contentRoot;
View Full Code Here

TOP

Related Classes of com.google.dart.engine.context.AnalysisContext

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.