Commit b93f735f authored by Gerson SUNYE's avatar Gerson SUNYE
Browse files

Merge branch 'master' into 'master'

Fix #901, #898, #810 : ShortInstantiation 1pts & LongInstantiation 1pts & DoNotExtendJavaLangThrowable 2pts

Closes #901, #898, and #810

See merge request naomod/mde/projet-2019!36
parents 5532f0ec 1335df21
<?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="LongInstantiation">
<ownedElements name="(default package)">
<ownedElements xsi:type="java:ClassDeclaration" originalCompilationUnit="//@compilationUnits.0" name="LongPass">
<modifier visibility="public"/>
<bodyDeclarations xsi:type="java:FieldDeclaration" originalCompilationUnit="//@compilationUnits.0">
<modifier/>
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
<fragments originalCompilationUnit="//@compilationUnits.0" name="i">
<initializer xsi:type="java:MethodInvocation" originalCompilationUnit="//@compilationUnits.0" method="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.0">
<arguments xsi:type="java:NumberLiteral" originalCompilationUnit="//@compilationUnits.0" tokenValue="0"/>
<expression xsi:type="java:TypeAccess" type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
</initializer>
</fragments>
</bodyDeclarations>
<bodyDeclarations xsi:type="java:FieldDeclaration" originalCompilationUnit="//@compilationUnits.0">
<modifier/>
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.3"/>
<fragments originalCompilationUnit="//@compilationUnits.0" name="name">
<initializer xsi:type="java:StringLiteral" originalCompilationUnit="//@compilationUnits.0" escapedValue="&quot;culte&quot;"/>
</fragments>
</bodyDeclarations>
</ownedElements>
<ownedElements xsi:type="java:ClassDeclaration" originalCompilationUnit="//@compilationUnits.1" name="LongNotPass1">
<modifier visibility="public"/>
<bodyDeclarations xsi:type="java:FieldDeclaration" originalCompilationUnit="//@compilationUnits.1">
<modifier/>
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
<fragments originalCompilationUnit="//@compilationUnits.1" name="i">
<initializer xsi:type="java:ClassInstanceCreation" originalCompilationUnit="//@compilationUnits.1" method="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.1">
<arguments xsi:type="java:NumberLiteral" originalCompilationUnit="//@compilationUnits.1" tokenValue="0"/>
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
</initializer>
</fragments>
</bodyDeclarations>
</ownedElements>
<ownedElements xsi:type="java:ClassDeclaration" originalCompilationUnit="//@compilationUnits.2" name="LongNotPass2">
<modifier visibility="public"/>
<bodyDeclarations xsi:type="java:FieldDeclaration" originalCompilationUnit="//@compilationUnits.2">
<modifier/>
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
<fragments originalCompilationUnit="//@compilationUnits.2" name="x">
<initializer xsi:type="java:MethodInvocation" originalCompilationUnit="//@compilationUnits.2" method="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.0">
<arguments xsi:type="java:NumberLiteral" originalCompilationUnit="//@compilationUnits.2" tokenValue="0"/>
<expression xsi:type="java:TypeAccess" type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
</initializer>
</fragments>
</bodyDeclarations>
<bodyDeclarations xsi:type="java:FieldDeclaration" originalCompilationUnit="//@compilationUnits.2">
<modifier/>
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
<fragments originalCompilationUnit="//@compilationUnits.2" name="i">
<initializer xsi:type="java:ClassInstanceCreation" originalCompilationUnit="//@compilationUnits.2" method="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.1">
<arguments xsi:type="java:NumberLiteral" originalCompilationUnit="//@compilationUnits.2" tokenValue="0"/>
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
</initializer>
</fragments>
</bodyDeclarations>
<bodyDeclarations xsi:type="java:FieldDeclaration" originalCompilationUnit="//@compilationUnits.2">
<modifier/>
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
<fragments originalCompilationUnit="//@compilationUnits.2" name="i2">
<initializer xsi:type="java:ClassInstanceCreation" originalCompilationUnit="//@compilationUnits.2" method="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.1">
<arguments xsi:type="java:NumberLiteral" originalCompilationUnit="//@compilationUnits.2" tokenValue="1"/>
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
</initializer>
</fragments>
</bodyDeclarations>
</ownedElements>
</ownedElements>
<ownedElements name="java" proxy="true">
<ownedPackages name="lang" proxy="true">
<ownedElements xsi:type="java:ClassDeclaration" name="Long" proxy="true" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@type //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@fragments.0/@initializer/@expression //@ownedElements.0/@ownedElements.1/@bodyDeclarations.0/@type //@ownedElements.0/@ownedElements.1/@bodyDeclarations.0/@fragments.0/@initializer/@type //@ownedElements.0/@ownedElements.2/@bodyDeclarations.0/@type //@ownedElements.0/@ownedElements.2/@bodyDeclarations.0/@fragments.0/@initializer/@expression //@ownedElements.0/@ownedElements.2/@bodyDeclarations.1/@type //@ownedElements.0/@ownedElements.2/@bodyDeclarations.1/@fragments.0/@initializer/@type //@ownedElements.0/@ownedElements.2/@bodyDeclarations.2/@type //@ownedElements.0/@ownedElements.2/@bodyDeclarations.2/@fragments.0/@initializer/@type">
<bodyDeclarations xsi:type="java:MethodDeclaration" name="valueOf" proxy="true" usages="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@fragments.0/@initializer //@ownedElements.0/@ownedElements.2/@bodyDeclarations.0/@fragments.0/@initializer">
<parameters name="arg0" proxy="true">
<type type="//@orphanTypes.1"/>
</parameters>
</bodyDeclarations>
<bodyDeclarations xsi:type="java:ConstructorDeclaration" name="Long" proxy="true" usages="//@ownedElements.0/@ownedElements.1/@bodyDeclarations.0/@fragments.0/@initializer //@ownedElements.0/@ownedElements.2/@bodyDeclarations.1/@fragments.0/@initializer //@ownedElements.0/@ownedElements.2/@bodyDeclarations.2/@fragments.0/@initializer">
<parameters name="arg0" proxy="true">
<type type="//@orphanTypes.1"/>
</parameters>
</bodyDeclarations>
<superInterfaces type="//@ownedElements.1/@ownedPackages.0/@ownedElements.2"/>
<superClass type="//@ownedElements.1/@ownedPackages.0/@ownedElements.1"/>
</ownedElements>
<ownedElements xsi:type="java:ClassDeclaration" name="Number" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@superClass">
<superInterfaces type="//@ownedElements.1/@ownedPackages.1/@ownedElements.0"/>
</ownedElements>
<ownedElements xsi:type="java:InterfaceDeclaration" name="Comparable" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@superInterfaces.0 //@ownedElements.1/@ownedPackages.0/@ownedElements.3/@superInterfaces.1">
<typeParameters name="T" proxy="true"/>
</ownedElements>
<ownedElements xsi:type="java:ClassDeclaration" name="String" proxy="true" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@type">
<superInterfaces type="//@ownedElements.1/@ownedPackages.1/@ownedElements.0"/>
<superInterfaces type="//@ownedElements.1/@ownedPackages.0/@ownedElements.2"/>
<superInterfaces type="//@ownedElements.1/@ownedPackages.0/@ownedElements.4"/>
</ownedElements>
<ownedElements xsi:type="java:InterfaceDeclaration" name="CharSequence" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.3/@superInterfaces.2"/>
</ownedPackages>
<ownedPackages name="io" proxy="true">
<ownedElements xsi:type="java:InterfaceDeclaration" name="Serializable" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.1/@superInterfaces.0 //@ownedElements.1/@ownedPackages.0/@ownedElements.3/@superInterfaces.0"/>
</ownedPackages>
</ownedElements>
<orphanTypes xsi:type="java:PrimitiveTypeInt" name="int"/>
<orphanTypes xsi:type="java:PrimitiveTypeLong" name="long" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.0/@parameters.0/@type //@ownedElements.1/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.1/@parameters.0/@type"/>
<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="LongPass.java" originalFilePath="C:\Users\33659\Gerson-workspace\LongInstantiation\src\LongPass.java" types="//@ownedElements.0/@ownedElements.0"/>
<compilationUnits name="LongNotPass1.java" originalFilePath="C:\Users\33659\Gerson-workspace\LongInstantiation\src\LongNotPass1.java" types="//@ownedElements.0/@ownedElements.1"/>
<compilationUnits name="LongNotPass2.java" originalFilePath="C:\Users\33659\Gerson-workspace\LongInstantiation\src\LongNotPass2.java" types="//@ownedElements.0/@ownedElements.2"/>
</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="ShortInstantiation">
<ownedElements name="(default package)">
<ownedElements xsi:type="java:ClassDeclaration" originalCompilationUnit="//@compilationUnits.0" name="ShortNotPass1">
<modifier visibility="public"/>
<bodyDeclarations xsi:type="java:FieldDeclaration" originalCompilationUnit="//@compilationUnits.0">
<modifier/>
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
<fragments originalCompilationUnit="//@compilationUnits.0" name="i">
<initializer xsi:type="java:ClassInstanceCreation" originalCompilationUnit="//@compilationUnits.0" method="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.0">
<arguments xsi:type="java:NumberLiteral" originalCompilationUnit="//@compilationUnits.0" tokenValue="0"/>
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
</initializer>
</fragments>
</bodyDeclarations>
</ownedElements>
<ownedElements xsi:type="java:ClassDeclaration" originalCompilationUnit="//@compilationUnits.1" name="ShortNotPass2">
<modifier visibility="public"/>
<bodyDeclarations xsi:type="java:FieldDeclaration" originalCompilationUnit="//@compilationUnits.1">
<modifier/>
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
<fragments originalCompilationUnit="//@compilationUnits.1" name="x">
<initializer xsi:type="java:MethodInvocation" originalCompilationUnit="//@compilationUnits.1" method="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.1">
<arguments xsi:type="java:NumberLiteral" originalCompilationUnit="//@compilationUnits.1" tokenValue="0"/>
<expression xsi:type="java:TypeAccess" type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
</initializer>
</fragments>
</bodyDeclarations>
<bodyDeclarations xsi:type="java:FieldDeclaration" originalCompilationUnit="//@compilationUnits.1">
<modifier/>
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
<fragments originalCompilationUnit="//@compilationUnits.1" name="i">
<initializer xsi:type="java:ClassInstanceCreation" originalCompilationUnit="//@compilationUnits.1" method="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.0">
<arguments xsi:type="java:NumberLiteral" originalCompilationUnit="//@compilationUnits.1" tokenValue="0"/>
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
</initializer>
</fragments>
</bodyDeclarations>
<bodyDeclarations xsi:type="java:FieldDeclaration" originalCompilationUnit="//@compilationUnits.1">
<modifier/>
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
<fragments originalCompilationUnit="//@compilationUnits.1" name="i2">
<initializer xsi:type="java:ClassInstanceCreation" originalCompilationUnit="//@compilationUnits.1" method="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.0">
<arguments xsi:type="java:NumberLiteral" originalCompilationUnit="//@compilationUnits.1" tokenValue="1"/>
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
</initializer>
</fragments>
</bodyDeclarations>
</ownedElements>
<ownedElements xsi:type="java:ClassDeclaration" originalCompilationUnit="//@compilationUnits.2" name="ShortPass">
<modifier visibility="public"/>
<bodyDeclarations xsi:type="java:FieldDeclaration" originalCompilationUnit="//@compilationUnits.2">
<modifier/>
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
<fragments originalCompilationUnit="//@compilationUnits.2" name="i">
<initializer xsi:type="java:MethodInvocation" originalCompilationUnit="//@compilationUnits.2" method="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.1">
<arguments xsi:type="java:NumberLiteral" originalCompilationUnit="//@compilationUnits.2" tokenValue="0"/>
<expression xsi:type="java:TypeAccess" type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
</initializer>
</fragments>
</bodyDeclarations>
<bodyDeclarations xsi:type="java:FieldDeclaration" originalCompilationUnit="//@compilationUnits.2">
<modifier/>
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.3"/>
<fragments originalCompilationUnit="//@compilationUnits.2" name="name">
<initializer xsi:type="java:StringLiteral" originalCompilationUnit="//@compilationUnits.2" escapedValue="&quot;culte&quot;"/>
</fragments>
</bodyDeclarations>
</ownedElements>
</ownedElements>
<ownedElements name="java" proxy="true">
<ownedPackages name="lang" proxy="true">
<ownedElements xsi:type="java:ClassDeclaration" name="Short" proxy="true" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@type //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@fragments.0/@initializer/@type //@ownedElements.0/@ownedElements.1/@bodyDeclarations.0/@type //@ownedElements.0/@ownedElements.1/@bodyDeclarations.0/@fragments.0/@initializer/@expression //@ownedElements.0/@ownedElements.1/@bodyDeclarations.1/@type //@ownedElements.0/@ownedElements.1/@bodyDeclarations.1/@fragments.0/@initializer/@type //@ownedElements.0/@ownedElements.1/@bodyDeclarations.2/@type //@ownedElements.0/@ownedElements.1/@bodyDeclarations.2/@fragments.0/@initializer/@type //@ownedElements.0/@ownedElements.2/@bodyDeclarations.0/@type //@ownedElements.0/@ownedElements.2/@bodyDeclarations.0/@fragments.0/@initializer/@expression">
<bodyDeclarations xsi:type="java:ConstructorDeclaration" name="Short" proxy="true" usages="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@fragments.0/@initializer //@ownedElements.0/@ownedElements.1/@bodyDeclarations.1/@fragments.0/@initializer //@ownedElements.0/@ownedElements.1/@bodyDeclarations.2/@fragments.0/@initializer">
<parameters name="arg0" proxy="true">
<type type="//@orphanTypes.7"/>
</parameters>
</bodyDeclarations>
<bodyDeclarations xsi:type="java:MethodDeclaration" name="valueOf" proxy="true" usages="//@ownedElements.0/@ownedElements.1/@bodyDeclarations.0/@fragments.0/@initializer //@ownedElements.0/@ownedElements.2/@bodyDeclarations.0/@fragments.0/@initializer">
<parameters name="arg0" proxy="true">
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.3"/>
</parameters>
</bodyDeclarations>
<superInterfaces type="//@ownedElements.1/@ownedPackages.0/@ownedElements.2"/>
<superClass type="//@ownedElements.1/@ownedPackages.0/@ownedElements.1"/>
</ownedElements>
<ownedElements xsi:type="java:ClassDeclaration" name="Number" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@superClass">
<superInterfaces type="//@ownedElements.1/@ownedPackages.1/@ownedElements.0"/>
</ownedElements>
<ownedElements xsi:type="java:InterfaceDeclaration" name="Comparable" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@superInterfaces.0 //@ownedElements.1/@ownedPackages.0/@ownedElements.3/@superInterfaces.1">
<typeParameters name="T" proxy="true"/>
</ownedElements>
<ownedElements xsi:type="java:ClassDeclaration" name="String" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.1/@parameters.0/@type //@ownedElements.0/@ownedElements.2/@bodyDeclarations.1/@type">
<superInterfaces type="//@ownedElements.1/@ownedPackages.1/@ownedElements.0"/>
<superInterfaces type="//@ownedElements.1/@ownedPackages.0/@ownedElements.2"/>
<superInterfaces type="//@ownedElements.1/@ownedPackages.0/@ownedElements.4"/>
</ownedElements>
<ownedElements xsi:type="java:InterfaceDeclaration" name="CharSequence" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.3/@superInterfaces.2"/>
</ownedPackages>
<ownedPackages name="io" proxy="true">
<ownedElements xsi:type="java:InterfaceDeclaration" name="Serializable" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.1/@superInterfaces.0 //@ownedElements.1/@ownedPackages.0/@ownedElements.3/@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"/>
<orphanTypes xsi:type="java:PrimitiveTypeChar" name="char"/>
<orphanTypes xsi:type="java:PrimitiveTypeShort" name="short" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.0/@parameters.0/@type"/>
<orphanTypes xsi:type="java:PrimitiveTypeByte" name="byte"/>
<compilationUnits name="ShortNotPass1.java" originalFilePath="C:\Users\33659\Gerson-workspace\ShortInstantiation\src\ShortNotPass1.java" types="//@ownedElements.0/@ownedElements.0"/>
<compilationUnits name="ShortNotPass2.java" originalFilePath="C:\Users\33659\Gerson-workspace\ShortInstantiation\src\ShortNotPass2.java" types="//@ownedElements.0/@ownedElements.1"/>
<compilationUnits name="ShortPass.java" originalFilePath="C:\Users\33659\Gerson-workspace\ShortInstantiation\src\ShortPass.java" types="//@ownedElements.0/@ownedElements.2"/>
</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="throwable">
<ownedElements name="throwable">
<ownedElements xsi:type="java:ClassDeclaration" originalCompilationUnit="//@compilationUnits.0" name="ThrowablePass3">
<modifier visibility="public"/>
</ownedElements>
<ownedElements xsi:type="java:ClassDeclaration" originalCompilationUnit="//@compilationUnits.1" name="ThrowablePass1">
<modifier visibility="public"/>
<superClass type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
</ownedElements>
<ownedElements xsi:type="java:ClassDeclaration" originalCompilationUnit="//@compilationUnits.2" name="ThrowableNotPass4">
<modifier visibility="public"/>
<superClass type="//@ownedElements.1/@ownedPackages.0/@ownedElements.1"/>
</ownedElements>
<ownedElements xsi:type="java:ClassDeclaration" originalCompilationUnit="//@compilationUnits.3" name="ThrowablePass2">
<modifier visibility="public"/>
</ownedElements>
</ownedElements>
<ownedElements name="java" proxy="true">
<ownedPackages name="lang" proxy="true">
<ownedElements xsi:type="java:ClassDeclaration" name="Object" proxy="true" usagesInTypeAccess="//@ownedElements.0/@ownedElements.1/@superClass"/>
<ownedElements xsi:type="java:ClassDeclaration" name="Throwable" proxy="true" usagesInTypeAccess="//@ownedElements.0/@ownedElements.2/@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.1/@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"/>
<orphanTypes xsi:type="java:PrimitiveTypeChar" name="char"/>
<orphanTypes xsi:type="java:PrimitiveTypeShort" name="short"/>
<orphanTypes xsi:type="java:PrimitiveTypeByte" name="byte"/>
<compilationUnits name="ThrowablePass3.java" originalFilePath="C:\Users\33659\Gerson-workspace\throwable\src\throwable\ThrowablePass3.java" package="//@ownedElements.0" types="//@ownedElements.0/@ownedElements.0"/>
<compilationUnits name="ThrowablePass1.java" originalFilePath="C:\Users\33659\Gerson-workspace\throwable\src\throwable\ThrowablePass1.java" package="//@ownedElements.0" types="//@ownedElements.0/@ownedElements.1"/>
<compilationUnits name="ThrowableNotPass4.java" originalFilePath="C:\Users\33659\Gerson-workspace\throwable\src\throwable\ThrowableNotPass4.java" package="//@ownedElements.0" types="//@ownedElements.0/@ownedElements.2"/>
<compilationUnits name="ThrowablePass2.java" originalFilePath="C:\Users\33659\Gerson-workspace\throwable\src\throwable\ThrowablePass2.java" package="//@ownedElements.0" types="//@ownedElements.0/@ownedElements.3"/>
</java:Model>
......@@ -52,6 +52,8 @@ helper def: allMeasures(project : java!Model): Set(smm!Measure) =
thisModule.tooManyFields(),
thisModule.tooManyMethods(),
thisModule.returnFromFinallyBlock(),
thisModule.longInstantiation(),
thisModule.shortInstantiation(),
thisModule.returnEmptyArrayRatherThanNull(),
thisModule.excessiveParameterList(),
......@@ -71,6 +73,9 @@ helper def: allMeasures(project : java!Model): Set(smm!Measure) =
-- Error prone rules
--
thisModule.missingBreakInSwitch(),
-- Best practicices rules
thisModule.doNotExtendJavaLangThrowable(),
thisModule.avoidThrowingNewInstanceOfSameException()
};
......@@ -253,6 +258,71 @@ rule MeasureTooFewBranchesForASwitchStatement(switchStatement: java!SwitchStatem
tooFewBranchesForASwitchStatement;
}
}
--------------------------------------------- ShortInstantiation ---------------------------------------------
-- A Measure instance if the class violates the rule 'ShortInstantiation'.
rule MeasureShortInstantiation(variable : java!CompilationUnit) {
to
om: smm!ObservedMeasure (
measure <- noc,
measurements <- measurement
),
noc: smm!DimensionalMeasure (
name <- 'ShortInstantiation',
shortDescription <- 'Calling new Short() causes memory allocation that can be avoided by the static Short.valueOf(). It makes use of an internal cache that recycles earlier instances making it more memory efficient. Note that new Short() is deprecated since JDK 9 for that reason.'
),
measurement: smm!DirectMeasurement (
error<-'In the Class '+ variable.name + ' an instantiation of Short must be Short.ValueOf().'
)
do {
noc;
}
}
--------------------------------------------- LongInstantiation ---------------------------------------------
-- A Measure instance if the class violates the rule 'LongInstantiation'.
rule MeasureLongInstantiation(variable : java!CompilationUnit) {
to
om: smm!ObservedMeasure (
measure <- noc,
measurements <- measurement
),
noc: smm!DimensionalMeasure (
name <- 'LongInstantiation',
shortDescription <- 'Calling new Long() causes memory allocation that can be avoided by the static Long.valueOf(). It makes use of an internal cache that recycles earlier instances making it more memory efficient. Note that new Long() is deprecated since JDK 9 for that reason.'
),
measurement: smm!DirectMeasurement (
error<-'In the Class '+ variable.name + ' an instantiation of Long must be Long.ValueOf().'
)
do {
noc;
}
}
--------------------------------------------- DoNotExtendJavaLangThrowable ---------------------------------------------
-- A Measure instance if the class violates the rule DoNotExtendJavaLangThrowable.
rule MeasureDoNotExtendJavaLangThrowable(variable : java!ClassDeclaration) {
to
om: smm!ObservedMeasure (
measure <- noc,
measurements <- measurement
),
noc: smm!DimensionalMeasure (
name <- 'DoNotExtendJavaLangThrowable ',
shortDescription <- 'Extend Exception or RuntimeException instead of Throwable.'
),
measurement: smm!DirectMeasurement (
error<-'In the Class '+ variable.name + ' should not extend Throwable but RuntimeException or Exception .'
)
do {
noc;
}
}
-- Returns the number of branches in the switch statement passed in parameter
helper def: nbBranchesOfASwitchStatement(switchStatement:java!SwitchStatement) : Integer =
......
......@@ -17,4 +17,14 @@ helper def: switchStatementContainsMissingBreaks(ss: java!SwitchStatement): Bool
(thisModule.nbBranchesOfASwitchStatement(ss) - thisModule.nbIntentionalFallThroughOfASwitchStatement(ss)) > thisModule.nbBreakStatementOfASwitchStatement(ss)
;
--------------------------------------------------------------------------------------------------------
\ No newline at end of file
--------------------------------------------- DoNotExtendJavaLangThrowable ---------------------------------------------
-- Rule for metrics DoNotExtendJavaLangThrowable
helper def: doNotExtendJavaLangThrowable() : Set(smm!Measure) =
-- select all class with a superTyper
java!ClassDeclaration.allInstances()->select(it | it.superClass <> OclUndefined)
-- select all class who extend Throwable
->select(it2| it2.superClass.type.name = 'Throwable')
-- collect all results and send an error message
->collect(it3|thisModule.MeasureDoNotExtendJavaLangThrowable(it3))
;
\ No newline at end of file
......@@ -86,6 +86,7 @@ helper def: avoidThrowingNewInstanceOfSameException() : Set(smm!Measure) =
endif
);
--------------------------------------------- AvoidUsingShortType---------------------------------------------
--Detects the use of the primitive type 'short' for rule AvoidUsingShortType. Prefer the use of 'int' instead of 'short'.
......@@ -93,3 +94,27 @@ helper def: avoidUsingShortType() : Set(smm!Measure) =
java!VariableDeclarationStatement.allInstances()
->select(variable | variable.type.type.name = 'short')
->collect(variable | thisModule.MeasureAvoidUsingShortType(variable));
--------------------------------------------- ShortInstantiation ---------------------------------------------
-- Rule for metrics ShortInstantiation : return the set of class Measures that violates the rule.
helper def: shortInstantiation() : Set(smm!Measure) =
-- Take all ClassInstanceCreation with allInstances()
java!ClassInstanceCreation.allInstances()
-- Select all class who declare a Short type
->select(it| it.method.oclIsTypeOf(java!ConstructorDeclaration) and it.method.name = 'Short')
-- collect every results and send an error message
->collect(it2|thisModule.MeasureLongInstantiation(it2.originalCompilationUnit))
;
--------------------------------------------- LongInstantiation ---------------------------------------------
-- Rule for metricsLongInstantiation : return the set of class Measures that violates the rule.
helper def: longInstantiation() : Set(smm!Measure) =
-- Take all ClassInstanceCreation with allInstances()
java!ClassInstanceCreation.allInstances()
-- Select all class who declare a Long type
->select(it| it.method.oclIsTypeOf(java!ConstructorDeclaration) and it.method.name = 'Long')
-- collect every results and send an error message
->collect(it2|thisModule.MeasureLongInstantiation(it2.originalCompilationUnit))
;
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