Skip to content
This repository has been archived by the owner on Mar 1, 2022. It is now read-only.

Commit

Permalink
DCD waits for import paths before adding imports, can add imports at …
Browse files Browse the repository at this point in the history
…startup now
  • Loading branch information
WebFreak001 committed Feb 10, 2016
1 parent d54c509 commit 7e9bad2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion source/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
23 changes: 16 additions & 7 deletions source/com/dcd.d
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import std.conv;
import std.stdio;
import std.string;
import std.process;
import std.algorithm;
import core.thread;

import painlessjson;
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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]);
Expand Down

0 comments on commit 7e9bad2

Please sign in to comment.