[mono/monodevelop] c760fa4c: [CodeIssuesPad] Add File Grouping

"Therzok ([email protected])" <[email protected]> Mon, 11 Nov 2013 18:47:05 +0000
Newsgroups gmane.comp.gnome.mono.patches
Message-ID <00000142487d1300-66cc582d-7762-495d-8667-cf74146c5948-000000@email.amazonses.com>
   Branch: refs/heads/master
     Home: https://github.com/mono/monodevelop
  Compare: https://github.com/mono/monodevelop/compare/735f9c309ced...c760fa4c6972

   Commit: c760fa4c697280574da6fde58898f1908008dafe
   Author: Therzok <[email protected]> (Therzok)
     Date: 2013-11-11 18:45:47 GMT
      URL: https://github.com/mono/monodevelop/commit/c760fa4c697280574da6fde58898f1908008dafe

[CodeIssuesPad] Add File Grouping

Changed paths:
  M main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeIssuePad.cs
  M main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/ProjectGroupingProvider.cs
  M main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.csproj
  M main/tests/UnitTests/MonoDevelop.Refactoring/GroupingProviderTestBase.cs
  M main/tests/UnitTests/MonoDevelop.Refactoring/ProjectGroupingProviderTests.cs
  M main/tests/UnitTests/UnitTests.csproj
Added paths:
  A main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/FileGroupingProvider.cs
  A main/tests/UnitTests/MonoDevelop.Refactoring/FileGroupingProviderTests.cs

Modified: main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeIssuePad.cs
===================================================================
@@ -79,7 +79,8 @@ public class CodeIssuePadControl : VBox
 			typeof(CategoryGroupingProvider),
 			typeof(ProviderGroupingProvider),
 			typeof(SeverityGroupingProvider),
-			typeof(ProjectGroupingProvider)
+			typeof(ProjectGroupingProvider),
+			typeof(FileGroupingProvider)
 		};
 
 		public CodeIssuePadControl ()

Added: main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/FileGroupingProvider.cs
===================================================================
@@ -0,0 +1,50 @@
+//
+// FileGroupingProvider.cs
+//
+// Author:
+//       Marius Ungureanu <[email protected]>
+//
+// 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)
+		{
+			FilePath parent = issue.Project.FileName.ParentDirectory;
+			FilePath current = issue.File.FilePath;
+			if (current.IsChildPathOf (current))
+				return issue.File.FilePath.ToRelative (parent);
+			return current.ToRelative (issue.Project.ParentSolution.BaseDirectory);
+		}
+		#endregion
+	}
+}
+


Modified: main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/ProjectGroupingProvider.cs
===================================================================
@@ -24,7 +24,6 @@
 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 // THE SOFTWARE.
 using MonoDevelop.Projects;
-using System;
 
 namespace MonoDevelop.CodeIssues
 {


Modified: main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.csproj
===================================================================
@@ -153,6 +153,7 @@
     <Compile Include="MonoDevelop.CodeIssues\Runner\JobSlice.cs" />
     <Compile Include="MonoDevelop.CodeIssues\Runner\JobStatus.cs" />
     <Compile Include="MonoDevelop.CodeIssues\ProjectGroupingProvider.cs" />
+    <Compile Include="MonoDevelop.CodeIssues\FileGroupingProvider.cs" />
   </ItemGroup>
   <ItemGroup>
     <Folder Include="MonoDevelop.Refactoring\" />

Added: main/tests/UnitTests/MonoDevelop.Refactoring/FileGroupingProviderTests.cs
===================================================================
@@ -0,0 +1,55 @@
+//
+// FileGroupingProviderTests.cs
+//
+// Author:
+//       Marius Ungureanu <[email protected]>
+//
+// 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.CodeIssues;
+using MonoDevelop.Projects;
+
+namespace MonoDevelop.Refactoring
+{
+	public class FileGroupingProviderTests : GroupingProviderTestBase<FileGroupingProvider>
+	{
+		#region implemented abstract members of GroupingProviderTestBase
+
+		protected override FileGroupingProvider CreateProviderInstance ()
+		{
+			return new FileGroupingProvider ();
+		}
+
+		protected override IssueSummary[] GetDistinctSummaries ()
+		{
+			return new [] {
+				new IssueSummary {
+					File = new ProjectFile ("File1")
+				},
+				new IssueSummary {
+					File = new ProjectFile ("File2")
+				}
+			};
+		}
+
+		#endregion
+	}
+}
+


Modified: main/tests/UnitTests/MonoDevelop.Refactoring/GroupingProviderTestBase.cs
===================================================================
@@ -69,7 +69,8 @@ public abstract class GroupingProviderTestBase<T> where T: IGroupingProvider
 				Severity = Severity.None,
 				Project = new DotNetAssemblyProject {
 					Name = "ProjectName"
-				}
+				},
+				File = new ProjectFile ("FileName")
 			};
 		}
 		

Modified: main/tests/UnitTests/MonoDevelop.Refactoring/ProjectGroupingProviderTests.cs
===================================================================
@@ -24,7 +24,6 @@
 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 // THE SOFTWARE.
 using MonoDevelop.CodeIssues;
-using ICSharpCode.NRefactory.Refactoring;
 using MonoDevelop.Projects;
 
 namespace MonoDevelop.Refactoring


Modified: main/tests/UnitTests/UnitTests.csproj
===================================================================
@@ -297,6 +297,7 @@
     <Compile Include="MonoDevelop.Refactoring\AnalysisJobQueueTests.cs" />
     <Compile Include="MonoDevelop.Refactoring\SimpleAnalysisJobTests.cs" />
     <Compile Include="MonoDevelop.Refactoring\ProjectGroupingProviderTests.cs" />
+    <Compile Include="MonoDevelop.Refactoring\FileGroupingProviderTests.cs" />
   </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
   <Import Project="..\..\md.targets" />


_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches