Exemple #1
0
        public BinaryUnityFileCache(Lifetime lifetime, ISolution solution,
                                    IPersistentIndexManager persistentIndexManager, IShellLocks locks,
                                    ChangeManager changeManager)
            : base(lifetime, persistentIndexManager, BinaryFileCacheItem.Marshaller)
        {
            myGroupingEvent = solution.Locks.GroupingEvents.CreateEvent(lifetime, "UnityRefresherOnSaveEvent",
                                                                        TimeSpan.FromMilliseconds(500), Rgc.Guarded, () =>
            {
                var changedFiles = new JetHashSet <IPsiSourceFile>(myChangedFiles);
                myChangedFiles.Clear();

                if (changedFiles.Count > 0)
                {
                    locks.ExecuteWithWriteLock(() => changeManager.ExecuteAfterChange(() =>
                    {
                        var builder = new PsiModuleChangeBuilder();
                        foreach (var file in changedFiles)
                        {
                            if (file.IsValid())
                            {
                                builder.AddFileChange(file, PsiModuleChange.ChangeType.Modified);
                            }
                        }

                        changeManager.OnProviderChanged(solution, builder.Result, SimpleTaskExecutor.Instance);
                    }));
                }
            });
            myChangedFiles = new JetHashSet <IPsiSourceFile>();
        }
        public UnityCacheUpdater(Lifetime lifetime, ISolution solution, UnityYamlSupport unityYamlSupport, IShellLocks locks, ChangeManager changeManager, UnityExternalFilesModuleFactory factory)
        {
            var module = factory.PsiModule;

            if (module != null)
            {
                unityYamlSupport.IsUnityYamlParsingEnabled.Change.Advise_NoAcknowledgement(lifetime, (handler) =>
                {
                    if (handler.HasNew && handler.HasOld && handler.New == handler.Old)
                    {
                        return;
                    }

                    locks.ExecuteOrQueueReadLockEx(lifetime, "YamlParsingStateChange", () =>
                    {
                        var psiSourceFiles = module.SourceFiles.ToList();
                        if (psiSourceFiles.Any())
                        {
                            locks.ExecuteWithWriteLock(() => changeManager.ExecuteAfterChange(() =>
                            {
                                var changeBuilder = new PsiModuleChangeBuilder();
                                foreach (var sourceFile in psiSourceFiles)
                                {
                                    if (sourceFile.IsValid())
                                    {
                                        changeBuilder.AddFileChange(sourceFile, PsiModuleChange.ChangeType.Modified);
                                    }
                                }
                                changeManager.OnProviderChanged(solution, changeBuilder.Result, SimpleTaskExecutor.Instance);
                            }));
                        }
                    });
                });
            }
        }
Exemple #3
0
        private void OnDataFileChanged(Pair <IPsiSourceFile, T4FileDataDiff> pair)
        {
            if (pair.First != SourceFile)
            {
                return;
            }

            if (_shellLocks.IsWriteAccessAllowed())
            {
                OnDataFileChanged(pair.Second);
            }
            else
            {
                _shellLocks.ExecuteOrQueue(_lifetime, "T4PsiModuleOnFileDataChanged",
                                           () => _shellLocks.ExecuteWithWriteLock(() => OnDataFileChanged(pair.Second)));
            }
        }
 public ReflectedReferenceProviderValidator(Lifetime lifetime, IShellLocks shellLocks, ChangeManager changeManager, ISettingsStore settingsStore, ISolution solution)
 {
     var providerValidator = this;
     changeManager.Changed2.Advise(lifetime, Handler(solution, providerValidator));
     settingsStore.BindToContextLive(lifetime, ContextRange.Smart(solution.ToDataContext()))
         .GetValueProperty<MvcCustomReferencesSettings, bool>(lifetime, mvcSettings => mvcSettings.Enabled)
         .Change.Advise_NoAcknowledgement(lifetime,
             () =>
             {
                 if (lifetime.IsTerminated)
                     return;
                 shellLocks.ExecuteOrQueueReadLockEx(lifetime, "ReflectedReferenceProviderValidator", () => shellLocks.ExecuteWithWriteLock(providerValidator.FireOnChanged));
             });
 }