rescript-lang / rescript-lang/rescript

Completions defined in `editor.autocomplete` don't work on type aliases

Offen
#7,501 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
OCaml
Sterne
7.5k
Forks
485
Ø Merge
1 T. 2 Std.
Gemergte PRs (30 T.)
55

Beschreibung

I have a module BeltMapX with utility functions for working with Belt.Map.t.

I tried to set up autocomplete for pipe completion in rescript.json like so:

"editor": {
  "autocomplete": {
    "Belt.Map.t": ["BeltMapX"],
  }
}

This didn't work so I did some debugging in analysis/src/CompletionBackEnd.ml, and it turned out that mainTypeId is actually Belt_Map.t.

https://github.com/rescript-lang/rescript/blob/7b4bc420cd052e492aea6b607df8f7513210b422/analysis/src/CompletionBackEnd.ml#L1068-L1077

Updating my rescript.json config to use the unaliased type, as below, worked.

"editor": {
  "autocomplete": {
    "Belt_Map.t": ["BeltMapX"],
  }
}

Would it be possible to make the completions backend handle type aliases so that "Belt.Map.t": ["BeltMapX"] works?

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Start in analysis/src/CompletionBackEnd.ml at the handling referenced around lines 1068-1077, and compare the configured type name Belt.Map.t with the resolved Belt_Map.t. The work is done when autocomplete configured with the aliased type name produces completions for BeltMapX, while the existing unaliased configuration continues to work.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
ocaml
Bereich
compilers, developer-experience
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Ruhig
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
58/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.