Skip to content

Commit

Permalink
Merge pull request #18 from thedemons/fix-functionblock-name
Browse files Browse the repository at this point in the history
Fix function name recognition when refactoring function
  • Loading branch information
fortenforge authored Dec 12, 2023
2 parents 98471e9 + e2a3204 commit 9ee8b13
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 3 additions & 2 deletions CodeiumVS/Utilities/CodeAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ public static Span GetBlockSpan(ITextView view, int position, out IStructureTag?
) return null;

var splits = desc.Split('(');
string functionName = splits[0].Split(' ').Last();
string fullname = splits[0].Split(' ').Last();
string name = fullname.Split(':').Last().Split('.').Last();
string parameters = "";

if (splits.Length >= 2)
Expand All @@ -143,7 +144,7 @@ public static Span GetBlockSpan(ITextView view, int position, out IStructureTag?
parameters = parameters.Substring(0, parameters.LastIndexOf(')'));
}

return new(functionName, parameters, spans[0]);
return new(fullname, name, parameters, spans[0]);
}

public static FunctionBlock? GetFunctionBlock(IWpfTextView view, int line, int column)
Expand Down
10 changes: 9 additions & 1 deletion CodeiumVS/Utilities/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,18 @@ public override void Dispose()
}
}

internal class FunctionBlock(string name, string @params, TextSpan span)
internal class FunctionBlock(string fullname, string name, string @params, TextSpan span)
{
// full name of the function, including namespaces and classes
public readonly string FullName = fullname;

// short name of the function
public readonly string Name = name;

// parameters, not including the braces
public readonly string Params = @params;

// span of the function body
public readonly TextSpan Span = span;
}

0 comments on commit 9ee8b13

Please sign in to comment.