/// <summary> /// Performs the QuickFix, inserts the configured modifier into the location specified by the violation. /// </summary> /// <param name="solution"> /// Current Solution. /// </param> /// <param name="textControl"> /// Current Text Control to modify. /// </param> public void Execute(ISolution solution, ITextControl textControl) { JetBrains.DataFlow.LifetimeDefinition definition = JetBrains.DataFlow.Lifetimes.Define(solution.GetLifetime()); JetBrains.DataFlow.Lifetime lifetime = definition.Lifetime; try { unsafe { ChangeInspectionSeverityDialog dialog = new ChangeInspectionSeverityDialog(lifetime, this.commonIconsComponent); IContextBoundSettingsStore contextBoundSettingsStore = this.settingsStore.BindToContextTransient(ContextRange.Smart(textControl.Document.ToDataContext())); ConfigurableSeverityItem item = this.highlightingSettingsManager.GetSeverityItem(this.HighlightID); dialog.Severity = this.highlightingSettingsManager.GetConfigurableSeverity(this.HighlightID, solution); dialog.SeverityOptionsTitle = string.Format(item.FullTitle + ":"); dialog.CanBeError = !item.SolutionAnalysisRequired; if (dialog.ShowDialog(User32Dll.GetForegroundWindow()) == true) { IContextBoundSettingsStore store = contextBoundSettingsStore; if (dialog.SelectedSettingsLayer != null) { store = dialog.SelectedSettingsLayer.Model.SettingsStoreContext; } store.SetIndexedValue(HighlightingSettingsAccessor.InspectionSeverities, this.HighlightID, dialog.Severity); } } } finally { definition.Terminate(); } }
/// <summary> /// Performs the QuickFix, inserts the configured modifier into the location specified by /// the violation. /// </summary> /// <param name="solution"> /// Current Solution. /// </param> /// <param name="textControl"> /// Current Text Control to modify. /// </param> public void Execute(ISolution solution, ITextControl textControl) { using (ChangeSeverityDialog dialog = new ChangeSeverityDialog()) { ////var settings = HighlightingSettingsManager.Instance.Settings.Clone(); ////var severityItem = HighlightingSettingsManager.Instance.GetSeverityItem(this.HighlightID); ////dialog.Severity = settings.GetSeverity(this.HighlightID); ////dialog.Text = "Inspection options for \"" + severityItem.Title + "\""; ////if (dialog.ShowDialog(Shell.Instance.GetComponent<UIApplication>().MainWindow) == DialogResult.OK) ////{ //// settings.SetSeverity(this.HighlightID, dialog.Severity); //// HighlightingSettingsManager.Instance.Settings = settings; //// Daemon.GetInstance(solution).Invalidate(); ////} IContextBoundSettingsStore settingsStore = PsiSourceFileExtensions.GetSettingsStore(null, solution); IContextBoundSettingsStore contextBoundSettingsStore = settingsStore.SettingsStore.BindToContextTransient(ContextRange.Smart(textControl.Document.ToDataContext())); HighlightingSettingsManager settingsManager = HighlightingSettingsManager.Instance; HighlightingSettingsManager.ConfigurableSeverityItem item = settingsManager.GetSeverityItem(this.HighlightID); dialog.Severity = settingsManager.GetConfigurableSeverity(this.HighlightID, solution); dialog.Text = string.Format("Inspection Options for \"{0}\"", item.FullTitle); dialog.CanBeError = !item.SolutionAnalysisRequired; if (dialog.ShowDialog(Shell.Instance.GetComponent <UIApplication>().MainWindow) == DialogResult.OK) { contextBoundSettingsStore.SetIndexedValue(HighlightingSettingsAccessor.InspectionSeverities, this.HighlightID, dialog.Severity); } } }
internal static IEnumerable <ContextRange <Range> > RangesForObjectRequests( IEnumerable <Range> blobs, IEnumerable <Range> parts) { using (var blobIter = blobs.GetEnumerator()) using (var partIter = parts.GetEnumerator()) { var hasNextblob = blobIter.MoveNext(); var hasNextPart = partIter.MoveNext(); while (hasNextblob && hasNextPart) { var blob = blobIter.Current; var part = partIter.Current; if (blob.Overlaps(part)) { yield return(ContextRange.Create(blob.Intersect(part), blob)); } if (blob.End <= part.End) { hasNextblob = blobIter.MoveNext(); } if (blob.End >= part.End) { hasNextPart = partIter.MoveNext(); } } } }
public override int Read(byte[] buffer, int offset, int count) { var contextRange = ContextRange.Create(Range.ByLength(this.Position, count), this._outerContext); var progress = 0; foreach (var range in this._rangeTranslator.Translate(contextRange)) { // We know that every range length <= count. var rangeLength = (int)range.Range.Length; this._streamStore.Access(range.Context, stream => { stream.Position = range.Range.Start; for (var streamProgress = 0; streamProgress < rangeLength;) { streamProgress += stream.Read( buffer, offset + progress + streamProgress, rangeLength - streamProgress ); } }); progress += rangeLength; } this.Position += progress; return(progress); }
public UnityPluginInstaller( Lifetime lifetime, ILogger logger, ISolution solution, IShellLocks shellLocks, UnityPluginDetector detector, RdNotificationsModel notifications, ISettingsStore settingsStore, PluginPathsProvider pluginPathsProvider, UnityVersionDetector unityVersionDetector) { myPluginInstallations = new JetHashSet <FileSystemPath>(); myLifetime = lifetime; myLogger = logger; mySolution = solution; myShellLocks = shellLocks; myDetector = detector; myNotifications = notifications; myPluginPathsProvider = pluginPathsProvider; myUnityVersionDetector = unityVersionDetector; myBoundSettingsStore = settingsStore.BindToContextLive(myLifetime, ContextRange.Smart(solution.ToDataContext())); myQueue = new ProcessingQueue(myShellLocks, myLifetime); }
public UnityPluginInstaller( Lifetime lifetime, ILogger logger, ISolution solution, IShellLocks shellLocks, UnityPluginDetector detector, RdNotificationsModel notifications, ISettingsStore settingsStore, ApplicationPackages applicationPackages, ApplicationPackagesLocallyInstalled applicationPackagesLocallyInstalled, IEnumerable <ApplicationPackageArtifact> packages, IDeployedPackagesExpandLocationResolver resolver) { myPluginInstallations = new JetHashSet <FileSystemPath>(); myLifetime = lifetime; myLogger = logger; mySolution = solution; myShellLocks = shellLocks; myDetector = detector; myNotifications = notifications; myApplicationPackages = applicationPackages; myApplicationPackagesLocallyInstalled = applicationPackagesLocallyInstalled; myPackages = packages; myResolver = resolver; myBoundSettingsStore = settingsStore.BindToContextLive(myLifetime, ContextRange.Smart(solution.ToDataContext())); myQueue = new ProcessingQueue(myShellLocks, myLifetime); }
private void TransferBlob(IDs3Client client, Blob blob) { var ranges = this._rangesForRequests[blob]; var getLength = ranges.Sum(r => r.Length); this._transferrer.Transfer( client, this.BucketName, blob.Context, blob.Range.Start, this.JobId, ranges, new StreamTranslator <TItem, Blob>( this._rangeTranslator, this._resourceStore, blob, getLength ) ); var fullRequestRange = ContextRange.Create(Range.ByLength(0L, getLength), blob); foreach (var contextRange in this._rangeTranslator.Translate(fullRequestRange)) { this._itemTracker.CompleteRange(contextRange); } }
public UnitySettingsSynchronizer(Lifetime lifetime, ISolution solution, UnityHost host, ISettingsStore settingsStore) { var boundStore = settingsStore.BindToContextLive(lifetime, ContextRange.Smart(solution.ToDataContext())); var entry = boundStore.Schema.GetScalarEntry((UnitySettings s) => s.EnableShaderLabHippieCompletion); boundStore.GetValueProperty <bool>(lifetime, entry, null).Change.Advise_HasNew(lifetime, args => { solution.Locks.ExecuteOrQueueEx(lifetime, "EnableShaderLabHippieCompletion", () => host.PerformModelAction(rd => rd.EnableShaderLabHippieCompletion.Value = args.New)); }); var useYamlMergeSetting = boundStore.Schema.GetScalarEntry((UnitySettings s) => s.UseUnityYamlMerge); boundStore.GetValueProperty <bool>(lifetime, useYamlMergeSetting, null).Change.Advise_HasNew(lifetime, args => { solution.Locks.ExecuteOrQueueEx(lifetime, "UseUnityYamlMerge", () => host.PerformModelAction(rd => rd.UseUnityYamlMerge.Value = args.New)); }); var mergeParametersSetting = boundStore.Schema.GetScalarEntry((UnitySettings s) => s.MergeParameters); boundStore.GetValueProperty <string>(lifetime, mergeParametersSetting, null).Change.Advise_HasNew(lifetime, args => { solution.Locks.ExecuteOrQueueEx(lifetime, "MergeParameters", () => host.PerformModelAction(rd => rd.MergeParameters.Value = args.New)); }); }
public void MappingTranslateWorks() { var translator = new MappingRangeTranslator <string, string>( new KeyValuePairList <string, RangeMapping <string> > { { "foo", new RangeMapping <string>(Range.ByLength(0L, 100L), 1000L, "foo1") }, { "foo", new RangeMapping <string>(Range.ByLength(100L, 100L), 2000L, "foo1") }, { "foo", new RangeMapping <string>(Range.ByLength(200L, 100L), 3000L, "foo1") }, { "bar", new RangeMapping <string>(Range.ByLength(200L, 100L), 4000L, "bar1") }, { "foo", new RangeMapping <string>(Range.ByLength(300L, 100L), 0L, "foo2") } }.ToLookup(kvp => kvp.Key, kvp => kvp.Value) ); var result = translator.Translate(ContextRange.Create(Range.ByLength(50L, 300L), "foo")); CollectionAssert.AreEqual( new[] { ByPosition(1050L, 1099L, "foo1"), ByPosition(2000L, 2099, "foo1"), ByPosition(3000, 3099L, "foo1"), ByPosition(0L, 49L, "foo2"), }, result ); }
private ImplicitNullabilitySettings GetSettings(IPsiModule psiModule) { var contextRange = ContextRange.Smart(psiModule.ToDataContext()); var contextBoundSettingsStore = _settingsStore.BindToContextTransient(contextRange); return(contextBoundSettingsStore.GetKey <ImplicitNullabilitySettings>(_settingsOptimization)); }
private ImplicitNullabilityConfiguration GetImplicitNullabilityConfigurationFor( string testInput, Action <IContextBoundSettingsStore> changeSolutionSettings, Action <IContextBoundSettingsStore> changeProjectSettings = null) { ImplicitNullabilityConfiguration?result = null; var testInputFile = GetTestDataFilePath2(testInput + ".cs"); Assert.That(testInputFile.ExistsFile, Is.True, "fixate that the test input file exists"); WithSingleProject( testInputFile.FullPath, (lifetime, solution, project) => RunGuarded( () => { var settingsStore = solution.GetComponent <SettingsStore>() .CreateNestedTransaction(lifetime, "transacted test store"); changeSolutionSettings.Invoke( settingsStore.BindToContextTransient(ContextRange.ManuallyRestrictWritesToOneContext(solution.ToDataContext()))); changeProjectSettings?.Invoke( settingsStore.BindToContextTransient(ContextRange.ManuallyRestrictWritesToOneContext(project.ToDataContext()))); var sut = new ImplicitNullabilityConfigurationEvaluator(settingsStore, solution.GetComponent <ISettingsOptimization>()); result = sut.EvaluateFor(project.GetPsiModules().Single()); })); return(result.NotNull()); }
public PrefabImportCache(Lifetime lifetime, ISolution solution, ISettingsStore store, MetaFileGuidCache metaFileGuidCache, UnityExternalFilesModuleFactory unityExternalFilesModuleFactory, IShellLocks shellLocks) { myMetaFileGuidCache = metaFileGuidCache; myShellLocks = shellLocks; metaFileGuidCache.GuidChanged.Advise(lifetime, e => { myShellLocks.AssertWriteAccessAllowed(); var set = new HashSet <Guid>(); if (e.oldGuid != null) { InvalidateImportCache(e.oldGuid.Value, set); } if (e.newGuid != null) { InvalidateImportCache(e.newGuid.Value, set); } }); myUnityExternalFilesPsiModule = unityExternalFilesModuleFactory.PsiModule; var boundSettingsStoreLive = store.BindToContextLive(lifetime, ContextRange.Smart(solution.ToDataContext())); myCacheEnabled = boundSettingsStoreLive.GetValueProperty(lifetime, (UnitySettings key) => key.IsPrefabCacheEnabled); }
public UnityYamlDisableStrategy(Lifetime lifetime, ISolution solution, ISettingsStore settingsStore, UnityYamlSupport unityYamlSupport) { myUnityYamlSupport = unityYamlSupport; var boundStore = settingsStore.BindToContextLive(lifetime, ContextRange.ManuallyRestrictWritesToOneContext(solution.ToDataContext())); myShouldRunHeuristic = boundStore.GetValueProperty(lifetime, (UnitySettings s) => s.ShouldApplyYamlHugeFileHeuristic); }
private ImplicitNullabilityConfiguration GetImplicitNullabilityConfigurationFor( [NotNull] string testInput, [NotNull] Action <IContextBoundSettingsStore> changeSolutionSettings, Action <IContextBoundSettingsStore> changeProjectSettings = null) { ImplicitNullabilityConfiguration?result = null; var testInputFile = GetTestDataFilePath2(testInput + ".cs"); Assert.That(testInputFile.ExistsFile, Is.True, "fixate that the test input file exists"); WithSingleProject( testInputFile.FullPath, (lifetime, solution, project) => RunGuarded( () => { var sut = solution.GetComponent <ImplicitNullabilityConfigurationEvaluator>(); var settingsStore = project.GetComponent <SettingsStore>(); changeSolutionSettings.Invoke( settingsStore.BindToContextTransient(ContextRange.ManuallyRestrictWritesToOneContext(solution.ToDataContext()))); changeProjectSettings?.Invoke( settingsStore.BindToContextTransient(ContextRange.ManuallyRestrictWritesToOneContext(project.ToDataContext()))); result = sut.EvaluateFor(project.GetPsiModules().Single()); })); // Note that instead of using ExecuteWithinSettingsTransaction(), we change the solution/project settings (to be able to test // the usage to the correct DataContext). We close the solution afterwards to isolate the changes (has a small performance hit). RunGuarded(() => CloseSolution()); return(result.NotNull()); }
public UnityImplicitUsageHighlightingContributor(ISolution solution, ISettingsStore settingsStore, ITextControlManager textControlManager) { Solution = solution; TextControlManager = textControlManager; SettingsStore = settingsStore.BindToContextTransient(ContextRange.Smart(solution.ToDataContext())); }
public void CompletionEventsFire(IEnumerable <Range> ranges) { var tracker = new JobItemTracker <string>( new[] { Range.ByLength(0L, 100L), Range.ByLength(100L, 100L), Range.ByLength(200L, 100L) }.Select(r => ContextRange.Create(r, "foo")) ); var sizes = new List <long>(); var completions = new List <string>(); tracker.DataTransferred += sizes.Add; tracker.ItemCompleted += completions.Add; foreach (var part in ranges) { tracker.CompleteRange(ContextRange.Create(part, "foo")); } CollectionAssert.AreEqual(ranges.Select(r => r.Length), sizes); CollectionAssert.AreEqual(new[] { "foo" }, completions); }
/// <summary>Gets the client.</summary> /// <returns>Returns the client.</returns> public CodeAnnotationPackSettings GetSettings() { var boundSettings = this.mySettingsStore.BindToContextTransient(ContextRange.Smart((lt, contexts) => contexts.Empty)); var settings = boundSettings.GetKey <CodeAnnotationPackSettings>(SettingsOptimization.OptimizeDefault); return(settings); }
public UnityHlslAllErrorsPredicate(Lifetime lifetime, ISolution solution, UnitySolutionTracker unitySolutionTracker, ISettingsStore settingsStore) { myUnitySolutionTracker = unitySolutionTracker; mySuppressShaderErrors = settingsStore.BindToContextLive(lifetime, ContextRange.Smart(solution.ToDataContext())) .GetValueProperty(lifetime, (UnitySettings key) => key.SuppressShaderErrorHighlighting); mySuppressShaderErrorsInRenderPipeline = settingsStore.BindToContextLive(lifetime, ContextRange.Smart(solution.ToDataContext())) .GetValueProperty(lifetime, (UnitySettings key) => key.SuppressShaderErrorHighlightingInRenderPipelinePackages); }
private static ContextRange <T> ItIsContextRange <T>(T context, long offset, long length) where T : IComparable <T> { return(Match.Create( it => it.Context.Equals(context) && it.Range.Start == offset && it.Range.Length == length, () => ContextRange.Create(Range.ByLength(offset, length), context) )); }
private static TestLinkerSettings GetSettings(ISolution solution) { var settingsStore = solution.GetComponent <ISettingsStore>(); var settingsOptimization = solution.GetComponent <ISettingsOptimization>(); var contextBoundSettingsStore = settingsStore.BindToContextTransient(ContextRange.Smart(solution.ToDataContext())); return(contextBoundSettingsStore.GetKey <TestLinkerSettings>(settingsOptimization)); }
/// <summary> /// Adds the word to the dictionary. /// </summary> /// <param name="solution">The solution that is active.</param> /// <param name="textControl">The text control that is currently in use.</param> public void Execute(ISolution solution, ITextControl textControl) { var settingsStore = solution.GetComponent <ISettingsStore>(); var boundSettings = settingsStore.BindToContextTransient(ContextRange.Smart((lifetime, contexts) => contexts.Empty)); boundSettings.SetIndexedValue <SpellCheckSettings, string, byte>(x => x.UserEntries, _word, 0); Shell.Instance.GetComponent <ShellSpellCheckResources>().NotifyNewUserDictionaryWord(_word); // we must also notify the active spell checker of the new ignored word DaemonBase.GetInstance(solution).ForceReHighlight(_highlight.Range.Document); // without changing the document this is a way to request a re-processing of the document }
public UnityDeclarationHighlightingProviderBase(ISolution solution, CallGraphSwaExtensionProvider callGraphSwaExtensionProvider, SettingsStore settingsStore, PerformanceCriticalCodeCallGraphMarksProvider marksProvider, IElementIdProvider provider) { Solution = solution; CallGraphSwaExtensionProvider = callGraphSwaExtensionProvider; MarksProvider = marksProvider; Settings = settingsStore.BindToContextTransient(ContextRange.Smart(solution.ToDataContext())); myProvider = provider; }
public UnityDeclarationHighlightingProviderBase(ISolution solution, SolutionAnalysisService swa, CallGraphSwaExtensionProvider callGraphSwaExtensionProvider, SettingsStore settingsStore, PerformanceCriticalCodeCallGraphAnalyzer analyzer) { Solution = solution; Swa = swa; CallGraphSwaExtensionProvider = callGraphSwaExtensionProvider; Analyzer = analyzer; Settings = settingsStore.BindToContextTransient(ContextRange.Smart(solution.ToDataContext())); }
public static ContextRange ToContextRange([NotNull] this ITextControl textControl) { if (textControl == null) { throw new ArgumentNullException("textControl"); } return(ContextRange.Smart(textControl.ToDataContext())); }
public UnityEditorProtocol(Lifetime lifetime, ILogger logger, UnityHost host, IScheduler dispatcher, IShellLocks locks, ISolution solution, PluginPathsProvider pluginPathsProvider, ISettingsStore settingsStore, JetBrains.Application.ActivityTrackingNew.UsageStatistics usageStatistics, UnitySolutionTracker unitySolutionTracker, IThreading threading) { myComponentLifetime = lifetime; myLogger = logger; myDispatcher = dispatcher; myLocks = locks; mySolution = solution; myPluginPathsProvider = pluginPathsProvider; myUsageStatistics = usageStatistics; myThreading = threading; 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.SolutionFilePath.Directory; AdviseModelData(lifetime); // todo: consider non-Unity Solution with Unity-generated projects var protocolInstancePath = solFolder.Combine("Library/ProtocolInstance.json"); protocolInstancePath.Directory.CreateDirectory(); var watcher = new FileSystemWatcher(); watcher.Path = protocolInstancePath.Directory.FullPath; watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite; //Watch for changes in LastAccess and LastWrite times watcher.Filter = protocolInstancePath.Name; // Add event handlers. watcher.Changed += OnChanged; watcher.Created += OnChanged; lf.Bracket(() => { }, () => { watcher.Dispose(); }); watcher.EnableRaisingEvents = true; // Begin watching. // connect on start of Rider CreateProtocols(protocolInstancePath); }); }
public UnitySettingsSynchronizer( Lifetime lifetime, ISolution solution, SolutionModel solutionModel, ISettingsStore settingsStore) { myLifetime = lifetime; mySolutionModel = solutionModel; myBoundStore = settingsStore.BindToContextLive(lifetime, ContextRange.Smart(solution.ToDataContext())); }
public UnitySettingsSynchronizer( Lifetime lifetime, ISolution solution, UnityHost host, ISettingsStore settingsStore) { myLifetime = lifetime; myHost = host; myBoundStore = settingsStore.BindToContextLive(lifetime, ContextRange.Smart(solution.ToDataContext())); }
public UnityHighlightingContributor(ISolution solution, ISettingsStore settingsStore, ITextControlManager textControlManager, SolutionAnalysisService swa, PerformanceCriticalCodeCallGraphAnalyzer performanceCriticalCodeCallGraphAnalyzer) { Swa = swa; PerformanceAnalyzerId = performanceCriticalCodeCallGraphAnalyzer.AnalyzerId; Solution = solution; TextControlManager = textControlManager; SettingsStore = settingsStore.BindToContextTransient(ContextRange.Smart(solution.ToDataContext())); }
public UnityCommonIconProvider(ISolution solution, SolutionAnalysisService swa, CallGraphSwaExtensionProvider callGraphSwaExtensionProvider, SettingsStore settingsStore, PerformanceCriticalCodeCallGraphAnalyzer analyzer, UnityApi unityApi) { Solution = solution; Swa = swa; CallGraphSwaExtensionProvider = callGraphSwaExtensionProvider; Analyzer = analyzer; UnityApi = unityApi; Settings = settingsStore.BindToContextTransient(ContextRange.Smart(solution.ToDataContext())); }
public NameSuffixLinkedTypesProvider(ISolution solution, ISettingsStore settingsStore, ISettingsOptimization settingsOptimization) { var contextBoundSettingsStore = settingsStore.BindToContextTransient(ContextRange.Smart(solution.ToDataContext())); var settings = contextBoundSettingsStore.GetKey <TestLinkerSettings>(settingsOptimization); _namingStyle = settings.NamingStyle; _namingSuffixes = settings.NamingSuffixes.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries) .Select(x => Pair.Of(x, x.Length)) .ToList(); }