Fixed indentation
This commit is contained in:
parent
c0994dc792
commit
757c4dbb2d
94
ctags.d
94
ctags.d
|
@ -17,25 +17,25 @@ void doNothing(string, int, int, string) {}
|
|||
|
||||
void printCtags(File output, string[] fileNames)
|
||||
{
|
||||
string[] tags;
|
||||
foreach (fileName; fileNames)
|
||||
{
|
||||
File f = File(fileName);
|
||||
string[] tags;
|
||||
foreach (fileName; fileNames)
|
||||
{
|
||||
File f = File(fileName);
|
||||
auto bytes = uninitializedArray!(ubyte[])(f.size);
|
||||
f.rawRead(bytes);
|
||||
LexerConfig config;
|
||||
auto tokens = byToken(bytes, config);
|
||||
Module m = parseModule(tokens.array(), fileName, &doNothing);
|
||||
auto printer = new CTagsPrinter;
|
||||
printer.fileName = fileName;
|
||||
printer.visit(m);
|
||||
tags ~= printer.tagLines;
|
||||
}
|
||||
output.write("!_TAG_FILE_FORMAT\t2\n"
|
||||
LexerConfig config;
|
||||
auto tokens = byToken(bytes, config);
|
||||
Module m = parseModule(tokens.array(), fileName, &doNothing);
|
||||
auto printer = new CTagsPrinter;
|
||||
printer.fileName = fileName;
|
||||
printer.visit(m);
|
||||
tags ~= printer.tagLines;
|
||||
}
|
||||
output.write("!_TAG_FILE_FORMAT\t2\n"
|
||||
~ "!_TAG_FILE_SORTED\t1\n"
|
||||
~ "!_TAG_FILE_AUTHOR\tBrian Schott\n"
|
||||
~ "!_TAG_PROGRAM_URL\thttps://github.com/Hackerpilot/Dscanner/\n");
|
||||
tags.sort().copy(output.lockingTextWriter);
|
||||
tags.sort().copy(output.lockingTextWriter);
|
||||
}
|
||||
|
||||
class CTagsPrinter : ASTVisitor
|
||||
|
@ -46,47 +46,47 @@ class CTagsPrinter : ASTVisitor
|
|||
override void visit(ClassDeclaration dec)
|
||||
{
|
||||
tagLines ~= "%s\t%s\t%d;\"\tc%s\n".format(dec.name.value, fileName, dec.name.line, context);
|
||||
auto c = context;
|
||||
context = "\tclass:" ~ dec.name.value;
|
||||
auto c = context;
|
||||
context = "\tclass:" ~ dec.name.value;
|
||||
dec.accept(this);
|
||||
context = c;
|
||||
context = c;
|
||||
}
|
||||
|
||||
override void visit(StructDeclaration dec)
|
||||
{
|
||||
tagLines ~= "%s\t%s\t%d;\"\ts%s\n".format(dec.name.value, fileName, dec.name.line, context);
|
||||
auto c = context;
|
||||
context = "\tstruct:" ~ dec.name.value;
|
||||
auto c = context;
|
||||
context = "\tstruct:" ~ dec.name.value;
|
||||
dec.accept(this);
|
||||
context = c;
|
||||
context = c;
|
||||
}
|
||||
|
||||
override void visit(InterfaceDeclaration dec)
|
||||
{
|
||||
tagLines ~= "%s\t%s\t%d;\"\ti%s\n".format(dec.name.value, fileName, dec.name.line, context);
|
||||
auto c = context;
|
||||
context = "\tclass:" ~ dec.name.value;
|
||||
auto c = context;
|
||||
context = "\tclass:" ~ dec.name.value;
|
||||
dec.accept(this);
|
||||
context = c;
|
||||
context = c;
|
||||
}
|
||||
|
||||
override void visit(TemplateDeclaration dec)
|
||||
{
|
||||
tagLines ~= "%s\t%s\t%d;\"\tT%s\n".format(dec.name.value, fileName, dec.name.line, context);
|
||||
auto c = context;
|
||||
context = "\ttemplate:" ~ dec.name.value;
|
||||
auto c = context;
|
||||
context = "\ttemplate:" ~ dec.name.value;
|
||||
dec.accept(this);
|
||||
context = c;
|
||||
context = c;
|
||||
}
|
||||
|
||||
override void visit(FunctionDeclaration dec)
|
||||
{
|
||||
tagLines ~= "%s\t%s\t%d;\"\tf\tarity:%d%s\n".format(dec.name.value, fileName,
|
||||
dec.name.line, dec.parameters.parameters.length, context);
|
||||
auto c = context;
|
||||
context = "\tfunction:" ~ dec.name.value;
|
||||
auto c = context;
|
||||
context = "\tfunction:" ~ dec.name.value;
|
||||
dec.accept(this);
|
||||
context = c;
|
||||
context = c;
|
||||
}
|
||||
|
||||
override void visit(EnumDeclaration dec)
|
||||
|
@ -97,11 +97,11 @@ class CTagsPrinter : ASTVisitor
|
|||
return;
|
||||
}
|
||||
tagLines ~= "%s\t%s\t%d;\"\tg%s\n".format(dec.name.value, fileName,
|
||||
dec.name.line, context);
|
||||
auto c = context;
|
||||
context = "\tenum:" ~ dec.name.value;
|
||||
dec.name.line, context);
|
||||
auto c = context;
|
||||
context = "\tenum:" ~ dec.name.value;
|
||||
dec.accept(this);
|
||||
context = c;
|
||||
context = c;
|
||||
}
|
||||
|
||||
override void visit(UnionDeclaration dec)
|
||||
|
@ -112,31 +112,31 @@ class CTagsPrinter : ASTVisitor
|
|||
return;
|
||||
}
|
||||
tagLines ~= "%s\t%s\t%d;\"\tu%s\n".format(dec.name.value, fileName,
|
||||
dec.name.line, context);
|
||||
auto c = context;
|
||||
context = "\tunion:" ~ dec.name.value;
|
||||
dec.name.line, context);
|
||||
auto c = context;
|
||||
context = "\tunion:" ~ dec.name.value;
|
||||
dec.accept(this);
|
||||
context = c;
|
||||
context = c;
|
||||
}
|
||||
|
||||
override void visit(EnumMember mem)
|
||||
{
|
||||
tagLines ~= "%s\t%s\t%d;\"\te%s\n".format(mem.name.value, fileName,
|
||||
mem.name.line, context);
|
||||
}
|
||||
override void visit(EnumMember mem)
|
||||
{
|
||||
tagLines ~= "%s\t%s\t%d;\"\te%s\n".format(mem.name.value, fileName,
|
||||
mem.name.line, context);
|
||||
}
|
||||
|
||||
override void visit(VariableDeclaration dec)
|
||||
{
|
||||
foreach (d; dec.declarators)
|
||||
{
|
||||
{
|
||||
tagLines ~= "%s\t%s\t%d;\"\tv%s\n".format(d.name.value, fileName,
|
||||
d.name.line, context);
|
||||
}
|
||||
d.name.line, context);
|
||||
}
|
||||
dec.accept(this);
|
||||
}
|
||||
|
||||
string fileName;
|
||||
string[] tagLines;
|
||||
int suppressDepth;
|
||||
string context;
|
||||
int suppressDepth;
|
||||
string context;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue