Merge pull request #618 from WebFreak001/fix-empty-source-crash
add RequestKind.requiresSourceCode, fix #617 merged-on-behalf-of: Brian Schott <Hackerpilot@users.noreply.github.com>
This commit is contained in:
commit
dc14f03614
|
@ -78,6 +78,10 @@ enum RequestKind : ushort
|
|||
localUse = 0b00000010_00000000,
|
||||
/// Remove import directory from server
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
@ -281,22 +281,33 @@ int runServer(string[] args)
|
|||
info("Returning import path list");
|
||||
s.sendResponse(response);
|
||||
}
|
||||
else if (request.kind & RequestKind.autocomplete)
|
||||
else
|
||||
{
|
||||
info("Getting completions");
|
||||
s.sendResponse(complete(request, cache));
|
||||
// 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)
|
||||
{
|
||||
info("Getting completions");
|
||||
s.sendResponse(complete(request, cache));
|
||||
}
|
||||
else if (request.kind & RequestKind.doc)
|
||||
{
|
||||
info("Getting doc comment");
|
||||
s.trySendResponse(getDoc(request, cache), "Could not get DDoc information");
|
||||
}
|
||||
else if (request.kind & RequestKind.symbolLocation)
|
||||
s.trySendResponse(findDeclaration(request, cache), "Could not get symbol location");
|
||||
else if (request.kind & RequestKind.search)
|
||||
s.sendResponse(symbolSearch(request, cache));
|
||||
else if (request.kind & RequestKind.localUse)
|
||||
s.trySendResponse(findLocalUse(request, cache), "Couldnot find local usage");
|
||||
}
|
||||
else if (request.kind & RequestKind.doc)
|
||||
{
|
||||
info("Getting doc comment");
|
||||
s.trySendResponse(getDoc(request, cache), "Could not get DDoc information");
|
||||
}
|
||||
else if (request.kind & RequestKind.symbolLocation)
|
||||
s.trySendResponse(findDeclaration(request, cache), "Could not get symbol location");
|
||||
else if (request.kind & RequestKind.search)
|
||||
s.sendResponse(symbolSearch(request, cache));
|
||||
else if (request.kind & RequestKind.localUse)
|
||||
s.trySendResponse(findLocalUse(request, cache), "Couldnot find local usage");
|
||||
|
||||
sw.stop();
|
||||
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