Commit 9853f6f9 authored by Maxence COUTAND's avatar Maxence COUTAND
Browse files

Fixes #902, #896, #861, #883.

resolve all conflict

and naomod/mde/projet-2019#902

and naomod/mde/projet-2019#896

and naomod/mde/projet-2019#861

and naomod/mde/projet-2019#883
parent f102051e
<?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="add-empty-streaing">
<ownedElements name="(default package)">
<ownedElements xsi:type="java:ClassDeclaration" originalCompilationUnit="//@compilationUnits.0" name="Foo">
<modifier visibility="public"/>
<bodyDeclarations xsi:type="java:FieldDeclaration" originalCompilationUnit="//@compilationUnits.0">
<comments xsi:type="java:LineComment" originalCompilationUnit="//@compilationUnits.0" content="// inefficient"/>
<modifier/>
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
<fragments originalCompilationUnit="//@compilationUnits.0" name="s">
<initializer xsi:type="java:InfixExpression" originalCompilationUnit="//@compilationUnits.0" operator="+">
<rightOperand xsi:type="java:NumberLiteral" originalCompilationUnit="//@compilationUnits.0" tokenValue="123"/>
<leftOperand xsi:type="java:StringLiteral" originalCompilationUnit="//@compilationUnits.0" escapedValue="&quot;&quot;"/>
</initializer>
</fragments>
</bodyDeclarations>
<bodyDeclarations xsi:type="java:FieldDeclaration" originalCompilationUnit="//@compilationUnits.0">
<comments xsi:type="java:LineComment" originalCompilationUnit="//@compilationUnits.0" content="// preferred approach"/>
<modifier/>
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
<fragments originalCompilationUnit="//@compilationUnits.0" name="t">
<initializer xsi:type="java:MethodInvocation" originalCompilationUnit="//@compilationUnits.0" method="//@ownedElements.1/@ownedPackages.0/@ownedElements.3/@bodyDeclarations.0">
<arguments xsi:type="java:NumberLiteral" originalCompilationUnit="//@compilationUnits.0" tokenValue="456"/>
<expression xsi:type="java:TypeAccess" type="//@ownedElements.1/@ownedPackages.0/@ownedElements.3"/>
</initializer>
</fragments>
</bodyDeclarations>
<bodyDeclarations xsi:type="java:MethodDeclaration" originalCompilationUnit="//@compilationUnits.0" name="func">
<modifier visibility="public"/>
<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:NumberLiteral" originalCompilationUnit="//@compilationUnits.0" tokenValue="2"/>
<leftOperand xsi:type="java:StringLiteral" originalCompilationUnit="//@compilationUnits.0" escapedValue="&quot;&quot;"/>
</expression>
</statements>
</body>
<returnType type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
</bodyDeclarations>
</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.0/@type //@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@type //@ownedElements.0/@ownedElements.0/@bodyDeclarations.2/@returnType">
<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 //@ownedElements.1/@ownedPackages.0/@ownedElements.3/@superInterfaces.0">
<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="Integer" proxy="true" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@fragments.0/@initializer/@expression">
<bodyDeclarations xsi:type="java:MethodDeclaration" name="toString" proxy="true" usages="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@fragments.0/@initializer">
<parameters name="arg0" proxy="true">
<type type="//@orphanTypes.0"/>
</parameters>
</bodyDeclarations>
<superInterfaces type="//@ownedElements.1/@ownedPackages.0/@ownedElements.1"/>
<superClass type="//@ownedElements.1/@ownedPackages.0/@ownedElements.4"/>
</ownedElements>
<ownedElements xsi:type="java:ClassDeclaration" name="Number" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.3/@superClass">
<superInterfaces type="//@ownedElements.1/@ownedPackages.1/@ownedElements.0"/>
</ownedElements>
</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.1/@ownedPackages.0/@ownedElements.4/@superInterfaces.0"/>
</ownedPackages>
</ownedElements>
<orphanTypes xsi:type="java:PrimitiveTypeInt" name="int" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.3/@bodyDeclarations.0/@parameters.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"/>
<orphanTypes xsi:type="java:PrimitiveTypeChar" name="char"/>
<orphanTypes xsi:type="java:PrimitiveTypeShort" name="short"/>
<orphanTypes xsi:type="java:PrimitiveTypeByte" name="byte"/>
<compilationUnits name="Foo.java" originalFilePath="C:\Users\maxen\maxence\workspace\ATL\add-empty-streaing\src\Foo.java" commentList="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@comments.0 //@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@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="insuffisente-string-buffer-declaration">
<ownedElements name="(default package)">
<ownedElements xsi:type="java:ClassDeclaration" originalCompilationUnit="//@compilationUnits.0" name="Foo">
<modifier visibility="public"/>
<bodyDeclarations xsi:type="java:MethodDeclaration" originalCompilationUnit="//@compilationUnits.0" name="aFunction">
<modifier visibility="public"/>
<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="badStringBuffer" usageInVariableAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.1/@expression/@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: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:StringLiteral" originalCompilationUnit="//@compilationUnits.0" escapedValue="&quot;This is a long string that will exceed the default 16 characters&quot;"/>
<expression xsi:type="java:SingleVariableAccess" variable="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.0/@fragments.0"/>
</expression>
</statements>
<statements xsi:type="java:VariableDeclarationStatement" originalCompilationUnit="//@compilationUnits.0">
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
<fragments originalCompilationUnit="//@compilationUnits.0" name="goodStringBuffer" usageInVariableAccess="//@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.2">
<arguments xsi:type="java:NumberLiteral" originalCompilationUnit="//@compilationUnits.0" tokenValue="41"/>
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
</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:StringLiteral" originalCompilationUnit="//@compilationUnits.0" escapedValue="&quot;This is a long string, which is pre-sized&quot;"/>
<expression xsi:type="java:SingleVariableAccess" variable="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.2/@fragments.0"/>
</expression>
</statements>
<statements xsi:type="java:VariableDeclarationStatement" originalCompilationUnit="//@compilationUnits.0">
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.6"/>
<fragments originalCompilationUnit="//@compilationUnits.0" name="badStringBuilder" usageInVariableAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.5/@expression/@expression">
<initializer xsi:type="java:ClassInstanceCreation" originalCompilationUnit="//@compilationUnits.0" method="//@ownedElements.1/@ownedPackages.0/@ownedElements.6/@bodyDeclarations.0">
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.6"/>
</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.6/@bodyDeclarations.1">
<arguments xsi:type="java:StringLiteral" originalCompilationUnit="//@compilationUnits.0" escapedValue="&quot;This is a long string that will exceed the default 16 characters&quot;"/>
<expression xsi:type="java:SingleVariableAccess" variable="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.4/@fragments.0"/>
</expression>
</statements>
<statements xsi:type="java:VariableDeclarationStatement" originalCompilationUnit="//@compilationUnits.0">
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.6"/>
<fragments originalCompilationUnit="//@compilationUnits.0" name="goodStringBuilder" usageInVariableAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.7/@expression/@expression">
<initializer xsi:type="java:ClassInstanceCreation" originalCompilationUnit="//@compilationUnits.0" method="//@ownedElements.1/@ownedPackages.0/@ownedElements.6/@bodyDeclarations.2">
<arguments xsi:type="java:NumberLiteral" originalCompilationUnit="//@compilationUnits.0" tokenValue="41"/>
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.6"/>
</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.6/@bodyDeclarations.1">
<arguments xsi:type="java:StringLiteral" originalCompilationUnit="//@compilationUnits.0" escapedValue="&quot;This is a long string, which is pre-sized&quot;"/>
<expression xsi:type="java:SingleVariableAccess" variable="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.6/@fragments.0"/>
</expression>
</statements>
</body>
<returnType type="//@orphanTypes.5"/>
</bodyDeclarations>
</ownedElements>
</ownedElements>
<ownedElements name="java" proxy="true">
<ownedPackages name="lang" proxy="true">
<ownedElements xsi:type="java:ClassDeclaration" name="StringBuffer" proxy="true" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.0/@type //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.0/@fragments.0/@initializer/@type //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.2/@type //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.2/@fragments.0/@initializer/@type">
<bodyDeclarations xsi:type="java:ConstructorDeclaration" name="StringBuffer" proxy="true" usages="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.0/@fragments.0/@initializer"/>
<bodyDeclarations xsi:type="java:MethodDeclaration" name="append" proxy="true" usages="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.1/@expression //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.3/@expression">
<parameters name="arg0" proxy="true">
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.4"/>
</parameters>
</bodyDeclarations>
<bodyDeclarations xsi:type="java:ConstructorDeclaration" name="StringBuffer" proxy="true" usages="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.2/@fragments.0/@initializer">
<parameters name="arg0" proxy="true">
<type type="//@orphanTypes.0"/>
</parameters>
</bodyDeclarations>
<superInterfaces type="//@ownedElements.1/@ownedPackages.1/@ownedElements.0"/>
<superInterfaces type="//@ownedElements.1/@ownedPackages.0/@ownedElements.3"/>
<superClass type="//@ownedElements.1/@ownedPackages.0/@ownedElements.1"/>
</ownedElements>
<ownedElements xsi:type="java:ClassDeclaration" name="AbstractStringBuilder" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@superClass //@ownedElements.1/@ownedPackages.0/@ownedElements.6/@superClass">
<superInterfaces type="//@ownedElements.1/@ownedPackages.0/@ownedElements.2"/>
<superInterfaces type="//@ownedElements.1/@ownedPackages.0/@ownedElements.3"/>
</ownedElements>
<ownedElements xsi:type="java:InterfaceDeclaration" name="Appendable" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.1/@superInterfaces.0"/>
<ownedElements xsi:type="java:InterfaceDeclaration" name="CharSequence" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.1/@superInterfaces.1 //@ownedElements.1/@ownedPackages.0/@ownedElements.0/@superInterfaces.1 //@ownedElements.1/@ownedPackages.0/@ownedElements.4/@superInterfaces.2 //@ownedElements.1/@ownedPackages.0/@ownedElements.6/@superInterfaces.1"/>
<ownedElements xsi:type="java:ClassDeclaration" name="String" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.1/@parameters.0/@type //@ownedElements.1/@ownedPackages.0/@ownedElements.6/@bodyDeclarations.1/@parameters.0/@type">
<superInterfaces type="//@ownedElements.1/@ownedPackages.1/@ownedElements.0"/>
<superInterfaces type="//@ownedElements.1/@ownedPackages.0/@ownedElements.5"/>
<superInterfaces type="//@ownedElements.1/@ownedPackages.0/@ownedElements.3"/>
</ownedElements>
<ownedElements xsi:type="java:InterfaceDeclaration" name="Comparable" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.4/@superInterfaces.1">
<typeParameters name="T" proxy="true"/>
</ownedElements>
<ownedElements xsi:type="java:ClassDeclaration" name="StringBuilder" proxy="true" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.4/@type //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.4/@fragments.0/@initializer/@type //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.6/@type //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.6/@fragments.0/@initializer/@type">
<bodyDeclarations xsi:type="java:ConstructorDeclaration" name="StringBuilder" proxy="true" usages="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.4/@fragments.0/@initializer"/>
<bodyDeclarations xsi:type="java:MethodDeclaration" name="append" proxy="true" usages="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.5/@expression //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.7/@expression">
<parameters name="arg0" proxy="true">
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.4"/>
</parameters>
</bodyDeclarations>
<bodyDeclarations xsi:type="java:ConstructorDeclaration" name="StringBuilder" proxy="true" usages="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.6/@fragments.0/@initializer">
<parameters name="arg0" proxy="true">
<type type="//@orphanTypes.0"/>
</parameters>
</bodyDeclarations>
<superInterfaces type="//@ownedElements.1/@ownedPackages.1/@ownedElements.0"/>
<superInterfaces type="//@ownedElements.1/@ownedPackages.0/@ownedElements.3"/>
<superClass type="//@ownedElements.1/@ownedPackages.0/@ownedElements.1"/>
</ownedElements>
</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.1/@ownedPackages.0/@ownedElements.4/@superInterfaces.0 //@ownedElements.1/@ownedPackages.0/@ownedElements.6/@superInterfaces.0"/>
</ownedPackages>
</ownedElements>
<orphanTypes xsi:type="java:PrimitiveTypeInt" name="int" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.2/@parameters.0/@type //@ownedElements.1/@ownedPackages.0/@ownedElements.6/@bodyDeclarations.2/@parameters.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="Foo.java" originalFilePath="C:\Users\maxen\maxence\workspace\ATL\insuffisente-string-buffer-declaration\src\Foo.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="start-with">
<ownedElements name="(default package)">
<ownedElements xsi:type="java:ClassDeclaration" originalCompilationUnit="//@compilationUnits.0" name="Foo">
<modifier visibility="public"/>
<bodyDeclarations xsi:type="java:MethodDeclaration" originalCompilationUnit="//@compilationUnits.0" name="checkIt">
<modifier/>
<body originalCompilationUnit="//@compilationUnits.0">
<statements xsi:type="java:ReturnStatement" originalCompilationUnit="//@compilationUnits.0">
<expression xsi:type="java:MethodInvocation" originalCompilationUnit="//@compilationUnits.0" method="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.0">
<arguments xsi:type="java:StringLiteral" originalCompilationUnit="//@compilationUnits.0" escapedValue="&quot;a&quot;"/>
<expression xsi:type="java:SingleVariableAccess" variable="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@parameters.0"/>
</expression>
</statements>
</body>
<parameters originalCompilationUnit="//@compilationUnits.0" name="x" usageInVariableAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.0/@expression/@expression">
<modifier/>
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
</parameters>
<returnType type="//@orphanTypes.4"/>
</bodyDeclarations>
<bodyDeclarations xsi:type="java:MethodDeclaration" originalCompilationUnit="//@compilationUnits.0" name="checkItSize2">
<modifier/>
<body originalCompilationUnit="//@compilationUnits.0">
<statements xsi:type="java:ReturnStatement" originalCompilationUnit="//@compilationUnits.0">
<expression xsi:type="java:MethodInvocation" originalCompilationUnit="//@compilationUnits.0" method="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.0">
<arguments xsi:type="java:StringLiteral" originalCompilationUnit="//@compilationUnits.0" escapedValue="&quot;aa&quot;"/>
<expression xsi:type="java:SingleVariableAccess" variable="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@parameters.0"/>
</expression>
</statements>
</body>
<parameters originalCompilationUnit="//@compilationUnits.0" name="x" usageInVariableAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@body/@statements.0/@expression/@expression">
<modifier/>
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
</parameters>
<returnType type="//@orphanTypes.4"/>
</bodyDeclarations>
</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.0/@parameters.0/@type //@ownedElements.1/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.0/@parameters.0/@type //@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@parameters.0/@type">
<bodyDeclarations xsi:type="java:MethodDeclaration" name="startsWith" proxy="true" usages="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.0/@expression //@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@body/@statements.0/@expression">
<parameters name="arg0" proxy="true">
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
</parameters>
</bodyDeclarations>
<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"/>
</ownedPackages>
<ownedPackages name="io" proxy="true">
<ownedElements xsi:type="java:InterfaceDeclaration" name="Serializable" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@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" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@returnType //@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@returnType"/>
<orphanTypes xsi:type="java:PrimitiveTypeVoid" name="void"/>
<orphanTypes xsi:type="java:PrimitiveTypeChar" name="char"/>
<orphanTypes xsi:type="java:PrimitiveTypeShort" name="short"/>
<orphanTypes xsi:type="java:PrimitiveTypeByte" name="byte"/>
<compilationUnits name="Foo.java" originalFilePath="C:\Users\maxen\maxence\workspace\ATL\start-with\src\Foo.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="test-class-without-test">
<ownedElements name="(default package)">
<ownedElements xsi:type="java:ClassDeclaration" originalCompilationUnit="//@compilationUnits.0" name="FooTest">
<modifier visibility="public"/>
<bodyDeclarations xsi:type="java:MethodDeclaration" originalCompilationUnit="//@compilationUnits.0" name="itsNotATest">
<modifier visibility="public"/>
<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="FooTest.java" originalFilePath="C:\Users\maxen\maxence\workspace\ATL\test-class-without-test\src\FooTest.java" types="//@ownedElements.0/@ownedElements.0"/>
</java:Model>
...@@ -72,16 +72,18 @@ helper def: allMeasures(project : java!Model): Set(smm!Measure) = ...@@ -72,16 +72,18 @@ helper def: allMeasures(project : java!Model): Set(smm!Measure) =
-- Performance rules -- Performance rules
-- --
thisModule.addEmptyString(),
thisModule.avoidPrintStackTrace(), thisModule.avoidPrintStackTrace(),
thisModule.avoidRethrowingException(), thisModule.avoidRethrowingException(),
thisModule.avoidUsingShortType(), thisModule.avoidUsingShortType(),
thisModule.emptyStatementBlock(), thisModule.emptyStatementBlock(),
thisModule.insufficientStringBufferDeclaration(),
thisModule.integerInstantiation(), thisModule.integerInstantiation(),
thisModule.useIndexOfChar(), thisModule.useIndexOfChar(),
thisModule.uselessStringValueOf(), thisModule.uselessStringValueOf(),
thisModule.startsWith(),
thisModule.tooFewBranchesForASwitchStatement(), thisModule.tooFewBranchesForASwitchStatement(),
-- Documentation rules -- Documentation rules
-- --
thisModule.commentContent(), thisModule.commentContent(),
...@@ -105,6 +107,7 @@ helper def: allMeasures(project : java!Model): Set(smm!Measure) = ...@@ -105,6 +107,7 @@ helper def: allMeasures(project : java!Model): Set(smm!Measure) =
thisModule.importFromSamePackage(), thisModule.importFromSamePackage(),
thisModule.missingBreakInSwitch(), thisModule.missingBreakInSwitch(),
thisModule.suspiciousEqualsMethodName(), thisModule.suspiciousEqualsMethodName(),
thisModule.testClassWithoutTest(),
thisModule.UnconditionalIfStatement(), thisModule.UnconditionalIfStatement(),
thisModule.UseProperClassLoader(), thisModule.UseProperClassLoader(),
...@@ -1657,3 +1660,87 @@ rule MeasureAbstractClassWithoutAnyMethod(i : java!ClassDeclaration) { ...@@ -1657,3 +1660,87 @@ rule MeasureAbstractClassWithoutAnyMethod(i : java!ClassDeclaration) {
} }
} }
------------------------------------------- start with ------------------------------------------------------------------------------------
rule MeasureStartWith(w: java!MethodInvocation) {
to
om: smm!ObservedMeasure (
measure <- noc,
measurements <- measurement
),
noc: smm!DimensionalMeasure (
name <- 'startWith',
shortDescription <- ': methode startWith found in'
),
measurement: smm!DirectMeasurement (
error <- ' class'+ w.originalCompilationUnit.name+ 'has an instruction that use startWith, use chartAt(0) instand '
)
do {
noc;
}
}
------------------------------------------- insufficientStringBufferDeclaration ------------------------------------------------------------------------------------
rule MeasureInsufficientStringBufferDeclaration(w: java!CompilationUnit) {
to
om: smm!ObservedMeasure (
measure <- noc,
measurements <- measurement
),
noc: smm!DimensionalMeasure (
name <- 'insufficientStringBufferDeclaration',
shortDescription <- ' : insufficientStringBufferDeclaration.'
),
measurement: smm!DirectMeasurement (
error <- ' class'+ w.name+ 'has insufficientStringBufferDeclaration'
)
do {
noc;
}
}
------------------------------------------- testClassWithoutTest ------------------------------------------------------------------------------------
rule MeasureTestClassWithoutTest(w: java!CompilationUnit) {
to
om: smm!ObservedMeasure (
measure <- noc,
measurements <- measurement
),
noc: smm!DimensionalMeasure (
name <- 'testClassWithoutTest',
shortDescription <- ' : testClassWithoutTest.'
),
measurement: smm!DirectMeasurement (
error <- ' class'+ w.name+ 'has testClassWithoutTest'
)
do {
noc;
}
}
------------------------------------------- AddEmptyString ------------------------------------------------------------------------------------
rule MesureAddEmptyString(w: java!CompilationUnit) {
to
om: smm!ObservedMeasure (
measure <- noc,
measurements <- measurement
),
noc: smm!DimensionalMeasure (
name <- 'AddEmptyString',
shortDescription <- ' : AddEmptyString.'
),
measurement: smm!DirectMeasurement (
error <- ' class'+ w.name+ 'has AddEmptyString'
)
do {
noc;
}
}
\ No newline at end of file
...@@ -343,3 +343,20 @@ helper def: methodWithSameNameAsEnclosingClass() : Set(smm!Measure) = ...@@ -343,3 +343,20 @@ helper def: methodWithSameNameAsEnclosingClass() : Set(smm!Measure) =
java!MethodDeclaration.allInstances() java!MethodDeclaration.allInstances()
->select(method | method.name = method.abstractTypeDeclaration.name) ->select(method | method.name = method.abstractTypeDeclaration.name)
->collect(method | thisModule.MeasureMethodWithSameNameAsEnclosingClass(method)); ->collect(method | thisModule.MeasureMethodWithSameNameAsEnclosingClass(method));
------------------------------------------- testClassWithoutTest ------------------------------------------------------------------------------------
helper def: testClassWithoutTest() : Set(smm!Measure) =
java!ClassDeclaration.allInstances()
-> reject(each | each.isProxy())
-> reject(each| each.name.size() < 4)
-> select(each | each.name.substring(each.name.size()-3, each.name.size()) = 'Test')
-> select(each | each.nbTestMethod() = 0)
-> collect(each | thisModule.MeasureTestClassWithoutTest(each.originalCompilationUnit));
helper context java!ClassDeclaration def: nbTestMethod() : Integer =
self.bodyDeclarations
-> select(bodyDeclaration | bodyDeclaration.oclIsTypeOf(java!MethodDeclaration))
-> select(bodyDeclaration | bodyDeclaration.name.size() > 4)
-> select(each | each.name.substring(1, 4) = 'test')
-> size();
...@@ -132,3 +132,61 @@ helper def: stringToString() : Set(smm!Measure) = ...@@ -132,3 +132,61 @@ helper def: stringToString() : Set(smm!Measure) =
-> select( i | i.method.name = 'toString' and i.expression.variable.variablesContainer.type.type.name = 'String') -> select( i | i.method.name = 'toString' and i.expression.variable.variablesContainer.type.type.name = 'String')
-> collect ( i | thisModule.MeasureStringToString(i) ) -> collect ( i | thisModule.MeasureStringToString(i) )
; ;
--------------------------------------------- start with ---------------------------------------------
helper def: startsWith() : Set(smm!Measure) =
-- Take all MethodInvocation with allInstances()
java!MethodInvocation.allInstances()
->select(it| it.method.name= 'startsWith')
->select(it2| thisModule.isLengthUnder1(it2.arguments.first()))
->collect(err|thisModule.MeasureStartWith(err));
----- <=3 because we have to ignore '"' at begin and at end
helper def:isLengthUnder1(s:java!StringLiteral): Boolean =
s.escapedValue.size() <= 3 ;
--------------------------------------------- insufficientStringBufferDeclaration --------------------------------------------------------
helper def: insufficientStringBufferDeclaration() : Set(smm!Measure) =
java!MethodInvocation.allInstances()
->select(it| it.method.name = 'append')
->select(it1| it1.method.abstractTypeDeclaration.name = 'StringBuffer' or it1.method.abstractTypeDeclaration.name = 'StringBuilder')
->select(it2|thisModule.unsuffisentInisialization(it2.expression, it2.arguments.first()))
->collect(it2|thisModule.MeasureInsufficientStringBufferDeclaration(it2.originalCompilationUnit))
;
-- -2 to ignone " at the begin and at end
helper def:unsuffisentInisialization(variable:java!SingleVariableAccess, str:java!StringLiteral): Boolean =
str.escapedValue.size()-2 > thisModule.FixedSize(variable.variable.initializer);
helper def:FixedSize(variable:java!ClassInstanceCreation): Integer =
if variable.arguments.size() = 0 then
16
else
if variable.arguments.first().oclIsTypeOf(java!NumberLiteral) then
thisModule.sizeOf(variable.arguments.first())
else
thisModule.sizeOfLitteral(variable.arguments.first())
endif
endif;
helper def:sizeOfLitteral(variable:java!StringLiteral): Integer =
variable.escapedValue.size();
helper def:sizeOf(variable:java!NumberLiteral): Integer =
variable.tokenValue.toInteger();
------------------------------------------- AddEmptyString ------------------------------------------------------------------------------------
helper def: addEmptyString() : Set(smm!Measure) =
java!InfixExpression.allInstances()
->select(expression | expression.operator.name = '+')
->select(expression | (expression.leftOperand.oclIsTypeOf(java!StringLiteral) and expression.rightOperand.oclIsTypeOf(java!NumberLiteral)) or (expression.leftOperand.oclIsTypeOf(java!NumberLiteral) and expression.rightOperand.oclIsTypeOf(java!StringLiteral)))
->collect(expression | thisModule.MesureAddEmptyString(expression.originalCompilationUnit));
\ No newline at end of file
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