Package 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
-
-
Constructor Summary
Constructors Constructor Description IdentifiersMetric(polyglot.ast.Node astNode)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddMetrics(ClassData data)polyglot.visit.NodeVisitorenter(polyglot.ast.Node parent, polyglot.ast.Node n)voidreset()-
Methods inherited from class soot.toolkits.astmetrics.ASTMetric
enter, execute, getClassData, leave, printAstMetric
-
-
-
-
Constructor Detail
-
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;
-
-
Method Detail
-
addMetrics
public void addMetrics(ClassData data)
- Specified by:
addMetricsin classASTMetric
-
enter
public polyglot.visit.NodeVisitor enter(polyglot.ast.Node parent, polyglot.ast.Node n)- Overrides:
enterin classpolyglot.visit.NodeVisitor
-
-