Skip to content
This repository was archived by the owner on Apr 24, 2021. It is now read-only.

Commit 5c8124a

Browse files
committed
Don't show file path on hover.
1 parent 381c4aa commit 5c8124a

File tree

8 files changed

+11
-24
lines changed

8 files changed

+11
-24
lines changed

Changes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# master
22
- Fix issue in jump-to-definition on Windows. (See https://github.com/rescript-lang/rescript-vscode/issues/98) where the wrong URI was generated.
3-
3+
- Don't show file path on hover.
44

55
## Release 1.0.6 of rescript-vscode
66
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).

src/rescript-editor-support/EditorSupportCommands.re

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ let dumpLocations = (state, ~package, ~file, ~extra, ~selectPos, uri) => {
4444

4545
let hoverText =
4646
Hover.newHover(
47-
~rootUri=state.TopTypes.rootUri,
4847
~file,
4948
~getModule=State.fileForModule(state, ~package),
5049
loc,
@@ -121,8 +120,7 @@ let splitLineChar = pathWithPos => {
121120

122121
let dump = files => {
123122
Shared.cacheTypeToString := true;
124-
let rootPath = Unix.getcwd();
125-
let state = TopTypes.empty(~rootUri=Uri2.fromPath(rootPath));
123+
let state = TopTypes.empty();
126124
files
127125
|> List.iter(pathWithPos => {
128126
let (filePath, selectPos) = pathWithPos |> splitLineChar;
@@ -154,8 +152,7 @@ let autocomplete = (~currentFile, ~full, ~package, ~pos, ~state) => {
154152
};
155153

156154
let complete = (~pathWithPos, ~currentFile) => {
157-
let rootPath = Unix.getcwd();
158-
let state = TopTypes.empty(~rootUri=Uri2.fromPath(rootPath));
155+
let state = TopTypes.empty();
159156
switch (pathWithPos |> splitLineChar) {
160157
| (filePath, Some(pos)) =>
161158
let filePath = Files.maybeConcat(Unix.getcwd(), filePath);

src/rescript-editor-support/Hover.re

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ let showModule =
5959
};
6060
};
6161

62-
let newHover = (~rootUri, ~file: SharedTypes.file, ~getModule, loc) => {
62+
let newHover = (~file: SharedTypes.file, ~getModule, loc) => {
6363
switch (loc) {
6464
| SharedTypes.Explanation(text) => Some(text)
6565
| TypeDefinition(name, decl, _stamp) =>
@@ -144,9 +144,7 @@ let newHover = (~rootUri, ~file: SharedTypes.file, ~getModule, loc) => {
144144
| None =>
145145
let (typeString, docstring) = t |> fromType(~docstring=None);
146146
[typeString, docstring];
147-
| Some((docstring, {uri}, res)) =>
148-
let pathFromRoot = uri |> Uri2.pathFromRoot(~rootUri);
149-
147+
| Some((docstring, res)) =>
150148
let parts =
151149
switch (res) {
152150
| `Declared =>
@@ -171,7 +169,7 @@ let newHover = (~rootUri, ~file: SharedTypes.file, ~getModule, loc) => {
171169
[typeString, docstring];
172170
};
173171

174-
parts @ [Some(pathFromRoot)];
172+
parts;
175173
};
176174

177175
Some(String.concat("\n\n", parts |> Utils.filterMap(x => x)));

src/rescript-editor-support/MessageHandlers.re

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,6 @@ let handlers:
281281
let%opt (location, loc) = References.locForPos(~extra, pos);
282282
let%opt text =
283283
Hover.newHover(
284-
~rootUri=state.rootUri,
285284
~file,
286285
~getModule=State.fileForModule(state, ~package),
287286
loc,

src/rescript-editor-support/References.re

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ let definedForLoc = (~file, ~getModule, locKind) => {
9999
switch (tip) {
100100
| Constructor(name) =>
101101
let%opt constructor = Query.getConstructor(file, stamp, name);
102-
Some((None, file, `Constructor(constructor)));
102+
Some((None, `Constructor(constructor)));
103103
| Field(name) =>
104104
let%opt field = Query.getField(file, stamp, name);
105-
Some((None, file, `Field(field)));
105+
Some((None, `Field(field)));
106106
| _ =>
107107
maybeLog(
108108
"Trying for declared "
@@ -114,7 +114,7 @@ let definedForLoc = (~file, ~getModule, locKind) => {
114114
);
115115
let%opt declared =
116116
Query.declaredForTip(~stamps=file.stamps, stamp, tip);
117-
Some((declared.docstring, file, `Declared));
117+
Some((declared.docstring, `Declared));
118118
};
119119
};
120120

src/rescript-editor-support/RescriptEditorSupport.re

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ let getInitialState = params => {
6060
]),
6161
);
6262

63-
let state = TopTypes.empty(~rootUri);
63+
let state = TopTypes.empty();
6464

6565
Ok(state);
6666
};

src/rescript-editor-support/TopTypes.re

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,13 @@ type package = {
1717
};
1818

1919
type state = {
20-
rootUri: uri,
2120
documentText: Hashtbl.t(uri, string),
2221
packagesByRoot: Hashtbl.t(string, package),
2322
rootForUri: Hashtbl.t(uri, string),
2423
cmtCache: Hashtbl.t(filePath, (float, SharedTypes.file)),
2524
};
2625

27-
let empty = (~rootUri) => {
28-
rootUri,
26+
let empty = () => {
2927
documentText: Hashtbl.create(5),
3028
packagesByRoot: Hashtbl.create(1),
3129
rootForUri: Hashtbl.create(30),

src/rescript-editor-support/Uri2.re

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ module Uri: {
22
type t;
33
let fromPath: string => t;
44
let parse: string => option(t);
5-
let pathFromRoot: (~rootUri: t, t) => string;
65
let toPath: t => string;
76
let toString: t => string;
87
} = {
@@ -67,10 +66,6 @@ module Uri: {
6766
};
6867
let toPath = ({path}) => path;
6968
let toString = ({uri}) => uri;
70-
71-
let pathFromRoot = (~rootUri as {path: rootPath}, {path}) =>
72-
Utils.startsWith(path, rootPath)
73-
? "<root>" ++ Utils.sliceToEnd(path, String.length(rootPath)) : path;
7469
};
7570

7671
include Uri;

0 commit comments

Comments
 (0)