Browse Source

Add Query Classes for Assembly and Type, queries are still missing

pull/21/merge
PeterForstmeier 14 years ago
parent
commit
64ea71d751
  1. 2
      src/AddIns/Analysis/CodeQuality/CodeQualityAnalysis.csproj
  2. 2
      src/AddIns/Analysis/CodeQuality/Src/MainWindow.xaml.cs
  3. 51
      src/AddIns/Analysis/CodeQuality/Src/MainWindowModel.cs
  4. 4
      src/AddIns/Analysis/CodeQuality/Src/Utility/Queries/BaseQuery.cs
  5. 42
      src/AddIns/Analysis/CodeQuality/Src/Utility/Queries/QueryAssembly.cs
  6. 14
      src/AddIns/Analysis/CodeQuality/Src/Utility/Queries/QueryMethod.cs
  7. 6
      src/AddIns/Analysis/CodeQuality/Src/Utility/Queries/QueryNameSpace.cs
  8. 62
      src/AddIns/Analysis/CodeQuality/Src/Utility/Queries/QueryType.cs

2
src/AddIns/Analysis/CodeQuality/CodeQualityAnalysis.csproj

@ -152,8 +152,10 @@ @@ -152,8 +152,10 @@
<Compile Include="Src\Utility\Localizeable\LocalizableDescriptionAttribute.cs" />
<Compile Include="Src\Utility\Matrix.cs" />
<Compile Include="Src\Utility\Queries\BaseQuery.cs" />
<Compile Include="Src\Utility\Queries\QueryAssembly.cs" />
<Compile Include="Src\Utility\Queries\QueryMethod.cs" />
<Compile Include="Src\Utility\Queries\QueryNameSpace.cs" />
<Compile Include="Src\Utility\Queries\QueryType.cs" />
<Compile Include="Src\Utility\VisibleMatrix.cs" />
<Page Include="Resources\GridSplitterTemplate.xaml" />
<Page Include="Resources\GraphTemplate.xaml">

2
src/AddIns/Analysis/CodeQuality/Src/MainWindow.xaml.cs

@ -140,7 +140,7 @@ namespace ICSharpCode.CodeQualityAnalysis @@ -140,7 +140,7 @@ namespace ICSharpCode.CodeQualityAnalysis
graphLayout.ChangeGraph(graph);
var viewModel = this.DataContext as MainWindowViewModel;
//testhalber
viewModel.SelectedNode = item.INode;
viewModel.SelectedTreeNode = item.INode;
}
}

51
src/AddIns/Analysis/CodeQuality/Src/MainWindowModel.cs

@ -128,7 +128,7 @@ namespace ICSharpCode.CodeQualityAnalysis @@ -128,7 +128,7 @@ namespace ICSharpCode.CodeQualityAnalysis
public bool MetrixTabEnable
{
get {return SelectedNode != null;}
get {return SelectedTreeNode != null;}
}
string typeInfo;
@ -144,7 +144,8 @@ namespace ICSharpCode.CodeQualityAnalysis @@ -144,7 +144,8 @@ namespace ICSharpCode.CodeQualityAnalysis
public Module MainModule {
get { return mainModule; }
set { mainModule = value;
set {
mainModule = value;
base.RaisePropertyChanged(() =>this.MainModule);
Summary = String.Format("Module Name: {0} Namespaces: {1} Types {2} Methods: {3} Fields: {4}",
mainModule.Name,
@ -152,17 +153,16 @@ namespace ICSharpCode.CodeQualityAnalysis @@ -152,17 +153,16 @@ namespace ICSharpCode.CodeQualityAnalysis
mainModule.TypesCount,
mainModule.MethodsCount,
mainModule.FieldsCount);
//queryModule = new QueryMethod(MainModule);
}
}
private INode selectedNode;
private INode selectedTreeNode;
public INode SelectedNode {
get { return selectedNode; }
set { selectedNode = value;
base.RaisePropertyChanged(() =>this.SelectedNode);
public INode SelectedTreeNode {
get { return selectedTreeNode; }
set { selectedTreeNode = value;
base.RaisePropertyChanged(() =>this.SelectedTreeNode);
base.RaisePropertyChanged(() =>this.MetrixTabEnable);
Summary = UpdateToolStrip();
}
@ -171,7 +171,7 @@ namespace ICSharpCode.CodeQualityAnalysis @@ -171,7 +171,7 @@ namespace ICSharpCode.CodeQualityAnalysis
string UpdateToolStrip()
{
var t = SelectedNode as Type;
var t = SelectedTreeNode as Type;
if (t != null)
{
return string.Format("Type Namer {0} Methods {1} Fields {2}",
@ -179,7 +179,7 @@ namespace ICSharpCode.CodeQualityAnalysis @@ -179,7 +179,7 @@ namespace ICSharpCode.CodeQualityAnalysis
t.GetAllMethods().Count(),
t.GetAllFields().Count());
}
var ns = SelectedNode as Namespace;
var ns = SelectedTreeNode as Namespace;
if ( ns != null) {
return string.Format("Namespace Name {0} Types : {1} Methods: {2} Fields : {3}",
ns.Name,
@ -212,25 +212,26 @@ namespace ICSharpCode.CodeQualityAnalysis @@ -212,25 +212,26 @@ namespace ICSharpCode.CodeQualityAnalysis
void ActivateMetricsExecute ()
{
BaseQuery query = null;
itemsWithCommand.Clear();
switch (SelectedMetricsLevel) {
case MetricsLevel.Assembly:
query = new QueryAssembly(MainModule);
break;
case MetricsLevel.Namespace:
QueryNameSpace queryNs = new QueryNameSpace(MainModule);
ItemsWithCommand = queryNs.GetQueryList();
query = new QueryNameSpace(MainModule);
break;
case MetricsLevel.Type:
query = new QueryType(MainModule);
break;
case MetricsLevel.Method:
QueryMethod queryModule = new QueryMethod(MainModule);
ItemsWithCommand = queryModule.GetQueryList();
query = new QueryMethod(MainModule);
break;
default:
throw new Exception("Invalid value for MetricsLevel");
}
ItemsWithCommand = query.GetQueryList();
}
#endregion
@ -263,10 +264,20 @@ namespace ICSharpCode.CodeQualityAnalysis @@ -263,10 +264,20 @@ namespace ICSharpCode.CodeQualityAnalysis
void ExecuteSelectedItem()
{
TreeValueProperty = SelectedItemWithCommand.Metrics;
var list = SelectedItemWithCommand.Action.Invoke();
if (list != null ) {
Nodes = new ObservableCollection<INode>(list);
/*
var s = SelectedTreeNode;
var b = s as Namespace;
var c = s as Type;
var d = s as Method;
var a = s as Module;
*/
if (SelectedItemWithCommand != null) {
TreeValueProperty = SelectedItemWithCommand.Metrics;
var list = SelectedItemWithCommand.Action.Invoke();
if (list != null ) {
Nodes = new ObservableCollection<INode>(list);
}
}
}

4
src/AddIns/Analysis/CodeQuality/Src/Utility/Queries/BaseQuery.cs

@ -21,11 +21,11 @@ namespace ICSharpCode.CodeQualityAnalysis.Utility.Queries @@ -21,11 +21,11 @@ namespace ICSharpCode.CodeQualityAnalysis.Utility.Queries
MainModule = mainModule;
}
public Module MainModule {get; private set;}
protected Module MainModule {get; private set;}
public virtual List<ItemWithAction> GetQueryList ()
{
throw new InvalidOperationException("Must override");
return null;
}
}
}

42
src/AddIns/Analysis/CodeQuality/Src/Utility/Queries/QueryAssembly.cs

@ -0,0 +1,42 @@ @@ -0,0 +1,42 @@
/*
* Created by SharpDevelop.
* User: Peter Forstmeier
* Date: 05.01.2012
* Time: 20:13
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections.Generic;
using ICSharpCode.Core;
namespace ICSharpCode.CodeQualityAnalysis.Utility.Queries
{
/// <summary>
/// Description of QueryAssembly.
/// </summary>
public class QueryAssembly:BaseQuery
{
public QueryAssembly(Module mainModule):base(mainModule)
{
}
public override System.Collections.Generic.List<ItemWithAction> GetQueryList()
{
List<ItemWithAction> items = new List<ItemWithAction>();
items.Add(new ItemWithAction()
{
Description = "# of NameSpaces",
Metrics = "Instructions.Count",
Action = ExecuteNotImplemented
});
return items;
}
private List<INode> ExecuteNotImplemented()
{
MessageService.ShowMessage("Not Implemented yet","CodeQualityAnalysis");
return null;
}
}
}

14
src/AddIns/Analysis/CodeQuality/Src/Utility/Queries/QueryMethod.cs

@ -24,7 +24,6 @@ namespace ICSharpCode.CodeQualityAnalysis.Utility.Queries @@ -24,7 +24,6 @@ namespace ICSharpCode.CodeQualityAnalysis.Utility.Queries
{
}
private List <Method> QueryForMethod()
{
IEnumerable<Method> query = new List<Method>();
@ -35,17 +34,6 @@ namespace ICSharpCode.CodeQualityAnalysis.Utility.Queries @@ -35,17 +34,6 @@ namespace ICSharpCode.CodeQualityAnalysis.Utility.Queries
return query.ToList();
}
/*
private List <INode> QueryForMethod()
{
IEnumerable<INode> query = new List<INode>();
query = from ns in MainModule.Namespaces
from type in ns.Types
from method in type.Methods
select method;
return query.ToList();
}
*/
public override List<ItemWithAction> GetQueryList()
{
@ -58,7 +46,7 @@ namespace ICSharpCode.CodeQualityAnalysis.Utility.Queries @@ -58,7 +46,7 @@ namespace ICSharpCode.CodeQualityAnalysis.Utility.Queries
});
items.Add(new ItemWithAction()
{
Description = "Cyclomatic Complexity",
Description = "IL Cyclomatic Complexity",
Metrics = Metrics.CyclomaticComplexity.ToString(),
Action = ExecuteMethodComplexity
});

6
src/AddIns/Analysis/CodeQuality/Src/Utility/Queries/QueryNameSpace.cs

@ -25,6 +25,12 @@ namespace ICSharpCode.CodeQualityAnalysis.Utility.Queries @@ -25,6 +25,12 @@ namespace ICSharpCode.CodeQualityAnalysis.Utility.Queries
public override List<ItemWithAction> GetQueryList()
{
List<ItemWithAction> items = new List<ItemWithAction>();
items.Add(new ItemWithAction()
{
Description = "# of IL Instructions",
Metrics = "Instructions.Count",
Action = ExecuteNotImplemented
});
items.Add(new ItemWithAction()
{
Description = "# of Methods",

62
src/AddIns/Analysis/CodeQuality/Src/Utility/Queries/QueryType.cs

@ -0,0 +1,62 @@ @@ -0,0 +1,62 @@
/*
* Created by SharpDevelop.
* User: Peter Forstmeier
* Date: 03.01.2012
* Time: 19:51
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections.Generic;
using ICSharpCode.Core;
namespace ICSharpCode.CodeQualityAnalysis.Utility.Queries
{
/// <summary>
/// Description of QueryType.
/// </summary>
public class QueryType:BaseQuery
{
public QueryType(Module mainModule):base(mainModule)
{
}
public override System.Collections.Generic.List<ItemWithAction> GetQueryList()
{
List<ItemWithAction> items = new List<ItemWithAction>();
items.Add(new ItemWithAction()
{
Description = "# of IL Instructions",
Metrics = "Instructions.Count",
Action = ExecuteNotImplemented
});
items.Add(new ItemWithAction()
{
Description = "IL Cyclomatic Complexity",
Metrics = Metrics.CyclomaticComplexity.ToString(),
Action = ExecuteNotImplemented
});
items.Add(new ItemWithAction()
{
Description = "# of Methods",
Metrics = Metrics.CyclomaticComplexity.ToString(),
Action = ExecuteNotImplemented
});
items.Add(new ItemWithAction()
{
Description = "# of Fields",
Metrics = Metrics.Variables.ToString(),
Action = ExecuteNotImplemented
});
return items;
}
private List<INode> ExecuteNotImplemented()
{
MessageService.ShowMessage("Not Implemented yet","CodeQualityAnalysis");
return null;
}
}
}
Loading…
Cancel
Save