示例#1
0
        public ProductSettingsTracker(Lifetime lifetime, IProductNameAndVersion product, ClientFactory clientFactory, GlobalPerProductStorage globalPerProductStorage, IFileSystemTracker fileSystemTracker, JetBoxSettingsStorage jetBoxSettings)
        {
            myClientFactory = clientFactory;
              mySettingsStore = jetBoxSettings.SettingsStore.BindToContextLive(lifetime, ContextRange.ApplicationWide);
              mySettingsStore.Changed.Advise(lifetime, _ => InitClient());

              myRootFolder = FileSystemPath.Parse(product.ProductName);
              InitClient();

              var productSettingsPath = globalPerProductStorage.XmlFileStorage.Path;

              SyncFromCloud(productSettingsPath.Value);

              var fileTrackingLifetime = new SequentialLifetimes(lifetime);
              productSettingsPath.Change.Advise(lifetime,
            args =>
            {
              var path = args.Property.Value;
              if (lifetime.IsTerminated || path.IsNullOrEmpty())
              {
            fileTrackingLifetime.TerminateCurrent();
              }
              else
              {
            fileTrackingLifetime.Next(lt => fileSystemTracker.AdviseFileChanges(lt, path, delta => delta.Accept(new FileChangesVisitor(myClient, myRootFolder))));
              }
            });
        }
 public MonoFileSystemTrackerDisabler(IFileSystemTracker fileSystemTracker)
 {
     if (PlatformUtil.IsRunningOnMono)
     {
         fileSystemTracker.Enabled = false;
     }
 }
示例#3
0
        public UnityVersion(UnityProjectFileCacheProvider unityProjectFileCache,
                            ISolution solution, IFileSystemTracker fileSystemTracker, Lifetime lifetime, bool inTests = false)
        {
            myUnityProjectFileCache = unityProjectFileCache;
            mySolution = solution;

            if (inTests)
            {
                return;
            }

            var projectVersionTxtPath = mySolution.SolutionDirectory.Combine("ProjectSettings/ProjectVersion.txt");

            fileSystemTracker.AdviseFileChanges(lifetime,
                                                projectVersionTxtPath,
                                                _ => { myVersionFromProjectVersionTxt = TryGetVersionFromProjectVersion(projectVersionTxtPath); });
            myVersionFromProjectVersionTxt = TryGetVersionFromProjectVersion(projectVersionTxtPath);

            var editorInstanceJsonPath = mySolution.SolutionDirectory.Combine("Library/EditorInstance.json");

            fileSystemTracker.AdviseFileChanges(lifetime,
                                                editorInstanceJsonPath,
                                                _ => { myVersionFromEditorInstanceJson = TryGetApplicationPathFromEditorInstanceJson(editorInstanceJsonPath); });
            myVersionFromEditorInstanceJson = TryGetApplicationPathFromEditorInstanceJson(editorInstanceJsonPath);
        }
示例#4
0
        public UnityVersion(UnityProjectFileCacheProvider unityProjectFileCache,
                            ISolution solution, IFileSystemTracker fileSystemTracker, Lifetime lifetime,
                            IShellLocks locks)
        {
            myUnityProjectFileCache = unityProjectFileCache;
            mySolution = solution;

            if (locks.Dispatcher.IsAsyncBehaviorProhibited) // for tests
            {
                return;
            }

            var projectVersionTxtPath = mySolution.SolutionDirectory.Combine("ProjectSettings/ProjectVersion.txt");

            fileSystemTracker.AdviseFileChanges(lifetime,
                                                projectVersionTxtPath,
                                                _ => { myVersionFromProjectVersionTxt = TryGetVersionFromProjectVersion(projectVersionTxtPath); });
            myVersionFromProjectVersionTxt = TryGetVersionFromProjectVersion(projectVersionTxtPath);

            var editorInstanceJsonPath = mySolution.SolutionDirectory.Combine("Library/EditorInstance.json");

            fileSystemTracker.AdviseFileChanges(lifetime,
                                                editorInstanceJsonPath,
                                                _ => { myVersionFromEditorInstanceJson = TryGetApplicationPathFromEditorInstanceJson(editorInstanceJsonPath); });
            myVersionFromEditorInstanceJson = TryGetApplicationPathFromEditorInstanceJson(editorInstanceJsonPath);
        }
        public ProductSettingsTracker(Lifetime lifetime, ClientFactory clientFactory, IViewable<ISyncSource> syncSources, IFileSystemTracker fileSystemTracker, JetBoxSettingsStorage jetBoxSettings)
        {
            myClientFactory = clientFactory;
              mySettingsStore = jetBoxSettings.SettingsStore.BindToContextLive(lifetime, ContextRange.ApplicationWide);
              mySettingsStore.Changed.Advise(lifetime, _ => InitClient());

              myRootFolder = FileSystemPath.Parse("ReSharperPlatform");
              InitClient();

              syncSources.View(lifetime, (lt1, source) =>
            source.FilesToSync.View(lt1, (lt2, fileToSync) =>
            {
              SyncFromCloud(fileToSync.Value);

              var fileTrackingLifetime = new SequentialLifetimes(lt2);
              fileToSync.Change.Advise(lt2,
            args =>
            {
              var path = args.Property.Value;
              if (lifetime.IsTerminated || path.IsNullOrEmpty())
              {
                fileTrackingLifetime.TerminateCurrent();
              }
              else
              {
                fileTrackingLifetime.Next(lt =>
                    fileSystemTracker.AdviseFileChanges(lt, path,
                      delta => delta.Accept(new FileChangesVisitor(myClient, myRootFolder))));
              }
            });
            }));
        }
示例#6
0
 public T4OutsideSolutionSourceFileManager(Lifetime lifetime,
                                           [NotNull] IProjectFileExtensions projectFileExtensions,
                                           [NotNull] PsiProjectFileTypeCoordinator psiProjectFileTypeCoordinator,
                                           [NotNull] DocumentManager documentManager,
                                           [NotNull] ISolution solution,
                                           [NotNull] IT4Environment t4Environment,
                                           [NotNull] IFileSystemTracker fileSystemTracker,
                                           [NotNull] PsiSourceFileWithLocationTracker psiSourceFileWithLocationTracker
                                           )
 {
     ProjectFileExtensions         = projectFileExtensions;
     PsiProjectFileTypeCoordinator = psiProjectFileTypeCoordinator;
     DocumentManager = documentManager;
     SourceFiles     = new ConcurrentDictionary <FileSystemPath, IPsiSourceFile>();
     lifetime.OnTermination(this);
     PsiModule = new PsiModuleOnFileSystemPaths(
         solution,
         "T4OutsideSolution",
         Guid.NewGuid().ToString(),
         t4Environment.TargetFrameworkId,
         fileSystemTracker,
         lifetime,
         psiSourceFileWithLocationTracker,
         false);
 }
 public UnityExternalFilesModuleFactory(Lifetime lifetime, ISolution solution,
                                        IFileSystemTracker fileSystemTracker)
 {
     // TODO: Conditionally create this module
     // See changeBuilder.AddAssembly(module, ADDED)
     PsiModule = new UnityExternalFilesPsiModule(solution, "Unity external files", "UnityExternalFilesPsiModule",
                                                 TargetFrameworkId.Default, lifetime);
 }
        public UnityRefreshTracker(Lifetime lifetime, ISolution solution, UnityRefresher refresher,
                                   ILogger logger,
                                   IFileSystemTracker fileSystemTracker,
                                   UnityHost host,
                                   UnitySolutionTracker unitySolutionTracker)
        {
            myRefresher = refresher;
            myLogger    = logger;
            if (solution.GetData(ProjectModelExtensions.ProtocolSolutionKey) == null)
            {
                return;
            }

            unitySolutionTracker.IsUnityProjectFolder.AdviseOnce(lifetime, args =>
            {
                if (!args)
                {
                    return;
                }

                // Rgc.Guarded - beware RIDER-15577
                myGroupingEvent = solution.Locks.GroupingEvents.CreateEvent(lifetime, "UnityRefresherGroupingEvent",
                                                                            TimeSpan.FromMilliseconds(500),
                                                                            Rgc.Guarded, () =>
                {
                    refresher.Refresh(RefreshType.Normal);
                });

                host.PerformModelAction(rd => rd.Refresh.Advise(lifetime, force =>
                {
                    if (force)
                    {
                        refresher.Refresh(RefreshType.ForceRequestScriptReload);
                    }
                    else
                    {
                        myGroupingEvent.FireIncoming();
                    }
                }));
            });

            unitySolutionTracker.IsUnityProject.AdviseOnce(lifetime, args =>
            {
                if (!args)
                {
                    return;
                }

                var protocolSolution = solution.GetProtocolSolution();
                protocolSolution.Editors.AfterDocumentInEditorSaved.Advise(lifetime, _ =>
                {
                    logger.Verbose("protocolSolution.Editors.AfterDocumentInEditorSaved");
                    myGroupingEvent.FireIncoming();
                });

                fileSystemTracker.RegisterPrioritySink(lifetime, FileSystemChange, HandlingPriority.Other);
            });
        }
        public JetBoxSettingsStorage(Lifetime lifetime, ProductSettingsLocation productSettingsLocation, ISettingsSchema settingsSchema, DataContexts dataContexts, IThreading threading, IFileSystemTracker fileSystemTracker, FileSettingsStorageBehavior settingsStorageBehavior, ISettingsLogger settingsLogger, ISettingsChangeDispatch settingsChangeDispatch, SettingsStorageMountPoints.SelfCheckControl selfCheckControl)
        {
            var filePath = productSettingsLocation.GetUserSettingsNonRoamingDir(ProductSettingsLocationFlag.ThisProductThisVersionThisEnvironment).Combine("JetBox" + XmlFileSettingsStorage.SettingsStorageFileExtensionWithDot);
              var property = new Property<FileSystemPath>(lifetime, GetType().Name + "Path", filePath);
              var settingsProvider = new JetBoxSettingsProvider(lifetime, GetType().Name + "::Provider", property, true, 0, IsAvailable.Always, SettingsStoreSerializationToXmlDiskFile.SavingEmptyContent.DeleteFile, threading, fileSystemTracker, settingsStorageBehavior, new Dictionary<PropertyId, object>());
              var mounts = new SettingsStorageMountPoints(lifetime,
            new CollectionEvents<IProvider<ISettingsStorageMountPoint>>(lifetime, GetType() + "::Mounts") { settingsProvider }, threading, settingsLogger,
            selfCheckControl);

              mySettingsStore = new SettingsStore(lifetime, settingsSchema, mounts, dataContexts, null, settingsLogger, settingsChangeDispatch );
        }
示例#10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="StyleCopApiPool"/> class.
        /// </summary>
        /// <param name="lifetime">
        /// The lifetime.
        /// </param>
        /// <param name="settingsStore">The settings store</param>
        /// <param name="fileSystemTracker">
        /// The file system tracker.
        /// </param>
        public StyleCopApiPool(Lifetime lifetime, ISettingsStore settingsStore, IFileSystemTracker fileSystemTracker)
        {
            this.componentLifetime = lifetime;
            this.settingsStore     = settingsStore;
            this.fileSystemTracker = fileSystemTracker;

            this.reset = () =>
            {
                var initialObject = this.CreateApiObject();
                this.pool = new ObjectPool <StyleCopApi>(this.CreateApiObject, new[] { initialObject });
            };
            this.reset();
        }
 /// <summary>
 /// Initializes a new instance of the HighlightingRegistering class.
 /// </summary>
 /// <param name="fileSystemTracker">
 /// The file System Tracker.
 /// </param>
 public HighlightingRegistering(IFileSystemTracker fileSystemTracker)
 {
     // TODO: We shouldn't be doing any of this at runtime, especially not on each load
     // Registering highlightings should happen declaratively
     // Create this instance directly, rather than use the pool, because the pool needs to
     // be per-solution, as it caches settings for files in the solution
     Lifetimes.Using(
         lifetime =>
             {
                 // We don't really need the file system tracker - it's only used when we get
                 // settings, which we don't do as part of highlighting initialisation
                 StyleCopCore core = StyleCopCoreFactory.Create(lifetime, fileSystemTracker);
                 this.Init(core);
             });
 }
 public T4OutsideSolutionSourceFileManager(
     [NotNull] Lifetime lifetime,
     [NotNull] IProjectFileExtensions projectFileExtensions,
     [NotNull] PsiProjectFileTypeCoordinator psiProjectFileTypeCoordinator,
     [NotNull] DocumentManager documentManager,
     [NotNull] ISolution solution,
     [NotNull] T4Environment t4Environment,
     [NotNull] IFileSystemTracker fileSystemTracker)
 {
     _projectFileExtensions         = projectFileExtensions;
     _psiProjectFileTypeCoordinator = psiProjectFileTypeCoordinator;
     _documentManager = documentManager;
     _psiModule       = new PsiModuleOnFileSystemPaths(solution, "T4OutsideSolution", t4Environment.TargetFrameworkId, fileSystemTracker, lifetime);
     lifetime.AddDispose(_sourceFiles);
 }
示例#13
0
 /// <summary>
 /// Initializes a new instance of the HighlightingRegistering class.
 /// </summary>
 /// <param name="settingsStore">The settings store.</param>
 /// <param name="fileSystemTracker">
 /// The file System Tracker.
 /// </param>
 public HighlightingRegistering(ISettingsStore settingsStore, IFileSystemTracker fileSystemTracker)
 {
     // TODO: We shouldn't be doing any of this at runtime, especially not on each load
     // Registering highlightings should happen declaratively
     // Create this instance directly, rather than use the pool, because the pool needs to
     // be per-solution, as it caches settings for files in the solution
     Lifetimes.Using(
         temporaryLifetime =>
     {
         // We don't really need the file system tracker - it's only used when we get
         // settings, which we don't do as part of highlighting initialisation
         StyleCopCore core = StyleCopCoreFactory.Create(temporaryLifetime, settingsStore, fileSystemTracker);
         this.Register(core);
     });
 }
示例#14
0
        public UnitySolutionTracker(ISolution solution, IFileSystemTracker fileSystemTracker, Lifetime lifetime)
        {
            mySolution = solution;
            if (!solution.SolutionDirectory.IsAbsolute)
            {
                return;                                         // True in tests
            }
            SetValues();

            fileSystemTracker.AdviseDirectoryChanges(lifetime, mySolution.SolutionDirectory.Combine(ProjectExtensions.AssetsFolder), false,
                                                     OnChangeAction);
            // track not only folder itself, but also files inside
            fileSystemTracker.AdviseDirectoryChanges(lifetime, mySolution.SolutionDirectory.Combine(ProjectExtensions.ProjectSettingsFolder), true,
                                                     OnChangeActionProjectSettingsFolder);
        }
        public UnitySolutionTracker(ISolution solution, IFileSystemTracker fileSystemTracker, Lifetime lifetime, IShellLocks locks)
        {
            mySolution = solution;
            if (locks.Dispatcher.IsAsyncBehaviorProhibited) // for tests
            {
                return;
            }

            SetValues();

            fileSystemTracker.AdviseDirectoryChanges(lifetime, mySolution.SolutionDirectory.Combine(ProjectExtensions.AssetsFolder), false,
                                                     OnChangeAction);
            // track not only folder itself, but also files inside
            fileSystemTracker.AdviseDirectoryChanges(lifetime, mySolution.SolutionDirectory.Combine(ProjectExtensions.ProjectSettingsFolder), true,
                                                     OnChangeActionProjectSettingsFolder);
        }
 public ExternalCodeFilesProvider(
     IProjectFileExtensions projectFileExtensions,
     PsiProjectFileTypeCoordinator projectFileTypeCoordinator,
     ChangeManager changeManager,
     IFileSystemTracker fileSystemTracker,
     IShellLocks shellLocks,
     DocumentManager documentManager,
     ISettingsStore settingsStore)
 {
     _projectFileExtensions      = projectFileExtensions;
     _projectFileTypeCoordinator = projectFileTypeCoordinator;
     _changeManager     = changeManager;
     _fileSystemTracker = fileSystemTracker;
     _shellLocks        = shellLocks;
     _documentManager   = documentManager;
     _settingsStore     = settingsStore;
 }
 public T4OutsideSolutionSourceFileManager(
     Lifetime lifetime,
     [NotNull] IProjectFileExtensions projectFileExtensions,
     [NotNull] PsiProjectFileTypeCoordinator psiProjectFileTypeCoordinator,
     [NotNull] DocumentManager documentManager,
     [NotNull] ISolution solution,
     [NotNull] T4Environment t4Environment,
     [NotNull] IFileSystemTracker fileSystemTracker
     )
 {
     _projectFileExtensions         = projectFileExtensions;
     _psiProjectFileTypeCoordinator = psiProjectFileTypeCoordinator;
     _documentManager = documentManager;
     _sourceFiles     = new StrongToWeakDictionary <FileSystemPath, IPsiSourceFile>(lifetime);
     _psiModule       = new PsiModuleOnFileSystemPaths(solution, "T4OutsideSolution", Guid.NewGuid().ToString(), t4Environment.TargetFrameworkId, fileSystemTracker, lifetime);
     lifetime.OnTermination(_sourceFiles);
 }
示例#18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="StyleCopApiPool"/> class.
        /// </summary>
        /// <param name="lifetime">
        /// The lifetime.
        /// </param>
        /// <param name="settingsStore">The settings store</param>
        /// <param name="fileSystemTracker">
        /// The file system tracker.
        /// </param>
        /// <param name="highlightingRegistering">The highlighting registrar</param>
        public StyleCopApiPool(Lifetime lifetime, ISettingsStore settingsStore, IFileSystemTracker fileSystemTracker, HighlightingRegistering highlightingRegistering)
        {
            this.componentLifetime = lifetime;
            this.settingsStore     = settingsStore;
            this.fileSystemTracker = fileSystemTracker;

            this.reset = () =>
            {
                var initialObject = this.CreateApiObject();
                this.pool = new ObjectPool <StyleCopApi>(this.CreateApiObject, new[] { initialObject });

                // We need to re-register the highlightings, because we might have loaded a plugin from a location
                // specified in per-solution settings
                highlightingRegistering.Reregister(initialObject.Core);
            };
            this.reset();
        }
示例#19
0
        public UnityVersion(UnityProjectFileCacheProvider unityProjectFileCache,
                            ISolution solution, IFileSystemTracker fileSystemTracker, Lifetime lifetime,
                            UnitySolutionTracker unitySolutionTracker)
        {
            myUnityProjectFileCache = unityProjectFileCache;
            mySolution          = solution;
            myFileSystemTracker = fileSystemTracker;

            // SolutionDirectory isn't absolute in tests, and will throw if used with FileSystemTracker
            mySolutionDirectory = solution.SolutionDirectory;
            if (!mySolutionDirectory.IsAbsolute)
            {
                mySolutionDirectory = solution.SolutionDirectory.ToAbsolutePath(FileSystemUtil.GetCurrentDirectory());
            }

            unitySolutionTracker.IsUnityProjectFolder.WhenTrue(lifetime, SetActualVersionForSolution);
        }
示例#20
0
        public UnityExternalFilesModuleProcessor(Lifetime lifetime, ILogger logger, ISolution solution,
                                                 ChangeManager changeManager,
                                                 IShellLocks locks,
                                                 ISolutionLoadTasksScheduler scheduler,
                                                 IFileSystemTracker fileSystemTracker,
                                                 ProjectFilePropertiesFactory projectFilePropertiesFactory,
                                                 UnityYamlPsiSourceFileFactory psiSourceFileFactory,
                                                 UnityExternalFilesModuleFactory moduleFactory,
                                                 UnityYamlDisableStrategy unityYamlDisableStrategy,
                                                 BinaryUnityFileCache binaryUnityFileCache,
                                                 ISettingsSchema settingsSchema,
                                                 SettingsLayersProvider settingsLayersProvider,
                                                 AssetSerializationMode assetSerializationMode,
                                                 UnityYamlSupport unityYamlSupport)
        {
            myLifetime                     = lifetime;
            myLogger                       = logger;
            mySolution                     = solution;
            myChangeManager                = changeManager;
            myLocks                        = locks;
            myFileSystemTracker            = fileSystemTracker;
            myProjectFilePropertiesFactory = projectFilePropertiesFactory;
            myPsiSourceFileFactory         = psiSourceFileFactory;
            myModuleFactory                = moduleFactory;
            myUnityYamlDisableStrategy     = unityYamlDisableStrategy;
            myBinaryUnityFileCache         = binaryUnityFileCache;
            mySettingsSchema               = settingsSchema;
            mySettingsLayersProvider       = settingsLayersProvider;
            myAssetSerializationMode       = assetSerializationMode;
            myUnityYamlSupport             = unityYamlSupport;

            changeManager.RegisterChangeProvider(lifetime, this);

            myRootPaths = new JetHashSet <FileSystemPath>();

            // SolutionDirectory isn't absolute in tests, and will throw an exception if we use it when we call Exists
            mySolutionDirectory = solution.SolutionDirectory;
            if (!mySolutionDirectory.IsAbsolute)
            {
                mySolutionDirectory = solution.SolutionDirectory.ToAbsolutePath(FileSystemUtil.GetCurrentDirectory());
            }

            scheduler.EnqueueTask(new SolutionLoadTask(GetType().Name + ".Activate",
                                                       SolutionLoadTaskKinds.PreparePsiModules,
                                                       () => myChangeManager.AddDependency(myLifetime, mySolution.PsiModules(), this)));
        }
 public ExternalCodeFilesProvider(
     IProjectFileExtensions projectFileExtensions,
     PsiProjectFileTypeCoordinator projectFileTypeCoordinator,
     ChangeManager changeManager,
     IFileSystemTracker fileSystemTracker,
     IShellLocks shellLocks,
     DocumentManager documentManager,
     ISettingsStore settingsStore)
 {
     _projectFileExtensions = projectFileExtensions;
     _projectFileTypeCoordinator = projectFileTypeCoordinator;
     _changeManager = changeManager;
     _fileSystemTracker = fileSystemTracker;
     _shellLocks = shellLocks;
     _documentManager = documentManager;
     _settingsStore = settingsStore;
 }
