More work on the dscanner / dcd split
This commit is contained in:
parent
c83bb59a75
commit
6e5742167a
|
@ -1,3 +0,0 @@
|
||||||
[submodule "msgpack-d"]
|
|
||||||
path = msgpack-d
|
|
||||||
url = https://github.com/msgpack/msgpack-d.git
|
|
|
@ -317,7 +317,8 @@ local keywords = {
|
||||||
|
|
||||||
-- For this module to work the dscanner program must be installed. Configure the
|
-- For this module to work the dscanner program must be installed. Configure the
|
||||||
-- path to the executable here
|
-- path to the executable here
|
||||||
M.PATH_TO_DSCANNER = "/home/alaran/src/dscanner/dscanner"
|
M.PATH_TO_DSCANNER = "/home/brian/src/dscanner/dscanner"
|
||||||
|
M.PATH_TO_DCD_CLIENT = "/home/brian/src/dcd/dcd-client"
|
||||||
|
|
||||||
_M.textadept.editing.comment_string.dmd = '//'
|
_M.textadept.editing.comment_string.dmd = '//'
|
||||||
_M.textadept.run.compile_command.dmd = 'dmd -c -o- %(filename)'
|
_M.textadept.run.compile_command.dmd = 'dmd -c -o- %(filename)'
|
||||||
|
@ -341,7 +342,7 @@ local function showCompletionList(r)
|
||||||
buffer.auto_c_choose_single = false;
|
buffer.auto_c_choose_single = false;
|
||||||
buffer.auto_c_max_width = 0
|
buffer.auto_c_max_width = 0
|
||||||
local completions = {}
|
local completions = {}
|
||||||
for symbol, kind in r:gmatch("([@%w_]+) (%a)\n") do
|
for symbol, kind in r:gmatch("([@%w_]+)\t(%a)\n") do
|
||||||
completion = symbol
|
completion = symbol
|
||||||
if kind == "k" then
|
if kind == "k" then
|
||||||
completion = completion .. "?5"
|
completion = completion .. "?5"
|
||||||
|
@ -368,34 +369,25 @@ local function showCompletionList(r)
|
||||||
buffer.auto_c_choose_single = setting
|
buffer.auto_c_choose_single = setting
|
||||||
end
|
end
|
||||||
|
|
||||||
--events.connect(events.CHAR_ADDED, function(ch)
|
events.connect(events.CHAR_ADDED, function(ch)
|
||||||
-- if buffer:get_lexer() ~= "dmd" then return end
|
if buffer:get_lexer() ~= "dmd" then return end
|
||||||
-- if ch > 255 then return end
|
if ch > 255 then return end
|
||||||
-- local character = string.char(ch)
|
local character = string.char(ch)
|
||||||
-- if character == "." or character == "(" then
|
if character == "." or character == "(" then
|
||||||
-- 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_DSCANNER
|
local command = M.PATH_TO_DCD_CLIENT .. " -c" .. buffer.current_pos
|
||||||
-- .. (character == "." and " --dotComplete " or " --parenComplete ")
|
.. " " .. fileName
|
||||||
-- .. fileName .. " " .. buffer.current_pos .. " -I" .. buffer.filename:match(".+[\\/]")
|
print(command)
|
||||||
-- local p = io.popen(command)
|
local p = io.popen(command)
|
||||||
-- local r = p:read("*a")
|
local r = p:read("*a")
|
||||||
-- if r ~= "\n" then
|
if r ~= "\n" then
|
||||||
-- if character == "." then
|
showCompletionList(r)
|
||||||
-- showCompletionList(r)
|
end
|
||||||
-- elseif character == "(" then
|
os.remove(fileName)
|
||||||
-- if r:find("^completions\n") then
|
end
|
||||||
-- showCompletionList(r)
|
end)
|
||||||
-- elseif r:find("^calltips\n.*") then
|
|
||||||
-- r = r:gsub("^calltips\n", "")
|
|
||||||
-- buffer:call_tip_show(buffer.current_pos, r:gsub("\\n", "\n"):gsub("\\t", "\t"):match("(.*)%s+$"))
|
|
||||||
-- end
|
|
||||||
-- end
|
|
||||||
-- end
|
|
||||||
-- os.remove(fileName)
|
|
||||||
-- end
|
|
||||||
--end)
|
|
||||||
|
|
||||||
events.connect(events.FILE_AFTER_SAVE, function()
|
events.connect(events.FILE_AFTER_SAVE, function()
|
||||||
if buffer:get_lexer() ~= "dmd" then return end
|
if buffer:get_lexer() ~= "dmd" then return end
|
||||||
|
@ -406,18 +398,20 @@ events.connect(events.FILE_AFTER_SAVE, function()
|
||||||
for line in p:lines() do
|
for line in p:lines() do
|
||||||
lineNumber, column, level, message = string.match(line, "^.-%((%d+):(%d+)%)%[(%w+)%]: (.+)$")
|
lineNumber, column, level, message = string.match(line, "^.-%((%d+):(%d+)%)%[(%w+)%]: (.+)$")
|
||||||
local l = tonumber(lineNumber) - 1
|
local l = tonumber(lineNumber) - 1
|
||||||
local c = tonumber(column)
|
if l >= 0 then
|
||||||
if level == "error" then
|
local c = tonumber(column)
|
||||||
buffer.annotation_style[l] = 8
|
if level == "error" then
|
||||||
else
|
buffer.annotation_style[l] = 8
|
||||||
buffer.annotation_style[l] = 2
|
else
|
||||||
end
|
buffer.annotation_style[l] = 2
|
||||||
local t = buffer.annotation_text[l]
|
end
|
||||||
if #t > 0 then
|
local t = buffer.annotation_text[l]
|
||||||
buffer.annotation_text[l] = buffer.annotation_text[l] .. "\n" .. message
|
if #t > 0 then
|
||||||
else
|
buffer.annotation_text[l] = buffer.annotation_text[l] .. "\n" .. message
|
||||||
buffer.annotation_text[l] = message
|
else
|
||||||
end
|
buffer.annotation_text[l] = message
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
50
main.d
50
main.d
|
@ -40,40 +40,40 @@ int main(string[] args)
|
||||||
getopt(args, "I", &importDirs, "sloc|l", &sloc,
|
getopt(args, "I", &importDirs, "sloc|l", &sloc,
|
||||||
"json|j", &json, "highlight", &highlight,
|
"json|j", &json, "highlight", &highlight,
|
||||||
"ctags|c", &ctags, "recursive|r|R", &recursive, "help|h", &help,
|
"ctags|c", &ctags, "recursive|r|R", &recursive, "help|h", &help,
|
||||||
"tokenCount", &tokenCount, "syntaxCheck", &syntaxCheck);
|
"tokenCount", &tokenCount, "syntaxCheck|s", &syntaxCheck);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
stderr.writeln(e.msg);
|
stderr.writeln(e.msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (help)
|
if (help)
|
||||||
{
|
{
|
||||||
printHelp(args[0]);
|
printHelp(args[0]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto optionCount = count!"a"([sloc, highlight, ctags, json, tokenCount,
|
auto optionCount = count!"a"([sloc, highlight, ctags, json, tokenCount,
|
||||||
syntaxCheck]);
|
syntaxCheck]);
|
||||||
if (optionCount > 1)
|
if (optionCount > 1)
|
||||||
{
|
{
|
||||||
stderr.writeln("Too many options specified");
|
stderr.writeln("Too many options specified");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else if (optionCount < 1)
|
else if (optionCount < 1)
|
||||||
{
|
{
|
||||||
printHelp(args[0]);
|
printHelp(args[0]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (highlight)
|
if (highlight)
|
||||||
{
|
{
|
||||||
LexerConfig config;
|
LexerConfig config;
|
||||||
config.iterStyle = IterationStyle.everything;
|
config.iterStyle = IterationStyle.everything;
|
||||||
config.tokenStyle = TokenStyle.source;
|
config.tokenStyle = TokenStyle.source;
|
||||||
File f = args.length == 1 ? stdin : File(args[1]);
|
File f = args.length == 1 ? stdin : File(args[1]);
|
||||||
ubyte[] buffer = uninitializedArray!(ubyte[])(f.size);
|
ubyte[] buffer = uninitializedArray!(ubyte[])(f.size);
|
||||||
highlighter.highlight(byToken(f.rawRead(buffer), config),
|
highlighter.highlight(byToken(f.rawRead(buffer), config),
|
||||||
args.length == 1 ? "stdin" : args[1]);
|
args.length == 1 ? "stdin" : args[1]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,6 @@ int main(string[] args)
|
||||||
config.fileName = usingStdin ? "stdin" : args[1];
|
config.fileName = usingStdin ? "stdin" : args[1];
|
||||||
File f = usingStdin ? stdin : File(args[1]);
|
File f = usingStdin ? stdin : File(args[1]);
|
||||||
auto bytes = usingStdin ? cast(ubyte[]) [] : uninitializedArray!(ubyte[])(f.size);
|
auto bytes = usingStdin ? cast(ubyte[]) [] : uninitializedArray!(ubyte[])(f.size);
|
||||||
auto byteCount = f.size;
|
|
||||||
f.rawRead(bytes);
|
f.rawRead(bytes);
|
||||||
|
|
||||||
auto tokens = byToken(bytes, config);
|
auto tokens = byToken(bytes, config);
|
||||||
|
@ -140,6 +139,10 @@ options:
|
||||||
well as any paths specified in /etc/dmd.conf. This is only used for the
|
well as any paths specified in /etc/dmd.conf. This is only used for the
|
||||||
--parenComplete and --dotComplete options.
|
--parenComplete and --dotComplete options.
|
||||||
|
|
||||||
|
--syntaxCheck | -s [sourceFile]
|
||||||
|
Lexes and parses sourceFile, printing the line and column number of any
|
||||||
|
syntax errors to stdout. One error or warning is printed per line.
|
||||||
|
|
||||||
--ctags | -c sourceFile
|
--ctags | -c sourceFile
|
||||||
Generates ctags information from the given source code file. Note that
|
Generates ctags information from the given source code file. Note that
|
||||||
ctags information requires a filename, so stdin cannot be used in place
|
ctags information requires a filename, so stdin cannot be used in place
|
||||||
|
@ -147,6 +150,7 @@ options:
|
||||||
|
|
||||||
--recursive | -R | -r directory
|
--recursive | -R | -r directory
|
||||||
When used with --ctags, dscanner will produce ctags output for all .d
|
When used with --ctags, dscanner will produce ctags output for all .d
|
||||||
and .di files contained within directory and its sub-directories.`,
|
and .di files contained within the given directory and its
|
||||||
|
sub-directories.`,
|
||||||
programName);
|
programName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -190,6 +190,13 @@ struct Token
|
||||||
if (startIndex > other.startIndex) return 1;
|
if (startIndex > other.startIndex) return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int opCmp(size_t index) const nothrow pure
|
||||||
|
{
|
||||||
|
if (startIndex < index) return -1;
|
||||||
|
if (startIndex > index) return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -82,6 +82,9 @@ import std.string : format;
|
||||||
/**
|
/**
|
||||||
* Params:
|
* Params:
|
||||||
* tokens = the tokens parsed by std.d.lexer
|
* tokens = the tokens parsed by std.d.lexer
|
||||||
|
* messageFunction = a function to call on error or warning messages.
|
||||||
|
* The parameters are the file name, line number, column number,
|
||||||
|
* and the error or warning message.
|
||||||
* Returns: the parsed module
|
* Returns: the parsed module
|
||||||
*/
|
*/
|
||||||
Module parseModule(const(Token)[] tokens, string fileName,
|
Module parseModule(const(Token)[] tokens, string fileName,
|
||||||
|
@ -4117,9 +4120,15 @@ q{(int a, ...)
|
||||||
if (currentIsOneOf(stringLiteral, wstringLiteral, dstringLiteral))
|
if (currentIsOneOf(stringLiteral, wstringLiteral, dstringLiteral))
|
||||||
{
|
{
|
||||||
node.primary = advance();
|
node.primary = advance();
|
||||||
|
bool alreadyWarned = false;
|
||||||
while (currentIsOneOf(stringLiteral, wstringLiteral,
|
while (currentIsOneOf(stringLiteral, wstringLiteral,
|
||||||
dstringLiteral))
|
dstringLiteral))
|
||||||
{
|
{
|
||||||
|
if (!alreadyWarned)
|
||||||
|
{
|
||||||
|
warn("Implicit concatenation of string literals");
|
||||||
|
alreadyWarned = true;
|
||||||
|
}
|
||||||
node.primary.value ~= advance().value;
|
node.primary.value ~= advance().value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5913,7 +5922,9 @@ q{doStuff(5)}c;
|
||||||
string fileName;
|
string fileName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function that is called when a warning or error is encountered
|
* Function that is called when a warning or error is encountered.
|
||||||
|
* The parameters are the file name, line number, column number,
|
||||||
|
* and the error or warning message.
|
||||||
*/
|
*/
|
||||||
void function(string, int, int, string) messageFunction;
|
void function(string, int, int, string) messageFunction;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue