diff options
author | Michael Hutchinson <mhutchinson@novell.com> | 2010-07-30 09:30:21 +0400 |
---|---|---|
committer | Michael Hutchinson <mhutchinson@novell.com> | 2010-07-30 10:08:07 +0400 |
commit | dc84e1c90822cbf1655eb1d14c381702b8cb2680 (patch) | |
tree | a0a44cc22544ff8163257dcbd787dbf2502572ed /main/src/addins/MonoDevelop.AnalysisCore | |
parent | a464660b18aeec9c5961275dd55e77ff098a1ac1 (diff) |
Reorganize the AnalysisSource file & class layout
Moved files into folders and classes into namespaces to improve
the layout. Renamed some classes and made some classes nonpublic.
Diffstat (limited to 'main/src/addins/MonoDevelop.AnalysisCore')
20 files changed, 257 insertions, 189 deletions
diff --git a/main/src/addins/MonoDevelop.AnalysisCore/AnalysisCommands.cs b/main/src/addins/MonoDevelop.AnalysisCore/AnalysisCommands.cs index 65d4de32a5..7bc0f1aae8 100644 --- a/main/src/addins/MonoDevelop.AnalysisCore/AnalysisCommands.cs +++ b/main/src/addins/MonoDevelop.AnalysisCore/AnalysisCommands.cs @@ -31,6 +31,7 @@ using MonoDevelop.Core; using MonoDevelop.Ide.Gui;
using System.Collections.Generic;
using Gtk;
+using MonoDevelop.AnalysisCore.Gui;
namespace MonoDevelop.AnalysisCore
{
diff --git a/main/src/addins/MonoDevelop.AnalysisCore/AnalysisExtensions.cs b/main/src/addins/MonoDevelop.AnalysisCore/AnalysisExtensions.cs index e2e63e013e..26ee546ac9 100644 --- a/main/src/addins/MonoDevelop.AnalysisCore/AnalysisExtensions.cs +++ b/main/src/addins/MonoDevelop.AnalysisCore/AnalysisExtensions.cs @@ -30,6 +30,7 @@ using MonoDevelop.Core; using Mono.Addins;
using System.Linq;
using MonoDevelop.Ide.Codons;
+using MonoDevelop.AnalysisCore.Extensions;
namespace MonoDevelop.AnalysisCore
{
@@ -44,8 +45,8 @@ namespace MonoDevelop.AnalysisCore // This is a re-usable cache of computed trees. it will need to be flushed nodesByInput is cached.
// We should probably clean it via a LRU too.
- static Dictionary<NodeTreeType,RuleTreeRoot> analysisTreeCache
- = new Dictionary<NodeTreeType, RuleTreeRoot> ();
+ static Dictionary<RuleTreeType,RuleTreeRoot> analysisTreeCache
+ = new Dictionary<RuleTreeType, RuleTreeRoot> ();
static Dictionary<string,AnalysisTypeExtensionNode> ruleInputTypes
= new Dictionary<string, AnalysisTypeExtensionNode> ();
@@ -137,7 +138,7 @@ namespace MonoDevelop.AnalysisCore // Gets an analysis tree from the cache, or creates one.
// Cache may have null value if there were no nodes for the type.
- public static RuleTreeRoot GetAnalysisTree (NodeTreeType treeType)
+ public static RuleTreeRoot GetAnalysisTree (RuleTreeType treeType)
{
RuleTreeRoot tree;
if (analysisTreeCache .TryGetValue (treeType, out tree))
@@ -152,7 +153,7 @@ namespace MonoDevelop.AnalysisCore return tree;
}
- static RuleTreeRoot BuildTree (NodeTreeType treeType)
+ static RuleTreeRoot BuildTree (RuleTreeType treeType)
{
var nodes = GetTreeNodes (treeType, treeType.Input, 0);
if (nodes == null || nodes.Length == 0)
@@ -162,7 +163,7 @@ namespace MonoDevelop.AnalysisCore }
//recursively builds the rule tree for branches that terminate in leaves (rules with result outputs)
- static IRuleTreeNode[] GetTreeNodes (NodeTreeType treeType, string input, int depth)
+ static IRuleTreeNode[] GetTreeNodes (RuleTreeType treeType, string input, int depth)
{
var addinNodes = rulesByInput.Get (input);
if (addinNodes == null)
diff --git a/main/src/addins/MonoDevelop.AnalysisCore/AnalysisService.cs b/main/src/addins/MonoDevelop.AnalysisCore/AnalysisService.cs index f90b736f74..a611bbbe08 100644 --- a/main/src/addins/MonoDevelop.AnalysisCore/AnalysisService.cs +++ b/main/src/addins/MonoDevelop.AnalysisCore/AnalysisService.cs @@ -36,7 +36,7 @@ namespace MonoDevelop.AnalysisCore {
public static class AnalysisService
{
- public static IList<Result> Analyze<T> (T input, NodeTreeType treeType)
+ public static IList<Result> Analyze<T> (T input, RuleTreeType treeType)
{
Debug.Assert (typeof (T) == AnalysisExtensions.GetType (treeType.Input));
@@ -49,7 +49,7 @@ namespace MonoDevelop.AnalysisCore }
//TODO: proper job scheduler and discarding superseded jobs
- public static void QueueAnalysis <T> (T input, NodeTreeType treeType, Action<IList<Result>> callback)
+ public static void QueueAnalysis <T> (T input, RuleTreeType treeType, Action<IList<Result>> callback)
{
ThreadPool.QueueUserWorkItem (delegate {
try {
diff --git a/main/src/addins/MonoDevelop.AnalysisCore/AnalysisRuleAddinNode.cs b/main/src/addins/MonoDevelop.AnalysisCore/Extensions/AnalysisRuleAddinNode.cs index 609a23a1a7..df649b3037 100644 --- a/main/src/addins/MonoDevelop.AnalysisCore/AnalysisRuleAddinNode.cs +++ b/main/src/addins/MonoDevelop.AnalysisCore/Extensions/AnalysisRuleAddinNode.cs @@ -30,7 +30,7 @@ using Mono.Addins; using System.Reflection;
using System.Reflection.Emit;
-namespace MonoDevelop.AnalysisCore
+namespace MonoDevelop.AnalysisCore.Extensions
{
class NamedAnalysisRuleAddinNode : AnalysisRuleAddinNode
{
diff --git a/main/src/addins/MonoDevelop.AnalysisCore/AnalysisTypeExtensionNode.cs b/main/src/addins/MonoDevelop.AnalysisCore/Extensions/AnalysisTypeExtensionNode.cs index a98acf89cc..89d9164774 100644 --- a/main/src/addins/MonoDevelop.AnalysisCore/AnalysisTypeExtensionNode.cs +++ b/main/src/addins/MonoDevelop.AnalysisCore/Extensions/AnalysisTypeExtensionNode.cs @@ -27,7 +27,7 @@ using System;
using Mono.Addins;
-namespace MonoDevelop.AnalysisCore
+namespace MonoDevelop.AnalysisCore.Extensions
{
public class AnalysisTypeExtensionNode : TypeExtensionNode
{
diff --git a/main/src/addins/MonoDevelop.AnalysisCore/FixHandlerExtensionNode.cs b/main/src/addins/MonoDevelop.AnalysisCore/Extensions/FixHandlerExtensionNode.cs index a25464481d..9ab4a84d82 100644 --- a/main/src/addins/MonoDevelop.AnalysisCore/FixHandlerExtensionNode.cs +++ b/main/src/addins/MonoDevelop.AnalysisCore/Extensions/FixHandlerExtensionNode.cs @@ -27,7 +27,7 @@ using System; using Mono.Addins; -namespace MonoDevelop.AnalysisCore +namespace MonoDevelop.AnalysisCore.Extensions { public class FixHandlerExtensionNode : TypeExtensionNode { diff --git a/main/src/addins/MonoDevelop.AnalysisCore/FixableResult.cs b/main/src/addins/MonoDevelop.AnalysisCore/FixableResult.cs index d59699fea8..2514c9584d 100644 --- a/main/src/addins/MonoDevelop.AnalysisCore/FixableResult.cs +++ b/main/src/addins/MonoDevelop.AnalysisCore/FixableResult.cs @@ -25,11 +25,8 @@ // THE SOFTWARE.
using System;
+using System.Collections.Generic;
using MonoDevelop.Projects.Dom;
-using MonoDevelop.Core;
-using MonoDevelop.Refactoring.Rename;
-using MonoDevelop.Ide;
-using MonoDevelop.Refactoring;
namespace MonoDevelop.AnalysisCore
{
@@ -51,18 +48,15 @@ namespace MonoDevelop.AnalysisCore string FixType { get; }
}
- public class RenameMemberFix : IAnalysisFix
+ public interface IFixHandler
{
- public string NewName { get; private set; }
- public IMember Item { get; private set; }
-
- public RenameMemberFix (IMember item, string newName)
- {
- this.NewName = newName;
- this.Item = item;
- }
-
- public string FixType { get { return "RenameMember"; } }
+ IEnumerable<IAnalysisFixAction> GetFixes (MonoDevelop.Ide.Gui.Document doc, object fix);
+ }
+
+ public interface IAnalysisFixAction
+ {
+ string Label { get; }
+ void Fix ();
}
}
diff --git a/main/src/addins/MonoDevelop.AnalysisCore/FixHandler.cs b/main/src/addins/MonoDevelop.AnalysisCore/Fixes/RenameMemberFix.cs index 74f3e3f1ab..95e0d6507a 100644 --- a/main/src/addins/MonoDevelop.AnalysisCore/FixHandler.cs +++ b/main/src/addins/MonoDevelop.AnalysisCore/Fixes/RenameMemberFix.cs @@ -1,50 +1,54 @@ -// -// FixHandler.cs -// -// Author: -// Michael Hutchinson <mhutchinson@novell.com> -// -// Copyright (c) 2010 Novell, Inc. -// -// 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.Collections.Generic; -using MonoDevelop.Refactoring.Rename; -using MonoDevelop.Refactoring; -using MonoDevelop.Core; -using MonoDevelop.Ide; - -namespace MonoDevelop.AnalysisCore -{ - public interface IFixHandler - { - IEnumerable<IAnalysisFixAction> GetFixes (MonoDevelop.Ide.Gui.Document doc, object fix); - } - - public interface IAnalysisFixAction - { - string Label { get; } - void Fix (); - } - - public class RenameMemberHandler : IFixHandler +//
+// FixHandler.cs
+//
+// Author:
+// Michael Hutchinson <mhutchinson@novell.com>
+//
+// Copyright (c) 2010 Novell, Inc.
+//
+// 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.Collections.Generic;
+using MonoDevelop.Refactoring.Rename;
+using MonoDevelop.Refactoring;
+using MonoDevelop.Core;
+using MonoDevelop.Ide;
+using MonoDevelop.Projects.Dom;
+
+namespace MonoDevelop.AnalysisCore.Fixes
+{
+ public class RenameMemberFix : IAnalysisFix
+ {
+ public string NewName { get; private set; }
+ public IMember Item { get; private set; }
+
+ public RenameMemberFix (IMember item, string newName)
+ {
+ this.NewName = newName;
+ this.Item = item;
+ }
+
+ public string FixType { get { return "RenameMember"; } }
+ }
+
+ class RenameMemberHandler : IFixHandler { //FIXME: why is this invalid on the parseddocuments loaded when the doc is first loaded? //maybe the item's type's SourceProject is null? @@ -102,6 +106,5 @@ namespace MonoDevelop.AnalysisCore } } } - } -} - + }
+}
diff --git a/main/src/addins/MonoDevelop.AnalysisCore/AnalysisOptionsPanel.cs b/main/src/addins/MonoDevelop.AnalysisCore/Gui/AnalysisOptionsPanel.cs index 80ebb7481e..3dbab47935 100644 --- a/main/src/addins/MonoDevelop.AnalysisCore/AnalysisOptionsPanel.cs +++ b/main/src/addins/MonoDevelop.AnalysisCore/Gui/AnalysisOptionsPanel.cs @@ -29,7 +29,7 @@ using MonoDevelop.Ide.Gui.Dialogs; using Gtk;
using MonoDevelop.Core;
-namespace MonoDevelop.AnalysisCore
+namespace MonoDevelop.AnalysisCore.Gui
{
public class AnalysisOptionsPanel : OptionsPanel
{
diff --git a/main/src/addins/MonoDevelop.AnalysisCore/NodeTreeType.cs b/main/src/addins/MonoDevelop.AnalysisCore/Gui/ResultMarker.cs index 40f0e02eb5..54f054b829 100644 --- a/main/src/addins/MonoDevelop.AnalysisCore/NodeTreeType.cs +++ b/main/src/addins/MonoDevelop.AnalysisCore/Gui/ResultMarker.cs @@ -1,5 +1,5 @@ //
-// NodeTreeType.cs
+// ResultsEditorExtension.cs
//
// Author:
// Michael Hutchinson <mhutchinson@novell.com>
@@ -24,45 +24,40 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
-using System.Diagnostics;
+using Mono.TextEditor;
-namespace MonoDevelop.AnalysisCore
+namespace MonoDevelop.AnalysisCore.Gui
{
- // Type of the analysis tree. Basically a key for the analysis tree cache.
- public class NodeTreeType
+ class ResultMarker : UnderlineMarker
{
- string input, fileExtension;
+ Result result;
- public string Input { get { return input; } }
- public string FileExtension { get { return fileExtension; } }
-
- public NodeTreeType (string input, string fileExtension)
+ public ResultMarker (Result result) : base (
+ GetColor (result),
+ IsOneLine (result)? (result.Region.Start.Column - 1) : -1,
+ IsOneLine (result)? (result.Region.End.Column - 1) : -1)
{
- Debug.Assert (!string.IsNullOrEmpty (input));
- Debug.Assert (!string.IsNullOrEmpty (fileExtension));
-
- this.input = input;
- this.fileExtension = fileExtension;
+ this.result = result;
}
- public override bool Equals (object obj)
+ static bool IsOneLine (Result result)
{
- if (obj == null)
- return false;
- if (ReferenceEquals (this, obj))
- return true;
- var other = obj as NodeTreeType;
- return other != null && input == other.input && fileExtension == other.fileExtension;
+ return result.Region.Start.Line == result.Region.End.Line;
}
-
- public override int GetHashCode ()
+
+ public Result Result { get { return result; } }
+
+ //utility for debugging
+ public int Line { get { return result.Region.Start.Line - 1; } }
+ public int ColStart { get { return IsOneLine (result)? (result.Region.Start.Column - 1) : -1; } }
+ public int ColEnd { get { return IsOneLine (result)? (result.Region.End.Column - 1) : -1; } }
+ public string Message { get { return result.Message; } }
+
+ static string GetColor (Result result)
{
- unchecked {
- return (input != null ? input.GetHashCode () : 0)
- ^ (fileExtension != null ? fileExtension.GetHashCode () : 0);
- }
+ return result.Level == ResultLevel.Error
+ ? Mono.TextEditor.Highlighting.Style.ErrorUnderlineString
+ : Mono.TextEditor.Highlighting.Style.WarningUnderlineString;
}
}
}
-
diff --git a/main/src/addins/MonoDevelop.AnalysisCore/ResultTooltipProvider.cs b/main/src/addins/MonoDevelop.AnalysisCore/Gui/ResultTooltipProvider.cs index c36e4a9098..abe0944dc1 100644 --- a/main/src/addins/MonoDevelop.AnalysisCore/ResultTooltipProvider.cs +++ b/main/src/addins/MonoDevelop.AnalysisCore/Gui/ResultTooltipProvider.cs @@ -30,9 +30,9 @@ using MonoDevelop.SourceEditor; using System.Text;
using System.Collections.Generic;
-namespace MonoDevelop.AnalysisCore
+namespace MonoDevelop.AnalysisCore.Gui
{
- public class ResultTooltipProvider : ITooltipProvider
+ class ResultTooltipProvider : ITooltipProvider
{
public TooltipItem GetItem (TextEditor editor, int offset)
{
diff --git a/main/src/addins/MonoDevelop.AnalysisCore/ResultsEditorExtension.cs b/main/src/addins/MonoDevelop.AnalysisCore/Gui/ResultsEditorExtension.cs index 2aeee50c63..1ba6c45cec 100644 --- a/main/src/addins/MonoDevelop.AnalysisCore/ResultsEditorExtension.cs +++ b/main/src/addins/MonoDevelop.AnalysisCore/Gui/ResultsEditorExtension.cs @@ -35,7 +35,7 @@ using Mono.TextEditor; using System.Linq;
using MonoDevelop.Components.Commands;
-namespace MonoDevelop.AnalysisCore
+namespace MonoDevelop.AnalysisCore.Gui
{
public class ResultsEditorExtension : TextEditorExtension
{
@@ -95,7 +95,7 @@ namespace MonoDevelop.AnalysisCore void OnDocumentParsed (object sender, EventArgs args)
{
var doc = Document.ParsedDocument;
- var treeType = new NodeTreeType ("ParsedDocument", Path.GetExtension (doc.FileName));
+ var treeType = new RuleTreeType ("ParsedDocument", Path.GetExtension (doc.FileName));
AnalysisService.QueueAnalysis (doc, treeType, UpdateResults);
}
@@ -185,39 +185,4 @@ namespace MonoDevelop.AnalysisCore return list;
}
}
-
- //FIXME: make a tooltip and commands that can inspect these
- class ResultMarker : UnderlineMarker
- {
- Result result;
-
- public ResultMarker (Result result) : base (
- GetColor (result),
- IsOneLine (result)? (result.Region.Start.Column - 1) : -1,
- IsOneLine (result)? (result.Region.End.Column - 1) : -1)
- {
- this.result = result;
- }
-
- static bool IsOneLine (Result result)
- {
- return result.Region.Start.Line == result.Region.End.Line;
- }
-
- public Result Result { get { return result; } }
-
- //utility for debugging
- public int Line { get { return result.Region.Start.Line - 1; } }
- public int ColStart { get { return IsOneLine (result)? (result.Region.Start.Column - 1) : -1; } }
- public int ColEnd { get { return IsOneLine (result)? (result.Region.End.Column - 1) : -1; } }
- public string Message { get { return result.Message; } }
-
- static string GetColor (Result result)
- {
- return result.Level == ResultLevel.Error
- ? Mono.TextEditor.Highlighting.Style.ErrorUnderlineString
- : Mono.TextEditor.Highlighting.Style.WarningUnderlineString;
- }
- }
}
-
diff --git a/main/src/addins/MonoDevelop.AnalysisCore/MonoDevelop.AnalysisCore.addin.xml b/main/src/addins/MonoDevelop.AnalysisCore/MonoDevelop.AnalysisCore.addin.xml index 08a50c8fb6..c0dfee926b 100644 --- a/main/src/addins/MonoDevelop.AnalysisCore/MonoDevelop.AnalysisCore.addin.xml +++ b/main/src/addins/MonoDevelop.AnalysisCore/MonoDevelop.AnalysisCore.addin.xml @@ -21,8 +21,8 @@ <ExtensionNode name="Category" type="MonoDevelop.Ide.Codons.CategoryNode">
<ExtensionNodeSet id="MonoDevelop.AnalysisCore.Rules" />
</ExtensionNode>
- <ExtensionNode name="Rule" type="MonoDevelop.AnalysisCore.NamedAnalysisRuleAddinNode" />
- <ExtensionNode name="Adaptor" type="MonoDevelop.AnalysisCore.AdaptorAnalysisRuleAddinNode" />
+ <ExtensionNode name="Rule" type="MonoDevelop.AnalysisCore.Extensions.NamedAnalysisRuleAddinNode" />
+ <ExtensionNode name="Adaptor" type="MonoDevelop.AnalysisCore.Extensions.AdaptorAnalysisRuleAddinNode" />
</ExtensionNodeSet>
<ExtensionPoint path = "/MonoDevelop/AnalysisCore/Rules" name = "Analysis Rules">
@@ -32,22 +32,22 @@ <ExtensionPoint path = "/MonoDevelop/AnalysisCore/Types" name = "Analysis rule input/output types">
<Description>Analysis rule input/output types.</Description>
- <ExtensionNode name="Type" type="MonoDevelop.AnalysisCore.AnalysisTypeExtensionNode" />
+ <ExtensionNode name="Type" type="MonoDevelop.AnalysisCore.Extensions.AnalysisTypeExtensionNode" />
</ExtensionPoint>
<ExtensionPoint path = "/MonoDevelop/AnalysisCore/FixHandlers" name = "Fix handlers">
<Description>Fix handlers. Classes must implement IAnalysisFixHandler.</Description>
- <ExtensionNode name="Handler" type="MonoDevelop.AnalysisCore.FixHandlerExtensionNode" />
+ <ExtensionNode name="Handler" type="MonoDevelop.AnalysisCore.Extensions.FixHandlerExtensionNode" />
</ExtensionPoint>
<!-- Text editor integration -->
<Extension path = "/MonoDevelop/Ide/TextEditorExtensions">
- <Class class = "MonoDevelop.AnalysisCore.ResultsEditorExtension" />
+ <Class class = "MonoDevelop.AnalysisCore.Gui.ResultsEditorExtension" />
</Extension>
<Extension path = "/MonoDevelop/SourceEditor2/TooltipProviders">
- <Class id="AnalysisResults" class="MonoDevelop.AnalysisCore.ResultTooltipProvider" insertafter="Debug" />
+ <Class id="AnalysisResults" class="MonoDevelop.AnalysisCore.Gui.ResultTooltipProvider" insertafter="Debug" />
</Extension>
<!-- Quick fix commands -->
@@ -74,7 +74,8 @@ <!-- Options panels -->
<Extension path = "/MonoDevelop/Ide/GlobalOptionsDialog/Other">
- <Section id = "Analysis" _label = "Source Analysis" fill="true" class="MonoDevelop.AnalysisCore.AnalysisOptionsPanel"/>
+ <Section id = "Analysis" _label = "Source Analysis" fill="true"
+ class="MonoDevelop.AnalysisCore.Gui.AnalysisOptionsPanel"/>
</Extension>
<!-- Extensions to the addin points defined by this addin -->
@@ -85,13 +86,15 @@ </Extension>
<Extension path = "/MonoDevelop/AnalysisCore/Rules">
- <Adaptor func="MonoDevelop.AnalysisCore.Adapters.GetCompilationUnit" input="ParsedDocument" output="CompilationUnit" />
+ <Adaptor func="MonoDevelop.AnalysisCore.Rules.Adapters.GetCompilationUnit"
+ input="ParsedDocument" output="CompilationUnit" />
<Category _name="Design Guidelines" id="Design">
- <Rule _name="Naming Conventions" func="MonoDevelop.AnalysisCore.Rules.NamingConventions" input="CompilationUnit" />
+ <Rule _name="Naming Conventions" input="CompilationUnit"
+ func="MonoDevelop.AnalysisCore.Rules.NamingConventions.ClassNaming" />
</Category>
</Extension>
<Extension path = "/MonoDevelop/AnalysisCore/FixHandlers">
- <Handler fixName="RenameMember" class = "MonoDevelop.AnalysisCore.RenameMemberHandler" />
+ <Handler fixName="RenameMember" class = "MonoDevelop.AnalysisCore.Fixes.RenameMemberHandler" />
</Extension>
</Addin> diff --git a/main/src/addins/MonoDevelop.AnalysisCore/MonoDevelop.AnalysisCore.csproj b/main/src/addins/MonoDevelop.AnalysisCore/MonoDevelop.AnalysisCore.csproj index 84b69d5857..7e126336c7 100644 --- a/main/src/addins/MonoDevelop.AnalysisCore/MonoDevelop.AnalysisCore.csproj +++ b/main/src/addins/MonoDevelop.AnalysisCore/MonoDevelop.AnalysisCore.csproj @@ -101,26 +101,34 @@ </EmbeddedResource> </ItemGroup> <ItemGroup> - <Compile Include="ResultsEditorExtension.cs" /> - <Compile Include="AnalysisRuleAddinNode.cs" /> <Compile Include="AnalysisService.cs" /> - <Compile Include="RuleTreeNode.cs" /> <Compile Include="Result.cs" /> - <Compile Include="NodeTreeType.cs" /> - <Compile Include="AnalysisTypeExtensionNode.cs" /> <Compile Include="AnalysisExtensions.cs" /> - <Compile Include="Adaptors.cs" /> - <Compile Include="ResultTooltipProvider.cs" /> <Compile Include="AnalysisCommands.cs" /> <Compile Include="FixableResult.cs" /> - <Compile Include="FixHandlerExtensionNode.cs" /> - <Compile Include="FixHandler.cs" /> - <Compile Include="AnalysisOptionsPanel.cs" /> <Compile Include="AnalysisOptions.cs" /> + <Compile Include="Extensions\AnalysisTypeExtensionNode.cs" /> + <Compile Include="Extensions\FixHandlerExtensionNode.cs" /> + <Compile Include="Extensions\AnalysisRuleAddinNode.cs" /> + <Compile Include="Gui\ResultsEditorExtension.cs" /> + <Compile Include="Gui\ResultTooltipProvider.cs" /> + <Compile Include="RuleTree.cs" /> + <Compile Include="RuleTreeType.cs" /> + <Compile Include="Gui\AnalysisOptionsPanel.cs" /> + <Compile Include="Gui\ResultMarker.cs" /> + <Compile Include="Rules\Adaptors.cs" /> + <Compile Include="Fixes\RenameMemberFix.cs" /> + <Compile Include="Rules\NamingConventions.cs" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <ItemGroup> <None Include="README.txt" /> <None Include="TODO.txt" /> </ItemGroup> + <ItemGroup> + <Folder Include="Extensions\" /> + <Folder Include="Gui\" /> + <Folder Include="Rules\" /> + <Folder Include="Fixes\" /> + </ItemGroup> </Project> diff --git a/main/src/addins/MonoDevelop.AnalysisCore/Result.cs b/main/src/addins/MonoDevelop.AnalysisCore/Result.cs index d3d148f2ef..3dea5a3d0d 100644 --- a/main/src/addins/MonoDevelop.AnalysisCore/Result.cs +++ b/main/src/addins/MonoDevelop.AnalysisCore/Result.cs @@ -26,6 +26,7 @@ using System;
using MonoDevelop.Projects.Dom;
+using MonoDevelop.AnalysisCore.Extensions;
namespace MonoDevelop.AnalysisCore
{
diff --git a/main/src/addins/MonoDevelop.AnalysisCore/RuleTreeNode.cs b/main/src/addins/MonoDevelop.AnalysisCore/RuleTree.cs index 5d70a8451e..979ee3ed7a 100644 --- a/main/src/addins/MonoDevelop.AnalysisCore/RuleTreeNode.cs +++ b/main/src/addins/MonoDevelop.AnalysisCore/RuleTree.cs @@ -29,6 +29,7 @@ using System.Linq; using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
+using MonoDevelop.AnalysisCore.Extensions;
namespace MonoDevelop.AnalysisCore
{
@@ -113,9 +114,9 @@ namespace MonoDevelop.AnalysisCore sealed class RuleTreeRoot
{
IRuleTreeNode[] children;
- NodeTreeType treeType;
+ RuleTreeType treeType;
- public RuleTreeRoot (IRuleTreeNode[] children, NodeTreeType treeType)
+ public RuleTreeRoot (IRuleTreeNode[] children, RuleTreeType treeType)
{
this.children = children;
this.treeType = treeType;
@@ -127,6 +128,8 @@ namespace MonoDevelop.AnalysisCore ));
}
+ public RuleTreeType TreeType { get { return treeType; } }
+
public IEnumerable<Result> Analyze (object input)
{
return children.SelectMany (child => child.Analyze (input));
@@ -162,4 +165,40 @@ namespace MonoDevelop.AnalysisCore }
}
}
+
+ // Type of the analysis tree. Basically a key for the analysis tree cache.
+ public class RuleTreeType
+ {
+ string input, fileExtension;
+
+ public string Input { get { return input; } }
+ public string FileExtension { get { return fileExtension; } }
+
+ public RuleTreeType (string input, string fileExtension)
+ {
+ Debug.Assert (!string.IsNullOrEmpty (input));
+ Debug.Assert (!string.IsNullOrEmpty (fileExtension));
+
+ this.input = input;
+ this.fileExtension = fileExtension;
+ }
+
+ public override bool Equals (object obj)
+ {
+ if (obj == null)
+ return false;
+ if (ReferenceEquals (this, obj))
+ return true;
+ var other = obj as RuleTreeType;
+ return other != null && input == other.input && fileExtension == other.fileExtension;
+ }
+
+ public override int GetHashCode ()
+ {
+ unchecked {
+ return (input != null ? input.GetHashCode () : 0)
+ ^ (fileExtension != null ? fileExtension.GetHashCode () : 0);
+ }
+ }
+ }
}
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.AnalysisCore/RuleTreeType.cs b/main/src/addins/MonoDevelop.AnalysisCore/RuleTreeType.cs new file mode 100644 index 0000000000..0d869d7529 --- /dev/null +++ b/main/src/addins/MonoDevelop.AnalysisCore/RuleTreeType.cs @@ -0,0 +1,34 @@ +//
+// NodeTreeType.cs
+//
+// Author:
+// Michael Hutchinson <mhutchinson@novell.com>
+//
+// Copyright (c) 2010 Novell, Inc.
+//
+// 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.Diagnostics;
+
+namespace MonoDevelop.AnalysisCore
+{
+
+}
+
diff --git a/main/src/addins/MonoDevelop.AnalysisCore/Rules/Adaptors.cs b/main/src/addins/MonoDevelop.AnalysisCore/Rules/Adaptors.cs new file mode 100644 index 0000000000..70990c5422 --- /dev/null +++ b/main/src/addins/MonoDevelop.AnalysisCore/Rules/Adaptors.cs @@ -0,0 +1,41 @@ +//
+// Adaptors.cs
+//
+// Author:
+// Michael Hutchinson <mhutchinson@novell.com>
+//
+// Copyright (c) 2010 Novell, Inc.
+//
+// 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.Projects.Dom;
+using System.Collections.Generic;
+using MonoDevelop.AnalysisCore.Fixes;
+
+namespace MonoDevelop.AnalysisCore.Rules
+{
+ public static class Adapters
+ {
+ public static ICompilationUnit GetCompilationUnit (ParsedDocument input)
+ {
+ return input.CompilationUnit;
+ }
+ }
+}
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.AnalysisCore/Adaptors.cs b/main/src/addins/MonoDevelop.AnalysisCore/Rules/NamingConventions.cs index 2eca8163f6..9d9a55ae7c 100644 --- a/main/src/addins/MonoDevelop.AnalysisCore/Adaptors.cs +++ b/main/src/addins/MonoDevelop.AnalysisCore/Rules/NamingConventions.cs @@ -27,20 +27,12 @@ using System;
using MonoDevelop.Projects.Dom;
using System.Collections.Generic;
-
-namespace MonoDevelop.AnalysisCore
+using MonoDevelop.AnalysisCore.Fixes;
+namespace MonoDevelop.AnalysisCore.Rules
{
- public static class Adapters
- {
- public static ICompilationUnit GetCompilationUnit (ParsedDocument input)
- {
- return input.CompilationUnit;
- }
- }
-
- public static class Rules
+ public static class NamingConventions
{
- public static IEnumerable<Result> NamingConventions (ICompilationUnit input)
+ public static IEnumerable<Result> ClassNaming (ICompilationUnit input)
{
foreach (var type in input.Types) {
if (!char.IsUpper (type.Name[0])) {
@@ -56,4 +48,3 @@ namespace MonoDevelop.AnalysisCore }
}
}
-
diff --git a/main/src/addins/MonoDevelop.AnalysisCore/TODO.txt b/main/src/addins/MonoDevelop.AnalysisCore/TODO.txt index d4966d38d2..4597f6659a 100644 --- a/main/src/addins/MonoDevelop.AnalysisCore/TODO.txt +++ b/main/src/addins/MonoDevelop.AnalysisCore/TODO.txt @@ -3,12 +3,8 @@ Some things that still need to be done in AnalyzerCore: * LOTS of rules - both generic .NET (for ICompilationUnit) and
using an adaptor that would invoke the new C# parser.
-* A tooltip provider, for inspecting the error underlines.
-
* A pad, for viewing the rules list more directly.
-* Options for diablign on-the-fly analysis
-
* Support for configuring which rules are used, via additional
filters when building the analysis tree.
@@ -22,10 +18,6 @@ Some things that still need to be done in AnalyzerCore: * A scheduler for analysis jobs that would automatically discard outdated
queued jobs when a newer job comes in.
-* Ability for results to include a "quick fix". This would be a command which
- would be shown in the menu context menu. Possibly this could be done by
- simply flagging results with a key to a handler in another extension point.
-
* UserVisibleStringCollection type and a rule to spellcheck it, so anything
can output this node to generate spellchecking results.
@@ -42,7 +34,7 @@ Some things that would be nice, but aren't so immediately important: * Commands to suppress individual results, persisted in suppression files.
* Analysis on demand, with a results list. This could easily process all files
- in a prject or sln.
+ in a project or sln.
* Support for specifying rule priorities and using multiple analyser
trees at different frequencies for one document, in order to run
|