Browse Source

ported ExtractMethodCommand to ITextEditor

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4684 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Siegfried Pammer 17 years ago
parent
commit
c3fe371f8f
  1. 14
      src/AddIns/Misc/SharpRefactoring/SharpRefactoring.csproj
  2. 21
      src/AddIns/Misc/SharpRefactoring/Src/CSharpMethodExtractor.cs
  3. 27
      src/AddIns/Misc/SharpRefactoring/Src/ExtractMethodCommand.cs
  4. 6
      src/AddIns/Misc/SharpRefactoring/Src/Forms/ExtractMethodForm.cs
  5. 53
      src/AddIns/Misc/SharpRefactoring/Src/MethodExtractorBase.cs
  6. 5
      src/AddIns/Misc/SharpRefactoring/Src/Visitors/FindJumpInstructionsVisitor.cs
  7. 27
      src/AddIns/Misc/SharpRefactoring/Src/Visitors/FindMemberVisitor.cs

14
src/AddIns/Misc/SharpRefactoring/SharpRefactoring.csproj

@ -40,6 +40,12 @@
</PropertyGroup> </PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup> <ItemGroup>
<Reference Include="PresentationCore">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="PresentationFramework">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core"> <Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework> <RequiredTargetFramework>3.5</RequiredTargetFramework>
@ -47,6 +53,9 @@
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="WindowsBase">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="SharpRefactoring.addin"> <None Include="SharpRefactoring.addin">
@ -76,11 +85,6 @@
</EmbeddedResource> </EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\Libraries\ICSharpCode.TextEditor\Project\ICSharpCode.TextEditor.csproj">
<Project>{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}</Project>
<Name>ICSharpCode.TextEditor</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\Libraries\NRefactory\Project\NRefactory.csproj"> <ProjectReference Include="..\..\..\Libraries\NRefactory\Project\NRefactory.csproj">
<Project>{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}</Project> <Project>{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}</Project>
<Name>NRefactory</Name> <Name>NRefactory</Name>

21
src/AddIns/Misc/SharpRefactoring/Src/CSharpMethodExtractor.cs

