Skip to content
Snippets Groups Projects

[#2056] Better signature items support

  1. Dec 21, 2023
    • Ligo Lang's avatar
      [Bot] add changelog entry · 80820a15
      Ligo Lang authored
      80820a15
    • Heitor Toledo Lassarote de Paula's avatar
      Merge branch 'heitor.toledo/#2056-add-sig-items-to-scopes-part-2' into 'dev' · 5c68990e
      Heitor Toledo Lassarote de Paula authored
      Draft: [#2056] Better signature items support
      
      See merge request !2981
      5c68990e
    • Heitor Toledo Lassarote de Paula's avatar
      [#2056] Use a better representation for module paths · 1143c293
      Heitor Toledo Lassarote de Paula authored
      Problem: A module path can be resolved or not, but we don't properly
      represent that.
      
      Solution: Use a data structure that stores the original path, and also
      whether that was resolved or not.
      Verified
      1143c293
    • Heitor Toledo Lassarote de Paula's avatar
      [#2056] Document what is the difference between the req types · 891ee7cc
      Heitor Toledo Lassarote de Paula authored
      Problem: It's not clear what a declaration, definition, and
      implementation is.
      
      Solution: Add docs trying to clear it up.
      Verified
      891ee7cc
    • Heitor Toledo Lassarote de Paula's avatar
      [#2056] Find implementers from signature names · b833f100
      Heitor Toledo Lassarote de Paula authored
      Problem: If we have a definition like `module type T = ...`, and we look
      for implementers of `T`, we won't see useless information.
      
      Solution: Check if we are looking for the implementations of a
      signature. If so, just return the name of the module implementing that,
      rather than looking at its defs.
      Verified
      b833f100
    • Heitor Toledo Lassarote de Paula's avatar
      [#2056] Add references tests · 08022cdd
      Heitor Toledo Lassarote de Paula authored
      Problem: We need to check that references work with our changes.
      
      Solution: Refactor the test cases a little to avoid boilerplate and add
      tests for signature items.
      Verified
      08022cdd
    • Heitor Toledo Lassarote de Paula's avatar
      [#2056] Handle references for signature items · af9781c1
      Heitor Toledo Lassarote de Paula authored
      Problem: References for signature items aren't dealt with correctly.
      This also means that rename and prepare rename don't work as intended.
      
      Solution: Refactor some functions from `Go_to_definition` that will be
      useful for us in `References`. Now, we can find a subgraph of the mod
      graph that contains all modules that are reachable from one another
      somehow using the WCC algorithm, and for each module in this graph, get
      all of its definitions. Now, we can look for the definitions that match
      the name and level (type, term, module) of the thing we're trying to
      find a reference for. We change the existing functions in `References`
      to now deal with finding all references of multiple definitions rather
      than just one.
      
      For `Rename` and `Prepare_rename`, we just reuse the functions defined
      in `References` to handle the changes.
      Verified
      af9781c1
    • Heitor Toledo Lassarote de Paula's avatar
      [#2056] Handle "go to declaration" · fff9d2b8
      Heitor Toledo Lassarote de Paula authored
      Problem: There is a third confusingly named request: go to declaration.
      The specification doesn't say how this request should be handled, but I
      think it's fair to make it assume the old behavior of go to definition.
      
      Solution: Declare such request in the server, and implement it by simply
      returning the place where the reference came from. This mimics the old
      behavior of go to definition. So from a reference, such as `M.x`, we
      visit `x` within `M`, while in `I.x`, we visit `x` within `I`, while go
      to definition and go to implementation would behave different for each
      case.
      Verified
      fff9d2b8
    • Heitor Toledo Lassarote de Paula's avatar
      [#2056] Add definition tests · 3f24c45c
      Heitor Toledo Lassarote de Paula authored
      Problem: We should now check that definitions and implementations work
      well.
      
      Solution: Refactor the definitions test suite a little and add various
      tests.
      Verified
      3f24c45c
    • Heitor Toledo Lassarote de Paula's avatar
      [#2056] Support getting implementations of sigs · 3306a3f4
      Heitor Toledo Lassarote de Paula authored
      Problem: Until now, we implemented _go to definition_ without taking
      signatures and interfaces into consideration. However, we wish to
      properly deal with signature items in that request, as well as a new _go
      to implementations_ request.
      
      Solution: There are two main parts of the implementation: changes to the
      definitions pass of scopes, and changes to the go to definition module.
      
      In definitions, we keep track of what is a module and what is a
      signature, and additionally keep track of whatever signatures/interfaces
      each module/namespace implements. Some creativity was needed here, since
      the core AST deviates considerably when it comes to the structure of
      signature definitions and signature expressions. See the relevant
      comments for more information.
      
      In the request for go to definitions, we actually split the logic into
      two: for definitions and implementations.
      
      For definitions, we simply walk the `implements` field of each module,
      trying to get every relevant definition that matches the current symbol.
      
      For implementations, we build a graph with our homemade graph library
      using signatures as vertices for this graph. This graph is then
      transposed, so now we can traverse the children of each vertex rather
      than its parents. We fetch all relevant signatures on the way by
      cleverly traversing this graph.
      
      As a bonus, hovers are now fixed so they can distinguish module types
      and interfaces from modules and namespaces.
      Verified
      3306a3f4
    • Heitor Toledo Lassarote de Paula's avatar
      [#2056] Add missing syntax highlighting keyword and fix unbounded type · 6e913efd
      Heitor Toledo Lassarote de Paula authored
      annotations with includes
      
      Problem: `extends` was not recognized as a keyword by the syntax
      highlighting. Moreover, if an `include` followed some `val`, it would
      get highlighted as a type.
      
      Solution: Add `extends` to the list of JsLIGO keywords. Add `include` to
      the end of a type definition/annotation.
      
      Also, `implements` was duplicate in the list of JsLIGO keywords, so I
      removed one of them.
      Verified
      6e913efd
Loading