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