Browse Source

added ctor snippet for VB and fixed VB-specific issues in the InsertCtor*-logic

4.0
Siegfried Pammer 15 years ago
parent
commit
045f41469c
  1. 8
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Snippets/SnippetManager.cs
  2. 2
      src/AddIns/Misc/SharpRefactoring/Project/Src/Gui/InsertCtorDialog.xaml.cs
  3. 7
      src/AddIns/Misc/SharpRefactoring/Project/Src/InsertCtorSnippetRefactoring.cs

8
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Snippets/SnippetManager.cs

@ -219,6 +219,14 @@ End If",
End While", End While",
Keyword = "While" Keyword = "While"
}, },
new CodeSnippet {
Name = "ctor",
Description = "Constructor",
Text = @"Public Sub New(${anchor:parameterList})
${refactoring:ctor}
End Sub",
Keyword = "Sub"
},
new CodeSnippet { new CodeSnippet {
Name = "Select", Name = "Select",
Description = "Select statement", Description = "Select statement",

2
src/AddIns/Misc/SharpRefactoring/Project/Src/Gui/InsertCtorDialog.xaml.cs

@ -80,7 +80,7 @@ namespace SharpRefactoring.Gui
new ThrowStatement( new ThrowStatement(
new ObjectCreateExpression( new ObjectCreateExpression(
new TypeReference("ArgumentOutOfRangeException"), new TypeReference("ArgumentOutOfRangeException"),
new List<Expression>() { new PrimitiveExpression(w.ParameterName, '"' + w.ParameterName + '"'), new IdentifierExpression(w.ParameterName), new BinaryOperatorExpression(new PrimitiveExpression("Value must be between "), BinaryOperatorType.Add, new BinaryOperatorExpression(new IdentifierExpression("lower"), BinaryOperatorType.Add, new BinaryOperatorExpression(new PrimitiveExpression(" and "), BinaryOperatorType.Add, new IdentifierExpression("upper")))) } new List<Expression>() { new PrimitiveExpression(w.ParameterName, '"' + w.ParameterName + '"'), new IdentifierExpression(w.ParameterName), new BinaryOperatorExpression(new PrimitiveExpression("Value must be between "), BinaryOperatorType.Concat, new BinaryOperatorExpression(new IdentifierExpression("lower"), BinaryOperatorType.Concat, new BinaryOperatorExpression(new PrimitiveExpression(" and "), BinaryOperatorType.Concat, new IdentifierExpression("upper")))) }
) )
) )
) )

7
src/AddIns/Misc/SharpRefactoring/Project/Src/InsertCtorSnippetRefactoring.cs

@ -70,14 +70,17 @@ namespace SharpRefactoring
{ {
int i = 0; int i = 0;
foreach (var f in sourceClass.Fields.Where(field => !field.IsConst && field.IsStatic == sourceClass.IsStatic)) { foreach (var f in sourceClass.Fields.Where(field => !field.IsConst
&& field.IsStatic == sourceClass.IsStatic
&& field.ReturnType != null)) {
yield return new PropertyOrFieldWrapper(f) { Index = i, IsSelected = true }; yield return new PropertyOrFieldWrapper(f) { Index = i, IsSelected = true };
i++; i++;
} }
foreach (var p in sourceClass.Properties.Where(prop => prop.CanSet && !prop.IsIndexer foreach (var p in sourceClass.Properties.Where(prop => prop.CanSet && !prop.IsIndexer
&& PropertyRefactoringMenuBuilder.IsAutomaticProperty(prop) && PropertyRefactoringMenuBuilder.IsAutomaticProperty(prop)
&& prop.IsStatic == sourceClass.IsStatic)) { && prop.IsStatic == sourceClass.IsStatic
&& prop.ReturnType != null)) {
yield return new PropertyOrFieldWrapper(p) { Index = i, IsSelected = true }; yield return new PropertyOrFieldWrapper(p) { Index = i, IsSelected = true };
i++; i++;
} }

Loading…
Cancel
Save