add RequestKind.requiresSourceCode, fix #617
this is a or-combined mask of the request kinds which operate on `request.sourceCode`. Before if a client sent a request without source code (with empty source) to one of these commands, the server would crash with an assertion failure, now the server returns an empty response.
This commit is contained in:
parent
8e44bf8a3e
commit
8c53181ffd
|
@ -78,6 +78,10 @@ enum RequestKind : ushort
|
||||||
localUse = 0b00000010_00000000,
|
localUse = 0b00000010_00000000,
|
||||||
/// Remove import directory from server
|
/// Remove import directory from server
|
||||||
removeImport = 0b00000100_00000000,
|
removeImport = 0b00000100_00000000,
|
||||||
|
|
||||||
|
/// These request kinds require source code and won't be executed if there
|
||||||
|
/// is no source sent
|
||||||
|
requiresSourceCode = autocomplete | doc | symbolLocation | search | localUse,
|
||||||
// dfmt on
|
// dfmt on
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -281,6 +281,16 @@ int runServer(string[] args)
|
||||||
info("Returning import path list");
|
info("Returning import path list");
|
||||||
s.sendResponse(response);
|
s.sendResponse(response);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// these requests operate on and require source code
|
||||||
|
|
||||||
|
if ((request.kind & RequestKind.requiresSourceCode)
|
||||||
|
&& !request.sourceCode.length)
|
||||||
|
{
|
||||||
|
warning("Received a ", request.kind, " request without source code");
|
||||||
|
s.sendResponse(AutocompleteResponse.init);
|
||||||
|
}
|
||||||
else if (request.kind & RequestKind.autocomplete)
|
else if (request.kind & RequestKind.autocomplete)
|
||||||
{
|
{
|
||||||
info("Getting completions");
|
info("Getting completions");
|
||||||
|
@ -297,6 +307,7 @@ int runServer(string[] args)
|
||||||
s.sendResponse(symbolSearch(request, cache));
|
s.sendResponse(symbolSearch(request, cache));
|
||||||
else if (request.kind & RequestKind.localUse)
|
else if (request.kind & RequestKind.localUse)
|
||||||
s.trySendResponse(findLocalUse(request, cache), "Couldnot find local usage");
|
s.trySendResponse(findLocalUse(request, cache), "Couldnot find local usage");
|
||||||
|
}
|
||||||
|
|
||||||
sw.stop();
|
sw.stop();
|
||||||
info("Request processed in ", sw.peek().total!"msecs"(), " milliseconds");
|
info("Request processed in ", sw.peek().total!"msecs"(), " milliseconds");
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
set -e
|
||||||
|
set -u
|
||||||
|
|
||||||
|
../../bin/dcd-client $1 -s foo < /dev/null
|
||||||
|
../../bin/dcd-client $1 -c 1 < /dev/null
|
||||||
|
../../bin/dcd-client $1 -d -c 1 < /dev/null
|
||||||
|
../../bin/dcd-client $1 -u -c 1 < /dev/null
|
Loading…
Reference in New Issue