示例#22
0
        public BackendUnityProtocol(Lifetime lifetime, ILogger logger,
                                    BackendUnityHost backendUnityHost, FrontendBackendHost frontendBackendHost,
                                    IScheduler dispatcher, IShellLocks locks, ISolution solution,
                                    IApplicationWideContextBoundSettingStore settingsStore,
                                    UnitySolutionTracker unitySolutionTracker,
                                    UnityVersion unityVersion, NotificationsModel notificationsModel,
                                    IHostProductInfo hostProductInfo, IFileSystemTracker fileSystemTracker)
        {
            myPluginInstallations = new JetHashSet <FileSystemPath>();

            myLifetime            = lifetime;
            myLogger              = logger;
            myBackendUnityHost    = backendUnityHost;
            myDispatcher          = dispatcher;
            myLocks               = locks;
            mySolution            = solution;
            myUnityVersion        = unityVersion;
            myNotificationsModel  = notificationsModel;
            myHostProductInfo     = hostProductInfo;
            myFrontendBackendHost = frontendBackendHost;
            myBoundSettingsStore  = settingsStore.BoundSettingsStore;
            mySessionLifetimes    = new SequentialLifetimes(lifetime);

            if (solution.GetData(ProjectModelExtensions.ProtocolSolutionKey) == null)
            {
                return;
            }

            unitySolutionTracker.IsUnityProject.View(lifetime, (lf, args) =>
            {
                if (!args)
                {
                    return;
                }

                var solFolder = mySolution.SolutionDirectory;

                // todo: consider non-Unity Solution with Unity-generated projects
                var protocolInstancePath = solFolder.Combine("Library/ProtocolInstance.json");
                fileSystemTracker.AdviseFileChanges(lf, protocolInstancePath, OnProtocolInstanceJsonChange);

                // connect on start of Rider
                CreateProtocol(protocolInstancePath);
            });
        }
        public PackageManager(Lifetime lifetime, ISolution solution, ILogger logger,
                              UnitySolutionTracker unitySolutionTracker,
                              UnityVersion unityVersion,
                              IFileSystemTracker fileSystemTracker)
        {
            myLifetime          = lifetime;
            mySolution          = solution;
            myLogger            = logger;
            myUnityVersion      = unityVersion;
            myFileSystemTracker = fileSystemTracker;

            // Refresh the packages in the guarded context, safe from reentrancy.
            myGroupingEvent = solution.Locks.GroupingEvents.CreateEvent(lifetime, "Unity::PackageManager",
                                                                        TimeSpan.FromMilliseconds(500), Rgc.Guarded, DoRefresh);

            myPackagesById     = new DictionaryEvents <string, PackageData>(lifetime, "Unity::PackageManager");
            myPackageLifetimes = new Dictionary <string, LifetimeDefinition>();

            myPackagesFolder   = mySolution.SolutionDirectory.Combine("Packages");
            myPackagesLockPath = myPackagesFolder.Combine("packages-lock.json");
            myManifestPath     = myPackagesFolder.Combine("manifest.json");

            unitySolutionTracker.IsUnityProject.AdviseUntil(lifetime, value =>
            {
                if (!value)
                {
                    return(false);
                }

                ScheduleRefresh();

                // Track changes to manifest.json and packages-lock.json. Also track changes in the Packages folder, but
                // only top level, not recursively. We only want to update the packages if a new package has been added
                // or removed
                var packagesFolder = mySolution.SolutionDirectory.Combine("Packages");
                fileSystemTracker.AdviseFileChanges(lifetime, packagesFolder.Combine("packages-lock.json"),
                                                    _ => ScheduleRefresh());
                fileSystemTracker.AdviseFileChanges(lifetime, packagesFolder.Combine("manifest.json"),
                                                    _ => ScheduleRefresh());
                fileSystemTracker.AdviseDirectoryChanges(lifetime, packagesFolder, false, _ => ScheduleRefresh());

                // We're all set up, terminate the advise
                return(true);
            });
        }
        public UnityEditorProtocol(Lifetime lifetime, ILogger logger, UnityHost host,
                                   IScheduler dispatcher, IShellLocks locks, ISolution solution,
                                   ISettingsStore settingsStore, JetBrains.Application.ActivityTrackingNew.UsageStatistics usageStatistics,
                                   UnitySolutionTracker unitySolutionTracker, IThreading threading,
                                   UnityVersion unityVersion, NotificationsModel notificationsModel,
                                   IHostProductInfo hostProductInfo, IFileSystemTracker fileSystemTracker)
        {
            myPluginInstallations = new JetHashSet <FileSystemPath>();

            myComponentLifetime  = lifetime;
            myLogger             = logger;
            myDispatcher         = dispatcher;
            myLocks              = locks;
            mySolution           = solution;
            myUsageStatistics    = usageStatistics;
            myThreading          = threading;
            myUnityVersion       = unityVersion;
            myNotificationsModel = notificationsModel;
            myHostProductInfo    = hostProductInfo;
            myHost = host;
            myBoundSettingsStore = settingsStore.BindToContextLive(lifetime, ContextRange.Smart(solution.ToDataContext()));
            mySessionLifetimes   = new SequentialLifetimes(lifetime);

            if (solution.GetData(ProjectModelExtensions.ProtocolSolutionKey) == null)
            {
                return;
            }

            unitySolutionTracker.IsUnityProject.View(lifetime, (lf, args) =>
            {
                if (!args)
                {
                    return;
                }

                var solFolder = mySolution.SolutionDirectory;
                AdviseModelData(lifetime);

                // todo: consider non-Unity Solution with Unity-generated projects
                var protocolInstancePath = solFolder.Combine("Library/ProtocolInstance.json");
                fileSystemTracker.AdviseFileChanges(lf, protocolInstancePath, OnChangeAction);
                // connect on start of Rider
                CreateProtocols(protocolInstancePath);
            });
        }
示例#25
0
        /// <summary>
        /// The create.
        /// </summary>
        /// <param name="lifetime">
        /// The lifetime.
        /// </param>
        /// <param name="fileSystemTracker">
        /// The file System Tracker.
        /// </param>
        /// <returns>
        /// A new StyleCopCore object.
        /// </returns>
        public static StyleCopCore Create(Lifetime lifetime, IFileSystemTracker fileSystemTracker)
        {
            StyleCopTrace.In();

            ProjectSettingsFactory projectSettingsFactory = new ProjectSettingsFactory(lifetime, fileSystemTracker);
            SourceCodeFactory sourceCodeFactory = new SourceCodeFactory();

            ObjectBasedEnvironment environment = new ObjectBasedEnvironment(sourceCodeFactory.Create, projectSettingsFactory.Create);

            // TODO: Is there a nicer way of finding out the ReSharper install location?
            string path = Path.Combine(Path.GetDirectoryName(Assembly.GetCallingAssembly().Location), @"Extensions\StyleCop.StyleCop\StyleCopAddIns");
            string[] paths = { path };
            StyleCopObjectConsole styleCop = new StyleCopObjectConsole(environment, null, paths, false);

            projectSettingsFactory.StyleCopCore = styleCop.Core;

            return StyleCopTrace.Out(styleCop.Core);
        }
        public SettingsLoader(Lifetime lifetime, SimpleExtensionManager extensionManager,
                              UserInjectedSettingsLayers userInjectedSettingsLayers, IThreading threading,
                              IFileSystemTracker filetracker, FileSettingsStorageBehavior behavior)
        {
            // Check to see if we've been loaded as an extension - so we're either loaded
            // as a plugin on the command line (debugging) or we're in an environment that
            // doesn't support the default extension provider (e.g. VS2008)
            if (extensionManager.IsInstalled())
                return;

            var files = GetSettingsFiles();
            foreach (var file in files)
            {
                MountSettingsFile(lifetime, extensionManager.ExtensionId, file,
                    extensionManager.SettingsMountPointId, threading, filetracker,
                    behavior, userInjectedSettingsLayers);
            }
        }
        public UnitySolutionTracker(ISolution solution, IFileSystemTracker fileSystemTracker, Lifetime lifetime, bool inTests = false)
        {
            mySolution = solution;
            if (inTests)
            {
                IsUnityGeneratedProject.Value = false;
                IsUnityProject.Value          = false;
                IsUnityProjectFolder.Value    = false;
                return;
            }

            SetValues();

            fileSystemTracker.AdviseDirectoryChanges(lifetime, mySolution.SolutionDirectory.Combine(ProjectExtensions.AssetsFolder), false,
                                                     OnChangeAction);
            // track not only folder itself, but also files inside
            fileSystemTracker.AdviseDirectoryChanges(lifetime, mySolution.SolutionDirectory.Combine(ProjectExtensions.ProjectSettingsFolder), true,
                                                     OnChangeActionProjectSettingsFolder);
        }
