Exemplo n.º 1
0
 private void SaveFrontEndSnapshot(IWorkspaceBindingSnapshot snapshot)
 {
     Analysis.IgnoreResult(
         Task.Run(
             () => { FrontEndArtifactManager.SaveFrontEndSnapshot(snapshot); }),
         justification: "fire and forget"
         );
 }
Exemplo n.º 2
0
        /// <nodoc />
        public SnapshotBasedSpecProvider(IWorkspaceBindingSnapshot snapshot)
        {
            Contract.Requires(snapshot != null, "snapshot != null");

            m_snapshot = snapshot;

            // Need to materialize all the file names.
            snapshot.MaterializeDependencies();
        }
Exemplo n.º 3
0
        private void UpdateAndSaveSnapshot(Possible <ISourceFile>[] parseResults, IWorkspaceBindingSnapshot snapshot)
        {
            if (!FrontEndConfiguration.ConstructAndSaveBindingFingerprint())
            {
                return;
            }

            foreach (var sourceFile in parseResults)
            {
                ISourceFile source = sourceFile.Result;
                Contract.Assert(source.BindingSymbols != null, "source.BindingSymbols != null");

                snapshot.UpdateBindingFingerprint(
                    source.GetAbsolutePath(FrontEndContext.PathTable),
                    source.BindingSymbols.ReferencedSymbolsFingerprint,
                    source.BindingSymbols.DeclaredSymbolsFingerprint);
            }

            SaveFrontEndSnapshot(snapshot);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Serializes the front end snapshot to the given writer.
        /// </summary>
        public static void SerializeWorkspaceBindingSnapshot([NotNull] IWorkspaceBindingSnapshot snapshot, [NotNull] BuildXLWriter writer, PathTable pathTable)
        {
            // File format:
            // 1. # specs
            // 2. spec info for each spec in the workspace
            //   * spec path
            //   * bit vector of spec dependencies
            //   * bit vector of spec dependents
            //   * binding fingerprint
            snapshot.MaterializeDependencies();

            // 1. # specs
            writer.WriteCompact(snapshot.SourcesCount);

            // 2. spec info
            foreach (var source in snapshot.Sources)
            {
                // There is no perf issues right now, but we can consider to compute all the fingerprints in parallel.
                SerializeSpecBindingState(source, writer, pathTable);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Returns true if the given snapshot is still valid and all the parsed spec has the same symbols.
        /// </summary>
        private CanReuseSnapshotResult GetSnapshotReuseState(Possible <ISourceFile>[] specs, IWorkspaceBindingSnapshot snapshot)
        {
            var dirtySpecs   = new List <ISourceFile>();
            var invalidSpecs = new List <ISourceFile>();

            foreach (var s in specs)
            {
                // All specs should be valid here, getting result from the 'Result' property directly.
                ISourceFile spec = s.Result;

                var state = snapshot.TryGetSpecState(spec.GetAbsolutePath(FrontEndContext.PathTable));
                if (state == null)
                {
                    // If symbols is missing from the snapshot, we can't reuse it
                    return(CanReuseSnapshotResult.Invalid);
                }

                Contract.Assert(spec.BindingSymbols != null);
                Contract.Assert(state.BindingSymbols != null);

                if (spec.BindingSymbols.DeclaredSymbolsFingerprint != state.BindingSymbols.DeclaredSymbolsFingerprint)
                {
                    invalidSpecs.Add(spec);
                }
                else if (spec.BindingSymbols.ReferencedSymbolsFingerprint != state.BindingSymbols.ReferencedSymbolsFingerprint)
                {
                    dirtySpecs.Add(spec);
                }
            }

            return(new CanReuseSnapshotResult(dirtySpecs, invalidSpecs));
        }
Exemplo n.º 6
0
 /// <summary>
 /// <see cref="FrontEndCache.SaveFrontEndSnapshot"/>
 /// </summary>
 public void SaveFrontEndSnapshot(IWorkspaceBindingSnapshot snapshot)
 {
     m_frontEndCache.SaveFrontEndSnapshot(snapshot);
 }