Implemented stdin feature
This commit is contained in:
parent
e3fba24b7d
commit
b4b47eacfd
|
@ -47,7 +47,8 @@ AutocompleteResponse complete(AutocompleteRequest request, string[] importPaths)
|
|||
auto sortedTokens = assumeSorted(tokenArray);
|
||||
|
||||
auto beforeTokens = sortedTokens.lowerBound(cast(size_t) request.cursorPosition);
|
||||
if (beforeTokens[$ - 1] == TokenType.lParen && beforeTokens.length >= 2)
|
||||
|
||||
if (beforeTokens.length >= 2 && beforeTokens[$ - 1] == TokenType.lParen)
|
||||
{
|
||||
immutable(string)[] completions;
|
||||
switch (beforeTokens[$ - 2].type)
|
||||
|
@ -87,7 +88,7 @@ AutocompleteResponse complete(AutocompleteRequest request, string[] importPaths)
|
|||
break;
|
||||
}
|
||||
}
|
||||
else if (beforeTokens[$ - 1] == TokenType.dot && beforeTokens.length >= 2)
|
||||
else if (beforeTokens.length >= 2 && beforeTokens[$ - 1] == TokenType.dot)
|
||||
{
|
||||
switch (beforeTokens[$ - 2].type)
|
||||
{
|
||||
|
|
19
client.d
19
client.d
|
@ -83,8 +83,23 @@ int main(string[] args)
|
|||
bool usingStdin = args.length <= 1;
|
||||
string fileName = usingStdin ? "stdin" : args[1];
|
||||
File f = usingStdin ? stdin : File(args[1]);
|
||||
ubyte[] sourceCode = usingStdin ? cast(ubyte[]) [] : uninitializedArray!(ubyte[])(f.size);
|
||||
f.rawRead(sourceCode);
|
||||
ubyte[] sourceCode;
|
||||
if (usingStdin)
|
||||
{
|
||||
ubyte[4096] buf;
|
||||
while (true)
|
||||
{
|
||||
auto b = f.rawRead(buf);
|
||||
if (b.length == 0)
|
||||
break;
|
||||
sourceCode ~= b;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sourceCode = uninitializedArray!(ubyte[])(f.size);
|
||||
f.rawRead(sourceCode);
|
||||
}
|
||||
|
||||
// Create message
|
||||
AutocompleteRequest request;
|
||||
|
|
|
@ -72,10 +72,8 @@ function M.autocomplete(ch)
|
|||
local fileName = os.tmpname()
|
||||
local tmpFile = io.open(fileName, "w")
|
||||
tmpFile:write(buffer:get_text())
|
||||
local command = M.PATH_TO_DCD_CLIENT .. " -c" .. buffer.current_pos
|
||||
.. " " .. fileName
|
||||
print(command)
|
||||
local p = io.popen(command)
|
||||
local command = M.PATH_TO_DCD_CLIENT .. " -c" .. buffer.current_pos .. " " .. fileName
|
||||
local p = io.popen(command, "r")
|
||||
local r = p:read("*a")
|
||||
print(r)
|
||||
if r ~= "\n" then
|
||||
|
|
Loading…
Reference in New Issue