Operators
The operators are preprocessors or
comparators in the corresponding
phases of the pipeline. They're grouped as operators, because it's
possible to achieve the same results with both. The only difference is
the way they work. We illustrate this fact in another tutorial.
As an example, in an AST-based pipeline you could use a preprocessor to generalize the original source code by deleting nodes in the tree. But you could also use a comparator which considers all method declarations identical by ignoring their names.
The operators can be divided into two groups - independent and dependent. Independent operators work alone. Dependent operators need other operators to work.
As an example, in an AST-based pipeline you could use a preprocessor to generalize the original source code by deleting nodes in the tree. But you could also use a comparator which considers all method declarations identical by ignoring their names.
The operators can be divided into two groups - independent and dependent. Independent operators work alone. Dependent operators need other operators to work.
Independent operators
Annotators
Name |
Description |
|
---|---|---|
HeightAnnotator |
Annotates each node with the
number of the underlying nodes and blocks. Needed for HeightPoolingStrategy |
P |
MarkVariablesWithParentID |
Annotates all nodes that
represents variable names with the id of their parent node. Needed for RenameVariableNamesConsistent |
P |
NodeCountAnnotator |
Annotates all nodes with the
number of underlying nodes. |
P |
TokenLengthAnnotator |
Annotates all nodes with the
number of underlying tokens. |
P |
TokenTypesAnnotator |
Annotates all nodes with the
number of underlying different type tokens. |
P |
Methods
Name |
Description |
Example |
|
---|---|---|---|
GeneralizeMethodArgument- Types |
Removes types of the
method argements |
void setX(int x) becomes void setX(x) |
P |
GeneralizeMethodCallNames |
Removes method calls |
P |
|
GeneralizeMethodDecleration- Names |
Removes method decleration |
P |
|
GeneralizeMethodReturnTypes |
Removes returntype |
int getX() becomes getX() |
P |
RemoveEmptyMethods |
Removes methods without block
element |
abstract method declerations or
when RemoveEmptyBlocks
was used on a method with a empty block |
P |
RemoveGetMethodDeclerations |
Removes all declerations of
getter-methods |
String
getName(){...} |
P |
RemoveIsMethodDeclerations |
Removes all declerations of
is-methods |
boolean
isViewable(){...} |
P |
RemoveSetMethodDeclerations |
Removes all declerations of setter-methods | void
setName(String name) {...} |
P |
RemoveSimpleMethods |
Removes methods with only one
element |
P |
Operators
Name |
Description |
Example |
|
---|---|---|---|
AcceptAdditiveOperators |
Ignores if an operator is plus
or minus |
C |
|
AcceptAnds |
Ignores and operators |
& and && | C |
AcceptArithmeticOperators |
Ignores arithmetic operators |
+, -, *, / and % | C |
AcceptAssignments |
Ignores difference between all
assignments |
C |
|
AcceptBitOperators |
Ignores difference between bit
operators |
C |
|
AcceptBooleanKeywords |
Ignores difference between true and false |
C |
|
AcceptCharacterLiterals |
Ignores difference between
character literals |
'a' = 'b' |
C |
AcceptDecrementsOperators |
Ignores post- and predcrement
operators |
C |
|
AcceptEquals |
Ignores == and != |
C |
|
AcceptIncrementOperators |
Ignores post- and preincrement operators | C |
|
AcceptIntegralOperators |
Ignores all integral operators |
C |
|
AcceptLogicalOperators |
Ignores all logic operators |
||, &&, |,
& |
C |
AcceptMultiplicativeOperators |
Ignores all multiplicative
operators |
*, /, % |
C |
AcceptOperators |
Ignores all operators except
logical |
C |
|
AcceptOrs |
Ignores or operators |
| and || |
C |
AcceptRelationOperators |
Ignores all relation operators |
==, !=, <,
<=, >, >= |
C |
AcceptShiftOperators |
Ignores all shift operators |
<<,
>>, >>> |
|
CollapsePostfixOperators |
Removes all postfix operators |
i++ becomes
i |
P |
CollapsePrefixOperators |
Removes all prefix operators |
--i becomes
i |
P |
CollapseUnaryOperators |
Removes all unary operators |
~i becomes i |
P |
CollapseUnaryPlus |
Removes unary plusses |
+i becomes i |
P |
Variables and types
Name |
Description |
Example |
|
---|---|---|---|
AcceptNumberLiterals |
Ignores all numbers |
C |
|
AcceptNumberTypeNames |
Ignores number types |
int, float,
dobule, char etc. |
C |
AcceptPrimitives |
Ignores numbers, true and false |
C |
|
AcceptPrimitiveTypes |
Ignores primitive types (numeric
and boolean) |
C |
|
AcceptStringLiterals |
Ignores all string literals |
"JCCD" = "UNIX" |
C |
CollapseArrayElementAccess |
Removes array accesses |
a[0][1]
becomes a |
P |
CollapseCastExpressions |
Removes casts |
(int)a
becomes a |
P |
GeneralizeArrayInitializers |
Ignores different array
initializations |
int[] a = {1,2,3} equals int[] a = new int[]{7} |
P |
GeneralizeNewOperatorTypes |
Generalizes all object
instancings |
a = new Car(); becomes a; |
P |
GeneralizeTypes |
Removes all types from sourcecode |
P |
|
GeneralizeVariableDecleration- Types |
Removes types of variable
declerations |
P |
|
GeneralizeVariableNames |
Removes all variable names |
P |
|
NumberLiteralToDouble |
Ignores representation of numbers |
97.0 = 97f = a |
|
RemoveGenericTypes |
Removes generic types |
Vector<String> becomes Vector |
P |
RemoveVariableDecleration- Nodes |
Removes all variable declerations |
P |
|
RenameVariableNamesLocal-Consistent |
Renames variables consistent inside of blocks. The renaming is annotated in the corresponding node. | P |
Class / File
Name |
Description |
Example |
|
---|---|---|---|
AcceptClassKinds |
Ignores class, enum and interface
keywords |
C |
|
AcceptFileName |
Ignores file names |
C |
|
AcceptIdentifiers |
Ignores all identifiers |
C |
|
AcceptVariableIdentifiers |
Ignores all variable identifiers
|
C |
|
CompleteToBlock | Adds blocks to for, do, else, if and while when there are only single arguments. | if(true) make();
becomesif(true){ make();
} |
P |
GeneralizeClassDecleration- Name |
Removes class decleration name |
P |
|
ReduceIdentifiersToCapital-LetterSubstring | Reduces fully qualified identifiers to the part that begins with a capital. | my.package.Foo.Bar
becomes Foo.Bar |
P |
ReduceIdentifiersToLast-Substring | Reduces fully qualified identifiers to the last substring. | my.package.Foo.Bar becomes Bar |
P |
RemoveAnnotations |
Removes all annotations in the
source code |
P |
|
RemoveAssertions | Removes all assertions introduced through the keyword assert | P |
|
RemoveEmptyBlocks | Removes empty blocks | P |
|
RemoveEmptyGroupNodes |
Removes all group nodes which
don't have children |
P |
|
RemoveExtends |
Removes the extends-parts at the class and interface declaration | P |
|
RemoveImplements |
Removes the implements-parts at
the class declaration |
P |
|
RemoveImports |
Removes all imports |
P |
|
RemoveInterfaces |
Removes all interfaces |
P |
|
RemoveModifiers |
Removes all modifiers |
final public void
doIt(){...} becomes void doIt(){...} |
P |
RemovePackageInformation |
Removes package information |
P |
|
RemoveRedundantParantheses | Removes unnecessary parantheses | ((1 + 2) * 3)
becomes (1 + 2) * 3 |
P |
RemoveSemicolons |
Removes all semicolens |
P |
|
RemoveThrow |
Removes all throws introduced through the keyword throw | P |
|
RemoveThrowsClause |
Removes the throws-parts at the method decleration | P |
Technical
Name |
Description |
Example |
|
---|---|---|---|
AlwaysTrueAndComperator |
Assumes that two nodes are
always the same |
C |
|
AlwaysTrueOrComperator |
Assumes that two nodes are always the same | C |
|
CheckEquality |
Checks if two node have the same
type, number of children and text. |
C |
|
CollapseQualifiedTypeIdent- Nodes |
Technical: Removes qualified
type ident nodes from the AST. Saves some space after using RemoveGenericTypes. |
P |
Dependent operators
Variables
Name |
Description |
Example |
|
---|---|---|---|
CheckAnnotatedVariableNames |
Checks if the annotated variable
names are equal. Needs RenameVariableNames |
C |
|
CheckConsistentVariableNames |
Like CheckAnnotatedVariableNames, but checks also recursively all children |
C |
|
RenameVariableNames-Consistent |
Renames variables consistent in
the whole sourcecode. The renaming is annotated in the corresponding
node. Needs MarkVariablesWithParentID |
P |