Commit 1387978a authored by Khaled AMIRAT's avatar Khaled AMIRAT
Browse files

Merge branch 'master' into 'E19C506H'

# Conflicts:
#   src/main/atl/analysis.atl
parents c2ff1533 bdf26fc5
= Coventions
== Nommage de fichiers
Le nom du fichier `xmi` utilisé pour valider une règle doit avoir le même nom
que cette règle, dans le format _kebab case_.
Par exemple, si la règle s'appelle `UseArrayListInsteadOfVector`, le nom du
fichier xmi doit être `use-array-list-instead-of-vector.xmi`.
\ 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="UseArrayListInsteadOfVector">
<ownedElements name="(default package)">
<ownedElements xsi:type="java:ClassDeclaration" originalCompilationUnit="//@compilationUnits.0" name="testVectortoArraylist">
<modifier/>
<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">
<comments xsi:type="java:LineComment" originalCompilationUnit="//@compilationUnits.0" content="// create default vector " prefixOfParent="true"/>
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
<fragments originalCompilationUnit="//@compilationUnits.0" name="v" usageInVariableAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.1/@expression/@expression //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.2/@expression/@expression //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.3/@expression/@expression">
<initializer xsi:type="java:ClassInstanceCreation" originalCompilationUnit="//@compilationUnits.0" method="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.0">
<type type="//@orphanTypes.10"/>
</initializer>
</fragments>
<modifier/>
</statements>
<statements xsi:type="java:ExpressionStatement" originalCompilationUnit="//@compilationUnits.0">
<expression xsi:type="java:MethodInvocation" originalCompilationUnit="//@compilationUnits.0" method="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.1">
<arguments xsi:type="java:NumberLiteral" originalCompilationUnit="//@compilationUnits.0" tokenValue="1"/>
<expression xsi:type="java:SingleVariableAccess" variable="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.0/@fragments.0"/>
</expression>
</statements>
<statements xsi:type="java:ExpressionStatement" originalCompilationUnit="//@compilationUnits.0">
<expression xsi:type="java:MethodInvocation" originalCompilationUnit="//@compilationUnits.0" method="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.1">
<arguments xsi:type="java:NumberLiteral" originalCompilationUnit="//@compilationUnits.0" tokenValue="2"/>
<expression xsi:type="java:SingleVariableAccess" variable="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.0/@fragments.0"/>
</expression>
</statements>
<statements xsi:type="java:ExpressionStatement" originalCompilationUnit="//@compilationUnits.0">
<expression xsi:type="java:MethodInvocation" originalCompilationUnit="//@compilationUnits.0" method="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.1">
<arguments xsi:type="java:NumberLiteral" originalCompilationUnit="//@compilationUnits.0" tokenValue="3"/>
<expression xsi:type="java:SingleVariableAccess" variable="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.0/@fragments.0"/>
</expression>
</statements>
</body>
<parameters originalCompilationUnit="//@compilationUnits.0" name="arg">
<modifier/>
<type type="//@orphanTypes.9"/>
</parameters>
<returnType type="//@orphanTypes.5"/>
</bodyDeclarations>
</ownedElements>
</ownedElements>
<ownedElements name="java" proxy="true">
<ownedPackages name="util" proxy="true">
<ownedElements xsi:type="java:ClassDeclaration" name="Vector" proxy="true" usagesInImports="//@compilationUnits.0/@imports.0" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.0/@type //@orphanTypes.10/@type">
<bodyDeclarations xsi:type="java:ConstructorDeclaration" name="Vector" proxy="true" usages="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.0/@fragments.0/@initializer"/>
<bodyDeclarations xsi:type="java:MethodDeclaration" name="add" proxy="true" usages="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.1/@expression //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.2/@expression //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.3/@expression">
<parameters name="arg0" proxy="true">
<type type="//@ownedElements.1/@ownedPackages.1/@ownedElements.7"/>
</parameters>
</bodyDeclarations>
<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" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.1/@superInterfaces.0 //@ownedElements.1/@ownedPackages.0/@ownedElements.0/@superInterfaces.0">
<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="//@orphanTypes.9/@elementType">
<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.10/@typeArguments.0">
<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="Object" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.1/@parameters.0/@type"/>
</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"/>
</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/@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:ArrayType" name="java.lang.String[]" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@parameters.0/@type" dimensions="1">
<elementType type="//@ownedElements.1/@ownedPackages.1/@ownedElements.2"/>
</orphanTypes>
<orphanTypes xsi:type="java:ParameterizedType" name="java.util.Vector&lt;java.lang.Integer>" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.0/@fragments.0/@initializer/@type">
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
<typeArguments type="//@ownedElements.1/@ownedPackages.1/@ownedElements.5"/>
</orphanTypes>
<compilationUnits name="testVectortoArraylist.java" originalFilePath="/home/chanez/Documents/eclipse2/UseArrayListInsteadOfVector/src/testVectortoArraylist.java" commentList="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.0/@comments.0" types="//@ownedElements.0/@ownedElements.0">
<imports originalCompilationUnit="//@compilationUnits.0" importedElement="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
</compilationUnits>
</java:Model>
......@@ -144,3 +144,15 @@ helper def: integerInstantiation() : Set(smm!Measure) =
-- collect every result and sends an error message
->collect(it2|thisModule.MeasureIntegerInstantiation(it2.originalCompilationUnit))
;
--------------------------------------------- Use ArrayList Instead Of Vector ---------------------------------------------
helper def: UseArrayListInsteadOfVector() : Set(smm!Measure) =
-- Browse through all class(CompilationUnit)
--On recupere tout les new Vector et on verifie que le Vector appelé appartient au package java.utile
java!ConstructorDeclaration.allInstances()->
collect(i|i.abstractTypeDeclaration)
->select(p|p.name='Vector')->collect(i|i.package)
->select(p|p.name='util')->collect(i|i.package)
->select(p|p.name='java')
->collect(i |thisModule.RuleUseArrayListInsteadOfVector(i));
Supports Markdown
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