Skip to content

Commit bfc4ce1

Browse files
committed
Cleanup and refactor a lot of logic out to the extension functions, reduce some unnecessary ast searches
1 parent 2233a66 commit bfc4ce1

File tree

2 files changed

+158
-143
lines changed

2 files changed

+158
-143
lines changed

src/PowerShellEditorServices/Services/TextDocument/RenameService.cs

+1-23
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ private static TextEdit[] RenameVariable(Ast symbol, Ast scriptAst, RenameParams
132132
/// Finds the most specific renamable symbol at the given position
133133
/// </summary>
134134
/// <returns>Ast of the token or null if no renamable symbol was found</returns>
135-
internal static Ast? FindRenamableSymbol(ScriptFile scriptFile, ScriptPositionAdapter position)
135+
internal static Ast? FindRenamableSymbol(ScriptFile scriptFile, IScriptPosition position)
136136
{
137137
List<Type> renameableAstTypes = [
138138
// Functions
@@ -604,26 +604,4 @@ internal record ScriptExtentAdapter(IScriptExtent extent) : IScriptExtent
604604
public int StartColumnNumber => extent.StartColumnNumber;
605605
public int StartLineNumber => extent.StartLineNumber;
606606
public string Text => extent.Text;
607-
608-
public bool Contains(IScriptPosition position) => Contains(new ScriptPositionAdapter(position));
609-
610-
public bool Contains(ScriptPositionAdapter position)
611-
{
612-
if (position.Line < Start.Line || position.Line > End.Line)
613-
{
614-
return false;
615-
}
616-
617-
if (position.Line == Start.Line && position.Character < Start.Character)
618-
{
619-
return false;
620-
}
621-
622-
if (position.Line == End.Line && position.Character > End.Character)
623-
{
624-
return false;
625-
}
626-
627-
return true;
628-
}
629607
}

0 commit comments

Comments
 (0)