Browse Source

Formating

pull/520/head
JohnnyBravo75 11 years ago
parent
commit
e44a437f4d
  1. 177
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/OutlinePad/AstNodeHelper.cs
  2. 42
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/OutlinePad/CSharpOutlineNode.cs
  3. 2
      src/Libraries/SharpTreeView/ICSharpCode.TreeView/Themes/Generic.xaml

177
src/AddIns/BackendBindings/CSharpBinding/Project/Src/OutlinePad/AstNodeHelper.cs

@ -24,7 +24,6 @@ namespace CSharpBinding.OutlinePad @@ -24,7 +24,6 @@ namespace CSharpBinding.OutlinePad
using System.Windows;
using System.Windows.Media;
using System.Text;
using ICSharpCode.NRefactory.CSharp;
using ICSharpCode.AvalonEdit.Highlighting;
@ -55,7 +54,9 @@ namespace CSharpBinding.OutlinePad @@ -55,7 +54,9 @@ namespace CSharpBinding.OutlinePad
if (accessModifier == null && IsInterface(node.Parent)) {
return Modifiers.Public;
}
return accessModifier == null ? Modifiers.None : accessModifier.Modifier;
return accessModifier == null
? Modifiers.None
: accessModifier.Modifier;
}
private static string GetParameterDeclsAsString(AstNodeCollection<ParameterDeclaration> parameterDecls) {
@ -96,21 +97,21 @@ namespace CSharpBinding.OutlinePad @@ -96,21 +97,21 @@ namespace CSharpBinding.OutlinePad
public static bool IsAllowedNode(AstNode node) {
return (IsRegionStart(node)
|| IsRegionEnd(node)
|| IsClass(node)
|| IsInterface(node)
|| IsMethod(node)
|| IsField(node)
|| IsProperty(node)
|| IsNameSpace(node)
|| IsConstructor(node)
|| IsEvent(node)
|| IsDelegate(node)
|| IsIndexer(node)
|| IsEnum(node)
|| IsEnumMember(node)
|| IsStruct(node)
|| IsOperator(node)
|| IsRegionEnd(node)
|| IsClass(node)
|| IsInterface(node)
|| IsMethod(node)
|| IsField(node)
|| IsProperty(node)
|| IsNameSpace(node)
|| IsConstructor(node)
|| IsEvent(node)
|| IsDelegate(node)
|| IsIndexer(node)
|| IsEnum(node)
|| IsEnumMember(node)
|| IsStruct(node)
|| IsOperator(node)
);
}
@ -120,7 +121,7 @@ namespace CSharpBinding.OutlinePad @@ -120,7 +121,7 @@ namespace CSharpBinding.OutlinePad
internal static void SetRegionStartInfos(CSharpOutlineNode node, AstNode dataNode) {
var preProcessorNode = (PreProcessorDirective)dataNode;
node.ElementName = "****** " + preProcessorNode.Argument + " *****";
node.Name = "****** " + preProcessorNode.Argument + " *****";
node.ForegroundBrush = (regionHighLighting.Foreground as SimpleHighlightingBrush).GetBrush(null);
// node.Weight = regionHighLighting.FontWeight != null ? regionHighLighting.FontWeight.Value : FontWeights.Normal;
}
@ -131,7 +132,7 @@ namespace CSharpBinding.OutlinePad @@ -131,7 +132,7 @@ namespace CSharpBinding.OutlinePad
internal static void SetRegionEndInfos(CSharpOutlineNode node, AstNode dataNode) {
var preProcessorNode = (PreProcessorDirective)dataNode;
node.ElementName = "*********************";
node.Name = "*********************";
node.ForegroundBrush = (regionHighLighting.Foreground as SimpleHighlightingBrush).GetBrush(null);
// node.Weight = regionHighLighting.FontWeight != null ? regionHighLighting.FontWeight.Value : FontWeights.Normal;
}
@ -141,8 +142,8 @@ namespace CSharpBinding.OutlinePad @@ -141,8 +142,8 @@ namespace CSharpBinding.OutlinePad
}
internal static void SetDelegateNodeInfos(CSharpOutlineNode node, AstNode dataNode) {
var typeNode = (DelegateDeclaration)dataNode;
node.ElementName = typeNode.Name;
var typeNode = (DelegateDeclaration)dataNode;
node.Name = typeNode.Name;
if (colorizeNode)
node.ForegroundBrush = Brushes.Black;
// node.Weight = classHighLighting.FontWeight != null ? classHighLighting.FontWeight.Value : FontWeights.Normal;
@ -168,12 +169,13 @@ namespace CSharpBinding.OutlinePad @@ -168,12 +169,13 @@ namespace CSharpBinding.OutlinePad
}
internal static void SetStructNodeInfos(CSharpOutlineNode node, AstNode dataNode) {
var typeNode = (TypeDeclaration)dataNode;
node.ElementName = typeNode.Name;
var typeNode = (TypeDeclaration)dataNode;
node.Name = typeNode.Name;
node.IsExpanded = true;
if (colorizeNode)
node.ForegroundBrush = (classHighLighting.Foreground as SimpleHighlightingBrush).GetBrush(null);
// node.Weight = classHighLighting.FontWeight != null ? classHighLighting.FontWeight.Value : FontWeights.Normal;
node.IsExpanded = true;
switch(GetAccessModifier(dataNode)) {
case Modifiers.Public:
@ -196,8 +198,9 @@ namespace CSharpBinding.OutlinePad @@ -196,8 +198,9 @@ namespace CSharpBinding.OutlinePad
}
internal static void SetEnumMemberNodeInfos(CSharpOutlineNode node, AstNode dataNode) {
var enumMemberNode = (EnumMemberDeclaration)dataNode;
node.ElementName = enumMemberNode.Name;
var enumMemberNode = (EnumMemberDeclaration)dataNode;
node.Name = enumMemberNode.Name;
if (colorizeNode)
node.ForegroundBrush = Brushes.Black;
node.IconName = "Icons.16x16.Enum";
@ -208,11 +211,12 @@ namespace CSharpBinding.OutlinePad @@ -208,11 +211,12 @@ namespace CSharpBinding.OutlinePad
}
internal static void SetEnumNodeInfos(CSharpOutlineNode node, AstNode dataNode) {
var typeNode = (TypeDeclaration)dataNode;
node.ElementName = typeNode.Name;
var typeNode = (TypeDeclaration)dataNode;
node.Name = typeNode.Name;
node.IsExpanded = true;
if (colorizeNode)
node.ForegroundBrush = (classHighLighting.Foreground as SimpleHighlightingBrush).GetBrush(null);
node.IsExpanded = true;
switch(GetAccessModifier(dataNode)) {
case Modifiers.Public:
@ -235,15 +239,16 @@ namespace CSharpBinding.OutlinePad @@ -235,15 +239,16 @@ namespace CSharpBinding.OutlinePad
}
internal static void SetClassNodeInfos(CSharpOutlineNode node, AstNode dataNode) {
var typeNode = (TypeDeclaration)dataNode;
node.ElementName = typeNode.Name
var typeNode = (TypeDeclaration)dataNode;
node.Name = typeNode.Name
+ typeNode.LChevronToken
+ GetTypeParameterDeclsAsString(typeNode.TypeParameters)
+ typeNode.RChevronToken;
node.IsExpanded = true;
if (colorizeNode)
node.ForegroundBrush = (classHighLighting.Foreground as SimpleHighlightingBrush).GetBrush(null);
// node.Weight = classHighLighting.FontWeight != null ? classHighLighting.FontWeight.Value : FontWeights.Normal;
node.IsExpanded = true;
switch(GetAccessModifier(dataNode)) {
case Modifiers.Public:
@ -266,11 +271,11 @@ namespace CSharpBinding.OutlinePad @@ -266,11 +271,11 @@ namespace CSharpBinding.OutlinePad
}
internal static void SetEventNodeInfos(CSharpOutlineNode node, AstNode dataNode) {
var eventNode = (EventDeclaration)dataNode;
var varInitializer = eventNode.Children.FirstOrDefault(x => x is VariableInitializer) as VariableInitializer;
node.ElementName = (varInitializer != null)
? varInitializer.Name
: "<unknown>";
var eventNode = (EventDeclaration)dataNode;
var varInitializer = eventNode.Children.FirstOrDefault(x => x is VariableInitializer) as VariableInitializer;
node.Name = (varInitializer != null)
? varInitializer.Name
: "<unknown>";
if (colorizeNode)
node.ForegroundBrush = Brushes.Black;
@ -292,11 +297,13 @@ namespace CSharpBinding.OutlinePad @@ -292,11 +297,13 @@ namespace CSharpBinding.OutlinePad
}
internal static void SetInterfaceNodeInfos(CSharpOutlineNode node, AstNode dataNode) {
var typeNode = (TypeDeclaration)dataNode;
node.ElementName = typeNode.Name;
var typeNode = (TypeDeclaration)dataNode;
node.Name = typeNode.Name;
node.IsExpanded = true;
if (colorizeNode)
node.ForegroundBrush = (interfaceHighLighting.Foreground as SimpleHighlightingBrush).GetBrush(null);
node.IsExpanded = true;
switch(GetAccessModifier(dataNode)) {
case Modifiers.Public:
node.IconName = "Icons.16x16.Interface";
@ -318,18 +325,20 @@ namespace CSharpBinding.OutlinePad @@ -318,18 +325,20 @@ namespace CSharpBinding.OutlinePad
}
internal static void SetOperatorNodeInfos(CSharpOutlineNode node, AstNode dataNode) {
var operatorNode = (OperatorDeclaration)dataNode;
node.ElementName = operatorNode.OperatorToken
+ " " + operatorNode.OperatorTypeToken;
var operatorNode = (OperatorDeclaration)dataNode;
node.Name = operatorNode.OperatorToken
+ " "
+ operatorNode.OperatorTypeToken;
if (showExtendedInfos) {
node.ElementName += " " + operatorNode.LParToken
+ GetParameterDeclsAsString(operatorNode.Parameters)
+ operatorNode.RParToken;
}
if (colorizeNode)
node.ForegroundBrush = Brushes.Black;
if (showExtendedInfos) {
node.Name += " "
+ operatorNode.LParToken
+ GetParameterDeclsAsString(operatorNode.Parameters)
+ operatorNode.RParToken;
}
switch(GetAccessModifier(dataNode)) {
case Modifiers.Public:
node.IconName = "Icons.16x16.Method";
@ -348,12 +357,13 @@ namespace CSharpBinding.OutlinePad @@ -348,12 +357,13 @@ namespace CSharpBinding.OutlinePad
}
internal static void SetMethodNodeInfos(CSharpOutlineNode node, AstNode dataNode) {
var methodNode = (MethodDeclaration)dataNode;
node.ElementName = methodNode.Name;
var methodNode = (MethodDeclaration)dataNode;
node.Name = methodNode.Name;
node.ElementName += " " + methodNode.LParToken
+ (showExtendedInfos ? GetParameterDeclsAsString(methodNode.Parameters) : "")
+ methodNode.RParToken;
node.Name += " "
+ methodNode.LParToken
+ (showExtendedInfos ? GetParameterDeclsAsString(methodNode.Parameters) : "")
+ methodNode.RParToken;
if (colorizeNode)
node.ForegroundBrush = (methodHighLighting.Foreground as SimpleHighlightingBrush).GetBrush(null);
@ -390,7 +400,8 @@ namespace CSharpBinding.OutlinePad @@ -390,7 +400,8 @@ namespace CSharpBinding.OutlinePad
current++;
}
node.ElementName = fieldName.ToString();
node.Name = fieldName.ToString();
if (colorizeNode)
node.ForegroundBrush = Brushes.Black;
@ -413,14 +424,16 @@ namespace CSharpBinding.OutlinePad @@ -413,14 +424,16 @@ namespace CSharpBinding.OutlinePad
internal static void SetPropertyNodeInfos(CSharpOutlineNode node, AstNode dataNode) {
var propertyNode = (PropertyDeclaration)dataNode;
node.ElementName = propertyNode.Name;
node.Name = propertyNode.Name;
if (colorizeNode)
node.ForegroundBrush = Brushes.Black;
if (showExtendedInfos) {
node.ElementName += " " + propertyNode.LBraceToken
+ " " + propertyNode.Getter.Keyword + (!string.IsNullOrEmpty(propertyNode.Getter.Keyword.ToString()) ? ";" : "")
+ " " + propertyNode.Setter.Keyword + (!string.IsNullOrEmpty(propertyNode.Setter.Keyword.ToString()) ? ";" : "")
+ " " + propertyNode.RBraceToken;
node.Name += " " + propertyNode.LBraceToken
+ " " + propertyNode.Getter.Keyword + (!string.IsNullOrEmpty(propertyNode.Getter.Keyword.ToString()) ? ";" : "")
+ " " + propertyNode.Setter.Keyword + (!string.IsNullOrEmpty(propertyNode.Setter.Keyword.ToString()) ? ";" : "")
+ " " + propertyNode.RBraceToken;
}
switch(GetAccessModifier(dataNode)) {
case Modifiers.Public:
@ -441,17 +454,20 @@ namespace CSharpBinding.OutlinePad @@ -441,17 +454,20 @@ namespace CSharpBinding.OutlinePad
internal static void SetIndexerNodeInfos(CSharpOutlineNode node, AstNode dataNode) {
var indexerNode = (IndexerDeclaration)dataNode;
node.ElementName = indexerNode.ReturnType.ToString() + " " + indexerNode.ThisToken.ToString()
+ indexerNode.LBracketToken
+ GetParameterDeclsAsString(indexerNode.Parameters)
+ indexerNode.RBracketToken;
node.Name = indexerNode.ReturnType.ToString()
+ " "
+ indexerNode.ThisToken.ToString()
+ indexerNode.LBracketToken
+ GetParameterDeclsAsString(indexerNode.Parameters)
+ indexerNode.RBracketToken;
if (colorizeNode)
node.ForegroundBrush = Brushes.Black;
if (showExtendedInfos) {
node.ElementName += " " + indexerNode.LBraceToken
+ " " + indexerNode.Getter.Keyword + (!string.IsNullOrEmpty(indexerNode.Getter.Keyword.ToString()) ? ";" : "")
+ " " + indexerNode.Setter.Keyword + (!string.IsNullOrEmpty(indexerNode.Setter.Keyword.ToString()) ? ";" : "")
+ " " + indexerNode.RBraceToken;
node.Name += " " + indexerNode.LBraceToken
+ " " + indexerNode.Getter.Keyword + (!string.IsNullOrEmpty(indexerNode.Getter.Keyword.ToString()) ? ";" : "")
+ " " + indexerNode.Setter.Keyword + (!string.IsNullOrEmpty(indexerNode.Setter.Keyword.ToString()) ? ";" : "")
+ " " + indexerNode.RBraceToken;
}
switch(GetAccessModifier(dataNode)) {
case Modifiers.Public:
@ -471,10 +487,11 @@ namespace CSharpBinding.OutlinePad @@ -471,10 +487,11 @@ namespace CSharpBinding.OutlinePad
}
internal static void SetNameSpaceNodeInfos(CSharpOutlineNode node, AstNode dataNode) {
var nameSpaceNode = (NamespaceDeclaration)dataNode;
node.ElementName = nameSpaceNode.Name;
node.IconName = "Icons.16x16.NameSpace";
node.IsExpanded = true;
var nameSpaceNode = (NamespaceDeclaration)dataNode;
node.Name = nameSpaceNode.Name;
node.IconName = "Icons.16x16.NameSpace";
node.IsExpanded = true;
if (colorizeNode)
node.ForegroundBrush = (nameSpaceHighLighting.Foreground as SimpleHighlightingBrush).GetBrush(null);
// node.Weight = nameSpaceHighLighting.FontWeight != null ? nameSpaceHighLighting.FontWeight.Value : FontWeights.Normal;
@ -486,14 +503,15 @@ namespace CSharpBinding.OutlinePad @@ -486,14 +503,15 @@ namespace CSharpBinding.OutlinePad
internal static void SetConstructorNodeInfos(CSharpOutlineNode node, AstNode dataNode) {
var constructorNode = (ConstructorDeclaration)dataNode;
node.ElementName = constructorNode.Name;
node.Name = constructorNode.Name;
if (colorizeNode)
node.ForegroundBrush = Brushes.Black;
node.ElementName += " "
+ constructorNode.LParToken
+ (showExtendedInfos ? GetParameterDeclsAsString(constructorNode.Parameters) : "")
+ constructorNode.RParToken;
node.Name += " "
+ constructorNode.LParToken
+ (showExtendedInfos ? GetParameterDeclsAsString(constructorNode.Parameters) : "")
+ constructorNode.RParToken;
switch(GetAccessModifier(dataNode)) {
case Modifiers.Public:
@ -513,10 +531,11 @@ namespace CSharpBinding.OutlinePad @@ -513,10 +531,11 @@ namespace CSharpBinding.OutlinePad
}
internal static void SetDocumentNodeInfos(CSharpOutlineNode node, AstNode dataNode) {
node.ElementName = Path.GetFileName(((SyntaxTree)dataNode).FileName);
node.IconName = "C#.File.FullFile";
node.Name = Path.GetFileName(((SyntaxTree)dataNode).FileName);
node.IconName = "C#.File.FullFile";
node.IsExpanded = true;
node.Weight = FontWeights.Bold;
node.Weight = FontWeights.Bold;
if (colorizeNode)
node.ForegroundBrush = Brushes.Black;
}

42
src/AddIns/BackendBindings/CSharpBinding/Project/Src/OutlinePad/CSharpOutlineNode.cs

@ -25,30 +25,22 @@ using ICSharpCode.SharpDevelop; @@ -25,30 +25,22 @@ using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.TreeView;
using ICSharpCode.NRefactory.CSharp;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.Core.Presentation;
using System.Windows.Controls;
using ICSharpCode.AvalonEdit.Folding;
namespace CSharpBinding.OutlinePad
{
class CSharpOutlineNode : SharpTreeNode
{
string elementName, name, iconName;
public string ElementName {
get { return elementName; }
set {
this.elementName = value;
this.RaisePropertyChanged("Text");
}
}
string name, iconName;
public string Name {
get { return name; }
set {
this.name = value;
this.RaisePropertyChanged("Text");
if (this.name != value) {
this.name = value;
this.RaisePropertyChanged("Text");
}
}
}
@ -65,14 +57,16 @@ namespace CSharpBinding.OutlinePad @@ -65,14 +57,16 @@ namespace CSharpBinding.OutlinePad
public string IconName {
get { return iconName; }
set {
iconName = value;
this.RaisePropertyChanged("Icon");
if (iconName != value) {
iconName = value;
this.RaisePropertyChanged("Icon");
}
}
}
public string GetSourceText() {
if (StartMarker.IsDeleted || EndMarker.IsDeleted)
return "";
return string.Empty;
return Editor.Document.GetText(StartMarker.Offset, EndMarker.Offset - StartMarker.Offset);
}
@ -97,7 +91,7 @@ namespace CSharpBinding.OutlinePad @@ -97,7 +91,7 @@ namespace CSharpBinding.OutlinePad
}
public override object Text {
get { return (!string.IsNullOrEmpty(Name) ? ElementName + " (" + Name + ")" : ElementName); }
get { return Name; }
}
public override object Icon {
@ -127,18 +121,23 @@ namespace CSharpBinding.OutlinePad @@ -127,18 +121,23 @@ namespace CSharpBinding.OutlinePad
return weight;
}
set {
weight = value;
RaisePropertyChanged("FontWeight");
if (weight != value) {
weight = value;
RaisePropertyChanged("FontWeight");
}
}
}
FontStyle style = FontStyles.Normal;
public FontStyle Style {
get {
return style;
}
set {
style = value;
RaisePropertyChanged("FontStyle");
if (style != value) {
style = value;
RaisePropertyChanged("FontStyle");
}
}
}
@ -160,6 +159,7 @@ namespace CSharpBinding.OutlinePad @@ -160,6 +159,7 @@ namespace CSharpBinding.OutlinePad
if (cmd.CanExecute(this))
cmd.Execute(this);
}
protected override void OnCollapsing() {
var cmd = new HandleFoldingCommand();
if (cmd.CanExecute(this))

2
src/Libraries/SharpTreeView/ICSharpCode.TreeView/Themes/Generic.xaml

@ -182,6 +182,8 @@ @@ -182,6 +182,8 @@
<Border Background="{TemplateBinding Background}">
<Default:SharpTreeNodeView Name="nodeView"
Foreground="{Binding Foreground}"
FontWeight="{Binding Weight}"
FontStyle="{Binding Style}"
HorizontalAlignment="Left" />
</Border>
</Border>

Loading…
Cancel
Save