Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#### :bug: Bug Fix

- Fix invalid range for `definition`. https://github.com/rescript-lang/rescript-vscode/pull/781
- Don't emit object keys in uppercase as namespace. https://github.com/rescript-lang/rescript-vscode/pull/798

## 1.18.0

Expand Down
11 changes: 8 additions & 3 deletions analysis/src/SemanticTokens.ml
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ let emitFromLoc ~loc ~type_ emitter =

let emitLongident ?(backwards = false) ?(jsx = false)
?(lowerCaseToken = if jsx then Token.JsxLowercase else Token.Variable)
?(upperCaseToken = Token.Namespace) ?(lastToken = None) ?(posEnd = None) ~pos
~lid ~debug emitter =
?(upperCaseToken = Token.Namespace) ?(lastToken = None) ?(posEnd = None)
~pos ~lid ~debug emitter =
let rec flatten acc lid =
match lid with
| Longident.Lident txt -> txt :: acc
Expand Down Expand Up @@ -309,7 +309,12 @@ let command ~debug ~emitter ~path =
Ast_iterator.default_iterator.expr iterator e
| Pexp_record (cases, _) ->
cases
|> List.iter (fun (label, _) -> emitter |> emitRecordLabel ~label ~debug);
|> List.filter_map (fun ((label : Longident.t Location.loc), _) ->
match label.txt with
| Longident.Lident s when not (Utils.isFirstCharUppercase s) ->
Some label
| _ -> None)
|> List.iter (fun label -> emitter |> emitRecordLabel ~label ~debug);
Ast_iterator.default_iterator.expr iterator e
| Pexp_field (_, label) | Pexp_setfield (_, label, _) ->
emitter |> emitRecordLabel ~label ~debug;
Expand Down
3 changes: 3 additions & 0 deletions analysis/src/Utils.ml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ let endsWith s suffix =
let l = String.length s in
p <= String.length s && String.sub s (l - p) p = suffix

let isFirstCharUppercase s =
String.length s > 0 && Char.equal s.[0] (Char.uppercase_ascii s.[0])

let cmtPosToPosition {Lexing.pos_lnum; pos_cnum; pos_bol} =
Protocol.{line = pos_lnum - 1; character = pos_cnum - pos_bol}

Expand Down
2 changes: 2 additions & 0 deletions analysis/tests/src/Highlight.res
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,5 @@ let _ = 3 == 3 || 3 === 3
let _ = (~_type_ as _) => ()

let _ = {"abc": 34}

let _ = {"Key": 2}
2 changes: 1 addition & 1 deletion analysis/tests/src/expected/Highlight.res.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Highlight src/Highlight.res
structure items:38 diagnostics:0
structure items:39 diagnostics:0
Lident: M 0:7 Namespace
Lident: C 1:9 Namespace
Lident: Component 1:13 Namespace
Expand Down