Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Lens #513

Merged
merged 10 commits into from
Jul 25, 2022
Prev Previous commit
Next Next commit
Add tests for code lenses.
  • Loading branch information
zth committed Jul 24, 2022
commit c79a8f9506ac84e36f5a93d902db0dcaaca14d59
2 changes: 1 addition & 1 deletion analysis/src/Commands.ml
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ let test ~path =
let line_end = 6 in
print_endline ("Inlay Hint " ^ path ^ " " ^ string_of_int line_start ^ ":" ^ string_of_int line_end);
inlayhint ~path ~pos:(line_start, line_end) ~maxLength:"25" ~debug:false)
| "clens" ->
| "cle" ->
print_endline ("Code Lens " ^ path);
codeLens ~path ~debug:false
| _ -> ());
Expand Down
6 changes: 1 addition & 5 deletions analysis/src/Protocol.ml
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,7 @@ let stringifyHint hint =
(Json.escape hint.label) hint.kind hint.paddingLeft hint.paddingRight

let stringifyCommand (command : command) =
Printf.sprintf
{|{
"title": "%s",
"command": "%s"
}|}
Printf.sprintf {|{"title": "%s", "command": "%s"}|}
(Json.escape command.title)
(Json.escape command.command)

Expand Down
11 changes: 11 additions & 0 deletions analysis/tests/src/CodeLens.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
let add = (x, y) => x + y

let foo = (~age, ~name) => name ++ string_of_int(age)

let ff = (~opt1=0, ~a, ~b, (), ~opt2=0, (), ~c) => a + b + c + opt1 + opt2

let compFF = Completion.ff

@react.component
let make = (~name) => React.string(name)
//^cle
15 changes: 15 additions & 0 deletions analysis/tests/src/expected/CodeLens.res.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Code Lens src/CodeLens.res
[{
"range": {"start": {"line": 9, "character": 4}, "end": {"line": 9, "character": 8}},
"command": {"title": "{\"name\": string} => React.element", "command": ""}
}, {
"range": {"start": {"line": 4, "character": 4}, "end": {"line": 4, "character": 6}},
"command": {"title": "(~opt1: int=?, ~a: int, ~b: int, unit, ~opt2: int=?, unit, ~c: int) => int", "command": ""}
}, {
"range": {"start": {"line": 2, "character": 4}, "end": {"line": 2, "character": 7}},
"command": {"title": "(~age: int, ~name: string) => string", "command": ""}
}, {
"range": {"start": {"line": 0, "character": 4}, "end": {"line": 0, "character": 7}},
"command": {"title": "(int, int) => int", "command": ""}
}]

2 changes: 1 addition & 1 deletion analysis/tests/src/expected/Dce.res.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
DCE src/Dce.res
issues:243
issues:249

3 changes: 2 additions & 1 deletion analysis/tests/src/expected/Debug.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ Dependencies: @rescript/react
Source directories: ./node_modules/@rescript/react/src ./node_modules/@rescript/react/src/legacy
Source files: ./node_modules/@rescript/react/src/React.res ./node_modules/@rescript/react/src/ReactDOM.res ./node_modules/@rescript/react/src/ReactDOMServer.res ./node_modules/@rescript/react/src/ReactDOMStyle.res ./node_modules/@rescript/react/src/ReactEvent.res ./node_modules/@rescript/react/src/ReactEvent.resi ./node_modules/@rescript/react/src/ReactTestUtils.res ./node_modules/@rescript/react/src/ReactTestUtils.resi ./node_modules/@rescript/react/src/RescriptReactErrorBoundary.res ./node_modules/@rescript/react/src/RescriptReactErrorBoundary.resi ./node_modules/@rescript/react/src/RescriptReactRouter.res ./node_modules/@rescript/react/src/RescriptReactRouter.resi ./node_modules/@rescript/react/src/legacy/ReactDOMRe.res ./node_modules/@rescript/react/src/legacy/ReasonReact.res
Source directories: ./src ./src/expected
Source files: ./src/Auto.res ./src/CompletePrioritize1.res ./src/CompletePrioritize2.res ./src/Completion.res ./src/Component.res ./src/Component.resi ./src/CreateInterface.res ./src/Cross.res ./src/Dce.res ./src/Debug.res ./src/Definition.res ./src/DefinitionWithInterface.res ./src/DefinitionWithInterface.resi ./src/Div.res ./src/DocumentSymbol.res ./src/Fragment.res ./src/Highlight.res ./src/Hover.res ./src/InlayHint.res ./src/Jsx.res ./src/Jsx.resi ./src/LongIdentTest.res ./src/Object.res ./src/Patterns.res ./src/RecModules.res ./src/RecordCompletion.res ./src/RecoveryOnProp.res ./src/References.res ./src/ReferencesWithInterface.res ./src/ReferencesWithInterface.resi ./src/Rename.res ./src/RenameWithInterface.res ./src/RenameWithInterface.resi ./src/TableclothMap.ml ./src/TableclothMap.mli ./src/TypeDefinition.res ./src/Xform.res
Source files: ./src/Auto.res ./src/CodeLens.res ./src/CompletePrioritize1.res ./src/CompletePrioritize2.res ./src/Completion.res ./src/Component.res ./src/Component.resi ./src/CreateInterface.res ./src/Cross.res ./src/Dce.res ./src/Debug.res ./src/Definition.res ./src/DefinitionWithInterface.res ./src/DefinitionWithInterface.resi ./src/Div.res ./src/DocumentSymbol.res ./src/Fragment.res ./src/Highlight.res ./src/Hover.res ./src/InlayHint.res ./src/Jsx.res ./src/Jsx.resi ./src/LongIdentTest.res ./src/Object.res ./src/Patterns.res ./src/RecModules.res ./src/RecordCompletion.res ./src/RecoveryOnProp.res ./src/References.res ./src/ReferencesWithInterface.res ./src/ReferencesWithInterface.resi ./src/Rename.res ./src/RenameWithInterface.res ./src/RenameWithInterface.resi ./src/TableclothMap.ml ./src/TableclothMap.mli ./src/TypeDefinition.res ./src/Xform.res
Impl cmt:./lib/bs/src/Auto.cmt res:./src/Auto.res
Impl cmt:./lib/bs/src/CodeLens.cmt res:./src/CodeLens.res
Impl cmt:./lib/bs/src/CompletePrioritize1.cmt res:./src/CompletePrioritize1.res
Impl cmt:./lib/bs/src/CompletePrioritize2.cmt res:./src/CompletePrioritize2.res
Impl cmt:./lib/bs/src/Completion.cmt res:./src/Completion.res
Expand Down