diff options
Diffstat (limited to 'main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues')
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/AnalyzersFromAssembly.cs | 106 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/BuiltInCodeDiagnosticProvider.cs | 111 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeDiagnosticDescriptor.cs | 185 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeDiagnosticFixDescriptor.cs | 89 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeDiagnosticProvider.cs (renamed from main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/ICodeIssueProviderSource.cs) | 38 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeDiagnosticRunner.cs | 108 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeIssue.cs | 108 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeIssueAddinNode.cs | 68 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeIssuePanelWidget.cs | 128 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeIssueProvider.cs | 207 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/DefaultCodeIssueCategories.cs | 44 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/DiagnosticResult.cs | 77 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/AbstractGroupingProvider.cs (renamed from main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/AbstractGroupingProvider.cs) | 0 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/ActionSummary.cs (renamed from main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/ActionSummary.cs) | 3 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/AnalysisState.cs (renamed from main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/AnalysisState.cs) | 0 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/AnalysisStateChangeEventArgs.cs (renamed from main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/AnalysisStateChangeEventArgs.cs) | 0 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/BatchFixer.cs (renamed from main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/BatchFixer.cs) | 62 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/CategoryGroupingProvider.cs (renamed from main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CategoryGroupingProvider.cs) | 0 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/CodeAnalysisBatchRunner.cs (renamed from main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeAnalysisBatchRunner.cs) | 206 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/CodeIssuePad.cs (renamed from main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeIssuePad.cs) | 0 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/ExactIssueMatcher.cs (renamed from main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/ExactIssueMatcher.cs) | 0 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/FileGroupingProvider.cs (renamed from main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/FileGroupingProvider.cs) | 92 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/GroupingDescriptionAttribute.cs (renamed from main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/GroupingDescriptionAttribute.cs) | 0 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/GroupingProviderChainControl.cs (renamed from main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/GroupingProviderChainControl.cs) | 0 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/GroupingProviderEventArgs.cs (renamed from main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/GroupingProviderEventArgs.cs) | 0 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/IActionMatcher.cs (renamed from main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/IActionMatcher.cs) | 0 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/IGroupingProvider.cs (renamed from main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/IGroupingProvider.cs) | 0 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/IIssueSummarySink.cs (renamed from main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/IIssueSummarySink.cs) | 0 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/IIssueTreeNode.cs (renamed from main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/IIssueTreeNode.cs) | 0 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/IssueGroup.cs (renamed from main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/IssueGroup.cs) | 0 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/IssueGroupEventArgs.cs (renamed from main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/IssueGroupEventArgs.cs) | 0 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/IssueMatch.cs (renamed from main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/IssueMatch.cs) | 0 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/IssueSummary.cs (renamed from main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/IssueSummary.cs) | 8 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/IssueTreeNodeEventArgs.cs (renamed from main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/IssueTreeNodeEventArgs.cs) | 0 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/NullGroupingProvider.cs (renamed from main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/NullGroupingProvider.cs) | 0 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/ProjectGroupingProvider.cs (renamed from main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/ProjectGroupingProvider.cs) | 0 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/ProviderGroupingProvider.cs (renamed from main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/ProviderGroupingProvider.cs) | 0 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/Runner/AnalysisJobQueue.cs (renamed from main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Runner/AnalysisJobQueue.cs) | 0 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/Runner/CodeIssueEventArgs.cs (renamed from main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Runner/CodeIssueEventArgs.cs) | 0 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/Runner/IAnalysisJob.cs (renamed from main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Runner/IAnalysisJob.cs) | 0 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/Runner/IJobContext.cs (renamed from main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Runner/IJobContext.cs) | 0 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/Runner/JobContext.cs (renamed from main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Runner/JobContext.cs) | 0 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/Runner/JobSlice.cs (renamed from main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Runner/JobSlice.cs) | 0 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/Runner/JobStatus.cs (renamed from main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Runner/JobStatus.cs) | 0 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/Runner/ProgressMonitorWrapperJob.cs (renamed from main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Runner/ProgressMonitorWrapperJob.cs) | 0 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/Runner/SimpleAnalysisJob.cs (renamed from main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Runner/SimpleAnalysisJob.cs) | 0 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/SeverityGroupingProvider.cs (renamed from main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/SeverityGroupingProvider.cs) | 0 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/SolutionAnalysisJob.cs (renamed from main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/SolutionAnalysisJob.cs) | 0 |
48 files changed, 951 insertions, 689 deletions
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/AnalyzersFromAssembly.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/AnalyzersFromAssembly.cs new file mode 100644 index 0000000000..05331147ab --- /dev/null +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/AnalyzersFromAssembly.cs @@ -0,0 +1,106 @@ +// +// AnalyzersFromAssembly.cs +// +// Author: +// Mike Krüger <mkrueger@xamarin.com> +// +// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using System.Linq; +using System.Collections.Generic; +using System.Threading; +using MonoDevelop.CodeIssues; +using Microsoft.CodeAnalysis.Diagnostics; +using Microsoft.CodeAnalysis.CodeFixes; +using ICSharpCode.NRefactory6.CSharp.Refactoring; +using MonoDevelop.Core; +using System.Threading.Tasks; +using MonoDevelop.Ide.Editor; +using MonoDevelop.CodeActions; +using Microsoft.CodeAnalysis.CodeRefactorings; +using ICSharpCode.NRefactory6.CSharp; + +namespace MonoDevelop.CodeIssues +{ + + class AnalyzersFromAssembly + { + public List<CodeDiagnosticDescriptor> Analyzers; + public List<CodeDiagnosticFixDescriptor> Fixes; + public List<CodeRefactoringDescriptor> Refactorings; + + public readonly static AnalyzersFromAssembly Empty = new AnalyzersFromAssembly (); + + public AnalyzersFromAssembly () + { + Analyzers = new List<CodeDiagnosticDescriptor> (); + Fixes = new List<CodeDiagnosticFixDescriptor> (); + Refactorings = new List<CodeRefactoringDescriptor> (); + } + + internal static AnalyzersFromAssembly CreateFrom (System.Reflection.Assembly asm, bool force = false) + { + var result = new AnalyzersFromAssembly (); + result.AddAssembly (asm, force); + return result; + } + + internal void AddAssembly (System.Reflection.Assembly asm, bool force = false) + { + if (!force) { + var assemblyName = asm.GetName ().Name; + if (assemblyName == "MonoDevelop.AspNet" || + assemblyName == "Microsoft.CodeAnalysis.CSharp" || + assemblyName != "ICSharpCode.NRefactory6.CSharp.Refactoring" && + !(asm.GetReferencedAssemblies ().Any (a => a.Name == diagnosticAnalyzerAssembly) && asm.GetReferencedAssemblies ().Any (a => a.Name == "MonoDevelop.Ide"))) + return; + } + foreach (var type in asm.GetTypes ()) { + var analyzerAttr = (DiagnosticAnalyzerAttribute)type.GetCustomAttributes (typeof(DiagnosticAnalyzerAttribute), false).FirstOrDefault (); + if (analyzerAttr != null) { + var analyzer = (DiagnosticAnalyzer)Activator.CreateInstance (type); + foreach (var diag in analyzer.SupportedDiagnostics) { + try { + Analyzers.Add (new CodeDiagnosticDescriptor (diag, analyzerAttr.Languages, type)); + } catch (Exception e) { + LoggingService.LogError ("error while adding diagnostic analyzer: " + diag.Id + " from assembly " + asm.FullName, e); + } + } + } + + var codeFixAttr = (ExportCodeFixProviderAttribute)type.GetCustomAttributes (typeof(ExportCodeFixProviderAttribute), false).FirstOrDefault (); + if (codeFixAttr != null) { + Fixes.Add (new CodeDiagnosticFixDescriptor (type, codeFixAttr)); + } + + var exportAttr = type.GetCustomAttributes (typeof(ExportCodeRefactoringProviderAttribute), false).FirstOrDefault () as ExportCodeRefactoringProviderAttribute; + if (exportAttr != null) { + Refactorings.Add (new CodeRefactoringDescriptor (type, exportAttr)); + } + } + } + + readonly static string diagnosticAnalyzerAssembly = typeof (DiagnosticAnalyzerAttribute).Assembly.GetName ().Name; + + } + +}
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/BuiltInCodeDiagnosticProvider.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/BuiltInCodeDiagnosticProvider.cs new file mode 100644 index 0000000000..bd00becc7c --- /dev/null +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/BuiltInCodeDiagnosticProvider.cs @@ -0,0 +1,111 @@ +// +// BuiltInCodeDiagnosticProvider.cs +// +// Author: +// Mike Krüger <mkrueger@xamarin.com> +// +// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using System.Linq; +using System.Collections.Generic; +using System.Threading; +using MonoDevelop.CodeIssues; +using MonoDevelop.Core; +using System.Threading.Tasks; +using MonoDevelop.Ide.Editor; +using MonoDevelop.CodeActions; + +namespace MonoDevelop.CodeIssues +{ + + /// <summary> + /// Provides all IDE code diagnostics and fix provider. + /// (Scans the app domain for providers) + /// </summary> + class BuiltInCodeDiagnosticProvider : CodeDiagnosticProvider + { + readonly static Task<AnalyzersFromAssembly> builtInDiagnostics; + + static BuiltInCodeDiagnosticProvider () + { + builtInDiagnostics = Task.Run (() => { + var result = new AnalyzersFromAssembly (); + foreach (var asm in AppDomain.CurrentDomain.GetAssemblies()) { + try { + result.AddAssembly (asm); + } catch (Exception e) { + LoggingService.LogError ("error while loading diagnostics in " + asm.FullName, e); + } + } + return result; + }); + } + + internal static CodeDiagnosticDescriptor GetCodeDiagnosticDescriptor (string diagnosticId) + { + foreach (var builtInDescriptor in BuiltInCodeDiagnosticProvider.GetBuiltInCodeDiagnosticDecsriptorsAsync (null).Result) { + if (builtInDescriptor.GetProvider ().SupportedDiagnostics.Any (diagnostic => diagnosticId == diagnostic.Id)) + return builtInDescriptor; + } + return null; + } + + internal async static Task<IEnumerable<CodeDiagnosticDescriptor>> GetBuiltInCodeDiagnosticDecsriptorsAsync (string language, bool includeDisabledNodes = false, CancellationToken cancellationToken = default (CancellationToken)) + { + builtInDiagnostics.Wait (cancellationToken); + var diags = await builtInDiagnostics; + var builtInCodeDiagnostics = diags.Analyzers; + if (string.IsNullOrEmpty (language)) + return includeDisabledNodes ? builtInCodeDiagnostics : builtInCodeDiagnostics.Where (act => act.IsEnabled); + return includeDisabledNodes ? builtInCodeDiagnostics.Where (ca => ca.Languages.Contains (language)) : builtInCodeDiagnostics.Where (ca => ca.Languages.Contains (language) && ca.IsEnabled); + } + + public async static Task<IEnumerable<CodeDiagnosticFixDescriptor>> GetBuiltInCodeFixDescriptorsAsync (string language, CancellationToken cancellationToken = default (CancellationToken)) + { + var diags = await builtInDiagnostics.ConfigureAwait (false); + var builtInCodeFixes = diags.Fixes; + return string.IsNullOrEmpty (language) ? builtInCodeFixes : builtInCodeFixes.Where (cfp => cfp.Languages.Contains (language)); + } + + public async static Task<IEnumerable<CodeRefactoringDescriptor>> GetBuiltInCodeRefactoringDescriptorsAsync (string language, bool includeDisabledNodes = false, CancellationToken cancellationToken = default (CancellationToken)) + { + var diags = await builtInDiagnostics.ConfigureAwait (false); + var builtInCodeFixes = diags.Refactorings; + return string.IsNullOrEmpty (language) ? builtInCodeFixes : builtInCodeFixes.Where (cfp => cfp.Language.Contains (language)); + } + + public override Task<IEnumerable<CodeDiagnosticFixDescriptor>> GetCodeFixDescriptorsAsync (DocumentContext document, string language, CancellationToken cancellationToken) + { + return GetBuiltInCodeFixDescriptorsAsync (language, cancellationToken); + } + + public override Task<IEnumerable<CodeDiagnosticDescriptor>> GetCodeDiagnosticDescriptorsAsync (DocumentContext document, string language, CancellationToken cancellationToken) + { + return GetBuiltInCodeDiagnosticDecsriptorsAsync (language, false, cancellationToken); + } + + public override Task<IEnumerable<CodeRefactoringDescriptor>> GetCodeRefactoringDescriptorsAsync (DocumentContext document, string language, CancellationToken cancellationToken = default (CancellationToken)) + { + return GetBuiltInCodeRefactoringDescriptorsAsync (language, false, cancellationToken); + } + } +}
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeDiagnosticDescriptor.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeDiagnosticDescriptor.cs new file mode 100644 index 0000000000..547c068621 --- /dev/null +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeDiagnosticDescriptor.cs @@ -0,0 +1,185 @@ +// +// CodeIssueDescriptor.cs +// +// Author: +// Mike Krüger <mkrueger@xamarin.com> +// +// Copyright (c) 2014 Xamarin Inc. (http://xamarin.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using Microsoft.CodeAnalysis.Diagnostics; +using MonoDevelop.Core; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Text; +using MonoDevelop.Ide.Editor; +using ICSharpCode.NRefactory6.CSharp; + +namespace MonoDevelop.CodeIssues +{ + class CodeDiagnosticDescriptor + { + readonly Type diagnosticAnalyzerType; + readonly Microsoft.CodeAnalysis.DiagnosticDescriptor descriptor; + + DiagnosticAnalyzer instance; + + + /// <summary> + /// Gets the identifier string. + /// </summary> + internal string IdString { + get { + return diagnosticAnalyzerType.FullName; + } + } + + public Type DiagnosticAnalyzerType { + get { + return diagnosticAnalyzerType; + } + } + + /// <summary> + /// Gets the display name for this issue. + /// </summary> + public string Name { get; private set; } + + /// <summary> + /// Gets the description of the issue provider (used in the option panel). + /// </summary> + + /// <summary> + /// Gets the languages for this issue. + /// </summary> + public string[] Languages { get; private set; } + + public DiagnosticSeverity? DiagnosticSeverity { + get { + DiagnosticSeverity? result = null; + + foreach (var diagnostic in GetProvider ().SupportedDiagnostics) { + if (!result.HasValue) + result = GetSeverity(diagnostic); + if (result != GetSeverity(diagnostic)) + return null; + } + return result; + } + + set { + if (!value.HasValue) + return; + foreach (var diagnostic in GetProvider ().SupportedDiagnostics) { + SetSeverity (diagnostic, value.Value); + } + } + } + + /// <summary> + /// Gets or sets a value indicating whether this code action is enabled by the user. + /// </summary> + /// <value><c>true</c> if this code action is enabled; otherwise, <c>false</c>.</value> + public bool IsEnabled { + get { + foreach (var diagnostic in GetProvider ().SupportedDiagnostics) { + if (!GetIsEnabled (diagnostic)) + return false; + } + return true; + } + set { + foreach (var diagnostic in GetProvider ().SupportedDiagnostics) { + SetIsEnabled (diagnostic, value); + } + } + } + + internal DiagnosticSeverity GetSeverity (DiagnosticDescriptor diagnostic) + { + return PropertyService.Get ("CodeIssues." + Languages + "." + IdString + "." + diagnostic.Id + ".severity", diagnostic.DefaultSeverity); + } + + internal void SetSeverity (DiagnosticDescriptor diagnostic, DiagnosticSeverity severity) + { + PropertyService.Set ("CodeIssues." + Languages + "." + IdString + "." + diagnostic.Id + ".severity", severity); + } + + internal bool GetIsEnabled (DiagnosticDescriptor diagnostic) + { + return PropertyService.Get ("CodeIssues." + Languages + "." + IdString + "." + diagnostic.Id + ".enabled", true); + } + + internal void SetIsEnabled (DiagnosticDescriptor diagnostic, bool value) + { + PropertyService.Set ("CodeIssues." + Languages + "." + IdString + "." + diagnostic.Id + ".enabled", value); + } + + internal CodeDiagnosticDescriptor (Microsoft.CodeAnalysis.DiagnosticDescriptor descriptor, string[] languages, Type codeIssueType) + { + if (descriptor == null) + throw new ArgumentNullException ("descriptor"); + if (languages == null) + throw new ArgumentNullException ("languages"); + if (codeIssueType == null) + throw new ArgumentNullException ("codeIssueType"); + Name = descriptor.Title.ToString () ?? "unnamed"; + Languages = languages; + this.descriptor = descriptor; + this.diagnosticAnalyzerType = codeIssueType; + } + + /// <summary> + /// Gets the roslyn code action provider. + /// </summary> + public DiagnosticAnalyzer GetProvider () + { + if (instance == null) + instance = (DiagnosticAnalyzer)Activator.CreateInstance(diagnosticAnalyzerType); + + return instance; + } + + public override string ToString () + { + return string.Format ("[CodeIssueDescriptor: IdString={0}, Name={1}, Language={2}]", IdString, Name, Languages); + } + + public bool CanDisableWithPragma { get { return !string.IsNullOrEmpty (descriptor.Id); } } + + const string analysisDisableTag = "Analysis "; + + public void DisableWithPragma (TextEditor editor, DocumentContext context, TextSpan span) + { + using (editor.OpenUndoGroup ()) { + var start = editor.OffsetToLocation (span.Start); + var end = editor.OffsetToLocation (span.End); + editor.InsertText ( + editor.LocationToOffset (end.Line + 1, 1), + editor.GetVirtualIndentationString (end.Line) + "#pragma warning restore " + descriptor.Id + editor.EolMarker + ); + editor.InsertText ( + editor.LocationToOffset (start.Line, 1), + editor.GetVirtualIndentationString (start.Line) + "#pragma warning disable " + descriptor.Id + editor.EolMarker + ); + } + } + } +} + diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeDiagnosticFixDescriptor.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeDiagnosticFixDescriptor.cs new file mode 100644 index 0000000000..7f26e14572 --- /dev/null +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeDiagnosticFixDescriptor.cs @@ -0,0 +1,89 @@ +// +// CodeFixDescriptor.cs +// +// Author: +// Mike Krüger <mkrueger@xamarin.com> +// +// Copyright (c) 2014 Xamarin Inc. (http://xamarin.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using Microsoft.CodeAnalysis.CodeFixes; +using Microsoft.CodeAnalysis.Diagnostics; +using System.Linq; +using MonoDevelop.Core; + +namespace MonoDevelop.CodeIssues +{ + class CodeDiagnosticFixDescriptor + { + readonly Type codeFixProviderType; + readonly ExportCodeFixProviderAttribute attribute; + CodeFixProvider instance; + + public string Name { + get { + return attribute.Name; + } + } + + public string[] Languages { + get { + return attribute.Languages; + } + } + + internal CodeDiagnosticFixDescriptor (Type codeFixProviderType, ExportCodeFixProviderAttribute attribute) + { + if (codeFixProviderType == null) + throw new ArgumentNullException ("codeFixProviderType"); + if (attribute == null) + throw new ArgumentNullException ("attribute"); + this.codeFixProviderType = codeFixProviderType; + this.attribute = attribute; + } + + public CodeFixProvider GetCodeFixProvider () + { + if (instance == null) { + try { + instance = (CodeFixProvider)Activator.CreateInstance (codeFixProviderType); + } catch (InvalidCastException e) { + LoggingService.LogError (codeFixProviderType + " can't be cast to CodeFixProvider."); + throw; + } + } + + return instance; + } + + public CodeDiagnosticDescriptor GetCodeDiagnosticDescriptor (string language) + { + var fixableIds = GetCodeFixProvider ().FixableDiagnosticIds.ToList (); + + foreach (var descriptor in BuiltInCodeDiagnosticProvider.GetBuiltInCodeDiagnosticDecsriptorsAsync (language).Result) { + if (descriptor.GetProvider ().SupportedDiagnostics.Any (diagnostic => fixableIds.Contains (diagnostic.Id))) + return descriptor; + + } + return null; + + } + } +} diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/ICodeIssueProviderSource.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeDiagnosticProvider.cs index 39ddd1a037..3cb3dd1da5 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/ICodeIssueProviderSource.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeDiagnosticProvider.cs @@ -1,21 +1,21 @@ -// -// ICodeIssueProviderSource.cs -// +// +// CodeDiagnosticProvider.cs +// // Author: // Mike Krüger <mkrueger@xamarin.com> -// -// Copyright (c) 2012 Xamarin Inc. (http://xamarin.com) -// +// +// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com) +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: -// +// // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -23,23 +23,23 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. + using System.Collections.Generic; using System.Threading; -using MonoDevelop.Ide.TypeSystem; -using MonoDevelop.Projects; -using Mono.TextEditor; +using MonoDevelop.CodeIssues; +using System.Threading.Tasks; +using MonoDevelop.Ide.Editor; +using MonoDevelop.CodeActions; namespace MonoDevelop.CodeIssues { /// <summary> - /// A code issue provider source provides a way for language backends to add a set of generated code issue providers. + /// The code diagnostic provider gives a list of code diagnostic & fix providers from an arbitrary source. /// </summary> - public interface ICodeIssueProviderSource + abstract class CodeDiagnosticProvider { - /// <summary> - /// Gets the providers. - /// </summary> - IEnumerable<CodeIssueProvider> GetProviders (); + public abstract Task<IEnumerable<CodeDiagnosticDescriptor>> GetCodeDiagnosticDescriptorsAsync (DocumentContext document, string language, CancellationToken cancellationToken = default (CancellationToken)); + public abstract Task<IEnumerable<CodeDiagnosticFixDescriptor>> GetCodeFixDescriptorsAsync (DocumentContext document, string language, CancellationToken cancellationToken = default (CancellationToken)); + public abstract Task<IEnumerable<CodeRefactoringDescriptor>> GetCodeRefactoringDescriptorsAsync (DocumentContext document, string language, CancellationToken cancellationToken = default (CancellationToken)); } -} - +}
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeDiagnosticRunner.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeDiagnosticRunner.cs new file mode 100644 index 0000000000..233ae1fc6f --- /dev/null +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeDiagnosticRunner.cs @@ -0,0 +1,108 @@ +// +// CodeAnalysisRunner.cs +// +// Author: +// Mike Krüger <mkrueger@xamarin.com> +// +// Copyright (c) 2012 Xamarin Inc. (http://xamarin.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +//#define PROFILE +using System; +using System.Linq; +using MonoDevelop.AnalysisCore; +using System.Collections.Generic; +using MonoDevelop.Ide.Gui; +using System.Threading; +using MonoDevelop.CodeIssues; +using Microsoft.CodeAnalysis.Diagnostics; +using Microsoft.CodeAnalysis.CodeFixes; +using MonoDevelop.CodeActions; +using MonoDevelop.Core; +using MonoDevelop.AnalysisCore.Gui; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis; +using System.Threading.Tasks; + +namespace MonoDevelop.CodeIssues +{ + static class CodeDiagnosticRunner + { + public static IEnumerable<Result> Check (AnalysisDocument analysisDocument, CancellationToken cancellationToken) + { + var input = analysisDocument.DocumentContext; + if (!AnalysisOptions.EnableFancyFeatures || input.Project == null || !input.IsCompileableInProject || input.AnalysisDocument == null) + return Enumerable.Empty<Result> (); + try { + var model = input.ParsedDocument.GetAst<SemanticModel> (); + if (model == null) + return Enumerable.Empty<Result> (); + var compilation = model.Compilation; + var language = CodeRefactoringService.MimeTypeToLanguage (analysisDocument.Editor.MimeType); + + var providers = new List<DiagnosticAnalyzer> (); + var alreadyAdded = new HashSet<Type>(); + var diagnostics = CodeRefactoringService.GetCodeDiagnosticsAsync (analysisDocument.DocumentContext, language, cancellationToken); + foreach (var diagnostic in diagnostics.Result) { + if (alreadyAdded.Contains (diagnostic.DiagnosticAnalyzerType)) + continue; + alreadyAdded.Add (diagnostic.DiagnosticAnalyzerType); + var provider = diagnostic.GetProvider (); + providers.Add (provider); + } + if (providers.Count == 0 || cancellationToken.IsCancellationRequested) + return Enumerable.Empty<Result> (); + var localCompilation = CSharpCompilation.Create ( + compilation.AssemblyName, + new[] { model.SyntaxTree }, + compilation.References, + (CSharpCompilationOptions)compilation.Options + ); + + CompilationWithAnalyzers compilationWithAnalyzer; + try { + compilationWithAnalyzer = localCompilation.WithAnalyzers (System.Collections.Immutable.ImmutableArray<DiagnosticAnalyzer>.Empty.AddRange (providers), null, cancellationToken); + } catch (Exception) { + return Enumerable.Empty<Result> (); + } + + if (input.ParsedDocument == null || cancellationToken.IsCancellationRequested) + return Enumerable.Empty<Result> (); + var diagnosticList = new List<Diagnostic> (); + diagnosticList.AddRange (compilationWithAnalyzer.GetAnalyzerDiagnosticsAsync ().Result); + return diagnosticList + .Where (d => !d.Id.StartsWith("CS", StringComparison.Ordinal)) + .Select (diagnostic => { + var res = new DiagnosticResult(diagnostic); + // var line = analysisDocument.Editor.GetLineByOffset (res.Region.Start); + // Console.WriteLine (diagnostic.Id + "/" + res.Region +"/" + analysisDocument.Editor.GetTextAt (line)); + return res; + }); + } catch (OperationCanceledException) { + return Enumerable.Empty<Result> (); + } catch (AggregateException ae) { + ae.Flatten ().Handle (ix => ix is OperationCanceledException); + return Enumerable.Empty<Result> (); + } catch (Exception e) { + LoggingService.LogError ("Error while running diagnostics.", e); + return Enumerable.Empty<Result> (); + } + } + } +}
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeIssue.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeIssue.cs deleted file mode 100644 index 846f4dc678..0000000000 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeIssue.cs +++ /dev/null @@ -1,108 +0,0 @@ -// -// CodeIssue.cs -// -// Author: -// Mike Krüger <mkrueger@xamarin.com> -// -// Copyright (c) 2012 Xamarin Inc. (http://xamarin.com) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -using System; -using Mono.TextEditor; -using System.Collections.Generic; -using ICSharpCode.NRefactory.CSharp.Refactoring; -using ICSharpCode.NRefactory.TypeSystem; -using ICSharpCode.NRefactory.Refactoring; - -namespace MonoDevelop.CodeIssues -{ - /// <summary> - /// A code issue marks an issue inside a text editor. An issue is a description shown in the tooltip and - /// (optionally) a set of code actions to solve the issue. - /// </summary> - public class CodeIssue - { - /// <summary> - /// Gets or sets the description shown in the tooltip. - /// </summary> - public string Description { - get; - private set; - } - - /// <summary> - /// Gets or sets the region of the issue. - /// </summary> - public DomRegion Region { - get; - private set; - } - - - - /// <summary> - /// Gets or sets a value indicating how this issue should be marked inside the text editor. - /// Note: There is only one code issue provider generated therfore providers need to be state less. - /// </summary> - public IssueMarker IssueMarker { get; private set; } - - - /// <summary> - /// Gets or sets the code actions to solve the issue. - /// </summary> - public IEnumerable<MonoDevelop.CodeActions.CodeAction> Actions { - get; - private set; - } - - public string InspectorIdString { - get; - private set; - } - - /// <summary> - /// Gets or sets the code action providers for this issue. - /// </summary> - public IList<Type> ActionProvider { - get; - set; - } - - /// <summary> - /// Initializes a new instance of the <see cref="MonoDevelop.CodeIssues.CodeIssue"/> class. - /// </summary> - public CodeIssue (IssueMarker issueMarker, string description, string fileName, DocumentLocation start, DocumentLocation end, string inspectorIdString, IEnumerable<MonoDevelop.CodeActions.CodeAction> actions = null) : this (issueMarker, description, new DomRegion (fileName, start, end), inspectorIdString, actions) - { - } - - /// <summary> - /// Initializes a new instance of the <see cref="MonoDevelop.CodeIssues.CodeIssue"/> class. - /// </summary> - public CodeIssue (IssueMarker issueMarker, string description, DomRegion region, string inspectorIdString, IEnumerable<MonoDevelop.CodeActions.CodeAction> actions = null) - { - IssueMarker = issueMarker; - Description = description; - Region = region; - Actions = actions; - InspectorIdString = inspectorIdString; - } - - } -} - diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeIssueAddinNode.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeIssueAddinNode.cs deleted file mode 100644 index d8aee4e498..0000000000 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeIssueAddinNode.cs +++ /dev/null @@ -1,68 +0,0 @@ -// -// InspectorAddinNode.cs -// -// Author: -// Mike Krüger <mkrueger@novell.com> -// -// Copyright (c) 2011 Novell, Inc (http://www.novell.com) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -using System; -using MonoDevelop.SourceEditor; -using Mono.Addins; -using MonoDevelop.Core; -using MonoDevelop.SourceEditor.QuickTasks; -using ICSharpCode.NRefactory.CSharp; -using ICSharpCode.NRefactory.Refactoring; - -namespace MonoDevelop.CodeIssues -{ - public class CodeIssueAddinNode : TypeExtensionNode - { - [NodeAttribute ("mimeType", Required=true, Description="The mime type of this action.")] - string mimeType = null; - public string MimeType { - get { - return mimeType; - } - } - - [NodeAttribute ("severity", Required=true, Localizable=false, Description="The severity of this action.")] - Severity severity; - public Severity Severity { - get { - return severity; - } - } - - CodeIssueProvider inspector; - public CodeIssueProvider Inspector { - get { - if (inspector == null) { - inspector = (CodeIssueProvider)CreateInstance (); - inspector.DefaultSeverity = severity; - inspector.SetMimeType (MimeType); - } - return inspector; - } - } - - } -} - diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeIssuePanelWidget.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeIssuePanelWidget.cs index 241f9281f6..b9d01f4337 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeIssuePanelWidget.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeIssuePanelWidget.cs @@ -28,14 +28,14 @@ using MonoDevelop.Ide.Gui.Dialogs; using Gtk; using MonoDevelop.Core; using System.Linq; -using MonoDevelop.SourceEditor; using MonoDevelop.Refactoring; using System.Collections.Generic; -using Mono.TextEditor; -using ICSharpCode.NRefactory.Refactoring; using GLib; using MonoDevelop.Components; using Gdk; +using MonoDevelop.Ide.Editor; +using MonoDevelop.CodeActions; +using Microsoft.CodeAnalysis; using MonoDevelop.SourceEditor.QuickTasks; namespace MonoDevelop.CodeIssues @@ -73,19 +73,21 @@ namespace MonoDevelop.CodeIssues partial class CodeIssuePanelWidget : Bin { readonly string mimeType; - readonly TreeStore treeStore = new TreeStore (typeof(string), typeof(BaseCodeIssueProvider), typeof (string)); - readonly Dictionary<BaseCodeIssueProvider, Severity> severities = new Dictionary<BaseCodeIssueProvider, Severity> (); - readonly Dictionary<BaseCodeIssueProvider, bool> enableState = new Dictionary<BaseCodeIssueProvider, bool> (); + readonly TreeStore treeStore = new TreeStore (typeof(string), typeof(Tuple<CodeDiagnosticDescriptor, DiagnosticDescriptor>), typeof (string)); + readonly Dictionary<Tuple<CodeDiagnosticDescriptor, DiagnosticDescriptor>, DiagnosticSeverity?> severities = new Dictionary<Tuple<CodeDiagnosticDescriptor, DiagnosticDescriptor>, DiagnosticSeverity?> (); + readonly Dictionary<Tuple<CodeDiagnosticDescriptor, DiagnosticDescriptor>, bool> enableState = new Dictionary<Tuple<CodeDiagnosticDescriptor, DiagnosticDescriptor>, bool> (); void GetAllSeverities () { - foreach (var node in RefactoringService.GetInspectors (mimeType)) { - severities [node] = node.GetSeverity (); - enableState [node] = node.GetIsEnabled (); - if (node.HasSubIssues) { - foreach (var subIssue in node.SubIssues) { - severities [subIssue] = subIssue.GetSeverity (); - enableState [subIssue] = subIssue.GetIsEnabled (); + foreach (var node in BuiltInCodeDiagnosticProvider.GetBuiltInCodeDiagnosticDecsriptorsAsync (CodeRefactoringService.MimeTypeToLanguage (mimeType), true).Result) { + var root = new Tuple<CodeDiagnosticDescriptor, DiagnosticDescriptor> (node, null); + severities [root] = node.DiagnosticSeverity; + enableState [root] = node.IsEnabled; + if (node.GetProvider ().SupportedDiagnostics.Length > 1) { + foreach (var subIssue in node.GetProvider ().SupportedDiagnostics) { + var sub = new Tuple<CodeDiagnosticDescriptor, DiagnosticDescriptor> (node, subIssue); + severities [sub] = node.GetSeverity (subIssue); + enableState [sub] = node.GetIsEnabled (subIssue); } } } @@ -102,8 +104,8 @@ namespace MonoDevelop.CodeIssues bool SelectCodeIssue (string idString, TreeIter iter) { do { - var provider = treeStore.GetValue (iter, 1) as BaseCodeIssueProvider; - if (provider != null && provider.IdString == idString) { + var provider = (Tuple<CodeDiagnosticDescriptor, DiagnosticDescriptor>)treeStore.GetValue (iter, 1); + if (provider != null && idString == provider.Item1.IdString) { treeviewInspections.ExpandToPath (treeStore.GetPath (iter)); treeviewInspections.Selection.SelectIter (iter); return true; @@ -120,33 +122,30 @@ namespace MonoDevelop.CodeIssues return false; } - static string GetDescription (Severity severity) + static string GetDescription (DiagnosticSeverity severity) { switch (severity) { - case Severity.None: + case DiagnosticSeverity.Hidden: return GettextCatalog.GetString ("Do not show"); - case Severity.Error: + case DiagnosticSeverity.Error: return GettextCatalog.GetString ("Error"); - case Severity.Warning: + case DiagnosticSeverity.Warning: return GettextCatalog.GetString ("Warning"); - case Severity.Hint: - return GettextCatalog.GetString ("Hint"); - case Severity.Suggestion: - return GettextCatalog.GetString ("Suggestion"); + case DiagnosticSeverity.Info: + return GettextCatalog.GetString ("Info"); default: throw new ArgumentOutOfRangeException (); } } - Xwt.Drawing.Image GetIcon (Severity severity) + Xwt.Drawing.Image GetIcon (DiagnosticSeverity severity) { switch (severity) { - case Severity.Error: + case DiagnosticSeverity.Error: return QuickTaskOverviewMode.ErrorImage; - case Severity.Warning: + case DiagnosticSeverity.Warning: return QuickTaskOverviewMode.WarningImage; - case Severity.Hint: - case Severity.Suggestion: + case DiagnosticSeverity.Info: return QuickTaskOverviewMode.SuggestionImage; default: return QuickTaskOverviewMode.OkImage; @@ -157,25 +156,24 @@ namespace MonoDevelop.CodeIssues { categories.Clear (); treeStore.Clear (); - - var grouped = severities.Keys.OfType<CodeIssueProvider> () - .Where (node => string.IsNullOrEmpty (filter) || node.Title.IndexOf (filter, StringComparison.OrdinalIgnoreCase) > 0) - .GroupBy (node => node.Category) + var grouped = severities.Keys + .Where (node => node.Item2 == null && (string.IsNullOrEmpty (filter) || node.Item1.Name.IndexOf (filter, StringComparison.OrdinalIgnoreCase) > 0)) + .GroupBy (node => node.Item1.GetProvider ().SupportedDiagnostics.First ().Category) .OrderBy (g => g.Key, StringComparer.Ordinal); foreach (var g in grouped) { TreeIter categoryIter = treeStore.AppendValues ("<b>" + g.Key + "</b>", null, null); categories [g.Key] = categoryIter; - foreach (var node in g.OrderBy (n => n.Title, StringComparer.Ordinal)) { - var title = node.Title; + foreach (var node in g.OrderBy (n => n.Item1.Name, StringComparer.Ordinal)) { + var title = node.Item1.Name; MarkupSearchResult (filter, ref title); - var nodeIter = treeStore.AppendValues (categoryIter, title, node, node.Description); - if (node.HasSubIssues) { - foreach (var subIssue in node.SubIssues) { - title = subIssue.Title; + var nodeIter = treeStore.AppendValues (categoryIter, title, node, node.Item1.Name); + if (node.Item1.GetProvider ().SupportedDiagnostics.Length > 1) { + foreach (var subIssue in node.Item1.GetProvider ().SupportedDiagnostics) { + title = subIssue.Description.ToString (); MarkupSearchResult (filter, ref title); - treeStore.AppendValues (nodeIter, title, subIssue, subIssue.Description); + treeStore.AppendValues (nodeIter, title, new Tuple<CodeDiagnosticDescriptor, DiagnosticDescriptor> (node.Item1, subIssue), subIssue.Description); } } } @@ -241,7 +239,7 @@ namespace MonoDevelop.CodeIssues toggleRenderer.Toggled += delegate(object o, ToggledArgs args) { TreeIter iter; if (treeStore.GetIterFromString (out iter, args.Path)) { - var provider = (BaseCodeIssueProvider)treeStore.GetValue (iter, 1); + var provider = (Tuple<CodeDiagnosticDescriptor, DiagnosticDescriptor>)treeStore.GetValue (iter, 1); enableState[provider] = !enableState[provider]; } }; @@ -251,7 +249,7 @@ namespace MonoDevelop.CodeIssues titleCol.PackStart (toggleRenderer, false); titleCol.Sizing = TreeViewColumnSizing.Autosize; titleCol.SetCellDataFunc (toggleRenderer, delegate (TreeViewColumn treeColumn, CellRenderer cell, TreeModel model, TreeIter iter) { - var provider = (BaseCodeIssueProvider)model.GetValue (iter, 1); + var provider = (Tuple<CodeDiagnosticDescriptor, DiagnosticDescriptor>)treeStore.GetValue (iter, 1); if (provider == null) { toggleRenderer.Visible = false; return; @@ -284,12 +282,11 @@ namespace MonoDevelop.CodeIssues col.MinWidth = 100; col.Expand = false; - var comboBoxStore = new ListStore (typeof(string), typeof(Severity)); + var comboBoxStore = new ListStore (typeof(string), typeof(DiagnosticSeverity)); // comboBoxStore.AppendValues (GetDescription (Severity.None), Severity.None); - comboBoxStore.AppendValues (GetDescription (Severity.Error), Severity.Error); - comboBoxStore.AppendValues (GetDescription (Severity.Warning), Severity.Warning); - comboBoxStore.AppendValues (GetDescription (Severity.Hint), Severity.Hint); - comboBoxStore.AppendValues (GetDescription (Severity.Suggestion), Severity.Suggestion); + comboBoxStore.AppendValues (GetDescription (DiagnosticSeverity.Error), DiagnosticSeverity.Error); + comboBoxStore.AppendValues (GetDescription (DiagnosticSeverity.Warning), DiagnosticSeverity.Warning); + comboBoxStore.AppendValues (GetDescription (DiagnosticSeverity.Info), DiagnosticSeverity.Info); comboRenderer.Model = comboBoxStore; comboRenderer.Mode = CellRendererMode.Activatable; comboRenderer.TextColumn = 0; @@ -307,8 +304,8 @@ namespace MonoDevelop.CodeIssues return; do { if ((string)comboBoxStore.GetValue (storeIter, 0) == args.NewText) { - var provider = (BaseCodeIssueProvider)treeStore.GetValue (iter, 1); - var severity = (Severity)comboBoxStore.GetValue (storeIter, 1); + var provider = (Tuple<CodeDiagnosticDescriptor, DiagnosticDescriptor>)treeStore.GetValue (iter, 1); + var severity = (DiagnosticSeverity)comboBoxStore.GetValue (storeIter, 1); severities[provider] = severity; return; } @@ -316,15 +313,19 @@ namespace MonoDevelop.CodeIssues }; col.SetCellDataFunc (comboRenderer, delegate (TreeViewColumn treeColumn, CellRenderer cell, TreeModel model, TreeIter iter) { - var provider = (BaseCodeIssueProvider)model.GetValue (iter, 1); + var provider = (Tuple<CodeDiagnosticDescriptor, DiagnosticDescriptor>)treeStore.GetValue (iter, 1); if (provider == null) { comboRenderer.Visible = false; return; } var severity = severities[provider]; + if (!severity.HasValue) { + comboRenderer.Visible = false; + return; + } comboRenderer.Visible = true; - comboRenderer.Text = GetDescription (severity); - comboRenderer.Icon = GetIcon (severity); + comboRenderer.Text = GetDescription (severity.Value); + comboRenderer.Icon = GetIcon (severity.Value); }); treeviewInspections.HeadersVisible = false; treeviewInspections.Model = treeStore; @@ -342,10 +343,25 @@ namespace MonoDevelop.CodeIssues public void ApplyChanges () { - foreach (var kv in severities) - kv.Key.SetSeverity (kv.Value); - foreach (var kv in enableState) - kv.Key.SetIsEnabled (kv.Value); + foreach (var kv in severities) { + var userSeverity = kv.Value; + if (!userSeverity.HasValue) + continue; + if (kv.Key.Item2 == null) { + kv.Key.Item1.DiagnosticSeverity = userSeverity; + continue; + } + kv.Key.Item1.SetSeverity (kv.Key.Item2, userSeverity.Value); + } + + foreach (var kv in enableState) { + var userIsEnabled = kv.Value; + if (kv.Key.Item2 == null) { + kv.Key.Item1.IsEnabled = userIsEnabled; + continue; + } + kv.Key.Item1.SetIsEnabled (kv.Key.Item2, userIsEnabled); + } } } -}
\ No newline at end of file +} diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeIssueProvider.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeIssueProvider.cs deleted file mode 100644 index d9a2abe2ef..0000000000 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeIssueProvider.cs +++ /dev/null @@ -1,207 +0,0 @@ -// -// IInspector.cs -// -// Author: -// Mike Krüger <mkrueger@xamarin.com> -// -// Copyright (c) 2012 Xamarin <http://xamarin.com> -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -using System.Collections.Generic; -using System.Threading; -using MonoDevelop.Core; -using ICSharpCode.NRefactory.Refactoring; -using Mono.TextEditor; -using System; - -namespace MonoDevelop.CodeIssues -{ - public abstract class BaseCodeIssueProvider - { - public virtual CodeIssueProvider Parent { - get { - return null; - } - } - /// <summary> - /// Gets or sets the type of the MIME the provider is attached to. - /// </summary> - public abstract string MimeType { - get; - } - - /// <summary> - /// Gets or sets the title of the issue provider (used in the option panel). - /// </summary> - public string Title { get; set; } - - /// <summary> - /// Gets or sets the description of the issue provider (used in the option panel). - /// </summary> - public string Description { get; set; } - - - /// <summary> - /// Gets the identifier string used as property ID tag. - /// </summary> - public virtual string IdString { - get { - return "refactoring.codeissues." + MimeType + "." + GetType ().FullName; - } - } - - /// <summary> - /// Gets or sets the default severity. Note that GetSeverity () should be called to get the valid value inside the IDE. - /// </summary> - public Severity DefaultSeverity { get; set; } - - /// <summary> - /// Gets or sets a value indicating whether this issue is enabled. Note that GetIsEnabled () should be called to get the valid value inside the IDE. - /// </summary> - /// <value><c>true</c> if this instance is enabled; otherwise, <c>false</c>.</value> - public bool IsEnabledByDefault { get; set; } - - /// <summary> - /// Gets the current (user defined) severity. - /// </summary> - protected Severity severity; - - public Severity GetSeverity () - { - return severity; - } - - /// <summary> - /// Sets the user defined severity. - /// </summary> - public void SetSeverity (Severity severity) - { - if (this.severity == severity) - return; - this.severity = severity; - PropertyService.Set (IdString, severity); - } - - - protected bool isEnabled; - - public bool GetIsEnabled () - { - return isEnabled; - } - - /// <summary> - /// Sets the user defined severity. - /// </summary> - public void SetIsEnabled (bool isEnabled) - { - if (this.isEnabled == isEnabled) - return; - this.isEnabled = isEnabled; - PropertyService.Set (IdString + ".isEnabled", isEnabled); - } - - protected void UpdateSeverity () - { - severity = PropertyService.Get<Severity> (IdString, DefaultSeverity); - isEnabled = PropertyService.Get<bool> (IdString+ ".isEnabled", IsEnabledByDefault); - } - - /// <summary> - /// Gets all the code issues inside a document. - /// </summary> - public abstract IEnumerable<CodeIssue> GetIssues (object refactoringContext, CancellationToken cancellationToken); - - public virtual bool CanDisableOnce { get { return false; } } - - public virtual bool CanDisableAndRestore { get { return false; } } - - public virtual bool CanDisableWithPragma { get { return false; } } - - public virtual bool CanSuppressWithAttribute { get { return false; } } - - public virtual void DisableOnce (MonoDevelop.Ide.Gui.Document document, DocumentRegion loc) - { - throw new NotSupportedException (); - } - - public virtual void DisableAndRestore (MonoDevelop.Ide.Gui.Document document, DocumentRegion loc) - { - throw new NotSupportedException (); - } - - public virtual void DisableWithPragma (MonoDevelop.Ide.Gui.Document document, DocumentRegion loc) - { - throw new NotSupportedException (); - } - - public virtual void SuppressWithAttribute (MonoDevelop.Ide.Gui.Document document, DocumentRegion loc) - { - throw new NotSupportedException (); - } - } - - - /// <summary> - /// A code issue provider is a factory that creates code issues of a given document. - /// </summary> - public abstract class CodeIssueProvider : BaseCodeIssueProvider - { - string mimeType; - public override string MimeType { - get { - return mimeType; - } - } - - public void SetMimeType (string mimeType) - { - this.mimeType = mimeType; - UpdateSeverity (); - } - - /// <summary> - /// Gets or sets the category of the issue provider (used in the option panel). - /// </summary> - public string Category { get; set; } - - /// <summary> - /// If true this issue has sub issues. - /// </summary> - public abstract bool HasSubIssues { get; } - - /// <summary> - /// Gets the sub issues of this issue. If HasSubIssus == false an InvalidOperationException is thrown. - /// </summary> - public virtual IEnumerable<BaseCodeIssueProvider> SubIssues { get { throw new InvalidOperationException (); } } - - /// <summary> - /// Gets the effective set of providers. The effective set of providers - /// is either the sub issues (if it has sub issues) or simply itself (otherwise). - /// </summary> - /// <returns>The effective provider set.</returns> - public IEnumerable<BaseCodeIssueProvider> GetEffectiveProviderSet() - { - if (HasSubIssues) - return SubIssues; - return new[] { this }; - } - } -} - diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/DefaultCodeIssueCategories.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/DefaultCodeIssueCategories.cs deleted file mode 100644 index 68f473ed32..0000000000 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/DefaultCodeIssueCategories.cs +++ /dev/null @@ -1,44 +0,0 @@ -// -// DefaultInspectionCategories.cs -// -// Author: -// Mike Krüger <mkrueger@xamarin.com> -// -// Copyright (c) 2012 Xamarin <http://xamarin.com> -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -using System; -using MonoDevelop.Core; - -namespace MonoDevelop.CodeIssues -{ - /// <summary> - /// Default code issue categories provide strings to common categories used in the code issue options panel. - /// </summary> - public static class DefaultCodeIssueCategories - { - public readonly static string Improvements = GettextCatalog.GetString ("Code Improvements"); - public readonly static string CodeQualityIssues = GettextCatalog.GetString ("Code Quality Issues"); - public readonly static string ConstraintViolations = GettextCatalog.GetString ("Constraint Violations"); - public readonly static string Redundancies = GettextCatalog.GetString ("Redundancies"); - public readonly static string Opportunities = GettextCatalog.GetString ("Language Usage Opportunities"); - public readonly static string Notifications = GettextCatalog.GetString ("Code Notifications"); - } -} - diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/DiagnosticResult.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/DiagnosticResult.cs new file mode 100644 index 0000000000..f14a822101 --- /dev/null +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/DiagnosticResult.cs @@ -0,0 +1,77 @@ +// +// CodeAnalysisRunner.cs +// +// Author: +// Mike Krüger <mkrueger@xamarin.com> +// +// Copyright (c) 2012 Xamarin Inc. (http://xamarin.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +//#define PROFILE +using System; +using MonoDevelop.AnalysisCore; +using ICSharpCode.NRefactory6.CSharp; +using Microsoft.CodeAnalysis.Text; +using Microsoft.CodeAnalysis; + +namespace MonoDevelop.CodeIssues +{ + class DiagnosticResult : Result + { + readonly Diagnostic diagnostic; + + public Diagnostic Diagnostic { + get { + return diagnostic; + } + } + + public DiagnosticResult (Diagnostic diagnostic) : base (GetSpan (diagnostic), diagnostic.GetMessage ()) + { + if (diagnostic == null) + throw new ArgumentNullException ("diagnostic"); + this.diagnostic = diagnostic; + + SetSeverity (diagnostic.Severity, GetIssueMarker ()); + } + + static TextSpan GetSpan (Diagnostic diagnostic) + { + int start = diagnostic.Location.SourceSpan.Start; + int end = diagnostic.Location.SourceSpan.End; + + foreach (var loc in diagnostic.AdditionalLocations) { + start = Math.Min (start, loc.SourceSpan.Start); + end = Math.Max (start, loc.SourceSpan.End); + } + + return TextSpan.FromBounds (start, end); + } + + IssueMarker GetIssueMarker () + { + if (diagnostic.Descriptor.Category == DiagnosticAnalyzerCategories.RedundanciesInCode || diagnostic.Descriptor.Category == DiagnosticAnalyzerCategories.RedundanciesInDeclarations) + return IssueMarker.GrayOut; + if (diagnostic.Severity == DiagnosticSeverity.Info) + return IssueMarker.DottedLine; + return IssueMarker.WavedLine; + } + } +} + diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/AbstractGroupingProvider.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/AbstractGroupingProvider.cs index 3f7cd390c7..3f7cd390c7 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/AbstractGroupingProvider.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/AbstractGroupingProvider.cs diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/ActionSummary.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/ActionSummary.cs index 42eda56ce6..7a560e69fd 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/ActionSummary.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/ActionSummary.cs @@ -23,11 +23,10 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -using Mono.TextEditor; +using MonoDevelop.Ide.Editor; namespace MonoDevelop.CodeIssues { - public class ActionSummary { /// <summary> diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/AnalysisState.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/AnalysisState.cs index 221e11d819..221e11d819 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/AnalysisState.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/AnalysisState.cs diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/AnalysisStateChangeEventArgs.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/AnalysisStateChangeEventArgs.cs index 7531189f08..7531189f08 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/AnalysisStateChangeEventArgs.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/AnalysisStateChangeEventArgs.cs diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/BatchFixer.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/BatchFixer.cs index a0d4cf4cde..c4c6491f05 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/BatchFixer.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/BatchFixer.cs @@ -36,9 +36,9 @@ using System.Threading; using MonoDevelop.Projects; using MonoDevelop.Ide.TypeSystem; using ICSharpCode.NRefactory.CSharp; -using Mono.TextEditor.Utils; using System.Text; -using Mono.TextEditor; +using MonoDevelop.Ide.Editor; +using MonoDevelop.Core.Text; namespace MonoDevelop.CodeIssues { @@ -77,10 +77,8 @@ namespace MonoDevelop.CodeIssues var fileSummaries = issueSummaries.Where (summary => summary.File == file); var inspectorIds = new HashSet<string> (fileSummaries.Select (summary => summary.InspectorIdString)); - bool hadBom; - Encoding encoding; bool isOpen; - var data = TextFileProvider.Instance.GetTextEditorData (file.FilePath, out hadBom, out encoding, out isOpen); + var data = TextFileProvider.Instance.GetTextEditorData (file.FilePath, out isOpen); IRefactoringContext refactoringContext; var realActions = GetIssues (data, file, inspectorIds, out refactoringContext).SelectMany (issue => issue.Actions).ToList (); if (realActions.Count == 0 || refactoringContext == null) @@ -94,44 +92,44 @@ namespace MonoDevelop.CodeIssues if (!isOpen) { // If the file is open we leave it to the user to explicitly save the file - TextFileUtility.WriteText (file.Name, data.Text, encoding, hadBom); + data.Save (); } }); return appliedActions; } - static IList<CodeIssue> GetIssues (TextEditorData data, ProjectFile file, ISet<string> inspectorIds, out IRefactoringContext refactoringContext) + static IList<CodeIssue> GetIssues (ITextDocument data, ProjectFile file, ISet<string> inspectorIds, out IRefactoringContext refactoringContext) { var issues = new List<CodeIssue> (); - - var document = TypeSystemService.ParseFile (file.Project, data); - if (document == null) { +// +// var document = TypeSystemService.ParseFile (file.Project, data); +// if (document == null) { refactoringContext = null; - return issues; - } - - var content = TypeSystemService.GetProjectContext (file.Project); - var compilation = content.AddOrUpdateFiles (document.ParsedFile).CreateCompilation (); - var resolver = new CSharpAstResolver (compilation, document.GetAst<SyntaxTree> (), document.ParsedFile as ICSharpCode.NRefactory.CSharp.TypeSystem.CSharpUnresolvedFile); - - refactoringContext = document.CreateRefactoringContextWithEditor (data, resolver, CancellationToken.None); - var context = refactoringContext; - foreach (var provider in GetInspectors (data, inspectorIds)) { - var severity = provider.GetSeverity (); - if (severity == Severity.None || !provider.GetIsEnabled ()) - continue; - try { - lock (issues) { - issues.AddRange (provider.GetIssues (context, CancellationToken.None)); - } - } catch (Exception ex) { - LoggingService.LogError ("Error while running code issue on: " + data.FileName, ex); - } - } +// return issues; +// } +// +// var content = TypeSystemService.GetProjectContext (file.Project); +// var compilation = content.AddOrUpdateFiles (document.ParsedFile).CreateCompilation (); +// var resolver = new CSharpAstResolver (compilation, document.GetAst<SyntaxTree> (), document.ParsedFile as ICSharpCode.NRefactory.CSharp.TypeSystem.CSharpUnresolvedFile); +// +// refactoringContext = document.CreateRefactoringContextWithEditor (data, resolver, CancellationToken.None); +// var context = refactoringContext; +// foreach (var provider in GetInspectors (data, inspectorIds)) { +// var severity = provider.GetSeverity (); +// if (severity == Severity.None || !provider.GetIsEnabled ()) +// continue; +// try { +// lock (issues) { +// issues.AddRange (provider.GetIssues (context, CancellationToken.None)); +// } +// } catch (Exception ex) { +// LoggingService.LogError ("Error while running code issue on: " + data.FileName, ex); +// } +// } return issues; } - static IList<CodeIssueProvider> GetInspectors (TextEditorData editor, ICollection<string> inspectorIds) + static IList<CodeIssueProvider> GetInspectors (IReadonlyTextDocument editor, ICollection<string> inspectorIds) { var inspectors = RefactoringService.GetInspectors (editor.MimeType).ToList (); return inspectors diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CategoryGroupingProvider.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/CategoryGroupingProvider.cs index bb7094f20d..bb7094f20d 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CategoryGroupingProvider.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/CategoryGroupingProvider.cs diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeAnalysisBatchRunner.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/CodeAnalysisBatchRunner.cs index 8463822b85..a2e9b91a5e 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeAnalysisBatchRunner.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/CodeAnalysisBatchRunner.cs @@ -39,125 +39,125 @@ using ICSharpCode.NRefactory.Refactoring; using MonoDevelop.Core; using System.Collections.Concurrent; using ICSharpCode.NRefactory.TypeSystem; -using Mono.TextEditor; using MonoDevelop.Core.Instrumentation; using MonoDevelop.Refactoring; using System.Collections.Generic; -using MonoDevelop.Core;
-
-namespace MonoDevelop.CodeIssues
-{
- public class CodeAnalysisBatchRunner
- {
- private readonly object _lock = new object ();
-
- private int workerCount;
-
- private readonly AnalysisJobQueue jobQueue = new AnalysisJobQueue ();
-
- public IJobContext QueueJob (IAnalysisJob job)
- {
- jobQueue.Add (job);
- EnsureRunning ();
- return new JobContext (job, jobQueue, this);
- }
-
- private void EnsureRunning ()
- {
- for (; Interlocked.Add (ref workerCount, 1) < Environment.ProcessorCount;) {
- new Thread (() => {
- try {
- ProcessQueue ();
- }
- finally {
- Interlocked.Add (ref workerCount, -1);
- }
- }).Start ();
- }
- }
-
- private void ProcessQueue ()
- {
- while (true) {
- try {
- using (var slice = GetSlice ()) {
- if (slice == null)
- // TODO: Do something smarter if the queue is empty
- return;
- AnalyzeFile (slice, slice.GetJobs ().SelectMany (job => job.GetIssueProviders (slice.File)));
- }
- } catch (Exception e) {
- LoggingService.LogInternalError (e);
- }
- }
- }
-
- private JobSlice GetSlice ()
- {
- lock (_lock) {
- return jobQueue.Dequeue (1).FirstOrDefault ();
- }
- }
-
- void AnalyzeFile (JobSlice item, IEnumerable<BaseCodeIssueProvider> codeIssueProviders) - { - var file = item.File; +using MonoDevelop.Core; - if (file.BuildAction != BuildAction.Compile) - return; +namespace MonoDevelop.CodeIssues +{ + public class CodeAnalysisBatchRunner + { + private readonly object _lock = new object (); - if (!(file.Project is DotNetProject)) - return; + private int workerCount; - TextEditorData editor; - try { - editor = TextFileProvider.Instance.GetReadOnlyTextEditorData (file.FilePath); - } catch (FileNotFoundException) { - // Swallow exception and ignore this file - return; - } - var document = TypeSystemService.ParseFile (file.Project, editor); - if (document == null) - return; + private readonly AnalysisJobQueue jobQueue = new AnalysisJobQueue (); - var content = TypeSystemService.GetProjectContext (file.Project); - var compilation = content.AddOrUpdateFiles (document.ParsedFile).CreateCompilation (); + public IJobContext QueueJob (IAnalysisJob job) + { + jobQueue.Add (job); + EnsureRunning (); + return new JobContext (job, jobQueue, this); + } - CSharpAstResolver resolver; - using (var timer = ExtensionMethods.ResolveCounter.BeginTiming ()) { - resolver = new CSharpAstResolver (compilation, document.GetAst<SyntaxTree> (), document.ParsedFile as ICSharpCode.NRefactory.CSharp.TypeSystem.CSharpUnresolvedFile); - try { - resolver.ApplyNavigator (new ExtensionMethods.ConstantModeResolveVisitorNavigator (ResolveVisitorNavigationMode.Resolve, null)); - } catch (Exception e) { - LoggingService.LogError ("Error while applying navigator", e); - } + private void EnsureRunning () + { + for (; Interlocked.Add (ref workerCount, 1) < Environment.ProcessorCount;) { + new Thread (() => { + try { + ProcessQueue (); + } + finally { + Interlocked.Add (ref workerCount, -1); + } + }).Start (); } - var context = document.CreateRefactoringContextWithEditor (editor, resolver, CancellationToken.None); + } - foreach (var provider in codeIssueProviders) { - if (item.CancellationToken.IsCancellationRequested) - break; - IList<IAnalysisJob> jobs; - lock (_lock) - jobs = item.GetJobs ().ToList (); - var jobsForProvider = jobs.Where (j => j.GetIssueProviders (file).Contains (provider)).ToList(); + private void ProcessQueue () + { + while (true) { try { - var issues = provider.GetIssues (context, CancellationToken.None).ToList (); - foreach (var job in jobsForProvider) { - // Call AddResult even if issues.Count == 0, to enable a job implementation to keep - // track of progress information. - job.AddResult (file, provider, issues); + using (var slice = GetSlice ()) { + if (slice == null) + // TODO: Do something smarter if the queue is empty + return; + AnalyzeFile (slice, slice.GetJobs ().SelectMany (job => job.GetIssueProviders (slice.File))); } - } catch (OperationCanceledException) { - // The operation was cancelled, no-op as the user-visible parts are - // handled elsewhere } catch (Exception e) { - foreach (var job in jobsForProvider) { - job.AddError (file, provider); - } + LoggingService.LogError ("Unhandled exception", e); + MessageService.ShowException (e); } } } + + private JobSlice GetSlice () + { + lock (_lock) { + return jobQueue.Dequeue (1).FirstOrDefault (); + } + } + + void AnalyzeFile (JobSlice item, IEnumerable<BaseCodeIssueProvider> codeIssueProviders) + { +// var file = item.File; +// +// if (file.BuildAction != BuildAction.Compile) +// return; +// +// if (!(file.Project is DotNetProject)) +// return; +// +// TextEditorData editor; +// try { +// editor = TextFileProvider.Instance.GetReadOnlyTextEditorData (file.FilePath); +// } catch (FileNotFoundException) { +// // Swallow exception and ignore this file +// return; +// } +// var document = TypeSystemService.ParseFile (file.Project, editor); +// if (document == null) +// return; +// +// var content = TypeSystemService.GetProjectContext (file.Project); +// var compilation = content.AddOrUpdateFiles (document.ParsedFile).CreateCompilation (); +// +// CSharpAstResolver resolver; +// using (var timer = ExtensionMethods.ResolveCounter.BeginTiming ()) { +// resolver = new CSharpAstResolver (compilation, document.GetAst<SyntaxTree> (), document.ParsedFile as ICSharpCode.NRefactory.CSharp.TypeSystem.CSharpUnresolvedFile); +// try { +// resolver.ApplyNavigator (new ExtensionMethods.ConstantModeResolveVisitorNavigator (ResolveVisitorNavigationMode.Resolve, null)); +// } catch (Exception e) { +// LoggingService.LogError ("Error while applying navigator", e); +// } +// } +// var context = document.CreateRefactoringContextWithEditor (editor, resolver, CancellationToken.None); +// +// foreach (var provider in codeIssueProviders) { +// if (item.CancellationToken.IsCancellationRequested) +// break; +// IList<IAnalysisJob> jobs; +// lock (_lock) +// jobs = item.GetJobs ().ToList (); +// var jobsForProvider = jobs.Where (j => j.GetIssueProviders (file).Contains (provider)).ToList(); +// try { +// var issues = provider.GetIssues (context, CancellationToken.None).ToList (); +// foreach (var job in jobsForProvider) { +// // Call AddResult even if issues.Count == 0, to enable a job implementation to keep +// // track of progress information. +// job.AddResult (file, provider, issues); +// } +// } catch (OperationCanceledException) { +// // The operation was cancelled, no-op as the user-visible parts are +// // handled elsewhere +// } catch (Exception e) { +// foreach (var job in jobsForProvider) { +// job.AddError (file, provider); +// } +// } +// } + } } } diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeIssuePad.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/CodeIssuePad.cs index c875894512..c875894512 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeIssuePad.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/CodeIssuePad.cs diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/ExactIssueMatcher.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/ExactIssueMatcher.cs index 3f1db8df72..3f1db8df72 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/ExactIssueMatcher.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/ExactIssueMatcher.cs diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/FileGroupingProvider.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/FileGroupingProvider.cs index a92561d2d6..aa1d64d7cf 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/FileGroupingProvider.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/FileGroupingProvider.cs @@ -1,46 +1,46 @@ -//
-// FileGroupingProvider.cs
-//
-// Author:
-// Marius Ungureanu <marius.ungureanu@xamarin.com>
-//
-// Copyright (c) 2013 Marius Ungureanu
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using MonoDevelop.Projects;
-using MonoDevelop.Core;
-
-namespace MonoDevelop.CodeIssues
-{
- [GroupingDescription("File")]
- public class FileGroupingProvider : AbstractGroupingProvider<ProjectFile>
- {
- #region implemented abstract members of AbstractGroupingProvider
- protected override ProjectFile GetGroupingKey (IssueSummary issue)
- {
- return issue.File;
- }
- protected override string GetGroupName (IssueSummary issue)
- {
- return issue.File.FilePath.ToRelative (issue.Project.BaseDirectory);
- }
- #endregion
- }
-}
-
+// +// FileGroupingProvider.cs +// +// Author: +// Marius Ungureanu <marius.ungureanu@xamarin.com> +// +// Copyright (c) 2013 Marius Ungureanu +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using MonoDevelop.Projects; +using MonoDevelop.Core; + +namespace MonoDevelop.CodeIssues +{ + [GroupingDescription("File")] + public class FileGroupingProvider : AbstractGroupingProvider<ProjectFile> + { + #region implemented abstract members of AbstractGroupingProvider + protected override ProjectFile GetGroupingKey (IssueSummary issue) + { + return issue.File; + } + protected override string GetGroupName (IssueSummary issue) + { + return issue.File.FilePath.ToRelative (issue.Project.BaseDirectory); + } + #endregion + } +} + diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/GroupingDescriptionAttribute.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/GroupingDescriptionAttribute.cs index 720084149e..720084149e 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/GroupingDescriptionAttribute.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/GroupingDescriptionAttribute.cs diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/GroupingProviderChainControl.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/GroupingProviderChainControl.cs index 3449d7b24b..3449d7b24b 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/GroupingProviderChainControl.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/GroupingProviderChainControl.cs diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/GroupingProviderEventArgs.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/GroupingProviderEventArgs.cs index f9eee0fc87..f9eee0fc87 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/GroupingProviderEventArgs.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/GroupingProviderEventArgs.cs diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/IActionMatcher.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/IActionMatcher.cs index 8e732f596a..8e732f596a 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/IActionMatcher.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/IActionMatcher.cs diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/IGroupingProvider.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/IGroupingProvider.cs index 19b0001bf4..19b0001bf4 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/IGroupingProvider.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/IGroupingProvider.cs diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/IIssueSummarySink.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/IIssueSummarySink.cs index af1cb51c0c..af1cb51c0c 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/IIssueSummarySink.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/IIssueSummarySink.cs diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/IIssueTreeNode.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/IIssueTreeNode.cs index 68cf43ef50..68cf43ef50 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/IIssueTreeNode.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/IIssueTreeNode.cs diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/IssueGroup.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/IssueGroup.cs index 10e261b7fc..10e261b7fc 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/IssueGroup.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/IssueGroup.cs diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/IssueGroupEventArgs.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/IssueGroupEventArgs.cs index 42787d4560..42787d4560 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/IssueGroupEventArgs.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/IssueGroupEventArgs.cs diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/IssueMatch.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/IssueMatch.cs index fbdaafcd57..fbdaafcd57 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/IssueMatch.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/IssueMatch.cs diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/IssueSummary.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/IssueSummary.cs index bb022e92a8..5e7c4d201c 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/IssueSummary.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/IssueSummary.cs @@ -53,10 +53,10 @@ namespace MonoDevelop.CodeIssues InspectorIdString = codeIssue.InspectorIdString }; issueSummary.Actions = codeIssue.Actions.Select (a => new ActionSummary { - Batchable = a.SupportsBatchRunning, - SiblingKey = a.SiblingKey, - Title = a.Title, - Region = a.DocumentRegion, +// Batchable = a.SupportsBatchRunning, +// SiblingKey = a.SiblingKey, +// Title = a., +// Region = a.DocumentRegion, IssueSummary = issueSummary }).ToList (); return issueSummary; diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/IssueTreeNodeEventArgs.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/IssueTreeNodeEventArgs.cs index 37d663f252..37d663f252 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/IssueTreeNodeEventArgs.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/IssueTreeNodeEventArgs.cs diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/NullGroupingProvider.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/NullGroupingProvider.cs index 677d9989c6..677d9989c6 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/NullGroupingProvider.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/NullGroupingProvider.cs diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/ProjectGroupingProvider.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/ProjectGroupingProvider.cs index 7ca19ba063..7ca19ba063 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/ProjectGroupingProvider.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/ProjectGroupingProvider.cs diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/ProviderGroupingProvider.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/ProviderGroupingProvider.cs index 7cdf46e461..7cdf46e461 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/ProviderGroupingProvider.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/ProviderGroupingProvider.cs diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Runner/AnalysisJobQueue.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/Runner/AnalysisJobQueue.cs index cdb3182fbb..cdb3182fbb 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Runner/AnalysisJobQueue.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/Runner/AnalysisJobQueue.cs diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Runner/CodeIssueEventArgs.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/Runner/CodeIssueEventArgs.cs index 53e3a29f8b..53e3a29f8b 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Runner/CodeIssueEventArgs.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/Runner/CodeIssueEventArgs.cs diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Runner/IAnalysisJob.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/Runner/IAnalysisJob.cs index 0ab2553b4f..0ab2553b4f 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Runner/IAnalysisJob.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/Runner/IAnalysisJob.cs diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Runner/IJobContext.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/Runner/IJobContext.cs index 4027081b81..4027081b81 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Runner/IJobContext.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/Runner/IJobContext.cs diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Runner/JobContext.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/Runner/JobContext.cs index e15c83c88e..e15c83c88e 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Runner/JobContext.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/Runner/JobContext.cs diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Runner/JobSlice.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/Runner/JobSlice.cs index 7802e21ada..7802e21ada 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Runner/JobSlice.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/Runner/JobSlice.cs diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Runner/JobStatus.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/Runner/JobStatus.cs index 02ca3eb1fd..02ca3eb1fd 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Runner/JobStatus.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/Runner/JobStatus.cs diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Runner/ProgressMonitorWrapperJob.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/Runner/ProgressMonitorWrapperJob.cs index b1eea307cf..b1eea307cf 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Runner/ProgressMonitorWrapperJob.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/Runner/ProgressMonitorWrapperJob.cs diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Runner/SimpleAnalysisJob.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/Runner/SimpleAnalysisJob.cs index 15878be01b..15878be01b 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Runner/SimpleAnalysisJob.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/Runner/SimpleAnalysisJob.cs diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/SeverityGroupingProvider.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/SeverityGroupingProvider.cs index dc129bb35e..dc129bb35e 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/SeverityGroupingProvider.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/SeverityGroupingProvider.cs diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/SolutionAnalysisJob.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/SolutionAnalysisJob.cs index 785c037dcd..785c037dcd 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/SolutionAnalysisJob.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/SolutionAnalysisJob.cs |