diff --git a/analysis/tests/src/CompletionMultipleEditorCompleteFrom.res b/analysis/tests/src/CompletionMultipleEditorCompleteFrom.res new file mode 100644 index 000000000..35950e161 --- /dev/null +++ b/analysis/tests/src/CompletionMultipleEditorCompleteFrom.res @@ -0,0 +1,22 @@ +@@warning("-26") +@@warning("-27") +@@warning("-110") + +module A = { + @editor.completeFrom(B) @editor.completeFrom(C) + type a +} + +module B = { + let b = (a: A.a) => 1 +} + +module C = { + open A + let c = (a: a) => {'c'} +} + +let a : A.a = %todo +// a. +// ^com +// B.b and C.c should be completed \ No newline at end of file diff --git a/analysis/tests/src/CompletionPipeProperty.res b/analysis/tests/src/CompletionPipeProperty.res new file mode 100644 index 000000000..3ef739ed9 --- /dev/null +++ b/analysis/tests/src/CompletionPipeProperty.res @@ -0,0 +1,23 @@ +module ObservablePoint = { + type op = { + mutable x: int, + mutable y: int, + } + + @send + external setBoth: (op, float) => unit = "set" + + @send + external set: (op, float, float) => unit = "set" +} + +module Sprite = { + type s = { + anchor: ObservablePoint.op, + } +} + +let sprite : Sprite.s = %todo + +// sprite.anchor. +// ^com \ No newline at end of file diff --git a/analysis/tests/src/Rxjs.res b/analysis/tests/src/Rxjs.res new file mode 100644 index 000000000..8d3cecbc1 --- /dev/null +++ b/analysis/tests/src/Rxjs.res @@ -0,0 +1,51 @@ +// These are bindings used in RxjsCompletion.res +// We are using a separate file to test complication for modules of external files. +type target + +module Subscriber = { + type t<'t> = {next: 't => unit} +} + +module Observable = { + // Complete items defined inside the parent module. + @editor.completeFrom(Rxjs) + type t<'t> + + type dispose = unit => unit + + @new @module("rxjs") + external make: (Subscriber.t<'t> => dispose) => t<'t> = "Observable" + + type subscription + + @send + external subscribe: (t<'t>, 't => unit) => subscription = "subscribe" +} + +@module("rxjs") +external fromEvent: (target, string) => Observable.t<'t> = "fromEvent" + +type operation<'t, 'u> + +@send +external pipe: (Observable.t<'t>, operation<'t, 'u>) => Observable.t<'u> = "pipe" + +@send +external pipe2: (Observable.t<'t>, operation<'t, 'u>, operation<'u, 'i>) => Observable.t<'i> = + "pipe" + +@module("rxjs") +external map: ('t => 'u) => operation<'t, 'u> = "map" + +@module("rxjs") +external distinctUntilChanged: unit => operation<'t, 't> = "distinctUntilChanged" + +@module("rxjs") +external merge: (Observable.t<'t>, Observable.t<'t>) => Observable.t<'t> = "merge" + +@module("rxjs") +external scan: (('acc, 't) => 'acc, 'acc) => operation<'t, 'acc> = "scan" + +@module("rxjs") +external combineLatest: (Observable.t<'a>, Observable.t<'b>) => Observable.t<('a, 'b)> = + "combineLatest" diff --git a/analysis/tests/src/RxjsCompletion.res b/analysis/tests/src/RxjsCompletion.res new file mode 100644 index 000000000..eaf2b40d4 --- /dev/null +++ b/analysis/tests/src/RxjsCompletion.res @@ -0,0 +1,39 @@ +@@warning("-26") +@@warning("-110") + +type keyPress = + | Up(string) + | Down(string) + +@val +external window: {..} = "window" + +let main = async () => { + let keyMapObservable = { + open Rxjs + + let keydown = + fromEvent(Obj.magic(window), "keydown")->pipe2( + map(event => Down(event["key"])), + distinctUntilChanged(), + ) + + let keyup = + fromEvent(Obj.magic(window), "keyup")->pipe2( + map(event => Up(event["key"])), + distinctUntilChanged(), + ) + + // merge(keydown, keyup). + // ^com + + // Rxjs.Observable.subscribe, Rxjs.pipe and Rxjs.pipe2 should be completed + } + + let (a,b) : ( Rxjs.Observable.t , Rxjs.Observable.t) = %todo + + // Rxjs.combineLatest(a, b). + // ^com + + // Rxjs.Observable.subscribe, Rxjs.pipe and Rxjs.pipe2 should be completed +} diff --git a/analysis/tests/src/expected/CompletionMultipleEditorCompleteFrom.res.txt b/analysis/tests/src/expected/CompletionMultipleEditorCompleteFrom.res.txt new file mode 100644 index 000000000..8476ebfc1 --- /dev/null +++ b/analysis/tests/src/expected/CompletionMultipleEditorCompleteFrom.res.txt @@ -0,0 +1,14 @@ +Complete src/CompletionMultipleEditorCompleteFrom.res 19:5 +posCursor:[19:5] posNoWhite:[19:4] Found expr:[19:3->19:5] +Pexp_field [19:3->19:4] _:[22:0->19:5] +Completable: Cpath Value[a]."" +Package opens Pervasives.JsxModules.place holder +Resolved opens 1 pervasives +ContextPath Value[a]."" +ContextPath Value[a] +Path a +CPPipe pathFromEnv:A found:true +Path A. +Path B. +[] + diff --git a/analysis/tests/src/expected/CompletionPipeProperty.res.txt b/analysis/tests/src/expected/CompletionPipeProperty.res.txt new file mode 100644 index 000000000..7cfbd37c9 --- /dev/null +++ b/analysis/tests/src/expected/CompletionPipeProperty.res.txt @@ -0,0 +1,50 @@ +Complete src/CompletionPipeProperty.res 21:17 +posCursor:[21:17] posNoWhite:[21:16] Found expr:[21:3->21:17] +Pexp_field [21:3->21:16] _:[23:0->21:17] +Completable: Cpath Value[sprite].anchor."" +Package opens Pervasives.JsxModules.place holder +Resolved opens 1 pervasives +ContextPath Value[sprite].anchor."" +ContextPath Value[sprite].anchor +ContextPath Value[sprite] +Path sprite +CPPipe pathFromEnv:Sprite found:true +Path Sprite.anchor +CPPipe pathFromEnv:ObservablePoint found:true +Path ObservablePoint. +[{ + "label": "->ObservablePoint.setBoth", + "kind": 12, + "tags": [], + "detail": "(op, float) => unit", + "documentation": null, + "sortText": "setBoth", + "textEdit": { + "range": {"start": {"line": 21, "character": 16}, "end": {"line": 21, "character": 16}}, + "newText": "->ObservablePoint.setBoth" + } + }, { + "label": "->ObservablePoint.set", + "kind": 12, + "tags": [], + "detail": "(op, float, float) => unit", + "documentation": null, + "sortText": "set", + "textEdit": { + "range": {"start": {"line": 21, "character": 16}, "end": {"line": 21, "character": 16}}, + "newText": "->ObservablePoint.set" + } + }, { + "label": "x", + "kind": 5, + "tags": [], + "detail": "int", + "documentation": {"kind": "markdown", "value": "```rescript\nx: int\n```\n\n```rescript\ntype op = {mutable x: int, mutable y: int}\n```"} + }, { + "label": "y", + "kind": 5, + "tags": [], + "detail": "int", + "documentation": {"kind": "markdown", "value": "```rescript\ny: int\n```\n\n```rescript\ntype op = {mutable x: int, mutable y: int}\n```"} + }] + diff --git a/analysis/tests/src/expected/Rxjs.res.txt b/analysis/tests/src/expected/Rxjs.res.txt new file mode 100644 index 000000000..e69de29bb diff --git a/analysis/tests/src/expected/RxjsCompletion.res.txt b/analysis/tests/src/expected/RxjsCompletion.res.txt new file mode 100644 index 000000000..f07e1dd72 --- /dev/null +++ b/analysis/tests/src/expected/RxjsCompletion.res.txt @@ -0,0 +1,62 @@ +Complete src/RxjsCompletion.res 26:29 +posCursor:[26:29] posNoWhite:[26:28] Found expr:[10:17->38:1] +posCursor:[26:29] posNoWhite:[26:28] Found expr:[11:2->32:78] +posCursor:[26:29] posNoWhite:[26:28] Found expr:[12:4->26:29] +posCursor:[26:29] posNoWhite:[26:28] Found expr:[14:4->26:29] +posCursor:[26:29] posNoWhite:[26:28] Found expr:[20:4->26:29] +posCursor:[26:29] posNoWhite:[26:28] Found expr:[26:7->26:29] +Pexp_field [26:7->26:28] _:[30:2->26:29] +Completable: Cpath Value[merge](Nolabel, Nolabel)."" +Raw opens: 1 Rxjs.place holder +Package opens Pervasives.JsxModules.place holder +Resolved opens 2 pervasives Rxjs.res +ContextPath Value[merge](Nolabel, Nolabel)."" +ContextPath Value[merge](Nolabel, Nolabel) +ContextPath Value[merge] +Path merge +CPPipe pathFromEnv:Observable found:true +Path Rxjs.Observable. +Path Rxjs. +[{ + "label": "->Observable.subscribe", + "kind": 12, + "tags": [], + "detail": "(t<'t>, 't => unit) => subscription", + "documentation": null, + "sortText": "subscribe", + "textEdit": { + "range": {"start": {"line": 26, "character": 28}, "end": {"line": 26, "character": 28}}, + "newText": "->Observable.subscribe" + } + }] + +Complete src/RxjsCompletion.res 34:30 +posCursor:[34:30] posNoWhite:[34:29] Found expr:[10:17->38:1] +posCursor:[34:30] posNoWhite:[34:29] Found expr:[10:11->38:1] +posCursor:[34:30] posNoWhite:[34:29] Found expr:[11:2->34:30] +posCursor:[34:30] posNoWhite:[34:29] Found expr:[32:2->34:30] +posCursor:[34:30] posNoWhite:[34:29] Found expr:[34:5->34:30] +Pexp_field [34:5->34:29] _:[38:0->34:30] +Completable: Cpath Value[Rxjs, combineLatest](Nolabel, Nolabel)."" +Package opens Pervasives.JsxModules.place holder +Resolved opens 1 pervasives +ContextPath Value[Rxjs, combineLatest](Nolabel, Nolabel)."" +ContextPath Value[Rxjs, combineLatest](Nolabel, Nolabel) +ContextPath Value[Rxjs, combineLatest] +Path Rxjs.combineLatest +CPPipe pathFromEnv:Observable found:true +Path Rxjs.Observable. +Path Rxjs. +[{ + "label": "->Rxjs.Observable.subscribe", + "kind": 12, + "tags": [], + "detail": "(t<'t>, 't => unit) => subscription", + "documentation": null, + "sortText": "subscribe", + "textEdit": { + "range": {"start": {"line": 34, "character": 29}, "end": {"line": 34, "character": 29}}, + "newText": "->Rxjs.Observable.subscribe" + } + }] +