adress Zombine's review

This commit is contained in:
Basile Burg 2017-06-14 13:52:00 +02:00
parent 1ab8a8ec08
commit aaa89143d2
No known key found for this signature in database
GPG Key ID: 1868039F415CB8CF
6 changed files with 28 additions and 24 deletions

2
.gitignore vendored
View File

@ -5,7 +5,7 @@
*.dll *.dll
# *nix binaries # *nix binaries
bin bin/
*.o *.o
*.a *.a
*.so *.so

View File

@ -213,16 +213,19 @@ in place of a file being edited.)
/usr/include/dmd/phobos/std/conv.d f 9494 /usr/include/dmd/phobos/std/conv.d f 9494
``` ```
## Find usage of symbol at cursor ## Find the use of the symbol at the cursor
```dcd-client --localUsage -c 123``` ```dcd-client --localUse -c 123```
The "--localUsage" or "-u" flags cause the client to instruct the server The "--localUse" or "-u" flags cause the client to instruct the server
to return all the local usages of the symbol located at the given cursor position. to return all the uses, within the same module, of the symbol located at the given cursor position.
#### Output format #### Output format
When usages exist, if the source symbol is an identifier (a type, a variable name, etc.) and if the symbol is not ambiguous then When uses exist, if the source symbol is an identifier (a type, a variable name, etc.)
the first line contains the location of the symbol (a file name or literally _stdin_), a tab then the offset to the symbol declaration, and if the symbol is not ambiguous then the first line contains the location of the symbol
each following line contains a byte offset, always relative to the supplied file, to a usage of the symbol. (a file name or literally _stdin_), a tab then the offset to the symbol declaration.
Following the first line is a list of all known uses of the symbol in the current file.
The list is composed of lines each containing a single number that indicates the byte offset
from the start of the file to the i-th use.
Otherwise the client outputs _00000_ so that the length of the answer is guaranteed to be at least 5 bytes. Otherwise the client outputs _00000_ so that the length of the answer is guaranteed to be at least 5 bytes.

View File

@ -50,7 +50,7 @@ int main(string[] args)
bool printVersion; bool printVersion;
bool listImports; bool listImports;
bool getIdentifier; bool getIdentifier;
bool localUsage; bool localUse;
string search; string search;
version(Windows) version(Windows)
{ {
@ -72,7 +72,8 @@ int main(string[] args)
"version", &printVersion, "listImports", &listImports, "version", &printVersion, "listImports", &listImports,
"tcp", &useTCP, "socketFile", &socketFile, "tcp", &useTCP, "socketFile", &socketFile,
"getIdentifier", &getIdentifier, "getIdentifier", &getIdentifier,
"localUsage|u", &localUsage); "localUsage", &localUse, // TODO:remove this line in Nov. 2017
"localUse|u", &localUse);
} }
catch (ConvException e) catch (ConvException e)
{ {
@ -214,8 +215,8 @@ int main(string[] args)
request.kind |= RequestKind.doc; request.kind |= RequestKind.doc;
else if (search) else if (search)
request.kind |= RequestKind.search; request.kind |= RequestKind.search;
else if(localUsage) else if(localUse)
request.kind |= RequestKind.localUsage; request.kind |= RequestKind.localUse;
else else
request.kind |= RequestKind.autocomplete; request.kind |= RequestKind.autocomplete;
@ -235,8 +236,8 @@ int main(string[] args)
printDocResponse(response); printDocResponse(response);
else if (search !is null) else if (search !is null)
printSearchResponse(response); printSearchResponse(response);
else if (localUsage) else if (localUse)
printLocalUsage(response); printLocalUse(response);
else else
printCompletionResponse(response); printCompletionResponse(response);
@ -283,8 +284,8 @@ Options:
Searches for symbolName in both stdin / the given file name as well as Searches for symbolName in both stdin / the given file name as well as
others files cached by the server. others files cached by the server.
--localUsage | -u --localUse | -u
Searches for all the usages of the symbol at the cursor location Searches for all the uses of the symbol at the cursor location
in the given filename (or stdin). in the given filename (or stdin).
--query | -q | --status --query | -q | --status
@ -395,7 +396,7 @@ void printSearchResponse(const AutocompleteResponse response)
} }
} }
void printLocalUsage(const AutocompleteResponse response) void printLocalUse(const AutocompleteResponse response)
{ {
if (response.symbolFilePath.length) if (response.symbolFilePath.length)
{ {

View File

@ -75,7 +75,7 @@ enum RequestKind : ushort
/// List import directories /// List import directories
listImports = 0b00000001_00000000, listImports = 0b00000001_00000000,
/// local symbol usage /// local symbol usage
localUsage = 0b00000010_00000000, localUse = 0b00000010_00000000,
// dfmt on // dfmt on
} }

View File

@ -51,13 +51,13 @@ import common.messages;
import containers.hashset; import containers.hashset;
/** /**
* Finds usage of the symbol at the cursor position in a single document. * Finds the uses of the symbol at the cursor position within a single document.
* Params: * Params:
* request = the autocompletion request * request = the autocompletion request.
* Returns: * Returns:
* the autocompletion response * the autocompletion response.
*/ */
public AutocompleteResponse findLocalUsage(AutocompleteRequest request, public AutocompleteResponse findLocalUse(AutocompleteRequest request,
ref ModuleCache moduleCache) ref ModuleCache moduleCache)
{ {
AutocompleteResponse response; AutocompleteResponse response;

View File

@ -318,11 +318,11 @@ int main(string[] args)
ubyte[] responseBytes = msgpack.pack(response); ubyte[] responseBytes = msgpack.pack(response);
s.send(responseBytes); s.send(responseBytes);
} }
else if (request.kind & RequestKind.localUsage) else if (request.kind & RequestKind.localUse)
{ {
try try
{ {
AutocompleteResponse response = findLocalUsage(request, cache); AutocompleteResponse response = findLocalUse(request, cache);
ubyte[] responseBytes = msgpack.pack(response); ubyte[] responseBytes = msgpack.pack(response);
s.send(responseBytes); s.send(responseBytes);
} }