Fix issues in the client.
This commit is contained in:
parent
b516277b0a
commit
7101d7a64b
24
client.d
24
client.d
|
|
@ -57,6 +57,8 @@ int main(string[] args)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AutocompleteRequest request;
|
||||||
|
|
||||||
if (help)
|
if (help)
|
||||||
{
|
{
|
||||||
printHelp(args[0]);
|
printHelp(args[0]);
|
||||||
|
|
@ -64,7 +66,6 @@ int main(string[] args)
|
||||||
}
|
}
|
||||||
else if (shutdown || clearCache)
|
else if (shutdown || clearCache)
|
||||||
{
|
{
|
||||||
AutocompleteRequest request;
|
|
||||||
if (shutdown)
|
if (shutdown)
|
||||||
request.kind = RequestKind.shutdown;
|
request.kind = RequestKind.shutdown;
|
||||||
else if (clearCache)
|
else if (clearCache)
|
||||||
|
|
@ -73,6 +74,19 @@ int main(string[] args)
|
||||||
scope (exit) { socket.shutdown(SocketShutdown.BOTH); socket.close(); }
|
scope (exit) { socket.shutdown(SocketShutdown.BOTH); socket.close(); }
|
||||||
return sendRequest(socket, request) ? 0 : 1;
|
return sendRequest(socket, request) ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
else if (importPaths.length > 0)
|
||||||
|
{
|
||||||
|
request.kind |= RequestKind.addImport;
|
||||||
|
request.importPaths = importPaths.map!(a => absolutePath(a)).array;
|
||||||
|
if (cursorPos == size_t.max)
|
||||||
|
{
|
||||||
|
TcpSocket socket = createSocket(port);
|
||||||
|
scope (exit) { socket.shutdown(SocketShutdown.BOTH); socket.close(); }
|
||||||
|
if (!sendRequest(socket, request))
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (cursorPos == size_t.max)
|
else if (cursorPos == size_t.max)
|
||||||
{
|
{
|
||||||
// cursor position is a required argument
|
// cursor position is a required argument
|
||||||
|
|
@ -107,19 +121,11 @@ int main(string[] args)
|
||||||
f.rawRead(sourceCode);
|
f.rawRead(sourceCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create message
|
|
||||||
AutocompleteRequest request;
|
|
||||||
request.fileName = fileName;
|
request.fileName = fileName;
|
||||||
request.importPaths = importPaths;
|
request.importPaths = importPaths;
|
||||||
request.sourceCode = sourceCode;
|
request.sourceCode = sourceCode;
|
||||||
request.cursorPosition = cursorPos;
|
request.cursorPosition = cursorPos;
|
||||||
|
|
||||||
if (importPaths.length > 0)
|
|
||||||
{
|
|
||||||
request.kind |= RequestKind.addImport;
|
|
||||||
request.importPaths = importPaths.map!(a => absolutePath(a)).array;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (symbolLocation)
|
if (symbolLocation)
|
||||||
request.kind |= RequestKind.symbolLocation;
|
request.kind |= RequestKind.symbolLocation;
|
||||||
else if (doc)
|
else if (doc)
|
||||||
|
|
|
||||||
|
|
@ -141,7 +141,10 @@ struct ModuleCache
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
import std.typecons;
|
import std.typecons;
|
||||||
File f = File(cachedLocation);
|
File f = File(cachedLocation);
|
||||||
ubyte[] source = cast(ubyte[]) Mallocator.it.allocate(cast(size_t)f.size);
|
immutable fileSize = cast(size_t)f.size;
|
||||||
|
if (fileSize == 0)
|
||||||
|
return symbols;
|
||||||
|
ubyte[] source = cast(ubyte[]) Mallocator.it.allocate(fileSize);
|
||||||
f.rawRead(source);
|
f.rawRead(source);
|
||||||
LexerConfig config;
|
LexerConfig config;
|
||||||
config.fileName = cachedLocation;
|
config.fileName = cachedLocation;
|
||||||
|
|
|
||||||
4
server.d
4
server.d
|
|
@ -145,8 +145,6 @@ int main(string[] args)
|
||||||
|
|
||||||
AutocompleteRequest request;
|
AutocompleteRequest request;
|
||||||
msgpack.unpack(buffer[size_t.sizeof .. bytesReceived], request);
|
msgpack.unpack(buffer[size_t.sizeof .. bytesReceived], request);
|
||||||
if (request.kind & RequestKind.addImport)
|
|
||||||
ModuleCache.addImportPaths(request.importPaths);
|
|
||||||
if (request.kind & RequestKind.clearCache)
|
if (request.kind & RequestKind.clearCache)
|
||||||
{
|
{
|
||||||
Log.info("Clearing cache.");
|
Log.info("Clearing cache.");
|
||||||
|
|
@ -157,6 +155,8 @@ int main(string[] args)
|
||||||
Log.info("Shutting down.");
|
Log.info("Shutting down.");
|
||||||
break serverLoop;
|
break serverLoop;
|
||||||
}
|
}
|
||||||
|
if (request.kind & RequestKind.addImport)
|
||||||
|
ModuleCache.addImportPaths(request.importPaths);
|
||||||
else if (request.kind & RequestKind.autocomplete)
|
else if (request.kind & RequestKind.autocomplete)
|
||||||
{
|
{
|
||||||
Log.info("Getting completions");
|
Log.info("Getting completions");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue