This commit is contained in:
Hackerpilot 2016-06-30 17:56:06 -07:00
parent 84092c36e7
commit aa8f2f4556
5 changed files with 33 additions and 17 deletions

@ -1 +1 @@
Subproject commit c99dd0b83afe80d3b647f73e400fa4bb8e48aace Subproject commit d3ce885de5a838347254cc41d702ffa53bbb3a5e

@ -1 +1 @@
Subproject commit 99527e49cd194a2cf72da2154cc8b0d9ba30816d Subproject commit 01d42177ca8fab5a0fea22f3f20873bc81e8257a

View File

@ -49,6 +49,7 @@ int main(string[] args)
bool query; bool query;
bool printVersion; bool printVersion;
bool listImports; bool listImports;
bool getIdentifier;
string search; string search;
version(Windows) version(Windows)
{ {
@ -68,7 +69,8 @@ int main(string[] args)
"clearCache", &clearCache, "symbolLocation|l", &symbolLocation, "clearCache", &clearCache, "symbolLocation|l", &symbolLocation,
"doc|d", &doc, "query|status|q", &query, "search|s", &search, "doc|d", &doc, "query|status|q", &query, "search|s", &search,
"version", &printVersion, "listImports", &listImports, "version", &printVersion, "listImports", &listImports,
"tcp", &useTCP, "socketFile", &socketFile); "tcp", &useTCP, "socketFile", &socketFile,
"getIdentifier", &getIdentifier);
} }
catch (ConvException e) catch (ConvException e)
{ {
@ -204,7 +206,7 @@ int main(string[] args)
request.cursorPosition = cursorPos; request.cursorPosition = cursorPos;
request.searchName = search; request.searchName = search;
if (symbolLocation) if (symbolLocation | getIdentifier)
request.kind |= RequestKind.symbolLocation; request.kind |= RequestKind.symbolLocation;
else if (doc) else if (doc)
request.kind |= RequestKind.doc; request.kind |= RequestKind.doc;
@ -223,6 +225,8 @@ int main(string[] args)
if (symbolLocation) if (symbolLocation)
printLocationResponse(response); printLocationResponse(response);
else if (getIdentifier)
printIdentifierResponse(response);
else if (doc) else if (doc)
printDocResponse(response); printDocResponse(response);
else if (search !is null) else if (search !is null)
@ -325,13 +329,22 @@ Socket createSocket(string socketFile, ushort port)
return socket; return socket;
} }
void printDocResponse(AutocompleteResponse response) void printDocResponse(ref const AutocompleteResponse response)
{ {
import std.array: join; import std.array: join;
response.docComments.join("\n").writeln; response.docComments.join("\n").writeln;
} }
void printLocationResponse(AutocompleteResponse response) void printIdentifierResponse(ref const AutocompleteResponse response)
{
if (response.completions.length == 0)
return;
write(response.completions[0]);
write("\t");
writeln(response.symbolIdentifier);
}
void printLocationResponse(ref const AutocompleteResponse response)
{ {
if (response.symbolFilePath is null) if (response.symbolFilePath is null)
writeln("Not found"); writeln("Not found");
@ -339,7 +352,7 @@ void printLocationResponse(AutocompleteResponse response)
writefln("%s\t%d", response.symbolFilePath, response.symbolLocation); writefln("%s\t%d", response.symbolFilePath, response.symbolLocation);
} }
void printCompletionResponse(AutocompleteResponse response) void printCompletionResponse(ref const AutocompleteResponse response)
{ {
if (response.completions.length > 0) if (response.completions.length > 0)
{ {

View File

@ -55,7 +55,6 @@ enum CompletionType : string
enum RequestKind : ushort enum RequestKind : ushort
{ {
// dfmt off // dfmt off
uninitialized = 0b00000000_00000000, uninitialized = 0b00000000_00000000,
/// Autocompletion /// Autocompletion
autocomplete = 0b00000000_00000001, autocomplete = 0b00000000_00000001,
@ -75,7 +74,6 @@ enum RequestKind : ushort
search = 0b00000000_10000000, search = 0b00000000_10000000,
/// List import directories /// List import directories
listImports = 0b00000001_00000000, listImports = 0b00000001_00000000,
// dfmt on // dfmt on
} }
@ -160,6 +158,11 @@ struct AutocompleteResponse
* Import paths that are registered by the server. * Import paths that are registered by the server.
*/ */
string[] importPaths; string[] importPaths;
/**
* Symbol identifier
*/
ulong symbolIdentifier;
} }
/** /**

View File

@ -783,7 +783,7 @@ DSymbol*[] getSymbolsByTokenChain(T)(Scope* completionScope,
if (shouldSwapWithType(completionType, symbols[0].kind, 0, tokens.length - 1)) if (shouldSwapWithType(completionType, symbols[0].kind, 0, tokens.length - 1))
{ {
symbols = symbols[0].type is null ? [] : [symbols[0].type]; symbols = symbols[0].type is null || symbols[0].type is symbols[0] ? [] : [symbols[0].type];
if (symbols.length == 0) if (symbols.length == 0)
return []; return [];
} }
@ -849,7 +849,7 @@ DSymbol*[] getSymbolsByTokenChain(T)(Scope* completionScope,
|| symbols[0].kind == CompletionKind.importSymbol || symbols[0].kind == CompletionKind.importSymbol
|| symbols[0].kind == CompletionKind.aliasName) || symbols[0].kind == CompletionKind.aliasName)
{ {
symbols = symbols[0].type is null ? [] : [symbols[0].type]; symbols = symbols[0].type is null || symbols[0].type is symbols[0] ? [] : [symbols[0].type];
if (symbols.length == 0) if (symbols.length == 0)
break loop; break loop;
} }
@ -865,7 +865,7 @@ DSymbol*[] getSymbolsByTokenChain(T)(Scope* completionScope,
} }
if (shouldSwapWithType(completionType, symbols[0].kind, i, tokens.length - 1)) if (shouldSwapWithType(completionType, symbols[0].kind, i, tokens.length - 1))
{ {
symbols = symbols[0].type is null ? [] : [symbols[0].type]; symbols = symbols[0].type is null || symbols[0].type is symbols[0] ? [] : [symbols[0].type];
if (symbols.length == 0) if (symbols.length == 0)
break loop; break loop;
} }
@ -874,7 +874,7 @@ DSymbol*[] getSymbolsByTokenChain(T)(Scope* completionScope,
&& (completionType == CompletionType.identifiers && (completionType == CompletionType.identifiers
|| i + 1 < tokens.length)) || i + 1 < tokens.length))
{ {
symbols = symbols[0].type is null ? [] : [symbols[0].type]; symbols = symbols[0].type is null || symbols[0].type is symbols[0] ? [] : [symbols[0].type];
} }
if (symbols.length == 0) if (symbols.length == 0)
break loop; break loop;
@ -892,14 +892,14 @@ DSymbol*[] getSymbolsByTokenChain(T)(Scope* completionScope,
skip(); skip();
if (!isSliceExpression(tokens, i)) if (!isSliceExpression(tokens, i))
{ {
symbols = symbols[0].type is null ? [] : [symbols[0].type]; symbols = symbols[0].type is null || symbols[0].type is symbols[0] ? [] : [symbols[0].type];
if (symbols.length == 0) if (symbols.length == 0)
break loop; break loop;
} }
} }
else if (symbols[0].qualifier == SymbolQualifier.assocArray) else if (symbols[0].qualifier == SymbolQualifier.assocArray)
{ {
symbols = symbols[0].type is null ? [] : [symbols[0].type]; symbols = symbols[0].type is null || symbols[0].type is symbols[0] ? [] : [symbols[0].type];
skip(); skip();
} }
else else
@ -1001,7 +1001,7 @@ void setCompletions(T)(ref AutocompleteResponse response,
{ {
if (symbols[0].kind == CompletionKind.aliasName) if (symbols[0].kind == CompletionKind.aliasName)
{ {
if (symbols[0].type is null) if (symbols[0].type is null || symbols[0].type is symbols[0])
return; return;
symbols = [symbols[0].type]; symbols = [symbols[0].type];
} }