Skip to content

Go To Definition Request #302

Description

@toddATavail

Support for locating the definitions associated with the name at the specified module coordinates. Mandated by Go To Definition Request.

This amounts to implementing org.eclipse.lsp4j.TextDocumentService.definition.

For guidance, the places to begin digging into Swing/Anvil are:

  • avail.anvil.AvailEditor.handleClick
  • avail.anvil.AvailWorkbench.navigateToDefinitionsOfName
  • avail.anvil.AvailWorkbench.allDefinitionsThen
  • avail.anvil.RenderingEngine.applyStylesAndPhrasePaths

Currently, the technique is:

  1. Resolve the mouse position to a document position
  2. Use the document position to obtain the TokenStyle associated with the PhraseNodeAttributeKey attribute that was applied by avail.anvil.RenderingEngine.applyStylesAndPhrasePaths
  3. Use the TokenStyle to obtain the name / symbol (NameInModule) and token index / message part index
  4. Use these to interrogate a Repository and a NamesIndex to obtain all definitions associated with the name / symbol

The message part index (usually called tokenIndexInName) is currently used only to highlight the message part that the user specified. It does not appear that LSP (or lsp4j) are capable of transmitting this additional information as opaque client data. If we want to preserve the current behavior, then we will need to reply with LocationLinks rather than mere Locations, and use the MessageSplitter (or something akin but with pared down functionality) in the IDEA plugin to identify and highlight the message part. The current behavior was nice enough to build in Swing/Anvil in the first place, but is likely to require significant additional effort to port to IDEA, so we may want to consider strict parity as a stretch goal.

The following items count as definitions:

  • Method definitions.
  • Semantic restriction definitions.
  • Grammatical restriction definitions.
  • Macro definitions.
  • Lexer definitions.
  • Module constant definitions.
  • Module variable definitions.
  • Local constant definitions.
  • Local variable definitions.
  • Function parameter definitions.
  • Function label definitions.

Note that abstract method declarations and forward method declarations explicitly do not qualify as definitions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions