Added destructors, constructors, and invariants to ctags output

This commit is contained in:
Hackerpilot 2014-05-01 15:22:13 -07:00
parent 9722183249
commit 3798387c19
3 changed files with 68 additions and 34 deletions

25
ctags.d
View File

@ -90,6 +90,26 @@ class CTagsPrinter : ASTVisitor
context = c;
}
override void visit(const Constructor dec)
{
tagLines ~= "this\t%s\t%d;\"\tf\tarity:%d%s\n".format(fileName,
dec.line, dec.parameters.parameters.length, context);
auto c = context;
context = "\tfunction: this";
dec.accept(this);
context = c;
}
override void visit(const Destructor dec)
{
tagLines ~= "~this\t%s\t%d;\"\tf%s\n".format(fileName, dec.line,
context);
auto c = context;
context = "\tfunction: this";
dec.accept(this);
context = c;
}
override void visit(const EnumDeclaration dec)
{
if (dec.name == tok!"")
@ -136,6 +156,11 @@ class CTagsPrinter : ASTVisitor
dec.accept(this);
}
override void visit(const Invariant dec)
{
tagLines ~= "invariant\t%s\t%d;\"\tv%s\n".format(fileName, dec.line, context);
}
alias visit = ASTVisitor.visit;
string fileName;

View File

@ -1239,7 +1239,9 @@ public:
}
/** */ MemberFunctionAttribute[] memberFunctionAttributes;
/** */ FunctionBody functionBody;
/** */ size_t location;
/** */ size_t line;
/** */ size_t column;
/** */ size_t index;
/** */ string comment;
mixin OpEquals;
}
@ -1780,6 +1782,8 @@ public:
}
/** */ BlockStatement blockStatement;
/** */ string comment;
size_t line;
size_t index;
mixin OpEquals;
}
@ -1873,12 +1877,12 @@ final class LinkageAttribute : ASTNode
public:
override void accept(ASTVisitor visitor) const
{
version (DIP61) mixin (visitIfNotNull!(identifier, identifierChain));
version (DIP61) mixin (visitIfNotNull!(identifier, identifierChain));
else mixin (visitIfNotNull!(identifier));
}
/** */ Token identifier;
/** */ bool hasPlusPlus;
version (DIP61) /** */ IdentifierChain identifierChain;
version (DIP61) /** */ IdentifierChain identifierChain;
mixin OpEquals;
}

View File

@ -113,7 +113,7 @@ class Parser
node.linkageAttribute = parseLinkageAttribute();
}
warn("Prefer the new \"'alias' identifier '=' type ';'\" syntax"
~ " to the old \"'alias' type identifier ';'\" syntax");
~ " to the old \"'alias' type identifier ';'\" syntax");
if ((node.type = parseType()) is null) return null;
auto ident = expect(tok!"identifier");
if (ident is null)
@ -1976,20 +1976,23 @@ class ClassFour(A, B) if (someTest()) : Super {}}c;
node.comment = comment;
comment = null;
if (expect(tok!"~") is null) return null;
node.index = current.index;
node.line = current.line;
node.column = current.column;
if (expect(tok!"this") is null) return null;
if (expect(tok!"(") is null) return null;
if (expect(tok!")") is null) return null;
if (currentIs(tok!";"))
advance();
else
{
MemberFunctionAttribute[] memberFunctionAttributes;
while(moreTokens() && currentIsMemberFunctionAttribute())
memberFunctionAttributes ~= parseMemberFunctionAttribute();
node.memberFunctionAttributes = ownArray(memberFunctionAttributes);
{
MemberFunctionAttribute[] memberFunctionAttributes;
while(moreTokens() && currentIsMemberFunctionAttribute())
memberFunctionAttributes ~= parseMemberFunctionAttribute();
node.memberFunctionAttributes = ownArray(memberFunctionAttributes);
node.functionBody = parseFunctionBody();
}
node.functionBody = parseFunctionBody();
}
return node;
}
@ -3185,6 +3188,8 @@ interface "Four"
Invariant parseInvariant()
{
auto node = allocate!Invariant;
node.index = current.index;
node.line = current.line;
if (expect(tok!"invariant") is null) return null;
if (currentIs(tok!"("))
{
@ -3414,11 +3419,11 @@ invariant() foo();
{
advance();
node.hasPlusPlus = true;
version(DIP61) if (currentIs(tok!","))
{
advance();
node.identifierChain = parseIdentifierChain();
}
version(DIP61) if (currentIs(tok!","))
{
advance();
node.identifierChain = parseIdentifierChain();
}
}
expect(tok!")");
return node;
@ -4545,18 +4550,18 @@ q{(int a, ...)
if (!currentIs(tok!"]"))
{
node.lower = parseAssignExpression();
if (node.lower is null)
{
error("assignExpression expected");
return null;
}
if (node.lower is null)
{
error("assignExpression expected");
return null;
}
expect(tok!"..");
node.upper = parseAssignExpression();
if (node.upper is null)
{
error("assignExpression expected");
return null;
}
if (node.upper is null)
{
error("assignExpression expected");
return null;
}
}
if (expect(tok!"]") is null) return null;
return node;
@ -4810,13 +4815,13 @@ q{(int a, ...)
mixin(traceEnterAndExit!(__FUNCTION__));
auto node = allocate!StructInitializer;
expect(tok!"{");
if (currentIs(tok!"}"))
advance();
else
{
node.structMemberInitializers = parseStructMemberInitializers();
expect(tok!"}");
}
if (currentIs(tok!"}"))
advance();
else
{
node.structMemberInitializers = parseStructMemberInitializers();
expect(tok!"}");
}
return node;
}
@ -6349,7 +6354,7 @@ protected:
case tok!"abstract":
case tok!"pure":
case tok!"nothrow":
return true;
return true;
mixin(BASIC_TYPE_CASES);
return !peekIs(tok!".");
case tok!"case":