soot.toolkits.astmetrics
Class IdentifiersMetric
java.lang.Object
polyglot.visit.NodeVisitor
soot.toolkits.astmetrics.ASTMetric
soot.toolkits.astmetrics.IdentifiersMetric
- All Implemented Interfaces:
- MetricInterface
public class IdentifiersMetric
- extends ASTMetric
- Author:
- Michael Batchelder
Created on 5-Mar-2006
Methods inherited from class polyglot.visit.NodeVisitor |
begin, finish, finish, leave, override, override, toString, visitEdge |
IdentifiersMetric
public IdentifiersMetric(polyglot.ast.Node astNode)
- Parameters:
astNode
- This metric will take a measure of the "complexity" of each identifier used
within the program. An identifier's complexity is computed as follows:
First the alpha tokens are parsed by splitting on non-alphas and capitals:
example identifier: getASTNode alpha tokens: get, AST, Node
example identifier: ___Junk$$name alpha tokens: Junk, name)
The alpha tokens are then counted and a 'token complexity' is formed by the ratio
of total tokens to the number of tokens found in the dictionary:
example identifier: getASTNode Total: 3, Found: 2, Complexity: 1.5
Then the 'character complexity' is computed, which is a ratio of total number of
characters to the number of non-complex characters. Non-complex characters are
those which are NOT part of a multiple string of non-alphas.
example identifier: ___Junk$$name complex char strings: '___', '$$'
number of non-complex (Junk + name): 8, total: 13, Complexity: 1.625
Finally, the total identifier complexity is the sum of the token and character
complexities multipled by the 'importance' of an identifier:
Multipliers are as follows:
Class multiplier = 3;
Method multiplier = 4;
Field multiplier = 2;
Formal multiplier = 1.5;
Local multiplier = 1;
reset
public void reset()
- Specified by:
reset
in class ASTMetric
addMetrics
public void addMetrics(ClassData data)
- Specified by:
addMetrics
in class ASTMetric
enter
public polyglot.visit.NodeVisitor enter(polyglot.ast.Node parent,
polyglot.ast.Node n)
- Overrides:
enter
in class polyglot.visit.NodeVisitor