示例#28
0
        public UnityRefreshTracker(Lifetime lifetime, ISolution solution, UnityRefresher refresher,
                                   ILogger logger,
                                   IFileSystemTracker fileSystemTracker,
                                   UnityHost host,
                                   UnitySolutionTracker unitySolutionTracker)
        {
            myRefresher = refresher;
            myLogger    = logger;
            if (solution.GetData(ProjectModelExtensions.ProtocolSolutionKey) == null)
            {
                return;
            }

            unitySolutionTracker.IsUnityProjectFolder.AdviseOnce(lifetime, args =>
            {
                if (!args)
                {
                    return;
                }
                host.PerformModelAction(rd => rd.Refresh.Advise(lifetime, force =>
                {
                    refresher.Refresh(force ? RefreshType.ForceRequestScriptReload : RefreshType.Normal);
                }));
            });

            unitySolutionTracker.IsUnityProject.AdviseOnce(lifetime, args =>
            {
                if (!args)
                {
                    return;
                }

                var protocolSolution = solution.GetProtocolSolution();
                protocolSolution.Editors.AfterDocumentInEditorSaved.Advise(lifetime, _ =>
                {
                    logger.Verbose("protocolSolution.Editors.AfterDocumentInEditorSaved");
                    refresher.Refresh(RefreshType.Normal);
                });

                fileSystemTracker.RegisterPrioritySink(lifetime, FileSystemChange, HandlingPriority.Other);
            });
        }
示例#29
0
        public UnitySolutionTracker(ISolution solution, IFileSystemTracker fileSystemTracker, Lifetime lifetime, IShellLocks locks)
        {
            mySolution = solution;

            IsAbleToEstablishProtocolConnectionWithUnity = new Property <bool>(lifetime, "IsAbleToEstablishProtocolConnectionWithUnity");
            if (locks.Dispatcher.IsAsyncBehaviorProhibited) // for tests
            {
                return;
            }

            IsAbleToEstablishProtocolConnectionWithUnity.SetValue(
                ProjectExtensions.IsAbleToEstablishProtocolConnectionWithUnity(mySolution.SolutionDirectory));

            fileSystemTracker.AdviseDirectoryChanges(lifetime, mySolution.SolutionDirectory.Combine(ProjectExtensions.AssetsFolder), false,
                                                     OnChangeAction);
            fileSystemTracker.AdviseDirectoryChanges(lifetime, mySolution.SolutionDirectory.Combine(ProjectExtensions.LibraryFolder), false,
                                                     OnChangeAction);
            fileSystemTracker.AdviseDirectoryChanges(lifetime, mySolution.SolutionDirectory.Combine(ProjectExtensions.ProjectSettingsFolder), false,
                                                     OnChangeAction);
        }
        public TemplatesLoader(Lifetime lifetime, GlobalSettings globalSettings, UserInjectedSettingsLayers userInjectedSettingsLayers,
            IThreading threading, IFileSystemTracker filetracker, FileSettingsStorageBehavior behavior)
        {
            var path = GetSettingsFile();

            var persistentId = new UserInjectedSettingsLayers.InjectedLayerPersistentIdentity(AngularJsInjectedLayerId);

            var pathAsProperty = new Property<FileSystemPath>(lifetime, "InjectedFileStoragePath", path);
            var serialization = new XmlFileSettingsStorage(lifetime, "angularjs-templates::" + path.FullPath.QuoteIfNeeded(), pathAsProperty,
                SettingsStoreSerializationToXmlDiskFile.SavingEmptyContent.DeleteFile, threading, filetracker, behavior);

            var descriptor = new UserInjectedSettingsLayers.UserInjectedLayerDescriptor(lifetime, globalSettings.ProductGlobalLayerId,
                persistentId, serialization.Storage, SettingsStorageMountPoint.MountPath.Default, () => { });
            descriptor.InitialMetadata.Set(UserFriendlySettingsLayers.DisplayName, "angularjs-templates");
            descriptor.InitialMetadata.Set(UserFriendlySettingsLayers.Origin, "AngularJS plugin");
            descriptor.InitialMetadata.Set(PreventDeletion, true);
            descriptor.InitialMetadata.Set(PreventReset, true);

            userInjectedSettingsLayers.RegisterUserInjectedLayer(lifetime, descriptor);
        }
示例#31
0
        public SettingsLoader(Lifetime lifetime, SimpleExtensionManager extensionManager,
                              UserInjectedSettingsLayers userInjectedSettingsLayers, IThreading threading,
                              IFileSystemTracker filetracker, FileSettingsStorageBehavior behavior)
        {
            // Check to see if we've been loaded as an extension - so we're either loaded
            // as a plugin on the command line (debugging) or we're in an environment that
            // doesn't support the default extension provider (e.g. VS2008)
            if (extensionManager.IsInstalled())
            {
                return;
            }

            var files = GetSettingsFiles();

            foreach (var file in files)
            {
                MountSettingsFile(lifetime, extensionManager.ExtensionId, file,
                                  extensionManager.SettingsMountPointId, threading, filetracker,
                                  behavior, userInjectedSettingsLayers);
            }
        }
        public TemplatesLoader(Lifetime lifetime, GlobalSettings globalSettings, UserInjectedSettingsLayers userInjectedSettingsLayers,
                               IThreading threading, IFileSystemTracker filetracker, FileSettingsStorageBehavior behavior)
        {
            var path = GetSettingsFile();

            var persistentId = new UserInjectedSettingsLayers.InjectedLayerPersistentIdentity(AngularJsInjectedLayerId);

            var pathAsProperty = new Property <FileSystemPath>(lifetime, "InjectedFileStoragePath", path);
            var serialization  = new XmlFileSettingsStorage(lifetime, "angularjs-templates::" + path.FullPath.QuoteIfNeeded(), pathAsProperty,
                                                            SettingsStoreSerializationToXmlDiskFile.SavingEmptyContent.DeleteFile, threading, filetracker, behavior);

            var descriptor = new UserInjectedSettingsLayers.UserInjectedLayerDescriptor(lifetime, globalSettings.ProductGlobalLayerId,
                                                                                        persistentId, serialization.Storage, SettingsStorageMountPoint.MountPath.Default, () => { });

            descriptor.InitialMetadata.Set(UserFriendlySettingsLayers.DisplayName, "angularjs-templates");
            descriptor.InitialMetadata.Set(UserFriendlySettingsLayers.Origin, "AngularJS plugin");
            descriptor.InitialMetadata.Set(PreventDeletion, true);
            descriptor.InitialMetadata.Set(PreventReset, true);

            userInjectedSettingsLayers.RegisterUserInjectedLayer(lifetime, descriptor);
        }
