Skip to content

TonelParser's findMethodEnd() doesn't understand character literals #466

Description

@je-foster

Bug

In tonelParser.ts, findMethodEnd looks for the closing ] of methods in a Tonel format file. But it treats the single quote in $' as the beginning (or end) of a string. Similar problems arise with other character literals like $", $[, etc. Consider the following method:

McpRouter >> quoteForFork: aString [
  | s |
  s := WriteStream on: String new.
  s nextPut: $'.
  aString do: [:c | c = $' ifTrue: [s nextPut: $']. s nextPut: c].
  s nextPut: $'.
  ^s contents
]

When findMethodEnd looks for the end of this method, it considers the four ' characters to delimit two strings:

.
  aString do: [:c | c = $

and

]. s nextPut: c].
  s nextPut: $

This causes one [ (in the first string) and two ] (in the second string) to be ignored, and the single remaining [ permanently increases the depth by 1 so it does not recognize the method's closing bracket as the end of the method.

Consequence

In the screenshot you can see that quoteForFork: is the final method selector appearing in the breadcrumb menu. The menu omits the file's 38 remaining selectors.

Fix

Advance the index by one after every $ to skip the next character. This line should do it: if (ch === "$") { j++; continue; }

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions