Skip to content

Commit

Permalink
Merge rescript-editor-support and this repo
Browse files Browse the repository at this point in the history
  • Loading branch information
chenglou committed Apr 23, 2021
1 parent 18c3731 commit c8ab832
Show file tree
Hide file tree
Showing 127 changed files with 28,313 additions and 81 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
test:
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]

runs-on: ${{matrix.os}}

steps:
- uses: actions/[email protected]

- name: Cache OCaml's opam
uses: actions/[email protected]
with:
path: ~/.opam
key: ${{matrix.os}}-latest-ocaml-4.06.1

- name: Use OCaml
uses: avsm/[email protected]
with:
ocaml-version: 4.06.1

- name: Use Node.js
uses: actions/[email protected]
with:
node-version: 14.4.0

- run: npm ci

# These 2 runs (or just the second?) are for when you have opam dependencies. We don't.
# Don't add deps. But if you ever do, un-comment these
# - run: opam pin add rescript-editor-support.dev . --no-action
# - run: opam install . --deps-only --with-doc --with-test

- run: eval $(opam env) && cd analysis && make test
if: matrix.os != 'windows-latest'
# CI windows running the binary somehow stucks. Not sure why. Disable for now.
- run: "cd analysis && & $env:CYGWIN_ROOT\\bin\\ocaml-env exec -- make"
if: matrix.os == 'windows-latest'

# Also avoids artifacts upload permission loss:
# https://github.com/actions/upload-artifact/tree/ee69f02b3dfdecd58bb31b4d133da38ba6fe3700#permission-loss
- name: Compress files
run: tar -cvf binary.tar -C server/analysis_binaries current-platform.exe

- uses: actions/upload-artifact@v2
with:
name: ${{matrix.os}}.exe
path: binary.tar
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
out
node_modules
client/server
.vscode-test
.vscode-test
*.exe
144 changes: 144 additions & 0 deletions analysis/.depend
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
src/BuildSystem.cmx : src/ModuleResolution.cmx src/Log.cmx src/Infix.cmx \
src/Files.cmx
src/EditorSupportCommands.cmx : src/Utils.cmx src/Uri2.cmx src/TopTypes.cmx \
src/State.cmx src/SharedTypes.cmx src/Shared.cmx src/References.cmx \
src/Protocol.cmx src/NewCompletions.cmx src/Hover.cmx src/Files.cmx
src/Files.cmx :
src/FindFiles.cmx : src/Utils.cmx src/SharedTypes.cmx \
src/ModuleResolution.cmx src/Log.cmx src/vendor/Json.cmx src/Infix.cmx \
src/Files.cmx src/BuildSystem.cmx
src/Hover.cmx : src/Utils.cmx src/SharedTypes.cmx src/Shared.cmx \
src/References.cmx src/Query.cmx
src/Infix.cmx : src/Log.cmx src/Files.cmx
src/Log.cmx :
src/MarkdownOfOCamldoc.cmx : src/vendor/odoc_parser/root.cmx \
src/vendor/odoc_parser/paths.cmx src/vendor/odoc_parser/parser_.cmx \
src/vendor/omd/omd.cmx src/Log.cmx src/vendor/odoc_parser/location_.cmx \
src/vendor/odoc_parser/error.cmx src/vendor/odoc_parser/comment.cmx
src/ModuleResolution.cmx : src/Infix.cmx src/Files.cmx
src/NewCompletions.cmx : src/Utils.cmx src/Uri2.cmx src/TopTypes.cmx \
src/State.cmx src/SharedTypes.cmx src/Shared.cmx src/Query.cmx \
src/Protocol.cmx src/PartialParser.cmx src/Log.cmx src/Infix.cmx \
src/Hover.cmx
src/Packages.cmx : src/Uri2.cmx src/TopTypes.cmx src/SharedTypes.cmx \
src/Log.cmx src/vendor/Json.cmx src/Infix.cmx src/FindFiles.cmx \
src/Files.cmx src/BuildSystem.cmx
src/PartialParser.cmx : src/SharedTypes.cmx src/Infix.cmx
src/PrepareUtils.cmx :
src/PrintType.cmx : src/vendor/res_outcome_printer/res_outcome_printer.cmx \
src/vendor/res_outcome_printer/res_doc.cmx
src/ProcessAttributes.cmx : src/SharedTypes.cmx src/PrepareUtils.cmx
src/ProcessCmt.cmx : src/Utils.cmx src/SharedTypes.cmx \
src/ProcessAttributes.cmx src/Infix.cmx
src/ProcessExtra.cmx : src/Utils.cmx src/SharedTypes.cmx src/Shared.cmx \
src/Query.cmx src/ProcessCmt.cmx src/ProcessAttributes.cmx src/Log.cmx
src/Process_406.cmx : src/SharedTypes.cmx src/Shared.cmx \
src/ProcessExtra.cmx src/ProcessCmt.cmx src/PrintType.cmx \
src/Process_406.cmi
src/Process_406.cmi : src/Uri2.cmx src/SharedTypes.cmx
src/Protocol.cmx :
src/Query.cmx : src/SharedTypes.cmx src/Log.cmx src/Infix.cmx
src/References.cmx : src/Utils.cmx src/Uri2.cmx src/SharedTypes.cmx \
src/Query.cmx src/Log.cmx src/Infix.cmx
src/RescriptEditorSupport.cmx : src/EditorSupportCommands.cmx
src/Shared.cmx : src/PrintType.cmx src/Files.cmx
src/SharedTypes.cmx : src/Utils.cmx src/Uri2.cmx src/Shared.cmx \
src/Infix.cmx
src/State.cmx : src/Utils.cmx src/Uri2.cmx src/TopTypes.cmx \
src/SharedTypes.cmx src/Process_406.cmx src/Packages.cmx \
src/vendor/omd/omd.cmx src/MarkdownOfOCamldoc.cmx src/Log.cmx \
src/Infix.cmx src/FindFiles.cmx src/Files.cmx src/BuildSystem.cmx
src/TopTypes.cmx : src/Uri2.cmx src/SharedTypes.cmx
src/Uri2.cmx :
src/Utils.cmx : src/Protocol.cmx
src/vendor/Json.cmx :
src/vendor/odoc_parser/ast.cmx : src/vendor/odoc_parser/paths.cmx \
src/vendor/odoc_parser/location_.cmx src/vendor/odoc_parser/comment.cmx
src/vendor/odoc_parser/comment.cmx : src/vendor/odoc_parser/paths.cmx \
src/vendor/odoc_parser/location_.cmx
src/vendor/odoc_parser/error.cmx : src/vendor/odoc_parser/location_.cmx
src/vendor/odoc_parser/helpers.cmx : src/vendor/odoc_parser/paths.cmx
src/vendor/odoc_parser/lang.cmx : src/vendor/odoc_parser/root.cmx \
src/vendor/odoc_parser/paths.cmx src/vendor/odoc_parser/comment.cmx
src/vendor/odoc_parser/location_.cmx :
src/vendor/odoc_parser/odoc_lexer.cmx : src/vendor/odoc_parser/token.cmx \
src/vendor/odoc_parser/parse_error.cmx \
src/vendor/odoc_parser/location_.cmx src/vendor/odoc_parser/error.cmx \
src/vendor/odoc_parser/odoc_lexer.cmi
src/vendor/odoc_parser/odoc_lexer.cmi : src/vendor/odoc_parser/token.cmx \
src/vendor/odoc_parser/location_.cmx
src/vendor/odoc_parser/parse_error.cmx : \
src/vendor/odoc_parser/location_.cmx src/vendor/odoc_parser/error.cmx
src/vendor/odoc_parser/parser_.cmx : src/vendor/odoc_parser/syntax.cmx \
src/vendor/odoc_parser/semantics.cmx \
src/vendor/odoc_parser/odoc_lexer.cmx \
src/vendor/odoc_parser/location_.cmx src/vendor/odoc_parser/error.cmx \
src/vendor/odoc_parser/ast.cmx src/vendor/odoc_parser/parser_.cmi
src/vendor/odoc_parser/parser_.cmi : src/vendor/odoc_parser/paths.cmi \
src/vendor/odoc_parser/error.cmx src/vendor/odoc_parser/comment.cmx \
src/vendor/odoc_parser/ast.cmx
src/vendor/odoc_parser/paths.cmx : src/vendor/odoc_parser/root.cmx \
src/vendor/odoc_parser/paths_types.cmx src/vendor/odoc_parser/paths.cmi
src/vendor/odoc_parser/paths.cmi : src/vendor/odoc_parser/root.cmi \
src/vendor/odoc_parser/paths_types.cmx
src/vendor/odoc_parser/paths_types.cmx : src/vendor/odoc_parser/root.cmx
src/vendor/odoc_parser/root.cmx : src/vendor/odoc_parser/root.cmi
src/vendor/odoc_parser/root.cmi :
src/vendor/odoc_parser/semantics.cmx : src/vendor/odoc_parser/token.cmx \
src/vendor/odoc_parser/paths.cmx src/vendor/odoc_parser/parse_error.cmx \
src/vendor/odoc_parser/location_.cmx src/vendor/odoc_parser/error.cmx \
src/vendor/odoc_parser/comment.cmx src/vendor/odoc_parser/ast.cmx \
src/vendor/odoc_parser/semantics.cmi
src/vendor/odoc_parser/semantics.cmi : src/vendor/odoc_parser/paths.cmi \
src/vendor/odoc_parser/error.cmx src/vendor/odoc_parser/comment.cmx \
src/vendor/odoc_parser/ast.cmx
src/vendor/odoc_parser/syntax.cmx : src/vendor/odoc_parser/token.cmx \
src/vendor/odoc_parser/parse_error.cmx \
src/vendor/odoc_parser/location_.cmx src/vendor/odoc_parser/helpers.cmx \
src/vendor/odoc_parser/error.cmx src/vendor/odoc_parser/comment.cmx \
src/vendor/odoc_parser/ast.cmx src/vendor/odoc_parser/syntax.cmi
src/vendor/odoc_parser/syntax.cmi : src/vendor/odoc_parser/token.cmx \
src/vendor/odoc_parser/location_.cmx src/vendor/odoc_parser/error.cmx \
src/vendor/odoc_parser/ast.cmx
src/vendor/odoc_parser/token.cmx : src/vendor/odoc_parser/comment.cmx
src/vendor/omd/html_characters.cmx :
src/vendor/omd/omd.cmx : src/vendor/omd/omd_representation.cmx \
src/vendor/omd/omd_parser.cmx src/vendor/omd/omd_lexer.cmx \
src/vendor/omd/omd_backend.cmx src/vendor/omd/omd.cmi
src/vendor/omd/omd.cmi : src/vendor/omd/omd_representation.cmi
src/vendor/omd/omd_backend.cmx : src/vendor/omd/omd_utils.cmx \
src/vendor/omd/omd_representation.cmx src/vendor/omd/omd_backend.cmi
src/vendor/omd/omd_backend.cmi : src/vendor/omd/omd_utils.cmi \
src/vendor/omd/omd_representation.cmi
src/vendor/omd/omd_html.cmx :
src/vendor/omd/omd_lexer.cmx : src/vendor/omd/omd_utils.cmx \
src/vendor/omd/omd_representation.cmx src/vendor/omd/omd_lexer.cmi
src/vendor/omd/omd_lexer.cmi : src/vendor/omd/omd_representation.cmi
src/vendor/omd/omd_parser.cmx : src/vendor/omd/omd_utils.cmx \
src/vendor/omd/omd_representation.cmx src/vendor/omd/omd_lexer.cmx \
src/vendor/omd/omd_backend.cmx src/vendor/omd/omd_parser.cmi
src/vendor/omd/omd_parser.cmi : src/vendor/omd/omd_utils.cmi \
src/vendor/omd/omd_representation.cmi
src/vendor/omd/omd_representation.cmx : src/vendor/omd/omd_utils.cmx \
src/vendor/omd/omd_representation.cmi
src/vendor/omd/omd_representation.cmi :
src/vendor/omd/omd_types.cmx :
src/vendor/omd/omd_utils.cmx : src/vendor/omd/omd_utils.cmi
src/vendor/omd/omd_utils.cmi :
src/vendor/omd/omd_xtxt.cmx : src/vendor/omd/omd_xtxt.cmi
src/vendor/omd/omd_xtxt.cmi :
src/vendor/res_outcome_printer/res_comment.cmx : \
src/vendor/res_outcome_printer/res_comment.cmi
src/vendor/res_outcome_printer/res_comment.cmi :
src/vendor/res_outcome_printer/res_doc.cmx : \
src/vendor/res_outcome_printer/res_minibuffer.cmx \
src/vendor/res_outcome_printer/res_doc.cmi
src/vendor/res_outcome_printer/res_doc.cmi :
src/vendor/res_outcome_printer/res_minibuffer.cmx : \
src/vendor/res_outcome_printer/res_minibuffer.cmi
src/vendor/res_outcome_printer/res_minibuffer.cmi :
src/vendor/res_outcome_printer/res_outcome_printer.cmx : \
src/vendor/res_outcome_printer/res_token.cmx \
src/vendor/res_outcome_printer/res_doc.cmx
src/vendor/res_outcome_printer/res_token.cmx : \
src/vendor/res_outcome_printer/res_comment.cmx
11 changes: 11 additions & 0 deletions analysis/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.merlin
!/.merlin
*.install
examples/*/lib
tests/lib
node_modules
*.cmi
*.cmt
*.cmti
*.cmx
*.o
15 changes: 15 additions & 0 deletions analysis/.merlin
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
B src
B src/vendor
B src/vendor/odoc_parser
B src/vendor/omd
B src/vendor/res_outcome_printer
B ../../.opam/4.06.1/lib/ocaml/compiler-libs/

S src
S src/vendor
S src/vendor/odoc_parser
S src/vendor/omd
S src/vendor/res_outcome_printer
S ../../.opam/4.06.1/lib/ocaml/compiler-libs/

FLG -w +26+27+32+33+39
5 changes: 5 additions & 0 deletions analysis/.ocamlformat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cases-exp-indent = 2
space-around-arrays = false
space-around-lists = false
space-around-records = false
space-around-variants = false
59 changes: 59 additions & 0 deletions analysis/Changes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# master
- Fix issue in jump-to-definition on Windows. (See https://github.com/rescript-lang/rescript-vscode/issues/98) where the wrong URI was generated.
- Don't show file path on hover.
- Add autocomplete for props in JSX components.
- Autocomplete: fix issue where `->` autocomplete was overruling `.`. See https://github.com/rescript-lang/rescript-editor-support/issues/99.
- Add pipe autocomplete for builtin list, array, string, option types. And for string and array literals.
- Fix hover on labels in component functions with compiler version 9.1, and labels with type annotation.

## Release 1.0.6 of rescript-vscode
This [commit](https://github.com/rescript-lang/rescript-editor-support/commit/03ee0d97b250474028d4fb08eac81ddb21ccb082) is vendored in [rescript-vscode 1.0.6](https://github.com/rescript-lang/rescript-vscode/releases/tag/1.0.6).

#### New features
- Add support for autocomplete for pipe-first `foo->`: the type of `foo` is used to determine the module to take completions from.
- Add support for autocomplete for decorators such as `@module` and `@val`.
- Add support for autocomplete of labelled arguments `foo(~label... )`.
- Add support for @deprecated attributes in autocomplete.
- Support for upcoming `rescript` npm package for the compiler. Looks for `rescript` in addition to `bs-platform` in `node_modules`.

#### Fixes

- Fix issue for uncurried functions where the internal definition of `Js.Fn.arity` is shown on hover. (See https://github.com/rescript-lang/rescript-editor-support/issues/62).
- Fix type hint when hovering over labeled arguments of components (See https://github.com/rescript-lang/rescript-editor-support/issues/63).
- Fix issue where values declared with type annotation would not show up in autocomplete, and would show no doc comment on hover. (See https://github.com/rescript-lang/rescript-vscode/issues/72).
- Fix hover on definitions inside a react component module, or whenever multiple definitins for the same value exist in the module (See https://github.com/rescript-lang/rescript-editor-support/issues/67).
- Fix autocomplete issue where multiple open's were considered in the wrong priority order (See https://github.com/rescript-lang/rescript-editor-support/issues/72).
- Autocomplete: add support for `open!` in addition to `open`.

## Release 1.0.5 of rescript-vscode
This [commit](https://github.com/rescript-lang/rescript-editor-support/commit/6bdd10f6af259edc5f9cbe5b9df06836de3ab865) is vendored in [rescript-vscode 1.0.5](https://github.com/rescript-lang/rescript-vscode/releases/tag/1.0.5).

- Add support for doc strings when hovering on modules.
- Add support for printing uncurried function types in hover.
- Fix autocomplete issue where `open Foo` would be picked up inside line comments (see https://github.com/rescript-lang/rescript-editor-support/issues/15).
- Don't print parens as in `A()` for 0-ary variants.
- Fix infinite loop in autocomplete that can cause `rescript-editor-support.exe` processes to use up 100% cpu.
- Fix jump to type definition for types defined in an inner module.

## Release 1.0.3 of rescript-vscode
This [commit](https://github.com/rescript-lang/rescript-editor-support/commit/214d220d8573f9f0c8d54e623c163e01617bf124) is vendored in [rescript-vscode 1.0.3](https://github.com/rescript-lang/rescript-vscode/releases/tag/1.0.3).

- Fix type shown when hovering on record fields (see https://github.com/rescript-lang/rescript-vscode/issues/52), and doc comments for records.
- Fix issue where type variables are printed with global renaming when hovering or autocompleting a module (see https://github.com/rescript-lang/rescript-editor-support/issues/38).
- Fix issue where a log file was always created (see https://github.com/rescript-lang/rescript-vscode/issues/47).
- Add support for hover on the id of toplevel module definitions (```module Id = ...```).

## Release 1.0.1 of rescript-vscode
This [commit](https://github.com/rescript-lang/rescript-editor-support/commit/232ad609766c415048750c5cc828973a9995f382) is vendored in [rescript-vscode 1.0.1](https://github.com/rescript-lang/rescript-vscode/releases/tag/1.0.1).

- Support printing inline records.
- Add typedef hover support.
- Always output valid json, even in case of internal error.
- Remove semicolon in module top level preview.
- Support syntax highlight in hover fenced blocks.
- Fix printing of variant arguments.
- Use outcome printer from the syntax to print type declarations.
- Fix issue in command-line parsing on Windows with paths of the form `c:/...:line:column`.

## Release 1.0.0 of rescript-vscode
This [commit](https://github.com/rescript-lang/rescript-editor-support/commit/d45f45793a307a3bb87dcac0542fd412669f1b6e) is vendored in [rescript-vscode 1.0.0](https://github.com/rescript-lang/rescript-vscode/releases/tag/1.0.0).
49 changes: 49 additions & 0 deletions analysis/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
SHELL = /bin/bash
MAKEFLAGS += --jobs 4
INCLUDES = -I src -I src/vendor/odoc_parser -I src/vendor/omd -I src/vendor/res_outcome_printer -I src/vendor

OCAMLOPT = ocamlopt.opt
OCAMLFLAGS = -g -w +26+27+32+33+39 -bin-annot -I +compiler-libs $(INCLUDES)
OCAMLDEP = ocamldep.opt

OUTPUT = ../server/analysis_binaries/current-platform.exe

%.cmi : %.mli
@echo Building $@
@$(OCAMLOPT) $(OCAMLFLAGS) -c $<
%.cmx : %.ml
@echo Building $@
@$(OCAMLOPT) $(OCAMLFLAGS) -c $<

include .depend
depend:
@$(OCAMLDEP) -native $(INCLUDES) `find src -name "*.ml" -o -name "*.mli"` > .depend

SOURCE_FILES = $(shell $(OCAMLDEP) -sort `find src -name "*.ml"` | sed -E "s/\.ml/.cmx/g")

$(OUTPUT): $(SOURCE_FILES)
@echo Linking...
@$(OCAMLOPT) $(OCAMLFLAGS) -O2 -o $(OUTPUT) \
-I +compiler-libs unix.cmxa str.cmxa ocamlcommon.cmxa $(INCLUDES) $(SOURCE_FILES)
@echo Done!

build-native: $(OUTPUT) depend

dce: build-native
../node_modules/.bin/reanalyze -dce-cmt src -suppress src/vendor

tests/node_modules/.bin/rescript:
@cd tests && npm install

tests/lib/.compiler.log: tests/node_modules/.bin/rescript
@cd tests && node_modules/.bin/rescript build -with-deps

test: dce tests/lib/.compiler.log
./test.sh

clean:
git clean -dfx src

.DEFAULT_GOAL := build-native

.PHONY: depend clean build-native dce test
39 changes: 39 additions & 0 deletions analysis/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Rescript Editor Support

This is a private command line binary used by [rescript-vscode](https://github.com/rescript-lang/rescript-vscode) to power a few functionalities such as jump to definition, hover and autocomplete.

The binary reads the `.cmt` and `.cmti` files and analyses them.

## Install

```
opam switch 4.06.1
```

## Build

```
make
```

The built artifact is in `lib/rescript-editor-support.exe`

## Test

```
make test
```

## Usage

Run:

```sh
lib/rescript-editor-support.exe --help
```

## History

This project is based on a fork of [Reason Language Server](https://github.com/jaredly/reason-language-server).

Distributed under the MIT License (see [LICENSE](./LICENSE)).
Loading

0 comments on commit c8ab832

Please sign in to comment.