Skip to content

Commit c766df7

Browse files
committed
Merge branch 'master' into code-actions
2 parents 17ab282 + 6761625 commit c766df7

File tree

11 files changed

+554
-94
lines changed

11 files changed

+554
-94
lines changed

.github/workflows/ci.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,58 @@ jobs:
7777
with:
7878
name: ${{matrix.os}}
7979
path: analysis/binary.tar
80+
81+
package:
82+
needs: test
83+
runs-on: ubuntu-18.04
84+
85+
steps:
86+
- uses: actions/[email protected]
87+
88+
- name: Use Node.js
89+
uses: actions/[email protected]
90+
with:
91+
node-version: 14.4.0
92+
93+
- run: npm ci
94+
- run: npm run compile
95+
96+
- name: Download MacOS binary
97+
uses: actions/[email protected]
98+
with:
99+
name: macos-latest
100+
path: ./server/analysis_binaries
101+
- run: tar -xvf binary.tar
102+
working-directory: ./server/analysis_binaries
103+
104+
- name: Download Linux binary
105+
uses: actions/[email protected]
106+
with:
107+
name: ubuntu-18.04
108+
path: ./server/analysis_binaries
109+
- run: tar -xvf binary.tar
110+
working-directory: ./server/analysis_binaries
111+
112+
- name: Download Windows binary
113+
uses: actions/[email protected]
114+
with:
115+
name: windows-latest
116+
path: ./server/analysis_binaries
117+
- run: tar -xvf binary.tar
118+
working-directory: ./server/analysis_binaries
119+
120+
- name: Cleanup tar file
121+
run: rm binary.tar
122+
working-directory: ./server/analysis_binaries
123+
124+
- name: Store short commit SHA for filename
125+
id: vars
126+
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
127+
128+
- name: Package Extension
129+
run: npx vsce package -o rescript-vscode-${{ steps.vars.outputs.sha_short }}.vsix
130+
131+
- uses: actions/upload-artifact@v2
132+
with:
133+
name: rescript-vscode-${{ steps.vars.outputs.sha_short }}.vsix
134+
path: rescript-vscode-${{ steps.vars.outputs.sha_short }}.vsix

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- Use semantic syntax highlighting (https://github.com/rescript-lang/rescript-vscode/pull/367).
88
- Report "Fatal error" when it happens in the compiler log (e.g. a make function with type annotation) and don't crash the extension.
99
- Fix issue in functions the form "~foo as name" where the location would only cover "ame".
10+
- Extend the command to create an interface file, to support components and ReScript decorators used in bindings.
1011

1112
## 1.2.1
1213

analysis/src/Cli.ml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,13 @@ Options:
4848

4949
./rescript-editor-analysis.exe rename src/MyFile.res 10 2 foo
5050

51-
dump: for debugging, show all definitions and hovers for MyFile.res and MyFile.res:
51+
semanticTokens: return token semantic highlighting info for MyFile.res
5252

53-
./rescript-editor-analysis.exe dump src/Foo.res src/MyFile.res
53+
./rescript-editor-analysis.exe semanticTokens src/MyFile.res
54+
55+
createInterface: print to stdout the interface file for src/MyFile.res
56+
57+
./rescript-editor-analysis.exe createInterface src/MyFile.res lib/bs/src/MyFile.cmi
5458

5559
test: run tests specified by special comments in file src/MyFile.res
5660

@@ -68,10 +72,7 @@ let main () =
6872
| [_; "typeDefinition"; path; line; col] ->
6973
Commands.typeDefinition ~path ~line:(int_of_string line)
7074
~col:(int_of_string col)
71-
| _ :: "dump" :: files -> Commands.dump files
7275
| [_; "documentSymbol"; path] -> Commands.documentSymbol ~path
73-
| [_; "semanticTokens"; currentFile] ->
74-
SemanticTokens.semanticTokens ~currentFile
7576
| [_; "hover"; path; line; col] ->
7677
Commands.hover ~path ~line:(int_of_string line) ~col:(int_of_string col)
7778
| [_; "codeAction"; path; line; col; currentFile] ->
@@ -83,6 +84,11 @@ let main () =
8384
| [_; "rename"; path; line; col; newName] ->
8485
Commands.rename ~path ~line:(int_of_string line) ~col:(int_of_string col)
8586
~newName
87+
| [_; "semanticTokens"; currentFile] ->
88+
SemanticTokens.semanticTokens ~currentFile
89+
| [_; "createInterface"; path; cmiFile] ->
90+
Printf.printf "\"%s\""
91+
(Json.escape (CreateInterface.command ~path ~cmiFile))
8692
| [_; "test"; path] -> Commands.test ~path
8793
| args when List.mem "-h" args || List.mem "--help" args -> prerr_endline help
8894
| _ ->

analysis/src/Commands.ml

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,5 @@
11
open SharedTypes
22

3-
let dumpLocations ~full =
4-
full.extra.locItems
5-
|> List.map (fun locItem ->
6-
let locItemTxt = locItemToString locItem in
7-
let hoverText = Hover.newHover ~full locItem in
8-
let hover =
9-
match hoverText with None -> "" | Some s -> String.escaped s
10-
in
11-
let uriLocOpt = References.definitionForLocItem ~full locItem in
12-
let def =
13-
match uriLocOpt with
14-
| None -> Protocol.null
15-
| Some (uri2, loc) ->
16-
Protocol.stringifyLocation
17-
{uri = Uri2.toString uri2; range = Utils.cmtLocToRange loc}
18-
in
19-
Protocol.stringifyRange (Utils.cmtLocToRange locItem.loc)
20-
^ "\n Hover: " ^ hover ^ "\n Definition: " ^ def ^ "\n locItem: "
21-
^ locItemTxt)
22-
|> String.concat "\n\n"
23-
24-
let dump files =
25-
Shared.cacheTypeToString := true;
26-
files
27-
|> List.iter (fun path ->
28-
let result =
29-
match Cmt.fromPath ~path with
30-
| None -> "[]"
31-
| Some full -> dumpLocations ~full
32-
in
33-
print_endline result)
34-
353
let completion ~path ~line ~col ~currentFile =
364
let pos = (line, col) in
375
let result =
@@ -376,6 +344,16 @@ let test ~path =
376344
Printf.printf "%s\nnewText:\n%s<--here\n%s%s\n"
377345
(Protocol.stringifyRange range)
378346
indent indent newText)))
347+
| "int" ->
348+
print_endline ("Create Interface " ^ path);
349+
let cmiFile =
350+
let open Filename in
351+
let ( ++ ) = concat in
352+
let name = chop_extension (basename path) ^ ".cmi" in
353+
let dir = dirname path in
354+
dir ++ parent_dir_name ++ "lib" ++ "bs" ++ "src" ++ name
355+
in
356+
Printf.printf "%s" (CreateInterface.command ~path ~cmiFile)
379357
| _ -> ());
380358
print_newline ())
381359
in

0 commit comments

Comments
 (0)