Merge pull request #40 from jwhear/master

Fix recursive Ctags
This commit is contained in:
Hackerpilot 2013-07-26 14:44:33 -07:00
commit 1dd2baf722
2 changed files with 13 additions and 20 deletions

21
main.d
View File

@ -258,30 +258,31 @@ int main(string[] args)
if (ctags)
{
stdout.writeln("!_TAG_FILE_FORMAT 2");
stdout.writeln("!_TAG_FILE_SORTED 1");
stdout.writeln("!_TAG_PROGRAM_URL https://github.com/Hackerpilot/Dscanner/");
if (!recursiveCtags)
{
auto tokens = tokenize(readText(args[1]));
auto mod = parseModule(tokens);
mod.writeCtagsTo(stdout, args[1]);
foreach (tag; mod.getCtags(args[1]))
stdout.writeln(tag);
}
else
{
Module m;
string[] allTags;
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);
}
auto mod = parseModule(tokens);
allTags ~= mod.getCtags(dirEntry.name);
}
m.writeCtagsTo(stdout, "");
allTags.sort();
foreach (tag; allTags)
stdout.writeln(tag);
}
}
return 0;

12
types.d
View File

@ -559,7 +559,7 @@ public:
/**
* Standards: http://ctags.sourceforge.net/FORMAT
*/
void writeCtagsTo(File file, string fileName)
string[] getCtags(string fileName)
{
string[] tags;
foreach (Enum e; enums)
@ -589,15 +589,7 @@ public:
{
tags ~= s.getCtags(fileName);
}
sort(tags);
file.writeln("!_TAG_FILE_FORMAT 2");
file.writeln("!_TAG_FILE_SORTED 1");
file.writeln("!_TAG_PROGRAM_URL https://github.com/Hackerpilot/Dscanner/");
foreach (tag; tags)
{
file.writeln(tag);
}
return tags;
}
}