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