Nantes Université

Skip to content
Extraits de code Groupes Projets
Valider 17806617 rédigé par Alexis's avatar Alexis
Parcourir les fichiers

Fix #668 #719 #772 #773 #842 #845 #846 #853

parents a7476c93 77876326
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
<?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="JUnitSpelling">
<ownedElements name="(default package)">
<ownedElements xsi:type="java:ClassDeclaration" originalCompilationUnit="//@compilationUnits.0" name="JUnitSpelling">
<modifier visibility="public"/>
<bodyDeclarations xsi:type="java:ClassDeclaration" originalCompilationUnit="//@compilationUnits.0" name="Foo">
<modifier visibility="public"/>
<bodyDeclarations xsi:type="java:MethodDeclaration" originalCompilationUnit="//@compilationUnits.0" name="setup">
<modifier visibility="public"/>
<body originalCompilationUnit="//@compilationUnits.0">
<comments xsi:type="java:LineComment" originalCompilationUnit="//@compilationUnits.0" content="// oops, should be setUp"/>
<statements xsi:type="java:ExpressionStatement" originalCompilationUnit="//@compilationUnits.0">
<expression xsi:type="java:MethodInvocation" originalCompilationUnit="//@compilationUnits.0" method="//@ownedElements.2/@ownedPackages.1/@ownedElements.1/@bodyDeclarations.0">
<arguments xsi:type="java:StringLiteral" originalCompilationUnit="//@compilationUnits.0" escapedValue="&quot;no empty block statement&quot;"/>
<expression xsi:type="java:SingleVariableAccess" variable="//@ownedElements.2/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.0/@fragments.0">
<qualifier xsi:type="java:TypeAccess" type="//@ownedElements.2/@ownedPackages.0/@ownedElements.0"/>
</expression>
</expression>
</statements>
</body>
<returnType type="//@orphanTypes.5"/>
</bodyDeclarations>
<bodyDeclarations xsi:type="java:MethodDeclaration" originalCompilationUnit="//@compilationUnits.0" name="TearDown">
<modifier visibility="public"/>
<body originalCompilationUnit="//@compilationUnits.0">
<comments xsi:type="java:LineComment" originalCompilationUnit="//@compilationUnits.0" content="// oops, should be tearDown"/>
<statements xsi:type="java:ExpressionStatement" originalCompilationUnit="//@compilationUnits.0">
<expression xsi:type="java:MethodInvocation" originalCompilationUnit="//@compilationUnits.0" method="//@ownedElements.2/@ownedPackages.1/@ownedElements.1/@bodyDeclarations.0">
<arguments xsi:type="java:StringLiteral" originalCompilationUnit="//@compilationUnits.0" escapedValue="&quot;no empty block statement&quot;"/>
<expression xsi:type="java:SingleVariableAccess" variable="//@ownedElements.2/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.0/@fragments.0">
<qualifier xsi:type="java:TypeAccess" type="//@ownedElements.2/@ownedPackages.0/@ownedElements.0"/>
</expression>
</expression>
</statements>
</body>
<returnType type="//@orphanTypes.5"/>
</bodyDeclarations>
<bodyDeclarations xsi:type="java:MethodDeclaration" originalCompilationUnit="//@compilationUnits.0" name="TEARdOwn">
<modifier visibility="public"/>
<body originalCompilationUnit="//@compilationUnits.0">
<statements xsi:type="java:ExpressionStatement" originalCompilationUnit="//@compilationUnits.0">
<expression xsi:type="java:MethodInvocation" originalCompilationUnit="//@compilationUnits.0" method="//@ownedElements.2/@ownedPackages.1/@ownedElements.1/@bodyDeclarations.0">
<arguments xsi:type="java:StringLiteral" originalCompilationUnit="//@compilationUnits.0" escapedValue="&quot;no empty block statement&quot;"/>
<expression xsi:type="java:SingleVariableAccess" variable="//@ownedElements.2/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.0/@fragments.0">
<qualifier xsi:type="java:TypeAccess" type="//@ownedElements.2/@ownedPackages.0/@ownedElements.0"/>
</expression>
</expression>
</statements>
</body>
<returnType type="//@orphanTypes.5"/>
</bodyDeclarations>
<bodyDeclarations xsi:type="java:MethodDeclaration" originalCompilationUnit="//@compilationUnits.0" name="SETup">
<modifier visibility="public"/>
<body originalCompilationUnit="//@compilationUnits.0">
<statements xsi:type="java:ExpressionStatement" originalCompilationUnit="//@compilationUnits.0">
<expression xsi:type="java:MethodInvocation" originalCompilationUnit="//@compilationUnits.0" method="//@ownedElements.2/@ownedPackages.1/@ownedElements.1/@bodyDeclarations.0">
<arguments xsi:type="java:StringLiteral" originalCompilationUnit="//@compilationUnits.0" escapedValue="&quot;no empty block statement&quot;"/>
<expression xsi:type="java:SingleVariableAccess" variable="//@ownedElements.2/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.0/@fragments.0">
<qualifier xsi:type="java:TypeAccess" type="//@ownedElements.2/@ownedPackages.0/@ownedElements.0"/>
</expression>
</expression>
</statements>
</body>
<returnType type="//@orphanTypes.5"/>
</bodyDeclarations>
<bodyDeclarations xsi:type="java:MethodDeclaration" originalCompilationUnit="//@compilationUnits.0" name="tearDown">
<modifier visibility="public"/>
<body originalCompilationUnit="//@compilationUnits.0">
<statements xsi:type="java:ExpressionStatement" originalCompilationUnit="//@compilationUnits.0">
<expression xsi:type="java:MethodInvocation" originalCompilationUnit="//@compilationUnits.0" method="//@ownedElements.2/@ownedPackages.1/@ownedElements.1/@bodyDeclarations.0">
<arguments xsi:type="java:StringLiteral" originalCompilationUnit="//@compilationUnits.0" escapedValue="&quot;no empty block statement&quot;"/>
<expression xsi:type="java:SingleVariableAccess" variable="//@ownedElements.2/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.0/@fragments.0">
<qualifier xsi:type="java:TypeAccess" type="//@ownedElements.2/@ownedPackages.0/@ownedElements.0"/>
</expression>
</expression>
</statements>
</body>
<returnType type="//@orphanTypes.5"/>
</bodyDeclarations>
<superClass type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
</bodyDeclarations>
</ownedElements>
</ownedElements>
<ownedElements name="junit" proxy="true">
<ownedPackages name="framework" proxy="true">
<ownedElements xsi:type="java:ClassDeclaration" name="TestCase" proxy="true" usagesInImports="//@compilationUnits.0/@imports.0" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@superClass">
<superInterfaces type="//@ownedElements.1/@ownedPackages.0/@ownedElements.2"/>
<superClass type="//@ownedElements.1/@ownedPackages.0/@ownedElements.1"/>
</ownedElements>
<ownedElements xsi:type="java:ClassDeclaration" name="Assert" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@superClass"/>
<ownedElements xsi:type="java:InterfaceDeclaration" name="Test" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@superInterfaces.0"/>
</ownedPackages>
</ownedElements>
<ownedElements name="java" proxy="true">
<ownedPackages name="lang" proxy="true">
<ownedElements xsi:type="java:ClassDeclaration" name="System" proxy="true" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@bodyDeclarations.0/@body/@statements.0/@expression/@expression/@qualifier //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@bodyDeclarations.1/@body/@statements.0/@expression/@expression/@qualifier //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@bodyDeclarations.2/@body/@statements.0/@expression/@expression/@qualifier //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@bodyDeclarations.3/@body/@statements.0/@expression/@expression/@qualifier //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@bodyDeclarations.4/@body/@statements.0/@expression/@expression/@qualifier">
<bodyDeclarations xsi:type="java:FieldDeclaration" proxy="true">
<fragments name="out" proxy="true" usageInVariableAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@bodyDeclarations.0/@body/@statements.0/@expression/@expression //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@bodyDeclarations.1/@body/@statements.0/@expression/@expression //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@bodyDeclarations.2/@body/@statements.0/@expression/@expression //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@bodyDeclarations.3/@body/@statements.0/@expression/@expression //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@bodyDeclarations.4/@body/@statements.0/@expression/@expression"/>
</bodyDeclarations>
</ownedElements>
<ownedElements xsi:type="java:ClassDeclaration" name="String" proxy="true" usagesInTypeAccess="//@ownedElements.2/@ownedPackages.1/@ownedElements.1/@bodyDeclarations.0/@parameters.0/@type">
<superInterfaces type="//@ownedElements.2/@ownedPackages.1/@ownedElements.0"/>
<superInterfaces type="//@ownedElements.2/@ownedPackages.0/@ownedElements.2"/>
<superInterfaces type="//@ownedElements.2/@ownedPackages.0/@ownedElements.3"/>
</ownedElements>
<ownedElements xsi:type="java:InterfaceDeclaration" name="Comparable" proxy="true" usagesInTypeAccess="//@ownedElements.2/@ownedPackages.0/@ownedElements.1/@superInterfaces.1">
<typeParameters name="T" proxy="true"/>
</ownedElements>
<ownedElements xsi:type="java:InterfaceDeclaration" name="CharSequence" proxy="true" usagesInTypeAccess="//@ownedElements.2/@ownedPackages.0/@ownedElements.1/@superInterfaces.2"/>
<ownedElements xsi:type="java:InterfaceDeclaration" name="AutoCloseable" proxy="true" usagesInTypeAccess="//@ownedElements.2/@ownedPackages.1/@ownedElements.4/@superInterfaces.0"/>
<ownedElements xsi:type="java:InterfaceDeclaration" name="Appendable" proxy="true" usagesInTypeAccess="//@ownedElements.2/@ownedPackages.1/@ownedElements.1/@superInterfaces.0"/>
</ownedPackages>
<ownedPackages name="io" proxy="true">
<ownedElements xsi:type="java:InterfaceDeclaration" name="Serializable" proxy="true" usagesInTypeAccess="//@ownedElements.2/@ownedPackages.0/@ownedElements.1/@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.0/@bodyDeclarations.0/@body/@statements.0/@expression //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@bodyDeclarations.1/@body/@statements.0/@expression //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@bodyDeclarations.2/@body/@statements.0/@expression //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@bodyDeclarations.3/@body/@statements.0/@expression //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@bodyDeclarations.4/@body/@statements.0/@expression">
<parameters name="arg0" proxy="true">
<type type="//@ownedElements.2/@ownedPackages.0/@ownedElements.1"/>
</parameters>
</bodyDeclarations>
<superInterfaces type="//@ownedElements.2/@ownedPackages.0/@ownedElements.5"/>
<superInterfaces type="//@ownedElements.2/@ownedPackages.1/@ownedElements.4"/>
<superClass type="//@ownedElements.2/@ownedPackages.1/@ownedElements.2"/>
</ownedElements>
<ownedElements xsi:type="java:ClassDeclaration" name="FilterOutputStream" proxy="true" usagesInTypeAccess="//@ownedElements.2/@ownedPackages.1/@ownedElements.1/@superClass">
<superClass type="//@ownedElements.2/@ownedPackages.1/@ownedElements.3"/>
</ownedElements>
<ownedElements xsi:type="java:ClassDeclaration" name="OutputStream" proxy="true" usagesInTypeAccess="//@ownedElements.2/@ownedPackages.1/@ownedElements.2/@superClass">
<superInterfaces type="//@ownedElements.2/@ownedPackages.1/@ownedElements.4"/>
<superInterfaces type="//@ownedElements.2/@ownedPackages.1/@ownedElements.5"/>
</ownedElements>
<ownedElements xsi:type="java:InterfaceDeclaration" name="Closeable" proxy="true" usagesInTypeAccess="//@ownedElements.2/@ownedPackages.1/@ownedElements.3/@superInterfaces.0 //@ownedElements.2/@ownedPackages.1/@ownedElements.1/@superInterfaces.1">
<superInterfaces type="//@ownedElements.2/@ownedPackages.0/@ownedElements.4"/>
</ownedElements>
<ownedElements xsi:type="java:InterfaceDeclaration" name="Flushable" proxy="true" usagesInTypeAccess="//@ownedElements.2/@ownedPackages.1/@ownedElements.3/@superInterfaces.1"/>
</ownedPackages>
</ownedElements>
<orphanTypes xsi:type="java:PrimitiveTypeInt" name="int"/>
<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"/>
<orphanTypes xsi:type="java:PrimitiveTypeVoid" name="void" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@bodyDeclarations.0/@returnType //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@bodyDeclarations.1/@returnType //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@bodyDeclarations.2/@returnType //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@bodyDeclarations.3/@returnType //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@bodyDeclarations.4/@returnType"/>
<orphanTypes xsi:type="java:PrimitiveTypeChar" name="char"/>
<orphanTypes xsi:type="java:PrimitiveTypeShort" name="short"/>
<orphanTypes xsi:type="java:PrimitiveTypeByte" name="byte"/>
<compilationUnits name="JUnitSpelling.java" originalFilePath="C:\Users\Thorrigan\Documents\Master\workspace\JUnitSpelling\src\JUnitSpelling.java" commentList="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@bodyDeclarations.0/@body/@comments.0 //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@bodyDeclarations.1/@body/@comments.0" types="//@ownedElements.0/@ownedElements.0">
<imports originalCompilationUnit="//@compilationUnits.0" importedElement="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
</compilationUnits>
</java:Model>
Ce diff est replié.
......@@ -132,6 +132,7 @@ helper def: allMeasures(project : java!Model): Set(smm!Measure) =
thisModule.emptyWhileStmt(),
thisModule.finalizeShouldBeProtected(),
thisModule.importFromSamePackage(),
thisModule.junitSpelling(),
thisModule.missingBreakInSwitch(),
thisModule.missingSerialVersionUID(),
thisModule.nonCaseLabelInSwitchStatement(),
......@@ -142,6 +143,7 @@ helper def: allMeasures(project : java!Model): Set(smm!Measure) =
thisModule.suspiciousHashcodeMethodName(),
thisModule.testClassWithoutTest(),
thisModule.UnconditionalIfStatement(),
thisModule.useEqualsToCompareString(),
thisModule.UseProperClassLoader(),
-- Best practices rules
......@@ -1213,6 +1215,27 @@ rule MeasureIntegerInstantiation(variable : java!CompilationUnit) {
}
}
-- ------------------------------------------- JUnitSpelling ---------------------------------------------
--- return a Measure for if "tearDown" or "setUp" arent spelled with a capital D and U and the rest is in lower case
rule MeasureJUnitSpelling(i : java!MethodDeclaration) {
to
om: smm!ObservedMeasure (
measure <- noc,
measurements <- measurement
),
noc: smm!DimensionalMeasure (
name <- 'JUnitSpelling',
shortDescription <- 'Some JUnit framework methods are easy to misspell.'
),
measurement: smm!DirectMeasurement (
error<-'The method Junit ' + i.name + ' is not spelled correctly.',
name<- i.name + ' is not spelled correctly'
)
do {
noc;
}
}
-- ------------------------------------------- LongInstantiation ---------------------------------------------
--- A Measure instance if the class violates the rule 'LongInstantiation'.
rule MeasureLongInstantiation(variable : java!CompilationUnit) {
......@@ -1663,6 +1686,31 @@ rule MeasureUseArraysAsList(w: java!CompilationUnit) {
}
}
-- UseEqualsToCompareStrings
--- Create a new measure to show a wrongful use of == or != to compare two Strings
--- Param - expression : an infix expression (i.e. LeftOperand operation RightOperand)
rule MeasureUseEqualsToCompareStrings(expression : java!InfixExpression) {
to
om: smm!ObservedMeasure (
measure <- noc,
measurements <- measurement
),
noc: smm!DimensionalMeasure(
name <- 'UseEqualsToCompareStrings',
shortDescription <- 'Use the methode equals() to compare strings.'
+'The use of == and != should be prohibited'
),
measurement : smm!DirectMeasurement(
error <- 'The method ' + thisModule.getMethodName(expression) +
' in the class' + expression.originalCompilationUnit.name +
' is using ' + expression.operator.toString() +
' instead of equals() to compare strings'
)
do {
noc;
}
}
--- creates a new Measure when the parameter of String.indexOf(char) is not of type char when checking for the index of a single character
rule MeasureUseIndexOfChar(method : java!MethodInvocation) {
to
......
......@@ -339,6 +339,14 @@ helper def: importFromSamePackage() : Set(smm!Measure) =
->select(import | import.importedElement = import.originalCompilationUnit.package)
->collect(import | thisModule.MeasureImportFromSamePackage(import));
-- ------------------------------------------- JUnitSpelling ---------------------------------------------
--- Helper for issue JUnitSpelling : Some JUnit framework methods are easy to misspell !("tearDown", "setUp").
helper def: junitSpelling() : Set(smm!Measure) =
java!MethodDeclaration.allInstances()
-> select(i | ((i.name <> 'tearDown' and i.name <> 'setUp') and (i.name.toLower() = 'teardown' or i.name.toLower() = 'setup')))
-> collect(i | thisModule.MeasureJUnitSpelling(i));
-----------------------------------------MethodWithSameNameAsEnclosingClass----------------------------------------------
-- Rule for metrics MethodWithSameNameAsEnclosingClass
helper def: methodWithSameNameAsEnclosingClass() : Set(smm!Measure) =
......@@ -444,6 +452,148 @@ helper def: suspiciousHashcodeMethodName(): Set(smm!Measure) =
->select(md | md.name.toLower() = 'hashcode')
->collect(md | thisModule.MeasureSuspiciousHashcodeMethodName(md));
-- Helpers for the UseEqualsToCompareString measure
--- Collect every utilisation of == or != that compares two strings
--- Return : A set of measures that contains each use of the aforementioned operator
helper def : useEqualsToCompareString() : Set(mm!Measure) =
java!InfixExpression.allInstances()
-> select(expression | expression.operator.name = '==' or expression.operator.name = '!=')
-> select(expression | thisModule.stringComparison(expression))
-> collect(expression | thisModule.MeasureUseEqualsToCompareStrings(expression));
--- Check if both operand of an infix expression are string
--- Param expression : A java infix expression
--- Return true : two strings are compared
--- else return false
helper def : stringComparison(expression : java!InfixExpression) : Boolean =
thisModule.isString(expression.leftOperand) or thisModule.isString(expression.rightOperand);
--- Called by stringComparison
--- Dispatch the use of isString according to the context
--- Param operand : A java expression
--- Return true : operand is a string
--- false otherwise
helper def : isString(operand : java!Expression) : Boolean =
operand.isString();
--- Called if an operand is an ArrayAccess
--- Return true : the element is a string,
--- return false otherwise
helper context java!ArrayAccess def: isString() : Boolean =
thisModule.variableIsString(self.array);
--- Called if an operand is a CastExpression
--- Return true : the current element is casted as a string
--- return false otherwise
helper context java!CastExpression def: isString() : Boolean =
thisModule.variableIsString(self.type);
--- Called if an operand is a field access
--- Return true : the field access is a string
--- return false otherwise
helper context java!FieldAccess def: isString() : Boolean =
thisModule.variableIsString(self.field.variable);
--- Called if an operand is a method invocation
--- Return true : the return type is String
--- else return false
helper context java!MethodInvocation def : isString() : Boolean =
thisModule.variableIsString(self.method);
--- Called if an operand is a parenthesized expression
--- Return true : the type of the expression is String
--- return false otherwise
helper context java!ParenthesizedExpression def : isString() : Boolean =
thisModule.variableIsString(self.expression);
--- Called if an operand is a single variable access
--- Return true : the variable is a string
--- else return false
helper context java!SingleVariableAccess def : isString() : Boolean =
thisModule.variableIsString(self);
--- Called if an operand is a string literal
--- Always return true
helper context java!StringLiteral def : isString() : Boolean =
true;
--- Called if the operand is 'this'
--- Return true : the expression is of type String
--- return false otherwise
helper context java!ThisExpression def: isString() : Boolean =
self.originalCompilationUnit.types
->exists(name | name = 'String');
--- Called if the context is not one of the aforementioned one
--- when isString() is called. Always return false
helper context java!Expression def: isString() : Boolean =
false;
-- ############################## variableIsString() helpers ##############################
--- Dispatch the call of variableIsString according to the context
--- Param variable : A java declaration of a variable
--- Return true : variable is a string
--- return false otherwise
helper def: variableIsString(variable : java!VariableDeclaration) : Boolean =
variable.variableIsString();
--- Called when the context is MethodDeclaration
--- See : variableIsString(variable : java!VariableDeclaration)
helper context java!AbstractMethodDeclaration def: variableIsString() : Boolean =
thisModule.variableIsString(self.returnType) or self.name = 'toString';
--- Called when the context is an AbstractVariablesContainer
--- See : variableIsString(variable : java!VariableDeclaration)
helper context java!AbstractVariablesContainer def: variableIsString() : Boolean =
thisModule.variableIsString(self.type);
--- Called when the context is a SingleVariableAccess
--- See : variableIsString(variable : java!VariableDeclaration)
helper context java!SingleVariableAccess def: variableIsString() : Boolean =
thisModule.variableIsString(self.variable);
--- Called when the context is a SingleVariableDeclaration
--- See : variableIsString(variable : java!VariableDeclaration)
helper context java!SingleVariableDeclaration def: variableIsString() : Boolean =
self.type.type.name = 'String';
--- Called when the context is AbstractMethodDeclaration
--- See : variableIsString(variable : java!VariableDeclaration)
helper context java!TypeAccess def: variableIsString() : Boolean =
self.type.name = 'String';
--- Called when the context is a VariableDeclarationFragment
--- See : variableIsString(variable : java!VariableDeclaration)
helper context java!VariableDeclarationFragment def: variableIsString() : Boolean =
thisModule.variableIsString(self.variablesContainer);
--- Default case, allows to deal with OclUndefined
--- Always return false
helper context OclAny def: variableIsString() : Boolean =
false;
-- ############################## getMethodName() helpers ##############################
--- Dispatch the call of getMethodName according to the
--- container context
--- Return the name of the method in which the expression is
helper def: getMethodName(expression : java!Expression) : String =
--let expr : OclAny = expr.eContainer() in expression.eContainer().getMethodName();
expression.getMethodName();
--- Called when the context is a MethodDeclaration
--- Return self.name : the name of the method
helper context java!MethodDeclaration def: getMethodName() : String =
self.name;
--- Called when the context is an ASTNode
--- Return the name of the method where the ASTNode by looking at its container
helper context java!ASTNode def: getMethodName() : String =
thisModule.getMethodName(self.eContainer());
--- Default case, allows to deal with OclUndefined
helper context OclAny def : getMethodName() : String =
'';
--------------------------------------------- MissingSerialVersionUID ---------------------------------------------
-- Helper for metrics MissingSerialVersionUID
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter