protected override void QueueAfterCommit() { if (CommitStage == T4CommitStage.DependencyInvalidation) { return; } CommitStage = T4CommitStage.DependencyInvalidation; try { using (WriteLockCookie.Create()) { // Filter just in case a miracle happens and the file gets deleted before being marked as dirty foreach (var file in IndirectDependencies.Where(file => file.IsValid())) { Services.Files.MarkAsDirty(file); Services.Caches.MarkAsDirty(file); } } IndirectDependencies.Clear(); Services.Files.CommitAllDocuments(); } finally { CommitStage = T4CommitStage.UserChangeApplication; } }
protected virtual void OnFilesIndirectlyAffected( T4FileInvalidationData data, [NotNull] ISet <IPsiSourceFile> indirectDependencies ) { Services.Locks.AssertMainThread(); foreach (var file in data.IndirectlyAffectedFiles) { IndirectDependencies.Add(file); } }
public T4FileDependencyInvalidator( Lifetime lifetime, [NotNull] IT4FileGraphNotifier notifier, [NotNull] IPsiServices services, [NotNull] ISolution solution, [NotNull] IPsiServices psiServices ) { Solution = solution; PsiServices = psiServices; services.Files.ObserveAfterCommit(lifetime, () => { if (CommitStage == T4CommitStage.DependencyInvalidation) { return; } CommitStage = T4CommitStage.DependencyInvalidation; try { using (WriteLockCookie.Create()) { // Filter just in case a miracle happens and the file gets deleted before being marked as dirty foreach (var file in IndirectDependencies.Where(file => file.IsValid())) { services.Files.MarkAsDirty(file); services.Caches.MarkAsDirty(file); } } IndirectDependencies.Clear(); services.Files.CommitAllDocuments(); } finally { CommitStage = T4CommitStage.UserChangeApplication; } }); notifier.OnFilesIndirectlyAffected += paths => { if (CommitStage == T4CommitStage.DependencyInvalidation) { return; } // We want all files that were included before the update // and all the files that have become included now // to be updated, so we'll mark them as dirty later IndirectDependencies.AddRange(paths .Distinct() .SelectMany(Solution.FindProjectItemsByLocation) .OfType <IProjectFile>() .Select(PsiServices.Modules.GetPsiSourceFilesFor) .SelectMany(sourceFiles => sourceFiles.AsEnumerable())); }; }
protected override void OnFilesIndirectlyAffected( T4FileInvalidationData data, ISet <IPsiSourceFile> indirectDependencies ) { if (CommitStage == T4CommitStage.DependencyInvalidation) { return; } // We want all files that were included before the update // and all the files that have become included now // to be updated, so we'll mark them as dirty later IndirectDependencies.AddRange(data.IndirectlyAffectedFiles); }
protected virtual void QueueAfterCommit() => Services.Locks.ExecuteOrQueue(Lifetime, ActivityName, () => { using var cookie = ReadLockCookie.Create(); // We need to have documents committed before we can do anything, // because after PSI file creation/deletion/etc the graph might contain incorrect information on whether // a certain file has a preprocessed root or not. // Also, some implementations access the PSI files, // which might become invalid after the simple queueing Services.Files.ExecuteAfterCommitAllDocuments(() => { AfterCommitSync(IndirectDependencies.WhereNotNull().Where(it => it.IsValid()).ToSet()); IndirectDependencies = new HashSet <IPsiSourceFile>(); }); });
protected virtual void QueueAfterCommit() => Services.Locks.ExecuteOrQueue(Lifetime, ActivityName, () => { AfterCommitSync(IndirectDependencies.WhereNotNull().Where(it => it.IsValid()).ToSet()); IndirectDependencies = new HashSet <IPsiSourceFile>(); });