From 85da52422463aaf4880500e683a1b7701c5d66c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20Tr=C3=A9guier?= Date: Thu, 9 Aug 2018 19:47:58 +0200 Subject: [PATCH] fix #521 - Add a request allowing to remove a set of import path --- dsymbol | 2 +- dub.json | 2 +- src/dcd/client/client.d | 22 +++++++++++++--------- src/dcd/common/messages.d | 4 +++- src/dcd/server/main.d | 5 +++++ 5 files changed, 23 insertions(+), 12 deletions(-) diff --git a/dsymbol b/dsymbol index 3b546ed..3a562af 160000 --- a/dsymbol +++ b/dsymbol @@ -1 +1 @@ -Subproject commit 3b546ed2b2551f61e0cf30d04f45682546387422 +Subproject commit 3a562af26b008084c7f70520f5b91b6357a7c919 diff --git a/dub.json b/dub.json index 124bf13..008456b 100644 --- a/dub.json +++ b/dub.json @@ -7,7 +7,7 @@ ], "license": "GPL-3.0", "dependencies": { - "dsymbol": "~>0.4.1", + "dsymbol": "~>0.4.3", "libdparse": "~>0.9.1", "msgpack-d": "~>1.0.0-beta.3", "stdx-allocator": "~>2.77.2" diff --git a/src/dcd/client/client.d b/src/dcd/client/client.d index a88587d..18a4207 100644 --- a/src/dcd/client/client.d +++ b/src/dcd/client/client.d @@ -39,7 +39,8 @@ int main(string[] args) sharedLog.fatalHandler = () {}; size_t cursorPos = size_t.max; - string[] importPaths; + string[] addedImportPaths; + string[] removedImportPaths; ushort port; bool help; bool shutdown; @@ -66,10 +67,11 @@ int main(string[] args) try { - getopt(args, "cursorPos|c", &cursorPos, "I", &importPaths, - "port|p", &port, "help|h", &help, "shutdown", &shutdown, - "clearCache", &clearCache, "symbolLocation|l", &symbolLocation, - "doc|d", &doc, "query|status|q", &query, "search|s", &search, + getopt(args, "cursorPos|c", &cursorPos, "I", &addedImportPaths, + "R", &removedImportPaths, "port|p", &port, "help|h", &help, + "shutdown", &shutdown, "clearCache", &clearCache, + "symbolLocation|l", &symbolLocation, "doc|d", &doc, + "query|status|q", &query, "search|s", &search, "version", &printVersion, "listImports", &listImports, "tcp", &useTCP, "socketFile", &socketFile, "getIdentifier", &getIdentifier, @@ -136,10 +138,12 @@ int main(string[] args) scope (exit) { socket.shutdown(SocketShutdown.BOTH); socket.close(); } return sendRequest(socket, request) ? 0 : 1; } - else if (importPaths.length > 0) + else if (addedImportPaths.length > 0 || removedImportPaths.length > 0) { - request.kind |= RequestKind.addImport; - request.importPaths = importPaths.map!(a => absolutePath(a)).array; + immutable bool adding = addedImportPaths.length > 0; + request.kind |= adding ? RequestKind.addImport : RequestKind.removeImport; + request.importPaths = (adding ? addedImportPaths : removedImportPaths) + .map!(a => absolutePath(a)).array; if (cursorPos == size_t.max) { Socket socket = createSocket(socketFile, port); @@ -199,7 +203,7 @@ int main(string[] args) } request.fileName = fileName; - request.importPaths = importPaths; + request.importPaths = addedImportPaths; request.sourceCode = sourceCode; request.cursorPosition = cursorPos; request.searchName = search; diff --git a/src/dcd/common/messages.d b/src/dcd/common/messages.d index 3eeeb7f..8453d7b 100644 --- a/src/dcd/common/messages.d +++ b/src/dcd/common/messages.d @@ -74,8 +74,10 @@ enum RequestKind : ushort search = 0b00000000_10000000, /// List import directories listImports = 0b00000001_00000000, - /// local symbol usage + /// Local symbol usage localUse = 0b00000010_00000000, + /// Remove import directory from server + removeImport = 0b00000100_00000000, // dfmt on } diff --git a/src/dcd/server/main.d b/src/dcd/server/main.d index 9e19c3e..ee586a1 100644 --- a/src/dcd/server/main.d +++ b/src/dcd/server/main.d @@ -256,6 +256,11 @@ int main(string[] args) cache.addImportPaths(request.importPaths); } + if (request.kind & RequestKind.removeImport) + { + cache.removeImportPaths(request.importPaths); + } + if (request.kind & RequestKind.listImports) { AutocompleteResponse response;