@ -5,11 +5,11 @@
// <version>$Revision: 3287 $</version> // <version>$Revision: 3287 $</version>
// </file> // </file>
using ICSharpCode.SharpDevelop.Editor;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.NRefactory; using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.Ast; using ICSharpCode.NRefactory.Ast;
@ -18,7 +18,6 @@ using ICSharpCode.NRefactory.Visitors;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom.NRefactoryResolver; using ICSharpCode.SharpDevelop.Dom.NRefactoryResolver;
using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.TextEditor.Document;
using SharpRefactoring.Visitors; using SharpRefactoring.Visitors;
using Dom = ICSharpCode.SharpDevelop.Dom; using Dom = ICSharpCode.SharpDevelop.Dom;
@ -28,8 +27,8 @@ namespace SharpRefactoring
{ {
static readonly StringComparer CSharpNameComparer = StringComparer.Ordinal; static readonly StringComparer CSharpNameComparer = StringComparer.Ordinal;
public CSharpMethodExtractor(ICSharpCode.TextEditor.TextEditorControl textEditor, ISelection selection) public CSharpMethodExtractor(ITextEditor textEditor)
: base(textEditor, selection) : base(textEditor)
{ {
} }
@ -47,7 +46,7 @@ namespace SharpRefactoring
public override bool Extract() public override bool Extract()
{ {
using (var parser = ParserFactory.CreateParser(SupportedLanguage.CSharp, new StringReader("class Tmp { void Test() {\n " + this.currentSelection.SelectedText + "\n}}"))) { using (var parser = ParserFactory.CreateParser(SupportedLanguage.CSharp, new StringReader("class Tmp { void Test() {\n " + this.textEditor.SelectedText + "\n}}"))) {
parser.Parse(); parser.Parse();
if (parser.Errors.Count > 0) { if (parser.Errors.Count > 0) {
@ -68,17 +67,17 @@ namespace SharpRefactoring
List<VariableDeclaration> otherReturnValues = new List<VariableDeclaration>(); List<VariableDeclaration> otherReturnValues = new List<VariableDeclaration>();
// Initialise new method // Initialise new method
newMethod.Body = GetBlock(this.currentSelection.SelectedText); newMethod.Body = GetBlock(this.textEditor.SelectedText);
newMethod.Body.StartLocation = new Location(0,0); newMethod.Body.StartLocation = new Location(0,0);
this.parentNode = GetParentMember(this.currentSelection.StartPosition.Line, this.currentSelection.StartPosition.Column, this.currentSelection.EndPosition.Line, this.currentSelection.EndPosition.Column); this.parentNode = GetParentMember(start, end);
if (parentNode == null) { if (parentNode == null) {
MessageService.ShowError("${res:AddIns.SharpRefactoring.ExtractMethod.InvalidSelection}"); MessageService.ShowError("${res:AddIns.SharpRefactoring.ExtractMethod.InvalidSelection}");
return false; return false;
} }
if (!CheckForJumpInstructions(newMethod, this.currentSelection)) if (!CheckForJumpInstructions(newMethod))
return false; return false;
newMethod.Modifier = parentNode.Modifier; newMethod.Modifier = parentNode.Modifier;
@ -101,12 +100,12 @@ namespace SharpRefactoring
bool isInitialized = (variable.Initializer != null) ? !variable.Initializer.IsNull : false; bool isInitialized = (variable.Initializer != null) ? !variable.Initializer.IsNull : false;
bool hasAssignment = HasAssignment(newMethod, variable); bool hasAssignment = HasAssignment(newMethod, variable);
if (IsInSel(variable.StartPos, this.currentSelection) && hasOccurrencesAfter) { if (IsInCurrentSelection(variable.StartPos) && hasOccurrencesAfter) {
possibleReturnValues.Add(new VariableDeclaration(variable.Name, variable.Initializer, variable.Type)); possibleReturnValues.Add(new VariableDeclaration(variable.Name, variable.Initializer, variable.Type));
otherReturnValues.Add(new VariableDeclaration(variable.Name, variable.Initializer, variable.Type)); otherReturnValues.Add(new VariableDeclaration(variable.Name, variable.Initializer, variable.Type));
} }
if (!(IsInSel(variable.StartPos, this.currentSelection) || IsInSel(variable.EndPos, this.currentSelection))) { if (!(IsInCurrentSelection(variable.StartPos) || IsInCurrentSelection(variable.EndPos))) {
ParameterDeclarationExpression newParam = null; ParameterDeclarationExpression newParam = null;
if ((hasOccurrencesAfter && isInitialized) || variable.WasRefParam) if ((hasOccurrencesAfter && isInitialized) || variable.WasRefParam)
@ -169,7 +168,7 @@ namespace SharpRefactoring
Dom.ExpressionResult res = new Dom.ExpressionResult(variable.Name, Dom.ExpressionResult res = new Dom.ExpressionResult(variable.Name,
Dom.DomRegion.FromLocation(variable.StartPos, variable.EndPos), Dom.DomRegion.FromLocation(variable.StartPos, variable.EndPos),
Dom.ExpressionContext.Default, null); Dom.ExpressionContext.Default, null);
Dom.ResolveResult result = this.GetResolver().Resolve(res, info, this.textEditor.Document.TextContent); Dom.ResolveResult result = this.GetResolver().Resolve(res, info, this.textEditor.Document.Text);
if (variable.Type.Type == "var") if (variable.Type.Type == "var")
variable.Type = Dom.Refactoring.CodeGenerator.ConvertType(result.ResolvedType, new Dom.ClassFinder(result.CallingMember)); variable.Type = Dom.Refactoring.CodeGenerator.ConvertType(result.ResolvedType, new Dom.ClassFinder(result.CallingMember));

27
src/AddIns/Misc/SharpRefactoring/Src/ExtractMethodCommand.cs

@ -5,18 +5,14 @@
// <version>$Revision$</version> // <version>$Revision$</version>
// </file> // </file>
using ICSharpCode.SharpDevelop.Dom.Refactoring;
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.NRefactory.PrettyPrinter; using ICSharpCode.NRefactory.PrettyPrinter;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Dom.Refactoring;
using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Refactoring; using ICSharpCode.SharpDevelop.Refactoring;
using ICSharpCode.TextEditor;
using SharpRefactoring.Forms; using SharpRefactoring.Forms;
namespace SharpRefactoring namespace SharpRefactoring
@ -26,7 +22,7 @@ namespace SharpRefactoring
protected override void Run(ITextEditor textEditor, RefactoringProvider provider) protected override void Run(ITextEditor textEditor, RefactoringProvider provider)
{ {
if (textEditor.SelectionLength > 0) { if (textEditor.SelectionLength > 0) {
/*
MethodExtractorBase extractor = GetCurrentExtractor(textEditor); MethodExtractorBase extractor = GetCurrentExtractor(textEditor);
if (extractor != null) { if (extractor != null) {
if (extractor.Extract()) { if (extractor.Extract()) {
@ -34,31 +30,28 @@ namespace SharpRefactoring
if (form.ShowDialog() == DialogResult.OK) { if (form.ShowDialog() == DialogResult.OK) {
extractor.ExtractedMethod.Name = form.Text; extractor.ExtractedMethod.Name = form.Text;
try { using (textEditor.Document.OpenUndoGroup()) {
textEditor.Document.UndoStack.StartUndoGroup();
extractor.InsertAfterCurrentMethod(); extractor.InsertAfterCurrentMethod();
extractor.InsertCall(); extractor.InsertCall();
textEditor.Document.FormattingStrategy.IndentLines(textEditor.ActiveTextAreaControl.TextArea, 0, textEditor.Document.TotalNumberOfLines - 1); textEditor.Language.FormattingStrategy.IndentLines(textEditor, 0, textEditor.Document.TotalNumberOfLines - 1);
} finally {
textEditor.Document.UndoStack.EndUndoGroup();
} }
textEditor.ActiveTextAreaControl.SelectionManager.ClearSelection(); textEditor.Select(textEditor.SelectionStart, 0);
} }
} }
}*/ }
} }
} }
/*
MethodExtractorBase GetCurrentExtractor(TextEditorControl editor) MethodExtractorBase GetCurrentExtractor(ITextEditor editor)
{ {
switch (ProjectBindingService.GetCodonPerCodeFileName(editor.FileName).Language) { switch (ProjectBindingService.GetCodonPerCodeFileName(editor.FileName).Language) {
case "C#": case "C#":
return new CSharpMethodExtractor(editor, editor.ActiveTextAreaControl.SelectionManager.SelectionCollection[0]); return new CSharpMethodExtractor(editor);
default: default:
MessageService.ShowError(string.Format(StringParser.Parse("${res:AddIns.SharpRefactoring.ExtractMethodNotSupported}"), ProjectBindingService.GetCodonPerCodeFileName(editor.FileName).Language)); MessageService.ShowError(string.Format(StringParser.Parse("${res:AddIns.SharpRefactoring.ExtractMethodNotSupported}"), ProjectBindingService.GetCodonPerCodeFileName(editor.FileName).Language));
return null; return null;
} }
}*/ }
} }
} }

6
src/AddIns/Misc/SharpRefactoring/Src/Forms/ExtractMethodForm.cs

@ -4,12 +4,10 @@
// <owner name="Siegfried Pammer" email="sie_pam@gmx.at"/> // <owner name="Siegfried Pammer" email="sie_pam@gmx.at"/>
// <version>$Revision$</version> // <version>$Revision$</version>
// </file> // </file>
using ICSharpCode.Core;
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using ICSharpCode.NRefactory; using ICSharpCode.Core;
using ICSharpCode.NRefactory.Ast; using ICSharpCode.NRefactory.Ast;
using ICSharpCode.NRefactory.PrettyPrinter; using ICSharpCode.NRefactory.PrettyPrinter;
using ICSharpCode.SharpDevelop.Refactoring; using ICSharpCode.SharpDevelop.Refactoring;

53
src/AddIns/Misc/SharpRefactoring/Src/MethodExtractorBase.cs

@ -4,6 +4,7 @@
// <owner name="Siegfried Pammer" email="sie_pam@gmx.at"/> // <owner name="Siegfried Pammer" email="sie_pam@gmx.at"/>
// <version>$Revision: 3287 $</version> // <version>$Revision: 3287 $</version>
// </file> // </file>
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
@ -15,8 +16,7 @@ using ICSharpCode.NRefactory.Ast;
using ICSharpCode.NRefactory.PrettyPrinter; using ICSharpCode.NRefactory.PrettyPrinter;
using ICSharpCode.NRefactory.Visitors; using ICSharpCode.NRefactory.Visitors;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.TextEditor; using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.TextEditor.Document;
using SharpRefactoring.Visitors; using SharpRefactoring.Visitors;
using Dom = ICSharpCode.SharpDevelop.Dom; using Dom = ICSharpCode.SharpDevelop.Dom;
@ -27,8 +27,7 @@ namespace SharpRefactoring
/// </summary> /// </summary>
public abstract class MethodExtractorBase public abstract class MethodExtractorBase
{ {
protected ICSharpCode.TextEditor.TextEditorControl textEditor; protected ITextEditor textEditor;
protected ISelection currentSelection;
protected IDocument currentDocument; protected IDocument currentDocument;
protected MethodDeclaration extractedMethod; protected MethodDeclaration extractedMethod;
protected ParametrizedNode parentNode; protected ParametrizedNode parentNode;
@ -50,14 +49,13 @@ namespace SharpRefactoring
get { return extractedMethod; } get { return extractedMethod; }
} }
public MethodExtractorBase(ICSharpCode.TextEditor.TextEditorControl textEditor, ISelection selection) public MethodExtractorBase(ITextEditor textEditor)
{ {
this.currentDocument = textEditor.Document; this.currentDocument = textEditor.Document;
this.textEditor = textEditor; this.textEditor = textEditor;
this.currentSelection = selection;
this.start = new Location(this.currentSelection.StartPosition.Column + 1, this.currentSelection.StartPosition.Line + 1); this.start = this.currentDocument.OffsetToPosition(this.textEditor.SelectionStart);
this.end = new Location(this.currentSelection.EndPosition.Column + 1, this.currentSelection.EndPosition.Line + 1); this.end = this.currentDocument.OffsetToPosition(this.textEditor.SelectionStart + this.textEditor.SelectionLength);
} }
protected static Statement CreateCaller(ParametrizedNode parent, MethodDeclaration method, VariableDeclaration returnVariable) protected static Statement CreateCaller(ParametrizedNode parent, MethodDeclaration method, VariableDeclaration returnVariable)
@ -116,7 +114,7 @@ namespace SharpRefactoring
builder.AppendLine(GenerateCode(v, false)); builder.AppendLine(GenerateCode(v, false));
} }
this.currentDocument.Replace(this.currentSelection.Offset, this.currentSelection.Length, builder.ToString() + "\r\n" + call); this.currentDocument.Replace(this.textEditor.SelectionStart, this.textEditor.SelectionLength, builder.ToString() + "\r\n" + call);
} }
public void InsertAfterCurrentMethod() public void InsertAfterCurrentMethod()
@ -128,30 +126,32 @@ namespace SharpRefactoring
code = code.TrimEnd('\r', '\n', ' ', '\t'); code = code.TrimEnd('\r', '\n', ' ', '\t');
Dom.IMember p = GetParentMember(this.textEditor, this.currentSelection.StartPosition.Line + 1, this.currentSelection.StartPosition.Column + 1); Dom.IMember p = GetParentMember(this.textEditor, start.Line, start.Column);
TextLocation loc = new ICSharpCode.TextEditor.TextLocation(
p.BodyRegion.EndColumn - 1, p.BodyRegion.EndLine - 1);
int offset = textEditor.Document.PositionToOffset(loc); int offset = textEditor.Document.PositionToOffset(p.BodyRegion.EndLine, p.BodyRegion.EndColumn);
textEditor.Document.Insert(offset, code); textEditor.Document.Insert(offset, code);
} }
} }
protected static bool CheckForJumpInstructions(MethodDeclaration method, ISelection selection) protected static bool CheckForJumpInstructions(MethodDeclaration method)
{ {
FindJumpInstructionsVisitor fjiv = new FindJumpInstructionsVisitor(method, selection); FindJumpInstructionsVisitor fjiv = new FindJumpInstructionsVisitor(method);
method.AcceptVisitor(fjiv, null); method.AcceptVisitor(fjiv, null);
return fjiv.IsOk; return fjiv.IsOk;
} }
protected static bool IsInSel(Location location, ISelection sel) protected bool IsInCurrentSelection(Location location)
{ {
bool result = (sel.ContainsPosition(new ICSharpCode.TextEditor.TextLocation(location.Column - 1, location.Line - 1))); return IsInCurrentSelection(textEditor.Document.PositionToOffset(location.Line, location.Column));
return result; }
protected bool IsInCurrentSelection(int offset)
{
return (offset >= textEditor.SelectionStart &&
offset < (textEditor.SelectionStart + textEditor.SelectionLength));
} }
protected static BlockStatement GetBlock(string data) protected static BlockStatement GetBlock(string data)
@ -198,17 +198,14 @@ namespace SharpRefactoring
return expressions; return expressions;
} }
protected virtual string GenerateCode(INode unit, bool installSpecials) protected abstract string GenerateCode(INode unit, bool installSpecials);
{
throw new InvalidOperationException("Cannot use plain MethodExtractor, please use a language specific implementation!");
}
protected Dom.IMember GetParentMember(ICSharpCode.TextEditor.TextEditorControl textEditor, TextLocation location) protected Dom.IMember GetParentMember(ITextEditor textEditor, Location location)
{ {
return GetParentMember(textEditor, location.Line, location.Column); return GetParentMember(textEditor, location.Line, location.Column);
} }
protected Dom.IMember GetParentMember(ICSharpCode.TextEditor.TextEditorControl textEditor, int line, int column) protected Dom.IMember GetParentMember(ITextEditor textEditor, int line, int column)
{ {
Dom.ParseInformation parseInfo = ParserService.GetParseInformation(textEditor.FileName); Dom.ParseInformation parseInfo = ParserService.GetParseInformation(textEditor.FileName);
if (parseInfo != null) { if (parseInfo != null) {
@ -230,9 +227,9 @@ namespace SharpRefactoring
return null; return null;
} }
protected ParametrizedNode GetParentMember(int startLine, int startColumn, int endLine, int endColumn) protected ParametrizedNode GetParentMember(Location start, Location end)
{ {
using (IParser parser = ParserFactory.CreateParser(SupportedLanguage.CSharp, new StringReader(this.currentDocument.TextContent))) { using (IParser parser = ParserFactory.CreateParser(SupportedLanguage.CSharp, new StringReader(this.currentDocument.Text))) {
parser.Parse(); parser.Parse();
if (parser.Errors.Count > 0) { if (parser.Errors.Count > 0) {
@ -240,7 +237,7 @@ namespace SharpRefactoring
return null; return null;
} }
FindMemberVisitor fmv = new FindMemberVisitor(startColumn, startLine, endColumn, endLine); FindMemberVisitor fmv = new FindMemberVisitor(start, end);
parser.CompilationUnit.AcceptVisitor(fmv, null); parser.CompilationUnit.AcceptVisitor(fmv, null);

5
src/AddIns/Misc/SharpRefactoring/Src/Visitors/FindJumpInstructionsVisitor.cs

@ -12,7 +12,6 @@ using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.Ast; using ICSharpCode.NRefactory.Ast;
using ICSharpCode.NRefactory.Visitors; using ICSharpCode.NRefactory.Visitors;
using Dom = ICSharpCode.SharpDevelop.Dom; using Dom = ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.TextEditor.Document;
namespace SharpRefactoring.Visitors namespace SharpRefactoring.Visitors
{ {
@ -22,7 +21,6 @@ namespace SharpRefactoring.Visitors
public class FindJumpInstructionsVisitor : AbstractAstVisitor public class FindJumpInstructionsVisitor : AbstractAstVisitor
{ {
MethodDeclaration method; MethodDeclaration method;
ISelection selection;
List<LabelStatement> labels; List<LabelStatement> labels;
List<CaseLabel> cases; List<CaseLabel> cases;
bool isOk = true; bool isOk = true;
@ -31,10 +29,9 @@ namespace SharpRefactoring.Visitors
get { return isOk; } get { return isOk; }
} }
public FindJumpInstructionsVisitor(MethodDeclaration method, ISelection selection) public FindJumpInstructionsVisitor(MethodDeclaration method)
{ {
this.method = method; this.method = method;
this.selection = selection;
this.labels = new List<LabelStatement>(); this.labels = new List<LabelStatement>();
this.cases = new List<CaseLabel>(); this.cases = new List<CaseLabel>();
} }

27
src/AddIns/Misc/SharpRefactoring/Src/Visitors/FindMemberVisitor.cs

@ -14,26 +14,23 @@ namespace SharpRefactoring.Visitors
{ {
public class FindMemberVisitor : AbstractAstVisitor public class FindMemberVisitor : AbstractAstVisitor
{ {
int startColumn, startLine; Location start, end;
int endColumn, endLine;
ParametrizedNode member = null; ParametrizedNode member = null;
public ParametrizedNode Member { public ParametrizedNode Member {
get { return member; } get { return member; }
} }
public FindMemberVisitor(int startColumn, int startLine, int endColumn, int endLine) public FindMemberVisitor(Location start, Location end)
{ {
this.startColumn = startColumn; this.start = start;
this.startLine = startLine; this.end = end;
this.endColumn = endColumn;
this.endLine = endLine;
} }
public override object VisitMethodDeclaration(MethodDeclaration methodDeclaration, object data) public override object VisitMethodDeclaration(MethodDeclaration methodDeclaration, object data)
{ {
if ((methodDeclaration.Body.StartLocation < new Location(startColumn + 1, startLine + 1)) && if ((methodDeclaration.Body.StartLocation < start) &&
(methodDeclaration.Body.EndLocation > new Location(endColumn + 1, endLine + 1))) { (methodDeclaration.Body.EndLocation > end)) {
this.member = methodDeclaration; this.member = methodDeclaration;
} }
@ -42,8 +39,8 @@ namespace SharpRefactoring.Visitors
public override object VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, object data) public override object VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, object data)
{ {
if ((propertyDeclaration.BodyStart < new Location(startColumn + 1, startLine + 1)) && if ((propertyDeclaration.BodyStart < start) &&
(propertyDeclaration.BodyEnd > new Location(endColumn + 1, endLine + 1))) { (propertyDeclaration.BodyEnd > end)) {
this.member = propertyDeclaration; this.member = propertyDeclaration;
} }
return base.VisitPropertyDeclaration(propertyDeclaration, data); return base.VisitPropertyDeclaration(propertyDeclaration, data);
@ -51,8 +48,8 @@ namespace SharpRefactoring.Visitors
public override object VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, object data) public override object VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, object data)
{ {
if ((constructorDeclaration.Body.StartLocation < new Location(startColumn + 1, startLine + 1)) && if ((constructorDeclaration.Body.StartLocation < start) &&
(constructorDeclaration.Body.EndLocation > new Location(endColumn + 1, endLine + 1))) { (constructorDeclaration.Body.EndLocation > end)) {
this.member = constructorDeclaration; this.member = constructorDeclaration;
} }
@ -61,8 +58,8 @@ namespace SharpRefactoring.Visitors
public override object VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration, object data) public override object VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration, object data)
{ {
if ((operatorDeclaration.Body.StartLocation < new Location(startColumn + 1, startLine + 1)) && if ((operatorDeclaration.Body.StartLocation < start) &&
(operatorDeclaration.Body.EndLocation > new Location(endColumn + 1, endLine + 1))) { (operatorDeclaration.Body.EndLocation > end)) {
this.member = operatorDeclaration; this.member = operatorDeclaration;
} }

Loading…
Cancel
Save