Browse Source

Improved range checking of variable references

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3520 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Siegfried Pammer 17 years ago
parent
commit
6136b45d69
  1. 22
      src/AddIns/Misc/SharpRefactoring/Src/CSharpMethodExtractor.cs

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

@ -117,7 +117,7 @@ namespace SharpRefactoring @@ -117,7 +117,7 @@ namespace SharpRefactoring
foreach (KeyValuePair<string, List<LocalLookupVariable>> pair in ltv.Variables) {
foreach (LocalLookupVariable variable in pair.Value) {
if (variable.StartPos > end)
if (variable.StartPos > end || variable.EndPos < start)
continue;
if (IsInSel(variable.StartPos, this.currentSelection) && HasOccurrencesAfter(true, this.parentNode, new Location(this.currentSelection.EndPosition.Column + 1, this.currentSelection.EndPosition.Line + 1), variable.Name, variable.StartPos, variable.EndPos)) {
@ -176,26 +176,6 @@ namespace SharpRefactoring @@ -176,26 +176,6 @@ namespace SharpRefactoring
newMethod.AcceptVisitor(t, null);
CreateReturnStatement(newMethod, possibleReturnValues);
bool hasReturnStatement = false;
foreach (INode node in newMethod.Body.Children) {
if (node is ReturnStatement) {
hasReturnStatement = true;
}
}
if (!hasReturnStatement) {
Dom.IMember member = GetParentMember(this.textEditor, this.currentSelection.StartPosition);
Dom.IReturnType returnType = TypeVisitor.CreateReturnType(newMethod.TypeReference, member.DeclaringType, member,
this.currentSelection.StartPosition.Line, this.currentSelection.StartPosition.Column, member.DeclaringType.ProjectContent, true);
if (returnType.IsReferenceType == null || returnType.IsReferenceType == true)
newMethod.Body.AddChild(new ReturnStatement(new PrimitiveExpression(null, "null")));
else
newMethod.Body.AddChild(new ReturnStatement(ExpressionBuilder.CreateDefaultValueForType(newMethod.TypeReference)));
}
this.extractedMethod = newMethod;

Loading…
Cancel
Save