Fixed issue #12. Fixed support for autocompleting version and scope statements
This commit is contained in:
parent
35f68506ea
commit
b07e9f94ef
28
README.md
28
README.md
|
@ -15,9 +15,13 @@ position is the character position in the **file**, not the line.
|
|||
resulting HTML will be written to standard output.
|
||||
* **-I** _includePath_ - Include _includePath_ in the list of paths used to search
|
||||
for imports. By default dscanner will search in the current working directory as
|
||||
well as any paths specified in /etc/dmd.conf.
|
||||
well as any paths specified in /etc/dmd.conf. This is only used for the
|
||||
--parenComplete and --dotComplete options
|
||||
* **--ctags** _sourceFile_ - Generates ctags information from the given source
|
||||
code file.
|
||||
* **--recursive** **-R** **-r** _directory_ - When used with --ctags, dscanner
|
||||
will produce ctags output for all .d and .di files contained within _directory_
|
||||
and its sub-directories.
|
||||
|
||||
# Dot Completion
|
||||
This is currently under development.
|
||||
|
@ -48,7 +52,27 @@ present.
|
|||
|
||||
|
||||
# Paren Completion
|
||||
This is currently under development.
|
||||
Provides either a call tip for a function call or a list of pre-defined version
|
||||
identifiers for a version() statement, or a list of scope identifiers for a
|
||||
scope() statement. Anyone integrating dscanner into a text editor needs to look
|
||||
at the first line of the output to determine whether to display an autocomplete
|
||||
list or a call tip. (In the case of Scintilla, these are different)
|
||||
### Call tips
|
||||
Outputs the word "calltips" followed by a newline, followed by the call tips for
|
||||
the function before the cursor. One overload of the function is printed per
|
||||
line. The call tip may have newlines and tabs escaped in the common "\n" and
|
||||
"\t" format. These should be un-escaped for display.
|
||||
##### Example output
|
||||
calltips
|
||||
Token[] tokenize(S inputString,\n\tIterationStyle iterationStyle)
|
||||
### Completions
|
||||
Outputs the word "completions" followed by a newline, followed by a completion
|
||||
list. See the documentation on the --dotComplete option for details
|
||||
##### Example output
|
||||
completions
|
||||
exit k
|
||||
failure k
|
||||
success k
|
||||
|
||||
# JSON output
|
||||
Generates a JSON summary of the input file.
|
||||
|
|
|
@ -95,6 +95,7 @@ body
|
|||
case TokenType.Return:
|
||||
case TokenType.New:
|
||||
case TokenType.Case:
|
||||
case TokenType.Assign:
|
||||
case TokenType.Delete:
|
||||
case TokenType.LBrace:
|
||||
case TokenType.LParen:
|
||||
|
@ -272,9 +273,9 @@ struct AutoComplete
|
|||
switch (tokens[index].type)
|
||||
{
|
||||
case TokenType.Version:
|
||||
return to!string(join(map!`a ~ " k"`(versions), "\n").array());
|
||||
return "completions\n" ~ to!string(join(map!`a ~ " k"`(versions), "\n").array());
|
||||
case TokenType.Scope:
|
||||
return to!string(join(map!`a ~ " k"`(scopes), "\n").array());
|
||||
return "completions\n" ~ to!string(join(map!`a ~ " k"`(scopes), "\n").array());
|
||||
case TokenType.If:
|
||||
case TokenType.Cast:
|
||||
case TokenType.While:
|
||||
|
@ -287,7 +288,7 @@ struct AutoComplete
|
|||
auto callChain = splitCallChain(tokens[startIndex .. index + 1]);
|
||||
auto expressionType = getTypeOfExpression(
|
||||
callChain[0 .. $ - 1], tokens, cursor);
|
||||
return to!string(context.getCallTipsFor(expressionType,
|
||||
return "calltips\n" ~ to!string(context.getCallTipsFor(expressionType,
|
||||
callChain[$ - 1].value, cursor).join("\n").array());
|
||||
}
|
||||
}
|
||||
|
|
39
main.d
39
main.d
|
@ -137,9 +137,10 @@ void main(string[] args)
|
|||
bool parenComplete;
|
||||
bool highlight;
|
||||
bool ctags;
|
||||
bool recursiveCtags;
|
||||
getopt(args, "I", &importDirs, "dotComplete", &dotComplete, "sloc", &sloc,
|
||||
"json", &json, "parenComplete", &parenComplete, "highlight", &highlight,
|
||||
"ctags", &ctags);
|
||||
"ctags", &ctags, "recursive|r|R", &recursiveCtags);
|
||||
|
||||
importDirs ~= loadConfig();
|
||||
|
||||
|
@ -183,12 +184,42 @@ void main(string[] args)
|
|||
|
||||
if (json || ctags)
|
||||
{
|
||||
auto tokens = tokenize(readText(args[1]));
|
||||
auto mod = parseModule(tokens);
|
||||
|
||||
if (json)
|
||||
{
|
||||
auto tokens = tokenize(readText(args[1]));
|
||||
auto mod = parseModule(tokens);
|
||||
mod.writeJSONTo(stdout);
|
||||
}
|
||||
else
|
||||
mod.writeCtagsTo(stdout, args[1]);
|
||||
{
|
||||
if (!recursiveCtags)
|
||||
{
|
||||
auto tokens = tokenize(readText(args[1]));
|
||||
auto mod = parseModule(tokens);
|
||||
mod.writeCtagsTo(stdout, args[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Module m;
|
||||
foreach (dirEntry; dirEntries(args[1], SpanMode.breadth))
|
||||
{
|
||||
if (!dirEntry.name.endsWith(".d", ".di"))
|
||||
continue;
|
||||
stderr.writeln("Generating tags for ", dirEntry.name);
|
||||
auto tokens = tokenize(readText(dirEntry.name));
|
||||
if (m is null)
|
||||
m = parseModule(tokens);
|
||||
else
|
||||
{
|
||||
auto mod = parseModule(tokens);
|
||||
m.merge(mod);
|
||||
}
|
||||
}
|
||||
m.writeCtagsTo(stdout, "");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue