inlay hint chores
This commit is contained in:
parent
5bc2a5af37
commit
7aacf0861e
|
@ -326,7 +326,7 @@ more is planned.
|
|||
|
||||
#### Example output
|
||||
|
||||
42 ->MyAlias->MyType
|
||||
l ->MyAlias->MyType 42
|
||||
|
||||
# Server
|
||||
|
||||
|
|
|
@ -86,7 +86,8 @@ int runClient(string[] args)
|
|||
getopt(args, "cursorPos|c", &cursorPos, "I", &addedImportPaths,
|
||||
"R", &removedImportPaths, "port|p", &port, "help|h", &help,
|
||||
"shutdown", &shutdown, "clearCache", &clearCache,
|
||||
"symbolLocation|l", &symbolLocation, "doc|d", &doc, "inlayHints", &inlayHints,
|
||||
"symbolLocation|l", &symbolLocation, "doc|d", &doc,
|
||||
"inlayHints", &inlayHints,
|
||||
"query|status|q", &query, "search|s", &search,
|
||||
"version", &printVersion, "listImports", &listImports,
|
||||
"tcp", &useTCP, "socketFile", &socketFile,
|
||||
|
@ -182,7 +183,7 @@ int runClient(string[] args)
|
|||
printImportList(response);
|
||||
return 0;
|
||||
}
|
||||
else if (search == null && cursorPos == size_t.max)
|
||||
else if (search == null && !inlayHints && cursorPos == size_t.max)
|
||||
{
|
||||
// cursor position is a required argument
|
||||
printHelp(args[0]);
|
||||
|
@ -300,6 +301,10 @@ Options:
|
|||
Gets documentation comments associated with the symbol at the cursor
|
||||
location.
|
||||
|
||||
--inlayHints
|
||||
For all supported variable usages, show value types. Currently shows
|
||||
alias definitions.
|
||||
|
||||
--search | -s symbolName
|
||||
Searches for symbolName in both stdin / the given file name as well as
|
||||
others files cached by the server.
|
||||
|
@ -393,9 +398,13 @@ void printInlayHintsResponse(ref const AutocompleteResponse response)
|
|||
{
|
||||
auto app = appender!(string[])();
|
||||
foreach (ref completion; response.completions)
|
||||
{
|
||||
app.put(makeTabSeparated(completion.symbolLocation.to!string, completion.identifier));
|
||||
}
|
||||
{
|
||||
app.put(makeTabSeparated(
|
||||
completion.kind == char.init ? "" : "" ~ completion.kind,
|
||||
completion.identifier,
|
||||
completion.symbolLocation.to!string
|
||||
));
|
||||
}
|
||||
foreach (line; app.data)
|
||||
writeln(line);
|
||||
}
|
||||
|
|
|
@ -78,6 +78,7 @@ public AutocompleteResponse getInlayHints(const AutocompleteRequest request,
|
|||
{
|
||||
AutocompleteResponse.Completion c;
|
||||
c.symbolLocation = it.location - 1;
|
||||
c.kind = CompletionKind.aliasName;
|
||||
|
||||
DSymbol* type = it.type;
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
l ->Point 208
|
|
@ -0,0 +1,17 @@
|
|||
// when extending the inlayHints capabilities, don't forget to update the --help
|
||||
// text inside client.d
|
||||
|
||||
import point;
|
||||
import point : P = Point;
|
||||
|
||||
void foo(int x, int y) {}
|
||||
void foo(Point point) {}
|
||||
void bar(P point, int z = 1) {}
|
||||
|
||||
void main()
|
||||
{
|
||||
P p;
|
||||
foo(1, 2);
|
||||
foo(p);
|
||||
bar(p, 3);
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
set -e
|
||||
set -u
|
||||
|
||||
../../bin/dcd-client $1 --inlayHints file.d > actual.txt
|
||||
diff actual.txt expected.txt --strip-trailing-cr
|
Loading…
Reference in New Issue