This commit is contained in:
parent
bb3b33b471
commit
1d807075fd
|
@ -42,6 +42,7 @@ import stupidlog;
|
|||
|
||||
AutocompleteResponse findDeclaration(const AutocompleteRequest request)
|
||||
{
|
||||
Log.info("Finding declaration");
|
||||
AutocompleteResponse response;
|
||||
LexerConfig config;
|
||||
config.fileName = "stdin";
|
||||
|
@ -63,8 +64,6 @@ AutocompleteResponse findDeclaration(const AutocompleteRequest request)
|
|||
const(Scope)* completionScope = generateAutocompleteTrees(tokenArray, "stdin");
|
||||
auto expression = getExpression(beforeTokens);
|
||||
|
||||
writeln(expression);
|
||||
|
||||
const(ACSymbol)*[] symbols = getSymbolsByTokenChain(completionScope, expression,
|
||||
request.cursorPosition, CompletionType.identifiers);
|
||||
|
||||
|
@ -75,6 +74,10 @@ AutocompleteResponse findDeclaration(const AutocompleteRequest request)
|
|||
Log.info(beforeTokens[$ - 1].value, " declared in ",
|
||||
response.symbolFilePath, " at ", response.symbolLocation);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.error("Could not find symbol");
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
@ -554,7 +557,7 @@ void setImportCompletions(T)(T tokens, ref AutocompleteResponse response)
|
|||
foreach (importDirectory; ModuleCache.getImportPaths())
|
||||
{
|
||||
string p = format("%s%s%s", importDirectory, dirSeparator, path);
|
||||
writeln("Checking for ", p);
|
||||
Log.trace("Checking for ", p);
|
||||
if (!exists(p))
|
||||
continue;
|
||||
foreach (string name; dirEntries(p, SpanMode.shallow))
|
||||
|
|
3
client.d
3
client.d
|
@ -214,6 +214,9 @@ AutocompleteResponse getResponse(TcpSocket socket)
|
|||
|
||||
void printLocationResponse(AutocompleteResponse response)
|
||||
{
|
||||
if (response.symbolFilePath is null)
|
||||
writeln("Not found");
|
||||
else
|
||||
writefln("%s\t%d", response.symbolFilePath, response.symbolLocation);
|
||||
}
|
||||
|
||||
|
|
|
@ -113,8 +113,15 @@ function M.gotoDeclaration()
|
|||
p:close()
|
||||
local tmpFile = io.open(fileName, "r")
|
||||
local r = tmpFile:read("*a")
|
||||
if r ~= "\n" then
|
||||
-- TODO: Go to declaration
|
||||
if r ~= "Not found\n" then
|
||||
path, position = r:match("^(.-)\t(%d+)")
|
||||
if (path ~= nil and position ~= nil) then
|
||||
if (path ~= "stdin") then
|
||||
io.open_file(path)
|
||||
end
|
||||
buffer:goto_pos(tonumber(position))
|
||||
buffer:word_right_end_extend()
|
||||
end
|
||||
end
|
||||
os.remove(fileName)
|
||||
end
|
||||
|
|
|
@ -31,6 +31,7 @@ keys.dmd = {
|
|||
(_USERHOME..'/modules/dmd/init.lua'):iconv('UTF-8', _CHARSET) },
|
||||
},
|
||||
['c\n'] = {autocomplete},
|
||||
['cG'] = {_M.dcd.gotoDeclaration},
|
||||
['down'] = {_M.dcd.cycleCalltips, 1},
|
||||
['up'] = {_M.dcd.cycleCalltips, -1},
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue