Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.

Commit 3bd7fe7

Browse files
committed
Re-run issue analysis when issue options are changed.
1 parent dc02fe5 commit 3bd7fe7

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

  • src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring

src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/IssueManager.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ public IEnumerable<CodeIssue> GetIssues(BaseRefactoringContext context)
8686
}
8787
}
8888

89+
static event Action IssueSeveritySettingsSaved;
90+
8991
internal static void SaveIssueSeveritySettings()
9092
{
9193
var properties = PropertyService.NestedProperties("CSharpIssueSeveritySettings");
@@ -97,6 +99,8 @@ internal static void SaveIssueSeveritySettings()
9799
properties.Set(provider.ProviderType.FullName, provider.CurrentSeverity);
98100
}
99101
}
102+
if (IssueSeveritySettingsSaved != null)
103+
IssueSeveritySettingsSaved();
100104
}
101105

102106
readonly ITextEditor editor;
@@ -107,14 +111,17 @@ public IssueManager(ITextEditor editor)
107111
this.editor = editor;
108112
this.markerService = editor.GetService(typeof(ITextMarkerService)) as ITextMarkerService;
109113
//SD.ParserService.ParserUpdateStepFinished += ParserService_ParserUpdateStepFinished;
110-
SD.ParserService.ParseInformationUpdated += new EventHandler<ParseInformationEventArgs>(SD_ParserService_ParseInformationUpdated);
114+
SD.ParserService.ParseInformationUpdated += SD_ParserService_ParseInformationUpdated;
115+
IssueSeveritySettingsSaved += RerunAnalysis; // re-run analysis when settings are changed
111116
editor.ContextActionProviders.Add(this);
112117
}
113118

114119
public void Dispose()
115120
{
116121
editor.ContextActionProviders.Remove(this);
117122
//SD.ParserService.ParserUpdateStepFinished -= ParserService_ParserUpdateStepFinished;
123+
SD.ParserService.ParseInformationUpdated -= SD_ParserService_ParseInformationUpdated;
124+
IssueSeveritySettingsSaved -= RerunAnalysis;
118125
if (cancellationTokenSource != null)
119126
cancellationTokenSource.Cancel();
120127
Clear();
@@ -256,6 +263,16 @@ void SD_ParserService_ParseInformationUpdated(object sender, ParseInformationEve
256263
}
257264
}
258265

266+
async void RerunAnalysis()
267+
{
268+
var snapshot = editor.Document.CreateSnapshot();
269+
var parseInfo = await SD.ParserService.ParseAsync(editor.FileName, snapshot) as CSharpFullParseInformation;
270+
if (parseInfo != null)
271+
RunAnalysis(snapshot, parseInfo);
272+
else
273+
Clear();
274+
}
275+
259276
async void RunAnalysis(ITextSource textSource, CSharpFullParseInformation parseInfo)
260277
{
261278
if (markerService == null)

0 commit comments

Comments
 (0)