示例#33
0
        public UnityVersion(UnityProjectFileCacheProvider unityProjectFileCache,
                            ISolution solution, IFileSystemTracker fileSystemTracker, Lifetime lifetime,
                            UnitySolutionTracker unitySolutionTracker)
        {
            myUnityProjectFileCache = unityProjectFileCache;
            mySolution = solution;

            unitySolutionTracker.IsUnityProjectFolder.AdviseOnce(lifetime, args =>
            {
                if (!args)
                {
                    return;
                }

                var projectVersionTxtPath =
                    mySolution.SolutionDirectory.Combine("ProjectSettings/ProjectVersion.txt");
                fileSystemTracker.AdviseFileChanges(lifetime,
                                                    projectVersionTxtPath,
                                                    _ =>
                {
                    myVersionFromProjectVersionTxt = TryGetVersionFromProjectVersion(projectVersionTxtPath);
                    ActualVersionForSolution.SetValue(myVersionFromProjectVersionTxt ??
                                                      GetActualVersionForSolution());
                });
                myVersionFromProjectVersionTxt = TryGetVersionFromProjectVersion(projectVersionTxtPath);

                var editorInstanceJsonPath = mySolution.SolutionDirectory.Combine("Library/EditorInstance.json");
                fileSystemTracker.AdviseFileChanges(lifetime,
                                                    editorInstanceJsonPath,
                                                    _ =>
                {
                    myVersionFromEditorInstanceJson =
                        TryGetApplicationPathFromEditorInstanceJson(editorInstanceJsonPath);
                });
                myVersionFromEditorInstanceJson =
                    TryGetApplicationPathFromEditorInstanceJson(editorInstanceJsonPath);

                ActualVersionForSolution.SetValue(GetActualVersionForSolution());
            });
        }
示例#34
0
        public UnitySolutionTracker(ISolution solution, IFileSystemTracker fileSystemTracker, Lifetime lifetime, IShellLocks locks,
                                    UnityHost unityHost, UnityReferencesTracker unityReferencesTracker)
        {
            mySolution = solution;
            if (locks.Dispatcher.IsAsyncBehaviorProhibited) // for tests
            {
                return;
            }

            SetValues();

            fileSystemTracker.AdviseDirectoryChanges(lifetime, mySolution.SolutionDirectory.Combine(ProjectExtensions.AssetsFolder), false,
                                                     OnChangeAction);
            // track not only folder itself, but also files inside
            fileSystemTracker.AdviseDirectoryChanges(lifetime, mySolution.SolutionDirectory.Combine(ProjectExtensions.ProjectSettingsFolder), true,
                                                     OnChangeActionProjectSettingsFolder);

            unityHost.PerformModelAction(model =>
            {
                unityReferencesTracker.HasUnityReference.Advise(lifetime, res => { model.HasUnityReference.SetValue(res); });
            });
        }
示例#35
0
        private void MountSettingsFile(Lifetime lifetime, string pluginId, FileSystemPath path,
                                       UserFriendlySettingsLayer.Identity hostId,
                                       IThreading threading, IFileSystemTracker filetracker,
                                       FileSettingsStorageBehavior behavior,
                                       UserInjectedSettingsLayers userInjectedSettingsLayers)
        {
            var id           = string.Format("extension::{0}-{1}", pluginId, path.Name);
            var persistentId = new LayerId(id);

            var pathAsProperty = new Property <FileSystemPath>(lifetime, "InjectedFileStoragePath", path);
            var serialization  = CreateXmlFileSettingsStorage(lifetime, threading, filetracker, behavior, id, pathAsProperty);
            var descriptor     = new LayerDescriptor(lifetime, hostId, persistentId, serialization.Storage,
                                                     MountPath.Default, () => { });

            descriptor.InitialMetadata.Set(UserFriendlySettingsLayers.DisplayName,
                                           string.Format("{0} » {1}", pluginId, path.NameWithoutExtension));
            descriptor.InitialMetadata.Set(UserFriendlySettingsLayers.Origin,
                                           string.Format("Published by plugin: {0}", pluginId));
            descriptor.InitialMetadata.Set(UserFriendlySettingsLayers.DiskFilePath, path);
            descriptor.InitialMetadata.Set(IsNonUserEditable, true);

            userInjectedSettingsLayers.RegisterUserInjectedLayer(lifetime, descriptor);
        }
        private void MountSettingsFile(Lifetime lifetime, string pluginId, FileSystemPath path,
                                       UserFriendlySettingsLayer.Identity hostId,
                                       IThreading threading, IFileSystemTracker filetracker,
                                       FileSettingsStorageBehavior behavior,
                                       UserInjectedSettingsLayers userInjectedSettingsLayers)
        {
            var id = string.Format("extension::{0}-{1}", pluginId, path.Name);
            var persistentId = new LayerId(id);

            var pathAsProperty = new Property<FileSystemPath>(lifetime, "InjectedFileStoragePath", path);
            var serialization = CreateXmlFileSettingsStorage(lifetime, threading, filetracker, behavior, id, pathAsProperty);
            var descriptor = new LayerDescriptor(lifetime, hostId, persistentId, serialization.Storage,
                                                 MountPath.Default, () => { });

            descriptor.InitialMetadata.Set(UserFriendlySettingsLayers.DisplayName,
                                           string.Format("{0} » {1}", pluginId, path.NameWithoutExtension));
            descriptor.InitialMetadata.Set(UserFriendlySettingsLayers.Origin,
                                           string.Format("Published by plugin: {0}", pluginId));
            descriptor.InitialMetadata.Set(UserFriendlySettingsLayers.DiskFilePath, path);
            descriptor.InitialMetadata.Set(IsNonUserEditable, true);

            userInjectedSettingsLayers.RegisterUserInjectedLayer(lifetime, descriptor);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="StyleCopSettings"/> class.
 /// </summary>
 /// <param name="lifetime">
 /// The lifetime of the settings object.
 /// </param>
 /// <param name="styleCopCore">
 /// The style cop core.
 /// </param>
 /// <param name="fileSystemTracker">
 /// The file system tracker.
 /// </param>
 public StyleCopSettings(Lifetime lifetime, StyleCopCore styleCopCore, IFileSystemTracker fileSystemTracker)
 {
     this.lifetime          = lifetime;
     this.styleCopCore      = styleCopCore;
     this.fileSystemTracker = fileSystemTracker;
 }
 private static XmlFileSettingsStorage CreateXmlFileSettingsStorage(Lifetime lifetime, IThreading threading, IFileSystemTracker filetracker, FileSettingsStorageBehavior behavior, string id, Property<FileSystemPath> pathAsProperty)
 {
     var internKeyPathComponent = Shell.Instance.GetComponent<InternKeyPathComponent>();
     return new XmlFileSettingsStorage(lifetime, id, pathAsProperty, SavingEmptyContent.KeepFile,
         threading, filetracker, behavior, internKeyPathComponent);
 }
 private static XmlFileSettingsStorage CreateXmlFileSettingsStorage(Lifetime lifetime, IThreading threading, IFileSystemTracker filetracker, FileSettingsStorageBehavior behavior, string id, Property<FileSystemPath> pathAsProperty)
 {
     return new XmlFileSettingsStorage(lifetime, id, pathAsProperty, SaveEmptyFilePolicy.KeepFile,
         threading, filetracker, behavior);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ProjectSettingsFactory"/> class.
 /// </summary>
 /// <param name="lifetime">
 /// The lifetime.
 /// </param>
 /// <param name="fileSystemTracker">
 /// The file system tracker.
 /// </param>
 public ProjectSettingsFactory(Lifetime lifetime, IFileSystemTracker fileSystemTracker)
 {
     this.lifetime = lifetime;
     this.fileSystemTracker = fileSystemTracker;
 }
示例#41
0
        public ProductSettingsTracker(Lifetime lifetime, ClientFactory clientFactory, IViewable <ISyncSource> syncSources, IFileSystemTracker fileSystemTracker, JetBoxSettingsStorage jetBoxSettings)
        {
            myClientFactory = clientFactory;
            mySettingsStore = jetBoxSettings.SettingsStore.BindToContextLive(lifetime, ContextRange.ApplicationWide);
            mySettingsStore.Changed.Advise(lifetime, _ => InitClient());

            myRootFolder = FileSystemPath.Parse("ReSharperPlatform");
            InitClient();

            syncSources.View(lifetime, (lt1, source) =>
                             source.FilesToSync.View(lt1, (lt2, fileToSync) =>
            {
                SyncFromCloud(fileToSync.Value);

                var fileTrackingLifetime = new SequentialLifetimes(lt2);
                fileToSync.Change.Advise(lt2,
                                         args =>
                {
                    var path = args.Property.Value;
                    if (lifetime.IsTerminated || path.IsNullOrEmpty())
                    {
                        fileTrackingLifetime.TerminateCurrent();
                    }
                    else
                    {
                        fileTrackingLifetime.Next(lt =>
                                                  fileSystemTracker.AdviseFileChanges(lt, path,
                                                                                      delta => delta.Accept(new FileChangesVisitor(myClient, myRootFolder))));
                    }
                });
            }));
        }
示例#42
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StyleCopApiPool"/> class.
 /// </summary>
 /// <param name="lifetime">
 /// The lifetime.
 /// </param>
 /// <param name="fileSystemTracker">
 /// The file system tracker.
 /// </param>
 public StyleCopApiPool(Lifetime lifetime, IFileSystemTracker fileSystemTracker)
 {
     this.pool = new ObjectPool<StyleCopApi>(() => new StyleCopApi(lifetime, StyleCopCoreFactory.Create(lifetime, fileSystemTracker), fileSystemTracker));
 }
示例#43
0
        public JetBoxSettingsStorage(Lifetime lifetime, ProductSettingsLocation productSettingsLocation, ISettingsSchema settingsSchema, DataContexts dataContexts, IThreading threading, IFileSystemTracker fileSystemTracker, IFileSettingsStorageBehavior settingsStorageBehavior, ISettingsLogger settingsLogger, ISettingsChangeDispatch settingsChangeDispatch, SettingsStorageMountPoints.SelfCheckControl selfCheckControl, InternKeyPathComponent interned)
        {
            var filePath         = productSettingsLocation.GetUserSettingsNonRoamingDir(ApplicationHostDetails.PerHostAndWave).Combine("JetBox" + XmlFileSettingsStorage.SettingsStorageFileExtensionWithDot);
            var property         = new Property <FileSystemPath>(lifetime, GetType().Name + "Path", filePath);
            var settingsProvider = new JetBoxSettingsProvider(lifetime, GetType().Name + "::Provider", property, true, 0, IsAvailable.Always, SettingsStoreSerializationToXmlDiskFile.SavingEmptyContent.DeleteFile, threading, fileSystemTracker, settingsStorageBehavior, interned, new Dictionary <PropertyId, object>());
            var mounts           = new SettingsStorageMountPoints(lifetime,
                                                                  new CollectionEvents <IProvider <ISettingsStorageMountPoint> >(lifetime, GetType() + "::Mounts")
            {
                settingsProvider
            }, threading, settingsLogger,
                                                                  selfCheckControl);

            mySettingsStore = new SettingsStore(lifetime, settingsSchema, mounts, dataContexts, null, settingsLogger, settingsChangeDispatch);
        }
示例#44
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StyleCopSettings"/> class.
 /// </summary>
 /// <param name="lifetime">
 /// The lifetime of the settings object.
 /// </param>
 /// <param name="styleCopCore">
 /// The style cop core.
 /// </param>
 /// <param name="fileSystemTracker">
 /// The file system tracker.
 /// </param>
 public StyleCopSettings(Lifetime lifetime, StyleCopCore styleCopCore, IFileSystemTracker fileSystemTracker)
 {
     this.lifetime = lifetime;
     this.styleCopCore = styleCopCore;
     this.fileSystemTracker = fileSystemTracker;
 }