From 7e9bad209b28552853e029c7edbe046ba32749d3 Mon Sep 17 00:00:00 2001 From: WebFreak001 Date: Wed, 10 Feb 2016 19:18:32 +0100 Subject: [PATCH] DCD waits for import paths before adding imports, can add imports at startup now --- source/app.d | 2 +- source/com/dcd.d | 23 ++++++++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/source/app.d b/source/app.d index f296de2..ae44f96 100644 --- a/source/app.d +++ b/source/app.d @@ -16,7 +16,7 @@ import std.json; import std.meta; import std.conv; -static immutable Version = [2, 3, 1]; +static immutable Version = [2, 3, 2]; __gshared Mutex writeMutex; void sendFinal(int id, JSONValue value) diff --git a/source/com/dcd.d b/source/com/dcd.d index 8c343da..963c88b 100644 --- a/source/com/dcd.d +++ b/source/com/dcd.d @@ -5,6 +5,7 @@ import std.conv; import std.stdio; import std.string; import std.process; +import std.algorithm; import core.thread; import painlessjson; @@ -35,21 +36,30 @@ import workspaced.api; /// This will start the dcd-server and load import paths from the current provider /// Call_With: `{"subcmd": "setup-server"}` @arguments("subcmd", "setup-server") -void setupServer() +void setupServer(string[] additionalImports = []) { - startServer(); - refreshImports(); + startServer(importPathProvider() ~ additionalImports); } /// This will start the dcd-server /// Call_With: `{"subcmd": "start-server"}` @arguments("subcmd", "start-server") -void startServer() +void startServer(string[] additionalImports = []) { if (isPortRunning(port)) throw new Exception("Already running dcd on port " ~ port.to!string); runningPort = port; - serverPipes = raw([serverPath, "--port", runningPort.to!string], Redirect.stdin | Redirect.stdoutToStderr); + string[] imports; + foreach (i; additionalImports) + imports ~= "-I" ~ i; + serverPipes = raw([serverPath, "--port", runningPort.to!string] ~ imports, Redirect.stdin | Redirect.stderr | Redirect.stdoutToStderr); + while (!serverPipes.stderr.eof) + { + string line = serverPipes.stderr.readln(); + stderr.writeln("Server: ", line); + if (line.canFind(" Startup completed in ")) + break; + } new Thread({ while (!serverPipes.stderr.eof) { @@ -299,8 +309,7 @@ void addImports(string[] imports) else if (data[0] == "identifiers") { DCDIdentifier[] identifiers; - foreach (line; - data[1 .. $]) + foreach (line; data[1 .. $]) { string[] splits = line.split('\t'); identifiers ~= DCDIdentifier(splits[0], splits[1]);