mirror of https://github.com/buggins/dlangide.git
parent
732044c229
commit
ce26caa73e
|
@ -35,9 +35,11 @@ struct CompletionSymbol {
|
||||||
char kind;
|
char kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
import dlangide.tools.editortool : CompletionTypes;
|
||||||
|
|
||||||
alias DocCommentsResultSet = Tuple!(DCDResult, "result", string[], "docComments");
|
alias DocCommentsResultSet = Tuple!(DCDResult, "result", string[], "docComments");
|
||||||
alias FindDeclarationResultSet = Tuple!(DCDResult, "result", string, "fileName", ulong, "offset");
|
alias FindDeclarationResultSet = Tuple!(DCDResult, "result", string, "fileName", ulong, "offset");
|
||||||
alias CompletionResultSet = Tuple!(DCDResult, "result", CompletionSymbol[], "output");
|
alias CompletionResultSet = Tuple!(DCDResult, "result", CompletionSymbol[], "output", CompletionTypes, "type");
|
||||||
|
|
||||||
|
|
||||||
class DCDTask {
|
class DCDTask {
|
||||||
|
@ -315,7 +317,12 @@ class DCDInterface : Thread {
|
||||||
result.output[i].name = to!dstring(s);
|
result.output[i].name = to!dstring(s);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
postProcessCompletions(result.output);
|
if (response.completionType == "calltips") {
|
||||||
|
result.type = CompletionTypes.CallTips;
|
||||||
|
} else {
|
||||||
|
result.type = CompletionTypes.IdentifierList;
|
||||||
|
postProcessCompletions(result.output);
|
||||||
|
}
|
||||||
debug(DCD) Log.d("DCD response:\n", response, "\nCompletion result:\n", result.output);
|
debug(DCD) Log.d("DCD response:\n", response, "\nCompletion result:\n", result.output);
|
||||||
}
|
}
|
||||||
override void postResults() {
|
override void postResults() {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
module dlangide.tools.d.deditorTool;
|
module dlangide.tools.d.deditortool;
|
||||||
|
|
||||||
import dlangide.tools.editorTool;
|
import dlangide.tools.editortool;
|
||||||
import dlangide.tools.d.dcdinterface;
|
import dlangide.tools.d.dcdinterface;
|
||||||
import dlangide.ui.dsourceedit;
|
import dlangide.ui.dsourceedit;
|
||||||
import dlangui.widgets.editors;
|
import dlangui.widgets.editors;
|
||||||
|
@ -127,7 +127,7 @@ class DEditorTool : EditorTool
|
||||||
}
|
}
|
||||||
|
|
||||||
DCDTask _getCompletionsTask;
|
DCDTask _getCompletionsTask;
|
||||||
override void getCompletions(DSourceEdit editor, TextPosition caretPosition, void delegate(dstring[] completions, string[] icons) callback) {
|
override void getCompletions(DSourceEdit editor, TextPosition caretPosition, void delegate(dstring[] completions, string[] icons, CompletionTypes type) callback) {
|
||||||
cancelGetCompletions();
|
cancelGetCompletions();
|
||||||
string[] importPaths = editor.importPaths();
|
string[] importPaths = editor.importPaths();
|
||||||
|
|
||||||
|
@ -198,7 +198,7 @@ class DEditorTool : EditorTool
|
||||||
icons ~= iconId;
|
icons ~= iconId;
|
||||||
labels ~= label.name;
|
labels ~= label.name;
|
||||||
}
|
}
|
||||||
callback(labels, icons);
|
callback(labels, icons, output.type);
|
||||||
_getCompletionsTask = null;
|
_getCompletionsTask = null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
module dlangide.tools.editorTool;
|
module dlangide.tools.editortool;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,7 +7,12 @@ import dlangui.core.types;
|
||||||
import dlangide.ui.frame;
|
import dlangide.ui.frame;
|
||||||
import dlangide.ui.dsourceedit;
|
import dlangide.ui.dsourceedit;
|
||||||
|
|
||||||
public import dlangide.tools.d.deditorTool;
|
public import dlangide.tools.d.deditortool;
|
||||||
|
|
||||||
|
enum CompletionTypes : int {
|
||||||
|
IdentifierList,
|
||||||
|
CallTips,
|
||||||
|
}
|
||||||
|
|
||||||
class EditorTool
|
class EditorTool
|
||||||
{
|
{
|
||||||
|
@ -17,7 +22,7 @@ class EditorTool
|
||||||
//Since files might be unsaved, we must send all the text content.
|
//Since files might be unsaved, we must send all the text content.
|
||||||
abstract void goToDefinition(DSourceEdit editor, TextPosition caretPosition);
|
abstract void goToDefinition(DSourceEdit editor, TextPosition caretPosition);
|
||||||
abstract void getDocComments(DSourceEdit editor, TextPosition caretPosition, void delegate(string[]) callback);
|
abstract void getDocComments(DSourceEdit editor, TextPosition caretPosition, void delegate(string[]) callback);
|
||||||
abstract void getCompletions(DSourceEdit editor, TextPosition caretPosition, void delegate(dstring[] labels, string[] icons) callback);
|
abstract void getCompletions(DSourceEdit editor, TextPosition caretPosition, void delegate(dstring[] labels, string[] icons, CompletionTypes type) callback);
|
||||||
|
|
||||||
void cancelGoToDefinition() {}
|
void cancelGoToDefinition() {}
|
||||||
void cancelGetDocComments() {}
|
void cancelGetDocComments() {}
|
||||||
|
@ -37,7 +42,7 @@ class DefaultEditorTool : EditorTool
|
||||||
//assert(0); //Go To Definition should not be called for normal files.
|
//assert(0); //Go To Definition should not be called for normal files.
|
||||||
}
|
}
|
||||||
|
|
||||||
override void getCompletions(DSourceEdit editor, TextPosition caretPosition, void delegate(dstring[] labels, string[] icons) callback) {
|
override void getCompletions(DSourceEdit editor, TextPosition caretPosition, void delegate(dstring[] labels, string[] icons, CompletionTypes type) callback) {
|
||||||
//assert(0);
|
//assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ import dlangide.workspace.project;
|
||||||
import dlangide.ui.commands;
|
import dlangide.ui.commands;
|
||||||
import dlangide.ui.settings;
|
import dlangide.ui.settings;
|
||||||
import dlangide.tools.d.dsyntax;
|
import dlangide.tools.d.dsyntax;
|
||||||
import dlangide.tools.editorTool;
|
import dlangide.tools.editortool;
|
||||||
import ddebug.common.debugger;
|
import ddebug.common.debugger;
|
||||||
|
|
||||||
import std.algorithm;
|
import std.algorithm;
|
||||||
|
@ -619,13 +619,27 @@ class DSourceEdit : SourceEdit, EditableContentMarksChangeListener {
|
||||||
_completionPopupMenu = null;
|
_completionPopupMenu = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
void showCompletionPopup(dstring[] suggestions, string[] icons) {
|
void showCallTipsPopup(dstring[] suggestions) {
|
||||||
|
// TODO: replace this temp solution
|
||||||
|
string[] list;
|
||||||
|
foreach(s; suggestions) {
|
||||||
|
list ~= s.toUTF8;
|
||||||
|
}
|
||||||
|
showDocCommentsPopup(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
void showCompletionPopup(dstring[] suggestions, string[] icons, CompletionTypes type) {
|
||||||
|
|
||||||
if(suggestions.length == 0) {
|
if(suggestions.length == 0) {
|
||||||
setFocus();
|
setFocus();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (type == CompletionTypes.CallTips) {
|
||||||
|
showCallTipsPopup(suggestions);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (suggestions.length == 1) {
|
if (suggestions.length == 1) {
|
||||||
insertCompletion(suggestions[0]);
|
insertCompletion(suggestions[0]);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -30,7 +30,7 @@ import dlangide.ui.debuggerui;
|
||||||
import dlangide.workspace.workspace;
|
import dlangide.workspace.workspace;
|
||||||
import dlangide.workspace.project;
|
import dlangide.workspace.project;
|
||||||
import dlangide.builders.builder;
|
import dlangide.builders.builder;
|
||||||
import dlangide.tools.editorTool;
|
import dlangide.tools.editortool;
|
||||||
|
|
||||||
import ddebug.common.execution;
|
import ddebug.common.execution;
|
||||||
import ddebug.common.nodebug;
|
import ddebug.common.nodebug;
|
||||||
|
@ -1176,9 +1176,9 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL
|
||||||
return true;
|
return true;
|
||||||
case IDEActions.GetCompletionSuggestions:
|
case IDEActions.GetCompletionSuggestions:
|
||||||
Log.d("Getting auto completion suggestions.");
|
Log.d("Getting auto completion suggestions.");
|
||||||
currentEditor.editorTool.getCompletions(currentEditor, currentEditor.caretPos, delegate(dstring[] results, string[] icons) {
|
currentEditor.editorTool.getCompletions(currentEditor, currentEditor.caretPos, delegate(dstring[] results, string[] icons, CompletionTypes type) {
|
||||||
if (currentEditor)
|
if (currentEditor)
|
||||||
currentEditor.showCompletionPopup(results, icons);
|
currentEditor.showCompletionPopup(results, icons, type);
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
case IDEActions.EditPreferences:
|
case IDEActions.EditPreferences:
|
||||||
|
|
Loading…
Reference in New Issue