vscode-abl / vscode-abl

MIT License
26 stars 5 forks source link

Syntax highlighting - system handles #183

Open danielbecroft opened 3 months ago

danielbecroft commented 3 months ago

LanguageServerInfo: 1.16.0-SNAPSHOT-607d691 -- ClientInfo: Visual Studio Code 1.92.2 -- JVM: Oracle Corporation 17.0.6+9-LTS-190

I've noticed that system handles (file-information, session, error-status etc are not being parsed correctly). They are all coming through as variable.language.abl:

define variable p as character no-undo.
define variable x as character no-undo.
define variable y as logical no-undo.

// scope(session): variable.language.abl source.abl
p = session:temp-directory.

// scope(file-information): variable.language.abl source.abl
x = file-information:full-pathname.

// scope(error-status)variable.language.abl source.abl
y =
    error-status:error
    or error-status:num-messages gt 0.

// scope(log-manager): variable.language.abl source.abl
log-manager:write-message("Lorem ipsum").

I've tried to have a poke around the abl-tmllanguage repository, and the tests are expecting that this is the case. For example, in specs/misc-statements/return-statement.spec.js (below), the session token is expected to be variable.language.abl

describe('', () => {
  let statement = `RETURN session:exit-code.`;
  let expectedTokens = [
    { "startIndex": 0, "endIndex": 6, "scopes": ["source.abl", "keyword.other.abl"] },  // 'RETURN'
    { "startIndex": 6, "endIndex": 7, "scopes": ["source.abl"] },  // ' '
    { "startIndex": 7, "endIndex": 14, "scopes": ["source.abl", "variable.language.abl"] },  // 'session'
    { "startIndex": 14, "endIndex": 15, "scopes": ["source.abl", "punctuation.separator.colon.abl"] },  // ':'
    { "startIndex": 15, "endIndex": 24, "scopes": ["source.abl", "entity.name.function.abl"] },  // 'exit-code'
    { "startIndex": 24, "endIndex": 25, "scopes": ["source.abl", "punctuation.terminator.abl"] }  // '.'
  ];
  shared.itShouldMatchExpectedScopes(statement, expectedTokens);
})

I can see scenarios like SessionManager (spec/type-name/type-name.spec.js), where it would be parsed as a variable, since this is a class/package name, not a system handle:

describe('', () => {
  let statement = `SessionManager:ContestDataset:READ-XML("longchar":U,
  lcDataset,
  "EMPTY":U, ?, ?) . `;

  let expectedTokens = [
    [
      { "startIndex": 0, "endIndex": 14, "scopes": ["source.abl", "variable.other.abl"] },  // 'SessionManager'
      { "startIndex": 14, "endIndex": 15, "scopes": ["source.abl", "punctuation.separator.colon.abl"] },  // ':'
      { "startIndex": 15, "endIndex": 29, "scopes": ["source.abl", "entity.name.function.abl"] },  // 'ContestDataset'
      { "startIndex": 29, "endIndex": 30, "scopes": ["source.abl", "punctuation.separator.colon.abl"] },  // ':'
      { "startIndex": 30, "endIndex": 38, "scopes": ["source.abl", "entity.name.function.abl"] },  // 'READ-XML'
// snipped

I don't know if it's an "simple" as changing abl.tmLanguage.json to this, but that breaks alot of tests (as noted above).

    "abl-system-handles": {
      "match": "(?i)\\s*(this-object|super|self|this-procedure|target-procedure|source-procedure|session|error-status|compiler|audit-control|audit-policy|clipboard|codebase-locator|color-table|debugger|dslog-manager|file-information|file-info|font-table|last-event|log-manager|profiler|rcode-information|rcode-info|security-policy|session|web-context)\\s*(?=:)",
      "captures": {
        "1": {
          "name": "keyword.other.abl" <<<<<<< here
        },
        "2": {
          "name": "punctuation.separator.colon.abl"
        }
      }
    },
PeterJudgeZA commented 2 months ago

I've noticed that system handles (file-information, session, error-status etc are not being parsed correctly). They are all coming through as variable.language.abl:

@danielbecroft What is your expectation here?

These are deliberately scoped to variable.language.abl , per the rules in https://macromates.com/manual/en/language_grammars#language_rules (which are used as a guideline for how to scope the many ABL statements and keywords ).

That page says

variable — variables. Not all languages allow easy identification (and thus markup) of these. ... language — reserved language variables like this, super, self, etc.****

danielbecroft commented 2 months ago

@PeterJudgeZA Good question. I guess I'm used to something like PDSOE that would highlight anything that's a keyword as a keyword. Contrast this to the parsing here, and it looks odd. It also look strange when this-object (on its own) is a keyword.other.abl, but as soon as it's got a colon after it, it becomes variable.language.abl:

// scope(this-procedure): keyword.other.abl source.abl (fore: keyword.other)
vHandle = this-procedure.

// scope(this-procedure):   variable.language.abl source.abl (fore: variable.language)
vHandle = this-procedure:first-sibling.

this-procedure hasn't changed from what it is, so I wouldn't be expecting a change to how it's highlighted.

It might just be what it is, and I'll have to get used to how it looks.

PeterJudgeZA commented 2 months ago

Contrast this to the parsing here, and it looks odd. It also look strange when this-object (on its own) is a keyword.other.abl, but as soon as it's got a colon after it, it becomes variable.language.abl:

Yes, good point. this-object and this-procedure (and the other system handles) should both always be scoped as variable.language.abl , regardless of any trailing colons.

-- peter


From: Daniel Becroft @.> Sent: Monday, September 9, 2024 12:05:41 AM To: vscode-abl/vscode-abl @.> Cc: Peter Judge @.>; Mention @.> Subject: Re: [vscode-abl/vscode-abl] Syntax highlighting - system handles (Issue #183)

@PeterJudgeZAhttps://github.com/PeterJudgeZA Good question. I guess I'm used to something like PDSOE that would highlight anything that's a keyword as a keyword. Contrast this to the parsing here, and it looks odd. It also look strange when this-object (on its own) is a keyword.other.abl, but as soon as it's got a colon after it, it becomes variable.language.abl:

// scope(this-procedure): keyword.other.abl source.abl (fore: keyword.other) vHandle = this-procedure.

// scope(this-procedure): variable.language.abl source.abl (fore: variable.language) vHandle = this-procedure:first-sibling.

this-procedure hasn't changed from what it is, so I wouldn't be expecting a change to how it's highlighted.

It might just be what it is, and I'll have to get used to how it looks.

— Reply to this email directly, view it on GitHubhttps://github.com/vscode-abl/vscode-abl/issues/183#issuecomment-2336854720, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AB7IJ2OQASC57KRASDVKT4LZVTJ4LAVCNFSM6AAAAABNTSXYMOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMZWHA2TINZSGA. You are receiving this because you were mentioned.