diff --git a/main.d b/main.d index 65ad307..400d8fb 100644 --- a/main.d +++ b/main.d @@ -139,12 +139,13 @@ void main(string[] args) bool ctags; bool recursiveCtags; bool format; + bool extendedFunctionTypes; try { getopt(args, "I", &importDirs, "dotComplete", &dotComplete, "sloc", &sloc, "json", &json, "parenComplete", &parenComplete, "highlight", &highlight, - "ctags", &ctags, "recursive|r|R", &recursiveCtags); + "ctags", &ctags, "recursive|r|R", &recursiveCtags, "extended|e", &extendedFunctionTypes); } catch (Exception e) { @@ -174,7 +175,7 @@ void main(string[] args) importDirs ~= getcwd(); auto tokens = args[1].readText().tokenize(); auto mod = parseModule(tokens); - CompletionContext context = new CompletionContext(mod); + CompletionContext context = new CompletionContext(mod, extendedFunctionTypes); context.importDirectories = importDirs; foreach (im; parallel(mod.imports)) { diff --git a/types.d b/types.d index 3f7b5bf..c7f498f 100644 --- a/types.d +++ b/types.d @@ -618,9 +618,10 @@ class CompletionContext { public: - this(Module mod) + this(Module mod, bool extendedFunctionTypes = false) { this.currentModule = mod; + this.extendedFunctionTypes = extendedFunctionTypes; } Tuple!(string, string)[string] getMembersOfType(string name) @@ -635,7 +636,7 @@ public: foreach (var; inherits.variables) typeMap[var.name] = Tuple!(string, string)(var.type, "m"); foreach (fun; inherits.functions) - typeMap[fun.name] = Tuple!(string, string)(fun.returnType, "f"); + typeMap[fun.name] = Tuple!(string, string)(fun.returnType, getFunctionType(fun)); foreach (parent; inherits.baseClasses) { foreach (k, v; getMembersOfType(parent)) @@ -654,7 +655,7 @@ public: foreach (var; s.variables) typeMap[var.name] = Tuple!(string, string)(var.type, "m"); foreach (fun; s.functions) - typeMap[fun.name] = Tuple!(string, string)(fun.returnType, "f"); + typeMap[fun.name] = Tuple!(string, string)(fun.returnType, getFunctionType(fun)); return typeMap; } foreach (Enum e; m.enums) @@ -722,6 +723,7 @@ public: Module currentModule; Module[] modules; string[] importDirectories; + bool extendedFunctionTypes; private: @@ -739,4 +741,23 @@ private: } return app.data; } + + string getFunctionType(Function f) { + string result = "f"; + if (extendedFunctionTypes) { + result ~= "::"; + bool first = true; + foreach (param; f.parameters) { + if (first) { + first = false; + } + else { + result ~= "::"; + } + result ~= param.type ~ " " ~ param.name; + } + result ~= "::"; + } + return result; + } }