@@ -93,6 +93,7 @@ public IALObject Read(IEnumerable<string> Lines)
9393 GetObjectProperties ( Lines , Target ) ;
9494 GetGlobalVariables ( Lines , Target ) ;
9595 GetSections ( Lines , Target ) ;
96+ GetRange ( Lines , Target ) ;
9697 Target . ProcessSections ( ) ;
9798 IALObject NewTarget ;
9899 OnRead ( Lines , Target , out NewTarget ) ;
@@ -248,7 +249,7 @@ public virtual void OnGetObjectProperty(string Line, IALSection Target, string p
248249 /// <param name="Target">Current ALObject instance</param>
249250 public void GetMethods ( IEnumerable < string > Lines , IALSection Target )
250251 {
251- var pattern = @"^\s{0,4}(local|procedure|trigger)\s+(.*?)\((.*?)\)\:?(.*)" ;
252+ var pattern = @"^\s{0,4}(local procedure |procedure|trigger)\s+(.*?)\((.*?)\)\:?(.*)" ;
252253 var procedures = Lines
253254 . Where ( w => Regex . IsMatch ( w , pattern ) )
254255 . ToList ( ) ;
@@ -333,15 +334,15 @@ public void GetMethods(IEnumerable<string> Lines, IALSection Target)
333334
334335 // Check for Attributes
335336 end = txtLines . IndexOf ( s ) - 1 ;
336- start = txtLines . IndexOf ( s ) - 1 ;
337- var testMethod = Lines . ElementAt ( start ) ;
338- while ( testMethod . Trim ( ) != String . Empty &&
337+ start = txtLines . IndexOf ( s ) - 1 ;
338+ var testMethod = Lines . ElementAt ( start ) ;
339+ while ( testMethod . Trim ( ) != String . Empty &&
339340 ! testMethod . ToLower ( ) . Contains ( "end;" ) &&
340341 ! testMethod . ToLower ( ) . Contains ( "{" ) )
342+ {
343+ if ( testMethod . ToLower ( ) . Contains ( "[test" ) )
341344 {
342- if ( testMethod . ToLower ( ) . Contains ( "[test" ) )
343- {
344- method . TestMethod = true ;
345+ method . TestMethod = true ;
345346 //break;
346347 }
347348
@@ -355,23 +356,23 @@ public void GetMethods(IEnumerable<string> Lines, IALSection Target)
355356 } ;
356357 attr . IsEvent = attr . Name . ToLower ( ) . Contains ( "event" ) ;
357358 method . Attributes . Add ( attr ) ;
358- }
359+ }
359360
360- start -= 1 ;
361- if ( start < 0 )
362- {
363- break ;
364- }
365- testMethod = Lines . ElementAt ( start ) ;
361+ start -= 1 ;
362+ if ( start < 0 )
363+ {
364+ break ;
366365 }
366+ testMethod = Lines . ElementAt ( start ) ;
367+ }
367368
368369 start += 1 ;
369370 end += 1 ;
370371 var linesAboveMethod = txtLines
371372 . GetRange ( start , end - start )
372373 . Select ( s => s . Trim ( ) )
373374 . Where ( w => ! w . StartsWith ( "[" ) ) ;
374- //.Where(w => w.StartsWith("//") || w.StartsWith("/*") || w.EndsWith("*/"));
375+ //.Where(w => w.StartsWith("//") || w.StartsWith("/*") || w.EndsWith("*/"));
375376 var txtAboveMethod = string . Join ( "\r \n " , linesAboveMethod ) ;
376377 txtAboveMethod = txtAboveMethod
377378 . Replace ( "///" , "" )
@@ -427,6 +428,25 @@ public ICollection<ALComment> GetComments(IEnumerable<string> Lines)
427428
428429 return comments ;
429430 }
431+ public void GetRange ( IEnumerable < string > Lines , IALObject Target )
432+ {
433+ string contents = String . Join ( "__" , Lines ) ;
434+ foreach ( ALMethod method in Target . Methods )
435+ {
436+ Match match = Regex . Match ( contents , $ "(.*)(local)? (procedure|trigger) { method . Name } \\ (", RegexOptions . IgnoreCase ) ;
437+ if ( ! match . Success )
438+ continue ;
439+ string textBeforeProcedure = contents . Substring ( 0 , match . Groups [ 1 ] . Length ) ;
440+ int startLineNo = ( textBeforeProcedure . Length - textBeforeProcedure . Replace ( "__" , "" ) . Length ) / 2 ;
441+ string pattern = ".{" + textBeforeProcedure . Length + "}.+?__ end;" ;
442+ match = Regex . Match ( contents , pattern , RegexOptions . IgnoreCase ) ;
443+ if ( ! match . Success )
444+ continue ;
445+ string textUntilEndOfProcedure = contents . Substring ( 0 , match . Groups [ 0 ] . Length ) ;
446+ int endLineNo = ( textUntilEndOfProcedure . Length - textUntilEndOfProcedure . Replace ( "__" , "" ) . Length ) / 2 ;
447+ method . MethodRange = new Range ( startLineNo , endLineNo ) ;
448+ }
449+ }
430450
431451 public void GetSections ( IEnumerable < string > Lines , IALSection Target )
432452 {
0 commit comments