11namespace NetContextServer . Extensions ;
22
3+ /// <summary>
4+ /// Provides extension methods for string manipulation and code content formatting.
5+ /// </summary>
36internal static class StringExtensions
47{
8+ /// <summary>
9+ /// Extracts a name from a line of code following a specified keyword.
10+ /// </summary>
11+ /// <param name="line">The line of code to analyze.</param>
12+ /// <param name="keyword">The keyword that precedes the name to extract.</param>
13+ /// <returns>The extracted name, or an empty string if no name is found.</returns>
14+ /// <remarks>
15+ /// The method looks for the first occurrence of the keyword followed by a space,
16+ /// then extracts the text until it encounters a space, opening brace, colon, or parenthesis.
17+ /// </remarks>
518 public static string ExtractName ( string line , string keyword )
619 {
720 int keywordIndex = line . IndexOf ( keyword + " " ) ;
@@ -30,6 +43,15 @@ public static string ExtractName(string line, string keyword)
3043 return string . Empty ;
3144 }
3245
46+ /// <summary>
47+ /// Extracts a method name from a line of code.
48+ /// </summary>
49+ /// <param name="line">The line of code containing the method declaration.</param>
50+ /// <returns>The extracted method name, or an empty string if no method name is found.</returns>
51+ /// <remarks>
52+ /// The method extracts the text between the last space and the opening parenthesis
53+ /// in the line, which typically represents the method name in a method declaration.
54+ /// </remarks>
3355 public static string ExtractMethodName ( string line )
3456 {
3557 // Extract the method name from the line (text before the opening parenthesis)
@@ -50,6 +72,20 @@ public static string ExtractMethodName(string line)
5072 return string . Empty ;
5173 }
5274
75+ /// <summary>
76+ /// Formats code content by managing blank lines and structural elements for improved readability.
77+ /// </summary>
78+ /// <param name="content">The code content to format.</param>
79+ /// <returns>The formatted code content with optimized blank line placement.</returns>
80+ /// <remarks>
81+ /// This method performs the following formatting operations:
82+ /// <list type="bullet">
83+ /// <item><description>Removes excessive blank lines</description></item>
84+ /// <item><description>Ensures proper structure with opening/closing braces</description></item>
85+ /// <item><description>Adds strategic blank lines before significant declarations</description></item>
86+ /// <item><description>Maintains a maximum ratio of 25% blank lines</description></item>
87+ /// </list>
88+ /// </remarks>
5389 public static string FormatCodeContent ( string content )
5490 {
5591 // First, remove all blank lines completely
0 commit comments