Skip to content

Support textDocument/documentHighlight message for usages of types #5445

@gavinmorrow

Description

@gavinmorrow

When triggering the message over the usage of a type in a file, highlight all instances of that type.

For example:

type Foobar {
//   ^^^^^^
  Foo
  Bar
}

type Qux(a) {
  // Cursor here (for example)
  //    ↓
  Qux(Foobar, a)
  //  ^^^^^^
}

const foo: Foobar = Foo
//         ^^^^^^

fn baz(foo: Foobar) -> Foobar {
//          ^^^^^^     ^^^^^^
  let quux: Foobar = foo
  //        ^^^^^^
  let qux: Qux(Foobar) = Qux(quux, foo)
  //           ^^^^^^
  case qux {
    Qux(Foo, Foo) -> Bar
    Qux(Bar, Bar) -> Foo
    _ → Foo
  }
}

Another example:

import foobar.{type Foobar, Foo, Bar}
//                  ^^^^^^

type Qux(a) {
  // Cursor here (for example)
  //    ↓
  Qux(Foobar, a)
  //  ^^^^^^
}

const foo: foobar.Foobar = Foo
//                ^^^^^^

fn baz(foo: Foobar) -> foobar.Foobar {
//          ^^^^^^            ^^^^^^
  let quux: Foobar = foo
  //        ^^^^^^
  let qux: Qux(foobar.Foobar) = Qux(quux, foo)
  //                  ^^^^^^
  case qux {
    Qux(Foo, Foo) -> Bar
    Qux(Bar, Bar) -> Foo
    _ → Foo
  }
}

See #5427.

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