Skip to content

Calls to user-defined and imported functions aren't highlighted #22

Open

Description

@mr-zwets

Calls to functions that are declared in the contract or imported, like requireVaultUnchanged(vaultIndex), show in the default text colour. The declaration function requireVaultUnchanged(...) gets a function colour, and so do built-ins like sha256(...) and checkSig(...).

Cause

syntaxes/cashscript.tmLanguage.json only scopes function names it knows in advance:

  • declaration-function matches the name after the function keyword.
  • global-functions lists the built-ins: abs, min, max, within, the hashing and signature-checking functions, date, toPaddedBytes and the LockingBytecode* constructors.
  • members covers split, reverse, slice and log.

No rule matches a general name( call, and the extension provides no semantic tokens that would fill the gap. Before 0.14, user code couldn't call functions, so the grammar never needed one. Now that contracts call their own and imported functions, those calls don't stand out.

Possible fix

Add a generic call pattern after the existing ones, so keywords (if, while, require), type casts (bytes6(...)) and the built-ins keep their current scopes:

"function-call": {
  "match": "\b([A-Za-z_]\w*)(?=\s*\()",
  "captures": {
    "1": { "name": "entity.name.function.call.cashscript" }
  }
}

And add { "include": "#function-call" } to the top-level patterns, after #declaration.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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