Skip to content

Commit

Permalink
fix method clean sourcing -> avoid false positives in dotAfterReturn
Browse files Browse the repository at this point in the history
  • Loading branch information
LinqLover committed Jan 5, 2025
1 parent d101d9f commit a4023d5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ withoutComments: noComments
withoutStrings: noStrings
withoutLiteralCharacters: noCharacters
"
Take a method source and remove the desired components.
Take a method source and remove the desired components, enabling simple parsing heuristics for analysis. (E.g., nested expressions can be counted more reliably if there are no irrelevant bracket characters in strings or comments.)
withoutPattern: only return method body
withoutComments: remove comments (including surrounding quotes)
withoutStrings: replace each literal string by empty string (to ensure valid syntax)
withoutCharacters: replace each literal character with $$
This probably can be expressed as a state machine-based parser, but this way,
it is only 3..4 methods.
"
Expand Down Expand Up @@ -33,6 +37,6 @@ withoutLiteralCharacters: noCharacters
ifTrue: [sourceStream next. stream nextPut: $$].
(noComments & wasInComment) | (noStrings & inString) ifFalse: [
(noComments & wasInComment) | (noStrings & wasInString & inString) ifFalse: [
(noComments and: [wasInComment ~~ inComment])
ifFalse: [stream nextPut: c]]]]
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"normalizedSource" : "topa 1/10/2015 11:56",
"normalizedSourceLines" : "JTM 5/28/2015 15:31",
"parseTree" : "AT 5/8/2008 09:37",
"source:withoutPattern:withoutComments:withoutStrings:withoutLiteralCharacters:" : "NA 7/2/2015 18:31",
"source:withoutPattern:withoutComments:withoutStrings:withoutLiteralCharacters:" : "ct 1/5/2025 01:03",
"sourceCode" : "topa 1/9/2015 18:39",
"sourceString" : "AT 5/8/2008 09:37",
"startOfMethodBodyIn:" : "BD 6/29/2018 12:56",
Expand Down

0 comments on commit a4023d5

Please sign in to comment.