Commit b85a98cb authored by Glenn PLOUHINEC's avatar Glenn PLOUHINEC Committed by Gerson SUNYE
Browse files

Fix #804 : CompareObjectsWithEquals

parent 3808da59
<?xml version="1.0" encoding="ASCII"?>
<java:Model xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:java="http://www.eclipse.org/MoDisco/Java/0.2.incubation/java" name="CompareObjectsWithEquals">
<ownedElements name="compareObjectsWithEquals">
<ownedElements xsi:type="java:ClassDeclaration" originalCompilationUnit="//@compilationUnits.0" name="CompareObjectsWithEquals" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.2/@type">
<modifier visibility="public"/>
<bodyDeclarations xsi:type="java:FieldDeclaration" originalCompilationUnit="//@compilationUnits.0">
<modifier visibility="private"/>
<type type="//@ownedElements.0/@ownedElements.1"/>
<fragments originalCompilationUnit="//@compilationUnits.0" name="f" usageInVariableAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.3/@body/@statements.1/@expression/@leftOperand/@field"/>
</bodyDeclarations>
<bodyDeclarations xsi:type="java:FieldDeclaration" originalCompilationUnit="//@compilationUnits.0">
<modifier visibility="private"/>
<type type="//@ownedElements.0/@ownedElements.1"/>
<fragments originalCompilationUnit="//@compilationUnits.0" name="g" usageInVariableAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.3/@body/@statements.1/@expression/@rightOperand"/>
</bodyDeclarations>
<bodyDeclarations xsi:type="java:FieldDeclaration" originalCompilationUnit="//@compilationUnits.0">
<modifier visibility="private"/>
<type type="//@ownedElements.0/@ownedElements.0"/>
<fragments originalCompilationUnit="//@compilationUnits.0" name="parent" usageInVariableAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.3/@body/@statements.3/@expression/@arguments.0/@leftOperand"/>
</bodyDeclarations>
<bodyDeclarations xsi:type="java:MethodDeclaration" originalCompilationUnit="//@compilationUnits.0" name="foo">
<modifier/>
<body originalCompilationUnit="//@compilationUnits.0">
<statements xsi:type="java:VariableDeclarationStatement" originalCompilationUnit="//@compilationUnits.0">
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
<fragments originalCompilationUnit="//@compilationUnits.0" name="s" usageInVariableAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.3/@body/@statements.1/@thenStatement/@expression/@leftHandSide //@ownedElements.0/@ownedElements.0/@bodyDeclarations.3/@body/@statements.2/@expression/@arguments.0">
<initializer xsi:type="java:StringLiteral" originalCompilationUnit="//@compilationUnits.0" escapedValue="&quot;&quot;"/>
</fragments>
<modifier/>
</statements>
<statements xsi:type="java:IfStatement" originalCompilationUnit="//@compilationUnits.0">
<expression xsi:type="java:InfixExpression" originalCompilationUnit="//@compilationUnits.0" operator="==">
<rightOperand xsi:type="java:SingleVariableAccess" variable="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@fragments.0"/>
<leftOperand xsi:type="java:FieldAccess" originalCompilationUnit="//@compilationUnits.0">
<field variable="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@fragments.0"/>
<expression xsi:type="java:ThisExpression" originalCompilationUnit="//@compilationUnits.0"/>
</leftOperand>
</expression>
<thenStatement xsi:type="java:ExpressionStatement" originalCompilationUnit="//@compilationUnits.0">
<expression xsi:type="java:Assignment" originalCompilationUnit="//@compilationUnits.0">
<leftHandSide xsi:type="java:SingleVariableAccess" variable="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.3/@body/@statements.0/@fragments.0"/>
<rightHandSide xsi:type="java:StringLiteral" originalCompilationUnit="//@compilationUnits.0" escapedValue="&quot;true&quot;"/>
</expression>
</thenStatement>
</statements>
<statements xsi:type="java:ExpressionStatement" originalCompilationUnit="//@compilationUnits.0">
<expression xsi:type="java:MethodInvocation" originalCompilationUnit="//@compilationUnits.0" method="//@ownedElements.1/@ownedPackages.1/@ownedElements.1/@bodyDeclarations.0">
<arguments xsi:type="java:SingleVariableAccess" variable="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.3/@body/@statements.0/@fragments.0"/>
<expression xsi:type="java:SingleVariableAccess" variable="//@ownedElements.1/@ownedPackages.0/@ownedElements.3/@bodyDeclarations.0/@fragments.0">
<qualifier xsi:type="java:TypeAccess" type="//@ownedElements.1/@ownedPackages.0/@ownedElements.3"/>
</expression>
</expression>
</statements>
<statements xsi:type="java:ExpressionStatement" originalCompilationUnit="//@compilationUnits.0">
<expression xsi:type="java:MethodInvocation" originalCompilationUnit="//@compilationUnits.0" method="//@ownedElements.1/@ownedPackages.1/@ownedElements.1/@bodyDeclarations.1">
<arguments xsi:type="java:InfixExpression" originalCompilationUnit="//@compilationUnits.0" operator="==">
<rightOperand xsi:type="java:ThisExpression" originalCompilationUnit="//@compilationUnits.0"/>
<leftOperand xsi:type="java:SingleVariableAccess" variable="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.2/@fragments.0"/>
</arguments>
<expression xsi:type="java:SingleVariableAccess" variable="//@ownedElements.1/@ownedPackages.0/@ownedElements.3/@bodyDeclarations.0/@fragments.0">
<qualifier xsi:type="java:TypeAccess" type="//@ownedElements.1/@ownedPackages.0/@ownedElements.3"/>
</expression>
</expression>
</statements>
</body>
<returnType type="//@orphanTypes.5"/>
</bodyDeclarations>
<bodyDeclarations xsi:type="java:MethodDeclaration" originalCompilationUnit="//@compilationUnits.0" name="foo1">
<modifier/>
<body originalCompilationUnit="//@compilationUnits.0">
<statements xsi:type="java:VariableDeclarationStatement" originalCompilationUnit="//@compilationUnits.0">
<type type="//@ownedElements.0/@ownedElements.1"/>
<fragments originalCompilationUnit="//@compilationUnits.0" name="x" usageInVariableAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.4/@body/@statements.1/@expression/@rightOperand">
<initializer xsi:type="java:ClassInstanceCreation" originalCompilationUnit="//@compilationUnits.0" method="//@ownedElements.0/@ownedElements.1/@bodyDeclarations.2">
<type type="//@ownedElements.0/@ownedElements.1"/>
</initializer>
</fragments>
<modifier/>
</statements>
<statements xsi:type="java:ReturnStatement" originalCompilationUnit="//@compilationUnits.0">
<expression xsi:type="java:InfixExpression" originalCompilationUnit="//@compilationUnits.0" operator="==">
<rightOperand xsi:type="java:SingleVariableAccess" variable="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.4/@body/@statements.0/@fragments.0"/>
<leftOperand xsi:type="java:SingleVariableAccess" variable="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.4/@parameters.0"/>
</expression>
</statements>
</body>
<parameters originalCompilationUnit="//@compilationUnits.0" name="y" usageInVariableAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.4/@body/@statements.1/@expression/@leftOperand">
<modifier/>
<type type="//@ownedElements.0/@ownedElements.1"/>
</parameters>
<returnType type="//@orphanTypes.4"/>
</bodyDeclarations>
<bodyDeclarations xsi:type="java:MethodDeclaration" originalCompilationUnit="//@compilationUnits.0" name="foo2">
<modifier/>
<body originalCompilationUnit="//@compilationUnits.0">
<statements xsi:type="java:ReturnStatement" originalCompilationUnit="//@compilationUnits.0">
<expression xsi:type="java:InfixExpression" originalCompilationUnit="//@compilationUnits.0" operator="==">
<rightOperand xsi:type="java:ClassInstanceCreation" originalCompilationUnit="//@compilationUnits.0" method="//@ownedElements.0/@ownedElements.1/@bodyDeclarations.2">
<type type="//@ownedElements.0/@ownedElements.1"/>
</rightOperand>
<leftOperand xsi:type="java:SingleVariableAccess" variable="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.5/@parameters.0"/>
</expression>
</statements>
</body>
<parameters originalCompilationUnit="//@compilationUnits.0" name="z" usageInVariableAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.5/@body/@statements.0/@expression/@leftOperand">
<modifier/>
<type type="//@ownedElements.0/@ownedElements.1"/>
</parameters>
<returnType type="//@orphanTypes.4"/>
</bodyDeclarations>
</ownedElements>
<ownedElements xsi:type="java:ClassDeclaration" originalCompilationUnit="//@compilationUnits.1" name="Foo" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@type //@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@type //@ownedElements.0/@ownedElements.0/@bodyDeclarations.4/@parameters.0/@type //@ownedElements.0/@ownedElements.0/@bodyDeclarations.4/@body/@statements.0/@type //@ownedElements.0/@ownedElements.0/@bodyDeclarations.4/@body/@statements.0/@fragments.0/@initializer/@type //@ownedElements.0/@ownedElements.0/@bodyDeclarations.5/@parameters.0/@type //@ownedElements.0/@ownedElements.0/@bodyDeclarations.5/@body/@statements.0/@expression/@rightOperand/@type">
<modifier visibility="public"/>
<bodyDeclarations xsi:type="java:MethodDeclaration" originalCompilationUnit="//@compilationUnits.1" name="bar">
<modifier/>
<body originalCompilationUnit="//@compilationUnits.1">
<statements xsi:type="java:ReturnStatement" originalCompilationUnit="//@compilationUnits.1">
<expression xsi:type="java:InfixExpression" originalCompilationUnit="//@compilationUnits.1" operator="==">
<rightOperand xsi:type="java:SingleVariableAccess" variable="//@ownedElements.0/@ownedElements.1/@bodyDeclarations.0/@parameters.1"/>
<leftOperand xsi:type="java:SingleVariableAccess" variable="//@ownedElements.0/@ownedElements.1/@bodyDeclarations.0/@parameters.0"/>
</expression>
</statements>
</body>
<parameters originalCompilationUnit="//@compilationUnits.1" name="a" usageInVariableAccess="//@ownedElements.0/@ownedElements.1/@bodyDeclarations.0/@body/@statements.0/@expression/@leftOperand">
<modifier/>
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
</parameters>
<parameters originalCompilationUnit="//@compilationUnits.1" name="b" usageInVariableAccess="//@ownedElements.0/@ownedElements.1/@bodyDeclarations.0/@body/@statements.0/@expression/@rightOperand">
<modifier/>
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
</parameters>
<returnType type="//@orphanTypes.4"/>
</bodyDeclarations>
<bodyDeclarations xsi:type="java:MethodDeclaration" originalCompilationUnit="//@compilationUnits.1" name="foo">
<modifier/>
<body originalCompilationUnit="//@compilationUnits.1">
<statements xsi:type="java:ReturnStatement" originalCompilationUnit="//@compilationUnits.1">
<expression xsi:type="java:InfixExpression" originalCompilationUnit="//@compilationUnits.1" operator="==">
<rightOperand xsi:type="java:SingleVariableAccess" variable="//@ownedElements.0/@ownedElements.1/@bodyDeclarations.1/@parameters.1"/>
<leftOperand xsi:type="java:SingleVariableAccess" variable="//@ownedElements.0/@ownedElements.1/@bodyDeclarations.1/@parameters.0"/>
</expression>
</statements>
</body>
<parameters originalCompilationUnit="//@compilationUnits.1" name="i" usageInVariableAccess="//@ownedElements.0/@ownedElements.1/@bodyDeclarations.1/@body/@statements.0/@expression/@leftOperand">
<modifier/>
<type type="//@orphanTypes.0"/>
</parameters>
<parameters originalCompilationUnit="//@compilationUnits.1" name="j" usageInVariableAccess="//@ownedElements.0/@ownedElements.1/@bodyDeclarations.1/@body/@statements.0/@expression/@rightOperand">
<modifier/>
<type type="//@orphanTypes.0"/>
</parameters>
<returnType type="//@orphanTypes.4"/>
</bodyDeclarations>
<bodyDeclarations xsi:type="java:ConstructorDeclaration" name="Foo" proxy="true" usages="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.4/@body/@statements.0/@fragments.0/@initializer //@ownedElements.0/@ownedElements.0/@bodyDeclarations.5/@body/@statements.0/@expression/@rightOperand"/>
</ownedElements>
</ownedElements>
<ownedElements name="java" proxy="true">
<ownedPackages name="lang" proxy="true">
<ownedElements xsi:type="java:ClassDeclaration" name="String" proxy="true" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.3/@body/@statements.0/@type //@ownedElements.1/@ownedPackages.1/@ownedElements.1/@bodyDeclarations.0/@parameters.0/@type //@ownedElements.0/@ownedElements.1/@bodyDeclarations.0/@parameters.0/@type //@ownedElements.0/@ownedElements.1/@bodyDeclarations.0/@parameters.1/@type">
<superInterfaces type="//@ownedElements.1/@ownedPackages.1/@ownedElements.0"/>
<superInterfaces type="//@ownedElements.1/@ownedPackages.0/@ownedElements.1"/>
<superInterfaces type="//@ownedElements.1/@ownedPackages.0/@ownedElements.2"/>
</ownedElements>
<ownedElements xsi:type="java:InterfaceDeclaration" name="Comparable" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@superInterfaces.1">
<typeParameters name="T" proxy="true"/>
</ownedElements>
<ownedElements xsi:type="java:InterfaceDeclaration" name="CharSequence" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@superInterfaces.2"/>
<ownedElements xsi:type="java:ClassDeclaration" name="System" proxy="true" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.3/@body/@statements.2/@expression/@expression/@qualifier //@ownedElements.0/@ownedElements.0/@bodyDeclarations.3/@body/@statements.3/@expression/@expression/@qualifier">
<bodyDeclarations xsi:type="java:FieldDeclaration" proxy="true">
<fragments name="out" proxy="true" usageInVariableAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.3/@body/@statements.2/@expression/@expression //@ownedElements.0/@ownedElements.0/@bodyDeclarations.3/@body/@statements.3/@expression/@expression"/>
</bodyDeclarations>
</ownedElements>
<ownedElements xsi:type="java:InterfaceDeclaration" name="AutoCloseable" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.1/@ownedElements.4/@superInterfaces.0"/>
<ownedElements xsi:type="java:InterfaceDeclaration" name="Appendable" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.1/@ownedElements.1/@superInterfaces.0"/>
</ownedPackages>
<ownedPackages name="io" proxy="true">
<ownedElements xsi:type="java:InterfaceDeclaration" name="Serializable" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@superInterfaces.0"/>
<ownedElements xsi:type="java:ClassDeclaration" name="PrintStream" proxy="true">
<bodyDeclarations xsi:type="java:MethodDeclaration" name="println" proxy="true" usages="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.3/@body/@statements.2/@expression">
<parameters name="arg0" proxy="true">
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
</parameters>
</bodyDeclarations>
<bodyDeclarations xsi:type="java:MethodDeclaration" name="println" proxy="true" usages="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.3/@body/@statements.3/@expression">
<parameters name="arg0" proxy="true">
<type type="//@orphanTypes.4"/>
</parameters>
</bodyDeclarations>
<superInterfaces type="//@ownedElements.1/@ownedPackages.0/@ownedElements.5"/>
<superInterfaces type="//@ownedElements.1/@ownedPackages.1/@ownedElements.4"/>
<superClass type="//@ownedElements.1/@ownedPackages.1/@ownedElements.2"/>
</ownedElements>
<ownedElements xsi:type="java:ClassDeclaration" name="FilterOutputStream" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.1/@ownedElements.1/@superClass">
<superClass type="//@ownedElements.1/@ownedPackages.1/@ownedElements.3"/>
</ownedElements>
<ownedElements xsi:type="java:ClassDeclaration" name="OutputStream" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.1/@ownedElements.2/@superClass">
<superInterfaces type="//@ownedElements.1/@ownedPackages.1/@ownedElements.4"/>
<superInterfaces type="//@ownedElements.1/@ownedPackages.1/@ownedElements.5"/>
</ownedElements>
<ownedElements xsi:type="java:InterfaceDeclaration" name="Closeable" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.1/@ownedElements.3/@superInterfaces.0 //@ownedElements.1/@ownedPackages.1/@ownedElements.1/@superInterfaces.1">
<superInterfaces type="//@ownedElements.1/@ownedPackages.0/@ownedElements.4"/>
</ownedElements>
<ownedElements xsi:type="java:InterfaceDeclaration" name="Flushable" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.1/@ownedElements.3/@superInterfaces.1"/>
</ownedPackages>
</ownedElements>
<orphanTypes xsi:type="java:PrimitiveTypeInt" name="int" usagesInTypeAccess="//@ownedElements.0/@ownedElements.1/@bodyDeclarations.1/@parameters.0/@type //@ownedElements.0/@ownedElements.1/@bodyDeclarations.1/@parameters.1/@type"/>
<orphanTypes xsi:type="java:PrimitiveTypeLong" name="long"/>
<orphanTypes xsi:type="java:PrimitiveTypeFloat" name="float"/>
<orphanTypes xsi:type="java:PrimitiveTypeDouble" name="double"/>
<orphanTypes xsi:type="java:PrimitiveTypeBoolean" name="boolean" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.4/@returnType //@ownedElements.0/@ownedElements.0/@bodyDeclarations.5/@returnType //@ownedElements.0/@ownedElements.1/@bodyDeclarations.0/@returnType //@ownedElements.0/@ownedElements.1/@bodyDeclarations.1/@returnType //@ownedElements.1/@ownedPackages.1/@ownedElements.1/@bodyDeclarations.1/@parameters.0/@type"/>
<orphanTypes xsi:type="java:PrimitiveTypeVoid" name="void" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.3/@returnType"/>
<orphanTypes xsi:type="java:PrimitiveTypeChar" name="char"/>
<orphanTypes xsi:type="java:PrimitiveTypeShort" name="short"/>
<orphanTypes xsi:type="java:PrimitiveTypeByte" name="byte"/>
<compilationUnits name="CompareObjectsWithEquals.java" originalFilePath="/home/glenn/photon-workspace/projetMDE/CompareObjectsWithEquals/src/compareObjectsWithEquals/CompareObjectsWithEquals.java" package="//@ownedElements.0" types="//@ownedElements.0/@ownedElements.0"/>
<compilationUnits name="Foo.java" originalFilePath="/home/glenn/photon-workspace/projetMDE/CompareObjectsWithEquals/src/compareObjectsWithEquals/Foo.java" package="//@ownedElements.0" types="//@ownedElements.0/@ownedElements.1"/>
</java:Model>
......@@ -82,9 +82,10 @@ helper def: allMeasures(project : java!Model): Set(smm!Measure) =
thisModule.suspiciousEqualsMethodName(),
thisModule.doNotExtendJavaLangThrowable(),
thisModule.doNotExtendJavaLangError(),
thisModule.compareObjectsWithEquals(),
-- Best practicices rules
thisModule.avoidThrowingNewInstanceOfSameException()
-- Best practices rules
thisModule.avoidThrowingNewInstanceOfSameException(),
thisModule.switchDensity()
};
......@@ -812,6 +813,29 @@ rule MeasureUnnecessaryReturn(state : java!ReturnStatement) {
do {
noc;
}
}
--------------------------------------------- MeasureCompareObjectsWithEquals ---------------------------------------------
--A measure instance if the class violates the rule MeasureCompareObjectsWithEquals.
rule MeasureCompareObjectsWithEquals(expression : java!InfixExpression) {
to
om: smm!ObservedMeasure (
measure <- noc,
measurements <- measurement
),
noc: smm!DimensionalMeasure (
name <- 'CompareObjectsWithEquals',
shortDescription <- 'Use equals() to compare object references; avoid comparing them with ==.'
),
measurement: smm!DirectMeasurement (
error<-'The Class '+ expression.originalCompilationUnit.name + ' is using == instead of equals() to compare objects.'
)
do {
noc;
}
}
--------------------------------------------- IntegerInstantiation ---------------------------------------------
......
......@@ -91,4 +91,56 @@ helper context java!MethodDeclaration def: hasReturnType() : Boolean =
helper context java!MethodDeclaration def: hasParameters() : Boolean =
not self.parameters.isEmpty();
--------------------------------------------- CompareObjectsWithEquals---------------------------------------------
--Detects a wrong usage of objects comparison, which use the '==' operator instead of 'equals' method.
helper def: compareObjectsWithEquals() : Set(smm!Measure) =
java!InfixExpression.allInstances()
->select(expression | expression.operator.name = '==')
->select(expression | thisModule.isWrongCompareObjectsUse(expression))
->collect(expression | thisModule.MeasureCompareObjectsWithEquals(expression));
--Detects if the right and left operands are Objects.
helper def: isWrongCompareObjectsUse(expression : java!InfixExpression) : Boolean =
thisModule.isObject(expression.leftOperand) and thisModule.isObject(expression.rightOperand);
----------isObject() helpers
--Indicates if an operand is an Object, using polymorphism, with various '<java!Expression>.isObject()' helpers.
helper def: isObject(operand : java!Expression) : Boolean =
operand.isObject();
--Default helper: an unrecognized type is evaluated.
helper context java!Expression def: isObject() : Boolean =
false;
helper context java!SingleVariableAccess def: isObject() : Boolean =
thisModule.variableIsObject(self.variable);
--An attribute 'this.xxx' of the class is evaluated
helper context java!FieldAccess def: isObject() : Boolean =
thisModule.variableIsObject(self.field.variable);
--The object 'this' is currently evaluated.
helper context java!ThisExpression def: isObject() : Boolean =
self.originalCompilationUnit.types
->exists(typeInstance | (typeInstance.oclIsTypeOf(java!ClassDeclaration)));
--A constructor is used in the evaluation.
helper context java!ClassInstanceCreation def: isObject() : Boolean =
self.type.type.oclIsTypeOf(java!ClassDeclaration);
----------
----------variableIsObject() helpers
--Differents variables types.
helper def: variableIsObject(variable : java!VariableDeclaration) : Boolean =
variable.variableIsObject();
helper context java!SingleVariableDeclaration def: variableIsObject() : Boolean =
self.type.type.oclIsTypeOf(java!ClassDeclaration);
helper context java!VariableDeclarationFragment def: variableIsObject() : Boolean =
self.variablesContainer.type.type.oclIsTypeOf(java!ClassDeclaration);
----------
--------------------------------------------------------------------------------------------------------
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment