public class IdentifiersMetric extends ASTMetric
| Constructor and Description |
|---|
IdentifiersMetric(polyglot.ast.Node astNode) |
| Modifier and Type | Method and Description |
|---|---|
void |
addMetrics(ClassData data) |
polyglot.visit.NodeVisitor |
enter(polyglot.ast.Node parent,
polyglot.ast.Node n) |
void |
reset() |
enter, execute, getClassData, leave, printAstMetricpublic IdentifiersMetric(polyglot.ast.Node astNode)
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;public void addMetrics(ClassData data)
addMetrics in class ASTMetricpublic polyglot.visit.NodeVisitor enter(polyglot.ast.Node parent,
polyglot.ast.Node n)
enter in class polyglot.visit.NodeVisitorCopyright © 2020 Soot OSS. All rights reserved.