diff --git a/.gitignore b/.gitignore index 56521a7..7313eb4 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,7 @@ *.dll # *nix binaries -bin +bin/ *.o *.a *.so diff --git a/README.md b/README.md index f752484..bf50b6c 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/src/client/client.d b/src/client/client.d index 5ae9546..c04e3f9 100644 --- a/src/client/client.d +++ b/src/client/client.d @@ -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) { diff --git a/src/common/messages.d b/src/common/messages.d index 3857f83..abee795 100644 --- a/src/common/messages.d +++ b/src/common/messages.d @@ -75,7 +75,7 @@ enum RequestKind : ushort /// List import directories listImports = 0b00000001_00000000, /// local symbol usage - localUsage = 0b00000010_00000000, + localUse = 0b00000010_00000000, // dfmt on } diff --git a/src/server/autocomplete.d b/src/server/autocomplete.d index a272e61..435b870 100644 --- a/src/server/autocomplete.d +++ b/src/server/autocomplete.d @@ -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; diff --git a/src/server/server.d b/src/server/server.d index ed3730a..acdc733 100644 --- a/src/server/server.d +++ b/src/server/server.d @@ -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); }