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
# *nix binaries
bin
bin/
*.o
*.a
*.so

View File

@ -213,16 +213,19 @@ in place of a file being edited.)
/usr/include/dmd/phobos/std/conv.d f 9494
```
## Find usage of symbol at cursor
```dcd-client --localUsage -c 123```
## Find the use of the symbol at the cursor
```dcd-client --localUse -c 123```
The "--localUsage" 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.
The "--localUse" or "-u" flags cause the client to instruct the server
to return all the uses, within the same module, of the symbol located at the given cursor position.
#### 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
the first line contains the location of the symbol (a file name or literally _stdin_), a tab then the offset to the symbol declaration,
each following line contains a byte offset, always relative to the supplied file, to a usage of the symbol.
When uses exist, if the source symbol is an identifier (a type, a variable name, etc.)
and if the symbol is not ambiguous then the first line contains the location 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.

View File

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

View File

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

View File

@ -51,13 +51,13 @@ import common.messages;
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:
* request = the autocompletion request
* request = the autocompletion request.
* Returns:
* the autocompletion response
* the autocompletion response.
*/
public AutocompleteResponse findLocalUsage(AutocompleteRequest request,
public AutocompleteResponse findLocalUse(AutocompleteRequest request,
ref ModuleCache moduleCache)
{
AutocompleteResponse response;

View File

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