mirror of https://github.com/buggins/dlangide.git
refactor DCDInterface
This commit is contained in:
parent
5cc61f1b76
commit
41c534d2b7
|
@ -64,7 +64,7 @@
|
||||||
<doXGeneration>1</doXGeneration>
|
<doXGeneration>1</doXGeneration>
|
||||||
<xfilename>$(IntDir)\$(TargetName).json</xfilename>
|
<xfilename>$(IntDir)\$(TargetName).json</xfilename>
|
||||||
<debuglevel>0</debuglevel>
|
<debuglevel>0</debuglevel>
|
||||||
<debugids>DebugInfo</debugids>
|
<debugids>DebugInfo DCD</debugids>
|
||||||
<versionlevel>0</versionlevel>
|
<versionlevel>0</versionlevel>
|
||||||
<versionids>Unicode USE_FREETYPE</versionids>
|
<versionids>Unicode USE_FREETYPE</versionids>
|
||||||
<dump_source>0</dump_source>
|
<dump_source>0</dump_source>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
module dlangide.tools.d.dcdinterface;
|
module dlangide.tools.d.dcdinterface;
|
||||||
|
|
||||||
import dlangui.core.logger;
|
import dlangui.core.logger;
|
||||||
|
import dlangui.core.files;
|
||||||
|
|
||||||
import dlangide.builders.extprocess;
|
import dlangide.builders.extprocess;
|
||||||
|
|
||||||
|
@ -26,33 +27,49 @@ class DCDInterface {
|
||||||
stdoutTarget = new ProtectedTextStorage();
|
stdoutTarget = new ProtectedTextStorage();
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultSet goToDefinition(in dstring content, int index) {
|
protected dstring[] invokeDcd(char[][] arguments, dstring content, out bool success) {
|
||||||
|
success = false;
|
||||||
ExternalProcess dcdProcess = new ExternalProcess();
|
ExternalProcess dcdProcess = new ExternalProcess();
|
||||||
|
|
||||||
ResultSet result;
|
|
||||||
if(dcdProcess.state != ExternalProcessState.None) {
|
|
||||||
result.result = DCDResult.FAIL;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
char[][] arguments = ["-l".dup, "-c".dup];
|
|
||||||
arguments ~= [to!(char[])(index)];
|
|
||||||
ProtectedTextStorage stdoutTarget = new ProtectedTextStorage();
|
ProtectedTextStorage stdoutTarget = new ProtectedTextStorage();
|
||||||
|
|
||||||
dcdProcess.run("dcd-client".dup, arguments, "/usr/bin".dup, stdoutTarget);
|
version(Windows) {
|
||||||
|
string dcd_client_name = "dcd-client.exe";
|
||||||
|
string dcd_client_dir = null;
|
||||||
|
} else {
|
||||||
|
string dcd_client_name = "dcd-client";
|
||||||
|
string dcd_client_dir = "/usr/bin";
|
||||||
|
}
|
||||||
|
dcdProcess.run(dcd_client_name.dup, arguments, dcd_client_dir ? dcd_client_dir.dup : null, stdoutTarget);
|
||||||
dcdProcess.write(content);
|
dcdProcess.write(content);
|
||||||
dcdProcess.wait();
|
dcdProcess.wait();
|
||||||
|
|
||||||
dstring[] output = stdoutTarget.readText.splitLines();
|
dstring[] output = stdoutTarget.readText.splitLines();
|
||||||
|
|
||||||
if(dcdProcess.poll() == ExternalProcessState.Stopped) {
|
if(dcdProcess.poll() == ExternalProcessState.Stopped) {
|
||||||
result.result = DCDResult.SUCCESS;
|
success = true;
|
||||||
}
|
}
|
||||||
else {
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
ResultSet goToDefinition(in dstring content, int index) {
|
||||||
|
ResultSet result;
|
||||||
|
|
||||||
|
char[][] arguments = ["-l".dup, "-c".dup];
|
||||||
|
arguments ~= [to!(char[])(index)];
|
||||||
|
|
||||||
|
bool success = false;
|
||||||
|
dstring[] output = invokeDcd(arguments, content, success);
|
||||||
|
|
||||||
|
if (success) {
|
||||||
|
result.result = DCDResult.SUCCESS;
|
||||||
|
} else {
|
||||||
result.result = DCDResult.FAIL;
|
result.result = DCDResult.FAIL;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
debug(DCD) Log.d("DCD output:\n", output);
|
||||||
|
|
||||||
if(output.length > 0) {
|
if(output.length > 0) {
|
||||||
if(output[0].indexOf("Not Found".dup) == 0) {
|
if(output[0].indexOf("Not Found".dup) == 0) {
|
||||||
result.result = DCDResult.NO_RESULT;
|
result.result = DCDResult.NO_RESULT;
|
||||||
|
@ -73,33 +90,24 @@ class DCDInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultSet getCompletions(in dstring content, int index) {
|
ResultSet getCompletions(in dstring content, int index) {
|
||||||
ExternalProcess dcdProcess = new ExternalProcess();
|
|
||||||
|
|
||||||
ResultSet result;
|
ResultSet result;
|
||||||
if(dcdProcess.state != ExternalProcessState.None) {
|
|
||||||
result.result = DCDResult.FAIL;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
char[][] arguments = ["-c".dup];
|
char[][] arguments = ["-c".dup];
|
||||||
arguments ~= [to!(char[])(index)];
|
arguments ~= [to!(char[])(index)];
|
||||||
ProtectedTextStorage stdoutTarget = new ProtectedTextStorage();
|
|
||||||
|
|
||||||
dcdProcess.run("dcd-client".dup, arguments, "/usr/bin".dup, stdoutTarget);
|
bool success = false;
|
||||||
dcdProcess.write(content);
|
dstring[] output = invokeDcd(arguments, content, success);
|
||||||
dcdProcess.wait();
|
|
||||||
|
|
||||||
dstring[] output = stdoutTarget.readText.splitLines();
|
if (success) {
|
||||||
|
|
||||||
if(dcdProcess.poll() == ExternalProcessState.Stopped) {
|
|
||||||
result.result = DCDResult.SUCCESS;
|
result.result = DCDResult.SUCCESS;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
result.result = DCDResult.FAIL;
|
result.result = DCDResult.FAIL;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
debug(DCD) Log.d("DCD output:\n", output);
|
||||||
|
|
||||||
if(output.length == 0) {
|
if (output.length == 0) {
|
||||||
result.result = DCDResult.NO_RESULT;
|
result.result = DCDResult.NO_RESULT;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,7 +93,9 @@ const Action ACTION_EDIT_TOGGLE_BLOCK_COMMENT = (new Action(EditorActions.Toggle
|
||||||
const Action ACTION_EDIT_PREFERENCES = (new Action(IDEActions.EditPreferences, "MENU_EDIT_PREFERENCES"c, null)).disableByDefault();
|
const Action ACTION_EDIT_PREFERENCES = (new Action(IDEActions.EditPreferences, "MENU_EDIT_PREFERENCES"c, null)).disableByDefault();
|
||||||
const Action ACTION_HELP_ABOUT = new Action(IDEActions.HelpAbout, "MENU_HELP_ABOUT"c);
|
const Action ACTION_HELP_ABOUT = new Action(IDEActions.HelpAbout, "MENU_HELP_ABOUT"c);
|
||||||
const Action ACTION_WINDOW_CLOSE_ALL_DOCUMENTS = new Action(IDEActions.WindowCloseAllDocuments, "MENU_WINDOW_CLOSE_ALL_DOCUMENTS"c);
|
const Action ACTION_WINDOW_CLOSE_ALL_DOCUMENTS = new Action(IDEActions.WindowCloseAllDocuments, "MENU_WINDOW_CLOSE_ALL_DOCUMENTS"c);
|
||||||
|
|
||||||
const Action ACTION_CREATE_NEW_WORKSPACE = new Action(IDEActions.CreateNewWorkspace, "Create new workspace"d);
|
const Action ACTION_CREATE_NEW_WORKSPACE = new Action(IDEActions.CreateNewWorkspace, "Create new workspace"d);
|
||||||
const Action ACTION_ADD_TO_CURRENT_WORKSPACE = new Action(IDEActions.AddToCurrentWorkspace, "Add to current workspace"d);
|
const Action ACTION_ADD_TO_CURRENT_WORKSPACE = new Action(IDEActions.AddToCurrentWorkspace, "Add to current workspace"d);
|
||||||
|
|
||||||
const Action ACTION_GO_TO_DEFINITION = new Action(IDEActions.GoToDefinition, "GO_TO_DEFINITION"c, ""c, KeyCode.KEY_G, KeyFlag.Control);
|
const Action ACTION_GO_TO_DEFINITION = new Action(IDEActions.GoToDefinition, "GO_TO_DEFINITION"c, ""c, KeyCode.KEY_G, KeyFlag.Control);
|
||||||
const Action ACTION_GET_COMPLETIONS = new Action(IDEActions.GetCompletionSuggestions, "SHOW_COMPLETIONS"c, ""c, KeyCode.KEY_G, KeyFlag.Control|KeyFlag.Shift);
|
const Action ACTION_GET_COMPLETIONS = new Action(IDEActions.GetCompletionSuggestions, "SHOW_COMPLETIONS"c, ""c, KeyCode.KEY_G, KeyFlag.Control|KeyFlag.Shift);
|
Loading…
Reference in New Issue