Commit 2afee0c0 authored by BRAULT Benjamin's avatar BRAULT Benjamin
Browse files

Merge branch 'master' into 'SimplifyBooleanAssertion'

# Conflicts:
#   src/main/atl/analysis.atl
parents 6815a21f 14ea4dfd
......@@ -11,6 +11,6 @@ target/
/metrics.xmi
*.launch
analysis.launch
!analysis.launch
*.orig
*.orig
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.m2m.atl.adt.launching.atlTransformation">
<stringAttribute key="ATL File Name" value="/projet-2019/src/main/atl/analysis.atl"/>
<stringAttribute key="ATL VM" value="EMF-specific VM"/>
<stringAttribute key="ATL_COMPILER" value="atl2006"/>
<booleanAttribute key="IS_REFINING" value="false"/>
<mapAttribute key="Input">
<mapEntry key="IN" value="java"/>
</mapAttribute>
<mapAttribute key="Libs">
<mapEntry key="bestPractices" value="/projet-2019/src/main/atl/bestPractices.asm"/>
<mapEntry key="codestyle" value="/projet-2019/src/main/atl/codestyle.asm"/>
<mapEntry key="design" value="/projet-2019/src/main/atl/design.asm"/>
<mapEntry key="documentation" value="/projet-2019/src/main/atl/documentation.asm"/>
<mapEntry key="errorProne" value="/projet-2019/src/main/atl/errorProne.asm"/>
<mapEntry key="multithreading" value="/projet-2019/src/main/atl/multithreading.asm"/>
<mapEntry key="performance" value="/projet-2019/src/main/atl/performance.asm"/>
</mapAttribute>
<mapAttribute key="Model Handler">
<mapEntry key="java" value="EMF"/>
<mapEntry key="smm" value="EMF"/>
</mapAttribute>
<mapAttribute key="ModelType">
<mapEntry key="IN" value="MODELINPUT"/>
<mapEntry key="OUT" value="MODELOUTPUT"/>
<mapEntry key="java" value="METAMODELINPUT"/>
<mapEntry key="smm" value="METAMODELOUTPUT"/>
</mapAttribute>
<mapAttribute key="Options">
<mapEntry key="OPTION_CLEAR" value="true"/>
<mapEntry key="OPTION_CONTENT_TYPE" value="false"/>
<mapEntry key="OPTION_DERIVED" value="true"/>
<mapEntry key="allowInterModelReferences" value="false"/>
<mapEntry key="printExecutionTime" value="true"/>
<mapEntry key="step" value="false"/>
<mapEntry key="supportUML2Stereotypes" value="false"/>
</mapAttribute>
<listAttribute key="OrderedInput">
<listEntry value="IN"/>
</listAttribute>
<listAttribute key="OrderedOutput">
<listEntry value="OUT"/>
</listAttribute>
<mapAttribute key="Output">
<mapEntry key="OUT" value="smm"/>
</mapAttribute>
<mapAttribute key="Path">
<mapEntry key="IN" value="/projet-2019/input/example.xmi"/>
<mapEntry key="OUT" value="/projet-2019/output/metrics.xmi"/>
<mapEntry key="java" value="uri:http://www.eclipse.org/MoDisco/Java/0.2.incubation/java"/>
<mapEntry key="smm" value="uri:http://www.eclipse.org/MoDisco/SMM/1.0.Beta2/smm"/>
</mapAttribute>
<listAttribute key="Superimpose"/>
<stringAttribute key="bad_container_name" value="/projet-2019/analysis.launch"/>
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
</listAttribute>
</launchConfiguration>
......@@ -2,24 +2,51 @@
# Pre-requisites : A correct analysis.launch file to serve as base
# This scripts generates for each input xmi, a corresponding ATL launch file
# Check parameter for current IN model name in analysis.launch
currentinput=""
base_file="build-tools/analysis.launch"
if [ -z "$1" ]
then
if [ ! -e $base_file ]
then
echo "Enter the name of current IN model in file analysis.launch (for e.g : ./gen-launch-config.sh comment-required)"
echo -e "No base file found. You can enter the name of a base file in parameter. For e.g.:\n./gen-launch-config.sh analysis.launch"
exit
fi
else
currentinput=$1
echo "Current input : $currentinput"
base_file=$1
fi
echo "Base file used: $base_file"
target_directory="launch_configurations" #Directory of all the launch configurations generated.
launch_group="atl_launch_group.launch" #Name of the Launch Group Configuration file.
delay=0 #Delay between each execution of the launch group, in seconds (must be an integer).
i=0 #Value used to distinguish the different configurations for the launch group
mkdir -p $target_directory
# These xml lines generates a Launch Group Configuration for Eclipse.
echo '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.debug.core.groups.GroupLaunchConfigurationType">' > $launch_group
# For each input file, generate the corresponding .launch file with this file's name as IN model
for file in input/*.xmi; do
filename=$(basename -- "$file") # get basename
filename="${filename%.*}" # remove extension
echo "$filename"
cp analysis.launch analysis-$filename.launch
sed -i "s/$currentinput/$filename/g" analysis-$filename.launch
echo "Replaced : $currentinput by $filename in file analysis-$filename.launch"
done
\ No newline at end of file
cp $base_file $target_directory/analysis-$filename.launch
echo "Created: analysis-$filename.launch"
sed -i "s/\/projet-2019\/input\/.*.xmi/\/projet-2019\/input\/$filename.xmi/g" $target_directory/analysis-$filename.launch # Replace the input in the .launch file.
echo '
<stringAttribute key="org.eclipse.debug.core.launchGroup.'"$i"'.action" value="DELAY"/>
<stringAttribute key="org.eclipse.debug.core.launchGroup.'"$i"'.actionParam" value="'"$delay"'"/>
<booleanAttribute key="org.eclipse.debug.core.launchGroup.'"$i"'.adoptIfRunning" value="false"/>
<booleanAttribute key="org.eclipse.debug.core.launchGroup.'"$i"'.enabled" value="true"/>
<stringAttribute key="org.eclipse.debug.core.launchGroup.'"$i"'.mode" value="run"/>
<stringAttribute key="org.eclipse.debug.core.launchGroup.'"$i"'.name" value="'"analysis-$filename"'"/>' >> $launch_group
((i++))
done
echo '
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
</listAttribute>
</launchConfiguration>' >> $launch_group
\ No newline at end of file
<?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="EmptyFinalizer">
<ownedElements name="(default package)">
<ownedElements xsi:type="java:ClassDeclaration" originalCompilationUnit="//@compilationUnits.0" name="EmptyFinalizerMtd">
<modifier visibility="public"/>
<bodyDeclarations xsi:type="java:MethodDeclaration" originalCompilationUnit="//@compilationUnits.0" name="finalize">
<modifier visibility="protected"/>
<body originalCompilationUnit="//@compilationUnits.0"/>
<returnType type="//@orphanTypes.5"/>
</bodyDeclarations>
</ownedElements>
</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/@returnType"/>
<orphanTypes xsi:type="java:PrimitiveTypeChar" name="char"/>
<orphanTypes xsi:type="java:PrimitiveTypeShort" name="short"/>
<orphanTypes xsi:type="java:PrimitiveTypeByte" name="byte"/>
<compilationUnits name="EmptyFinalizerMtd.java" originalFilePath="C:\Users\HP\eclipse-workspace-modeling-two\EmptyFinalizer\src\EmptyFinalizerMtd.java" types="//@ownedElements.0/@ownedElements.0"/>
</java:Model>
<?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="EmptyFinally">
<ownedElements name="(default package)">
<ownedElements xsi:type="java:ClassDeclaration" originalCompilationUnit="//@compilationUnits.0" name="EmptyfinallyBlock">
<modifier visibility="public"/>
<bodyDeclarations xsi:type="java:MethodDeclaration" originalCompilationUnit="//@compilationUnits.0" name="bar">
<modifier visibility="public"/>
<body originalCompilationUnit="//@compilationUnits.0">
<statements xsi:type="java:TryStatement" originalCompilationUnit="//@compilationUnits.0">
<body originalCompilationUnit="//@compilationUnits.0">
<statements xsi:type="java:VariableDeclarationStatement" originalCompilationUnit="//@compilationUnits.0">
<type type="//@orphanTypes.0"/>
<fragments originalCompilationUnit="//@compilationUnits.0" name="x">
<initializer xsi:type="java:NumberLiteral" originalCompilationUnit="//@compilationUnits.0" tokenValue="2"/>
</fragments>
<modifier/>
</statements>
</body>
<finally originalCompilationUnit="//@compilationUnits.0">
<comments xsi:type="java:LineComment" originalCompilationUnit="//@compilationUnits.0" content="// empty!" enclosedByParent="true"/>
</finally>
</statements>
</body>
<returnType type="//@orphanTypes.5"/>
</bodyDeclarations>
</ownedElements>
</ownedElements>
<orphanTypes xsi:type="java:PrimitiveTypeInt" name="int" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.0/@body/@statements.0/@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"/>
<orphanTypes xsi:type="java:PrimitiveTypeVoid" name="void" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@returnType"/>
<orphanTypes xsi:type="java:PrimitiveTypeChar" name="char"/>
<orphanTypes xsi:type="java:PrimitiveTypeShort" name="short"/>
<orphanTypes xsi:type="java:PrimitiveTypeByte" name="byte"/>
<compilationUnits name="EmptyfinallyBlock.java" originalFilePath="C:\Users\HP\eclipse-workspace-modeling-two\EmptyFinally\src\EmptyfinallyBlock.java" commentList="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.0/@finally/@comments.0" types="//@ownedElements.0/@ownedElements.0"/>
</java:Model>
<?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="SwitchStatementEmpty">
<ownedElements name="(default package)">
<ownedElements xsi:type="java:ClassDeclaration" originalCompilationUnit="//@compilationUnits.0" name="SwitchEmpty">
<modifier visibility="public"/>
<bodyDeclarations xsi:type="java:MethodDeclaration" originalCompilationUnit="//@compilationUnits.0" name="bar">
<modifier visibility="public"/>
<body originalCompilationUnit="//@compilationUnits.0">
<statements xsi:type="java:VariableDeclarationStatement" originalCompilationUnit="//@compilationUnits.0">
<type type="//@orphanTypes.0"/>
<fragments originalCompilationUnit="//@compilationUnits.0" name="x" usageInVariableAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.1/@expression">
<initializer xsi:type="java:NumberLiteral" originalCompilationUnit="//@compilationUnits.0" tokenValue="2"/>
</fragments>
<modifier/>
</statements>
<statements xsi:type="java:SwitchStatement" originalCompilationUnit="//@compilationUnits.0">
<comments xsi:type="java:LineComment" originalCompilationUnit="//@compilationUnits.0" content="// once there was code here" enclosedByParent="true"/>
<comments xsi:type="java:LineComment" originalCompilationUnit="//@compilationUnits.0" content="// but it's been commented out or something" enclosedByParent="true"/>
<expression xsi:type="java:SingleVariableAccess" variable="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.0/@fragments.0"/>
</statements>
</body>
<returnType type="//@orphanTypes.5"/>
</bodyDeclarations>
</ownedElements>
</ownedElements>
<orphanTypes xsi:type="java:PrimitiveTypeInt" name="int" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.0/@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"/>
<orphanTypes xsi:type="java:PrimitiveTypeVoid" name="void" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@returnType"/>
<orphanTypes xsi:type="java:PrimitiveTypeChar" name="char"/>
<orphanTypes xsi:type="java:PrimitiveTypeShort" name="short"/>
<orphanTypes xsi:type="java:PrimitiveTypeByte" name="byte"/>
<compilationUnits name="SwitchEmpty.java" originalFilePath="C:\Users\HP\eclipse-workspace-modeling-two\SwitchStatementEmpty\src\SwitchEmpty.java" commentList="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.1/@comments.0 //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.1/@comments.1" types="//@ownedElements.0/@ownedElements.0"/>
</java:Model>
<?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="EmptySyncBlock">
<ownedElements name="(default package)">
<ownedElements xsi:type="java:ClassDeclaration" originalCompilationUnit="//@compilationUnits.0" name="SyncBlock">
<modifier visibility="public"/>
<bodyDeclarations xsi:type="java:MethodDeclaration" originalCompilationUnit="//@compilationUnits.0" name="bar">
<modifier visibility="public"/>
<body originalCompilationUnit="//@compilationUnits.0">
<statements xsi:type="java:SynchronizedStatement" originalCompilationUnit="//@compilationUnits.0">
<body originalCompilationUnit="//@compilationUnits.0">
<comments xsi:type="java:LineComment" originalCompilationUnit="//@compilationUnits.0" content="// empty!" enclosedByParent="true"/>
</body>
<expression xsi:type="java:ThisExpression" originalCompilationUnit="//@compilationUnits.0"/>
</statements>
</body>
<returnType type="//@orphanTypes.5"/>
</bodyDeclarations>
</ownedElements>
</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/@returnType"/>
<orphanTypes xsi:type="java:PrimitiveTypeChar" name="char"/>
<orphanTypes xsi:type="java:PrimitiveTypeShort" name="short"/>
<orphanTypes xsi:type="java:PrimitiveTypeByte" name="byte"/>
<compilationUnits name="SyncBlock.java" originalFilePath="C:\Users\HP\eclipse-workspace-modeling-two\EmptySyncBlock\src\SyncBlock.java" commentList="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.0/@body/@comments.0" types="//@ownedElements.0/@ownedElements.0"/>
</java:Model>
<?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="shortvariablename">
<ownedElements name="shortvariablename">
<ownedElements xsi:type="java:ClassDeclaration" originalCompilationUnit="//@compilationUnits.0" name="Something">
<modifier visibility="public"/>
<bodyDeclarations xsi:type="java:FieldDeclaration" originalCompilationUnit="//@compilationUnits.0">
<modifier visibility="private" static="true"/>
<type type="//@orphanTypes.0"/>
<fragments originalCompilationUnit="//@compilationUnits.0" name="a" usageInVariableAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@body/@statements.0/@fragments.0/@initializer/@rightOperand //@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@body/@statements.1/@body/@statements.0/@expression/@rightHandSide">
<initializer xsi:type="java:NumberLiteral" originalCompilationUnit="//@compilationUnits.0" tokenValue="15"/>
</fragments>
</bodyDeclarations>
<bodyDeclarations xsi:type="java:MethodDeclaration" originalCompilationUnit="//@compilationUnits.0" name="main">
<modifier visibility="public" static="true"/>
<body originalCompilationUnit="//@compilationUnits.0">
<statements xsi:type="java:VariableDeclarationStatement" originalCompilationUnit="//@compilationUnits.0">
<type type="//@orphanTypes.0"/>
<fragments originalCompilationUnit="//@compilationUnits.0" name="b" usageInVariableAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@body/@statements.1/@body/@statements.0/@expression/@leftHandSide //@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@body/@statements.3/@body/@statements.0/@expression/@leftHandSide //@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@body/@statements.4/@body/@statements.0/@expression/@leftHandSide">
<initializer xsi:type="java:InfixExpression" originalCompilationUnit="//@compilationUnits.0" operator="+">
<rightOperand xsi:type="java:SingleVariableAccess" variable="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@fragments.0"/>
<leftOperand xsi:type="java:NumberLiteral" originalCompilationUnit="//@compilationUnits.0" tokenValue="20"/>
</initializer>
</fragments>
<modifier/>
</statements>
<statements xsi:type="java:ForStatement" originalCompilationUnit="//@compilationUnits.0">
<expression xsi:type="java:InfixExpression" originalCompilationUnit="//@compilationUnits.0" operator="&lt;">
<rightOperand xsi:type="java:NumberLiteral" originalCompilationUnit="//@compilationUnits.0" tokenValue="10"/>
<leftOperand xsi:type="java:SingleVariableAccess" variable="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@body/@statements.1/@initializers.0/@fragments.0"/>
</expression>
<updaters xsi:type="java:PostfixExpression" originalCompilationUnit="//@compilationUnits.0">
<operand xsi:type="java:SingleVariableAccess" variable="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@body/@statements.1/@initializers.0/@fragments.0"/>
</updaters>
<initializers xsi:type="java:VariableDeclarationExpression" originalCompilationUnit="//@compilationUnits.0">
<type type="//@orphanTypes.0"/>
<fragments originalCompilationUnit="//@compilationUnits.0" name="i" usageInVariableAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@body/@statements.1/@expression/@leftOperand //@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@body/@statements.1/@updaters.0/@operand">
<initializer xsi:type="java:NumberLiteral" originalCompilationUnit="//@compilationUnits.0" tokenValue="0"/>
</fragments>
<modifier/>
</initializers>
<body xsi:type="java:Block" originalCompilationUnit="//@compilationUnits.0">
<statements xsi:type="java:ExpressionStatement" originalCompilationUnit="//@compilationUnits.0">
<expression xsi:type="java:Assignment" originalCompilationUnit="//@compilationUnits.0" operator="+=">
<leftHandSide xsi:type="java:SingleVariableAccess" variable="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@body/@statements.0/@fragments.0"/>
<rightHandSide xsi:type="java:SingleVariableAccess" variable="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@fragments.0"/>
</expression>
</statements>
</body>
</statements>
<statements xsi:type="java:VariableDeclarationStatement" originalCompilationUnit="//@compilationUnits.0">
<type type="//@orphanTypes.9"/>
<fragments originalCompilationUnit="//@compilationUnits.0" name="numbers" usageInVariableAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@body/@statements.3/@expression">
<initializer xsi:type="java:ClassInstanceCreation" originalCompilationUnit="//@compilationUnits.0" method="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.0">
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
</initializer>
</fragments>
<modifier/>
</statements>
<statements xsi:type="java:EnhancedForStatement" originalCompilationUnit="//@compilationUnits.0">
<body xsi:type="java:Block" originalCompilationUnit="//@compilationUnits.0">
<statements xsi:type="java:ExpressionStatement" originalCompilationUnit="//@compilationUnits.0">
<expression xsi:type="java:Assignment" originalCompilationUnit="//@compilationUnits.0" operator="+=">
<leftHandSide xsi:type="java:SingleVariableAccess" variable="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@body/@statements.0/@fragments.0"/>
<rightHandSide xsi:type="java:SingleVariableAccess" variable="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@body/@statements.3/@parameter"/>
</expression>
</statements>
</body>
<expression xsi:type="java:SingleVariableAccess" variable="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@body/@statements.2/@fragments.0"/>
<parameter originalCompilationUnit="//@compilationUnits.0" name="j" usageInVariableAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@body/@statements.3/@body/@statements.0/@expression/@rightHandSide">
<modifier/>
<type type="//@ownedElements.1/@ownedPackages.1/@ownedElements.5"/>
</parameter>
</statements>
<statements xsi:type="java:TryStatement" originalCompilationUnit="//@compilationUnits.0">
<body originalCompilationUnit="//@compilationUnits.0">
<statements 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.1/@body/@statements.0/@fragments.0"/>
<rightHandSide xsi:type="java:NumberLiteral" originalCompilationUnit="//@compilationUnits.0" tokenValue="2"/>
</expression>
</statements>
</body>
<catchClauses originalCompilationUnit="//@compilationUnits.0">
<exception originalCompilationUnit="//@compilationUnits.0" name="e">
<modifier/>
<type type="//@ownedElements.1/@ownedPackages.1/@ownedElements.7"/>
</exception>
<body originalCompilationUnit="//@compilationUnits.0">
<statements xsi:type="java:ExpressionStatement" originalCompilationUnit="//@compilationUnits.0">
<expression xsi:type="java:MethodInvocation" originalCompilationUnit="//@compilationUnits.0" method="//@ownedElements.1/@ownedPackages.2/@ownedElements.1/@bodyDeclarations.0">
<arguments xsi:type="java:StringLiteral" originalCompilationUnit="//@compilationUnits.0" escapedValue="&quot;erreur&quot;"/>
<expression xsi:type="java:SingleVariableAccess" variable="//@ownedElements.1/@ownedPackages.1/@ownedElements.9/@bodyDeclarations.0/@fragments.0">
<qualifier xsi:type="java:TypeAccess" type="//@ownedElements.1/@ownedPackages.1/@ownedElements.9"/>
</expression>
</expression>
</statements>
</body>
</catchClauses>
</statements>
</body>
<parameters originalCompilationUnit="//@compilationUnits.0" name="ar" extraArrayDimensions="1">
<modifier/>
<type type="//@ownedElements.1/@ownedPackages.1/@ownedElements.2"/>
</parameters>
<returnType type="//@orphanTypes.5"/>
</bodyDeclarations>
</ownedElements>
</ownedElements>
<ownedElements name="java" proxy="true">
<ownedPackages name="util" proxy="true">
<ownedElements xsi:type="java:ClassDeclaration" name="ArrayList" proxy="true" usagesInImports="//@compilationUnits.0/@imports.0" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@body/@statements.2/@fragments.0/@initializer/@type">
<bodyDeclarations xsi:type="java:ConstructorDeclaration" name="ArrayList" proxy="true" usages="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@body/@statements.2/@fragments.0/@initializer"/>
<superInterfaces type="//@ownedElements.1/@ownedPackages.0/@ownedElements.4"/>
<superInterfaces type="//@ownedElements.1/@ownedPackages.0/@ownedElements.5"/>
<superInterfaces type="//@ownedElements.1/@ownedPackages.1/@ownedElements.1"/>
<superInterfaces type="//@ownedElements.1/@ownedPackages.2/@ownedElements.0"/>
<typeParameters name="E" proxy="true"/>
<superClass type="//@ownedElements.1/@ownedPackages.0/@ownedElements.1"/>
</ownedElements>
<ownedElements xsi:type="java:ClassDeclaration" name="AbstractList" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@superClass">
<superInterfaces type="//@ownedElements.1/@ownedPackages.0/@ownedElements.4"/>
<typeParameters name="E" proxy="true"/>
<superClass type="//@ownedElements.1/@ownedPackages.0/@ownedElements.2"/>
</ownedElements>
<ownedElements xsi:type="java:ClassDeclaration" name="AbstractCollection" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.1/@superClass">
<superInterfaces type="//@ownedElements.1/@ownedPackages.0/@ownedElements.3"/>
<typeParameters name="E" proxy="true"/>
</ownedElements>
<ownedElements xsi:type="java:InterfaceDeclaration" name="Collection" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.2/@superInterfaces.0 //@ownedElements.1/@ownedPackages.0/@ownedElements.4/@superInterfaces.0">
<superInterfaces type="//@ownedElements.1/@ownedPackages.1/@ownedElements.0"/>
<typeParameters name="E" proxy="true"/>
</ownedElements>
<ownedElements xsi:type="java:InterfaceDeclaration" name="List" proxy="true" usagesInImports="//@compilationUnits.0/@imports.1" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.1/@superInterfaces.0 //@ownedElements.1/@ownedPackages.0/@ownedElements.0/@superInterfaces.0 //@orphanTypes.9/@type">
<superInterfaces type="//@ownedElements.1/@ownedPackages.0/@ownedElements.3"/>
<typeParameters name="E" proxy="true"/>
</ownedElements>
<ownedElements xsi:type="java:InterfaceDeclaration" name="RandomAccess" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@superInterfaces.1"/>
</ownedPackages>
<ownedPackages name="lang" proxy="true">
<ownedElements xsi:type="java:InterfaceDeclaration" name="Iterable" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.3/@superInterfaces.0">
<typeParameters name="T" proxy="true"/>
</ownedElements>
<ownedElements xsi:type="java:InterfaceDeclaration" name="Cloneable" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@superInterfaces.2"/>
<ownedElements xsi:type="java:ClassDeclaration" name="String" proxy="true" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@parameters.0/@type //@ownedElements.1/@ownedPackages.2/@ownedElements.1/@bodyDeclarations.0/@parameters.0/@type">
<superInterfaces type="//@ownedElements.1/@ownedPackages.2/@ownedElements.0"/>
<superInterfaces type="//@ownedElements.1/@ownedPackages.1/@ownedElements.3"/>
<superInterfaces type="//@ownedElements.1/@ownedPackages.1/@ownedElements.4"/>
</ownedElements>
<ownedElements xsi:type="java:InterfaceDeclaration" name="Comparable" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.1/@ownedElements.2/@superInterfaces.1 //@ownedElements.1/@ownedPackages.1/@ownedElements.5/@superInterfaces.0">
<typeParameters name="T" proxy="true"/>
</ownedElements>
<ownedElements xsi:type="java:InterfaceDeclaration" name="CharSequence" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.1/@ownedElements.2/@superInterfaces.2"/>
<ownedElements xsi:type="java:ClassDeclaration" name="Integer" proxy="true" usagesInTypeAccess="//@orphanTypes.9/@typeArguments.0 //@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@body/@statements.3/@parameter/@type">
<superInterfaces type="//@ownedElements.1/@ownedPackages.1/@ownedElements.3"/>
<superClass type="//@ownedElements.1/@ownedPackages.1/@ownedElements.6"/>
</ownedElements>
<ownedElements xsi:type="java:ClassDeclaration" name="Number" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.1/@ownedElements.5/@superClass">
<superInterfaces type="//@ownedElements.1/@ownedPackages.2/@ownedElements.0"/>
</ownedElements>
<ownedElements xsi:type="java:ClassDeclaration" name="Exception" proxy="true" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@body/@statements.4/@catchClauses.0/@exception/@type">
<superClass type="//@ownedElements.1/@ownedPackages.1/@ownedElements.8"/>
</ownedElements>
<ownedElements xsi:type="java:ClassDeclaration" name="Throwable" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.1/@ownedElements.7/@superClass">
<superInterfaces type="//@ownedElements.1/@ownedPackages.2/@ownedElements.0"/>
</ownedElements>
<ownedElements xsi:type="java:ClassDeclaration" name="System" proxy="true" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@body/@statements.4/@catchClauses.0/@body/@statements.0/@expression/@expression/@qualifier">
<bodyDeclarations xsi:type="java:FieldDeclaration" proxy="true">
<fragments name="err" proxy="true" usageInVariableAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@body/@statements.4/@catchClauses.0/@body/@statements.0/@expression/@expression"/>
</bodyDeclarations>
</ownedElements>
<ownedElements xsi:type="java:InterfaceDeclaration" name="AutoCloseable" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.2/@ownedElements.4/@superInterfaces.0"/>
<ownedElements xsi:type="java:InterfaceDeclaration" name="Appendable" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.2/@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.3 //@ownedElements.1/@ownedPackages.1/@ownedElements.2/@superInterfaces.0 //@ownedElements.1/@ownedPackages.1/@ownedElements.6/@superInterfaces.0 //@ownedElements.1/@ownedPackages.1/@ownedElements.8/@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.1/@body/@statements.4/@catchClauses.0/@body/@statements.0/@expression">
<parameters name="arg0" proxy="true">
<type type="//@ownedElements.1/@ownedPackages.1/@ownedElements.2"/>
</parameters>
</bodyDeclarations>
<superInterfaces type="//@ownedElements.1/@ownedPackages.1/@ownedElements.11"/>
<superInterfaces type="//@ownedElements.1/@ownedPackages.2/@ownedElements.4"/>
<superClass type="//@ownedElements.1/@ownedPackages.2/@ownedElements.2"/>
</ownedElements>
<ownedElements xsi:type="java:ClassDeclaration" name="FilterOutputStream" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.2/@ownedElements.1/@superClass">
<superClass type="//@ownedElements.1/@ownedPackages.2/@ownedElements.3"/>
</ownedElements>
<ownedElements xsi:type="java:ClassDeclaration" name="OutputStream" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.2/@ownedElements.2/@superClass">
<superInterfaces type="//@ownedElements.1/@ownedPackages.2/@ownedElements.4"/>
<superInterfaces type="//@ownedElements.1/@ownedPackages.2/@ownedElements.5"/>
</ownedElements>
<ownedElements xsi:type="java:InterfaceDeclaration" name="Closeable" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.2/@ownedElements.3/@superInterfaces.0 //@ownedElements.1/@ownedPackages.2/@ownedElements.1/@superInterfaces.1">
<superInterfaces type="//@ownedElements.1/@ownedPackages.1/@ownedElements.10"/>
</ownedElements>
<ownedElements xsi:type="java:InterfaceDeclaration" name="Flushable" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.2/@ownedElements.3/@superInterfaces.1"/>
</ownedPackages>
</ownedElements>
<orphanTypes xsi:type="java:PrimitiveTypeInt" name="int" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@type //@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@body/@statements.0/@type //@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@body/@statements.1/@initializers.0/@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"/>
<orphanTypes xsi:type="java:PrimitiveTypeVoid" name="void" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@returnType"/>
<orphanTypes xsi:type="java:PrimitiveTypeChar" name="char"/>
<orphanTypes xsi:type="java:PrimitiveTypeShort" name="short"/>
<orphanTypes xsi:type="java:PrimitiveTypeByte" name="byte"/>
<orphanTypes xsi:type="java:ParameterizedType" name="java.util.List&lt;java.lang.Integer>" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@body/@statements.2/@type">
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.4"/>
<typeArguments type="//@ownedElements.1/@ownedPackages.1/@ownedElements.5"/>
</orphanTypes>
<compilationUnits name="Something.java" originalFilePath="C:\Users\Marion\_FACULTE\_M2\Model_photon\shortvariablename\src\shortvariablename\Something.java" package="//@ownedElements.0" types="//@ownedElements.0/@ownedElements.0">
<imports originalCompilationUnit="//@compilationUnits.0" importedElement="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
<imports originalCompilationUnit="//@compilationUnits.0" importedElement="//@ownedElements.1/@ownedPackages.0/@ownedElements.4"/>
</compilationUnits>
</java:Model>
......@@ -47,6 +47,7 @@ helper def: allMeasures(project : java!Model): Set(smm!Measure) =
thisModule.tooManyStaticImports(),
thisModule.avoidDollarSigns(),
thisModule.shortClassName(),
thisModule.shortVariableName(),
thisModule.extendsObject(),
thisModule.unnecessaryReturn(),
thisModule.longVariable(),
......@@ -94,13 +95,22 @@ helper def: allMeasures(project : java!Model): Set(smm!Measure) =
thisModule.emptyTryBlock(),
thisModule.emptyWhileStmt(),
thisModule.dontImportSun(),
thisModule.emptySwitchStatement(),
thisModule.emptySynchronizedBlock(),
thisModule.emptyFinallyBlock(),
thisModule.emptyfinalizeMethod(),
--thisModule.doNotThrowExceptionInFinally(),
--thisModule.finalizeShouldBeProtected(),
-- Best practices rules
thisModule.avoidThrowingNewInstanceOfSameException(),
thisModule.useAssertTrueInsteadOfAssertEquals(),
thisModule.useAssertSameInsteadOfAssertTrue(),
thisModule.switchDensity()
--thisModule.replaceVectorToList()
--thisModule.unusedPrivateMethod ()
--thisModule.avoidStringBufferField()
};
......@@ -187,6 +197,26 @@ rule MesureShortClassName(class : java!ClassDeclaration) {
}
}
-- A Measure instance if the variable violates the rule 'ShortVariableName'.
rule MesureShortVariableName(variable : java!VariableDeclaration) {
to
om: smm!ObservedMeasure (
measure <- noc,
measurements <- measurement
),
noc: smm!DimensionalMeasure (
name <- 'ShortVariableName',
shortDescription <- 'Short Variable names with fewer than e.g. three characters are not recommended.'
),
measurement: smm!DirectMeasurement (
error <- 'The Variable ' + variable.name + ' is too short.'
)
do {
noc;
}
}
-- creates a new Measure when Thread.run() is used instead of Thread.start()
rule MeasureDontCallThreadRun(method : java!MethodInvocation) {
......@@ -1097,26 +1127,85 @@ rule MesureFinalizeShouldBeProtected(m : java!MethodDeclaration) {
noc;
}
}
-----------------------EmptySwitchStatement---------------------------------------------
-- -----A Measure instance if the class use a Vector instead of ArrayList
rule RuleUseArrayListInsteadOfVector(tab :java!Package) {
-- A Measure instance if the class violates the rule 'EmptySwitchStatement'
rule MeasureEmptySwitchStatement(switchStatement: java!SwitchStatement) {
to
om: smm!ObservedMeasure (
measure <- noc,
measurements <- measurement
),
noc: smm!DimensionalMeasure (
name <- 'Use ArrayList Instead Of Vector',
shortDescription <- 'ArrayList is a much better Collection implementation than Vector'
noc: smm!DimensionalMeasure (
name <- 'Empty Switch Statement ',
shortDescription <- 'Empty Switch statements serve no purpose and should be removed.'
),
measurement: smm!DirectMeasurement (
error<- 'The Array Type Vector violates the rule Use ArrayList instead of Vector.'
error <- 'EmptyswitchStatement is detected in ' + switchStatement.originalCompilationUnit.name
)
do {
noc;
}
}
--------------------------------EmptySynchronizedBlock---------------------------------------------
-- A Measure instance if the class violates the rule 'EmptySynchronizedBlock'
rule MeasureEmptySynchronizedBlock(synchronizedBlock: java!SynchronizedStatement) {
to
om: smm!ObservedMeasure (
measure <- noc,
measurements <- measurement
),
noc: smm!DimensionalMeasure (
name <- 'Empty Synchronized Block ',
shortDescription <- 'Empty Synchronized Block serve no purpose and should be removed.'
),
measurement: smm!DirectMeasurement (
error <- 'EmptySynchronizedBlock is detected in ' + synchronizedBlock.originalCompilationUnit.name
)
do {
noc;
}
}
--------------------- EmptyFinallyBlock----------------------------------
--A measure instance if the class violates the rule EmptyFinallyBlock.
rule MeasureEmptyFinallyBlock(finallyBlock : java!TryStatement) {
to
om: smm!ObservedMeasure (
measure <- noc,
measurements <- measurement
),
noc: smm!DimensionalMeasure (
name <- 'EmptyFinallyBlock',
shortDescription <- ': Avoid empty Finally blocks - what s the point?'
),
measurement: smm!DirectMeasurement (
error <- 'EmptyFinallyBlock is detected in ' + finallyBlock.originalCompilationUnit.name