1 //          Copyright Brian Schott (Hackerpilot) 2014.
2 // Distributed under the Boost Software License, Version 1.0.
3 //    (See accompanying file LICENSE_1_0.txt or copy at
4 //          http://www.boost.org/LICENSE_1_0.txt)
5 
6 module analysis.stats_collector;
7 
8 import dparse.ast;
9 import dparse.lexer;
10 import analysis.base;
11 
12 class StatsCollector : BaseAnalyzer
13 {
14 	alias visit = ASTVisitor.visit;
15 
16 	this(string fileName)
17 	{
18 		super(fileName, null);
19 	}
20 
21 	override void visit(const Statement statement)
22 	{
23 		statementCount++;
24 		statement.accept(this);
25 	}
26 
27 	override void visit(const ClassDeclaration classDeclaration)
28 	{
29 		classCount++;
30 		classDeclaration.accept(this);
31 	}
32 
33 	override void visit(const InterfaceDeclaration interfaceDeclaration)
34 	{
35 		interfaceCount++;
36 		interfaceDeclaration.accept(this);
37 	}
38 
39 	override void visit(const FunctionDeclaration functionDeclaration)
40 	{
41 		functionCount++;
42 		functionDeclaration.accept(this);
43 	}
44 
45 	override void visit(const StructDeclaration structDeclaration)
46 	{
47 		structCount++;
48 		structDeclaration.accept(this);
49 	}
50 
51 	override void visit(const TemplateDeclaration templateDeclaration)
52 	{
53 		templateCount++;
54 		templateDeclaration.accept(this);
55 	}
56 
57 	uint interfaceCount;
58 	uint classCount;
59 	uint functionCount;
60 	uint templateCount;
61 	uint structCount;
62 	uint statementCount;
63 	uint lineOfCodeCount;
64 	uint undocumentedPublicSymbols;
65 }