diff --git a/dlangide.visualdproj b/dlangide.visualdproj index 5fe24e1..4a0d3e7 100644 --- a/dlangide.visualdproj +++ b/dlangide.visualdproj @@ -64,7 +64,7 @@ 1 $(IntDir)\$(TargetName).json 0 - DebugInfo + DebugInfo DCD 0 Unicode USE_FREETYPE 0 diff --git a/src/dlangide/tools/d/dcdinterface.d b/src/dlangide/tools/d/dcdinterface.d index f11b7d0..8f3aa4c 100644 --- a/src/dlangide/tools/d/dcdinterface.d +++ b/src/dlangide/tools/d/dcdinterface.d @@ -1,6 +1,7 @@ module dlangide.tools.d.dcdinterface; import dlangui.core.logger; +import dlangui.core.files; import dlangide.builders.extprocess; @@ -26,33 +27,49 @@ class DCDInterface { 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(); - 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(); - 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.wait(); dstring[] output = stdoutTarget.readText.splitLines(); 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; return result; } + debug(DCD) Log.d("DCD output:\n", output); + if(output.length > 0) { if(output[0].indexOf("Not Found".dup) == 0) { result.result = DCDResult.NO_RESULT; @@ -73,33 +90,24 @@ class DCDInterface { } ResultSet getCompletions(in dstring content, int index) { - ExternalProcess dcdProcess = new ExternalProcess(); ResultSet result; - if(dcdProcess.state != ExternalProcessState.None) { - result.result = DCDResult.FAIL; - return result; - } char[][] arguments = ["-c".dup]; arguments ~= [to!(char[])(index)]; - ProtectedTextStorage stdoutTarget = new ProtectedTextStorage(); - dcdProcess.run("dcd-client".dup, arguments, "/usr/bin".dup, stdoutTarget); - dcdProcess.write(content); - dcdProcess.wait(); + bool success = false; + dstring[] output = invokeDcd(arguments, content, success); - dstring[] output = stdoutTarget.readText.splitLines(); - - if(dcdProcess.poll() == ExternalProcessState.Stopped) { + if (success) { result.result = DCDResult.SUCCESS; - } - else { + } else { result.result = DCDResult.FAIL; return result; } + debug(DCD) Log.d("DCD output:\n", output); - if(output.length == 0) { + if (output.length == 0) { result.result = DCDResult.NO_RESULT; return result; } diff --git a/src/dlangide/ui/commands.d b/src/dlangide/ui/commands.d index b0b855f..b6d88c9 100644 --- a/src/dlangide/ui/commands.d +++ b/src/dlangide/ui/commands.d @@ -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_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_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_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); \ No newline at end of file +const Action ACTION_GET_COMPLETIONS = new Action(IDEActions.GetCompletionSuggestions, "SHOW_COMPLETIONS"c, ""c, KeyCode.KEY_G, KeyFlag.Control|KeyFlag.Shift);