forked from sbegaudeau/Ecore-Scala-Generation
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Key improvements of the generator with:
- better import support. - better respect of the naming convention of Scala. - correction of some invalid code generated. - better default values for fields and operations return value. - new properties files to improve the support of EMF datatypes.
- Loading branch information
1 parent
bdbc8eb
commit d56a4ff
Showing
39 changed files
with
1,467 additions
and
1,198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 32 additions & 2 deletions
34
...beonetwork.pim.ecore.gen.scala/src/org/obeonetwork/pim/ecore/gen/scala/common/imports.mtl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,43 @@ | ||
[comment encoding = UTF-8 /] | ||
[module imports('http://www.eclipse.org/emf/2002/GenModel', 'http://www.eclipse.org/emf/2002/Ecore')] | ||
|
||
[import org::obeonetwork::pim::ecore::gen::scala::common::type /] | ||
[import org::obeonetwork::pim::ecore::gen::scala::services::ecoreGenScalaUtil /] | ||
|
||
[template public genImports(aGenClass : GenClass) post(trim())] | ||
[aGenClass.mandatoryImports()/] | ||
|
||
// [protected ('for imports')] | ||
// [/protected] | ||
[/template] | ||
|
||
[template private mandatoryImports(aGenClass : GenClass)] | ||
[template private mandatoryImports(aGenClass : GenClass) post(trim())] | ||
[for (aString : String | aGenClass.importValue()->asSequence()->formatImport())] | ||
import [aString/]; | ||
[/for] | ||
[/template] | ||
|
||
[query private importValue(aGenClass : GenClass) : OrderedSet(String) = | ||
aGenClass.fieldsType() | ||
->union(aGenClass.operationsType())->asOrderedSet() | ||
->reject(anETypedElement : ETypedElement | anETypedElement.eType.genPackage().trim().size() = 0) | ||
.importQualifiedName()->asOrderedSet() | ||
/] | ||
|
||
[template public importQualifiedName(anETypedElement : ETypedElement)] | ||
[anETypedElement.eType.genQualifiedTypeName()/] | ||
[/template] | ||
|
||
|
||
[query private fieldsType(aGenClass : GenClass) : OrderedSet(ETypedElement) = | ||
aGenClass.ecoreClass.eStructuralFeatures->asOrderedSet() | ||
/] | ||
|
||
[/template] | ||
[query private operationsType(aGenClass : GenClass) : OrderedSet(ETypedElement) = | ||
let operations : OrderedSet(EOperation) = aGenClass.ecoreClass.eOperations in | ||
if (operations->size() > 0) then | ||
operations->filter(ETypedElement)->union(operations.eParameters->filter(ETypedElement)->asOrderedSet())->asOrderedSet() | ||
else | ||
operations.eParameters->asOrderedSet() | ||
endif | ||
/] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...ore.gen.scala/src/org/obeonetwork/pim/ecore/gen/scala/properties/defaultvalues.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
################################################################################ | ||
## Copyright (c) 2012 Obeo. | ||
## All rights reserved. This program and the accompanying materials | ||
## are made available under the terms of the Eclipse Public License v1.0 | ||
## which accompanies this distribution, and is available at | ||
## http://www.eclipse.org/legal/epl-v10.html | ||
## | ||
## Contributors: | ||
## Obeo - initial API and implementation | ||
################################################################################ | ||
__default-value__scala.math.BigDecimal = 0 | ||
__default-value__scala.math.BigInt = 0 | ||
__default-value__scala.Boolean = false | ||
__default-value__scala.Boolean = false | ||
__default-value__scala.Byte = null | ||
__default-value__Array[Byte] = Array[Byte]() | ||
__default-value__scala.Byte = 0 | ||
__default-value__scala.Char = 0 | ||
__default-value__java.lang.Character = new Character(0) | ||
__default-value__java.util.Date = null | ||
__default-value__org.eclipse.emf.common.util.DiagnosticChain = null | ||
__default-value__scala.Double = 0.0 | ||
__default-value__scala.Double = 0.0 | ||
__default-value__scala.collection.mutable.List = List() | ||
__default-value__org.eclipse.emf.common.util.Enumerator = null | ||
__default-value__org.eclipse.emf.ecore.util.FeatureMap = null | ||
__default-value__org.eclipse.emf.ecore.util.FeatureMap$Entry = null | ||
__default-value__scala.Float = 0.0f | ||
__default-value__scala.Float = 0.0f | ||
__default-value__scala.Int = 0 | ||
__default-value__java.lang.Integer = 0 | ||
__default-value__java.lang.reflect.InvocationTargetException = null | ||
__default-value__java.lang.Class = null | ||
__default-value__java.lang.Object = null | ||
__default-value__scala.Long = 0 | ||
__default-value__scala.Long = 0 | ||
__default-value__scala.collection.mutable.Map = null | ||
__default-value__org.eclipse.emf.ecore.resource.Resource = null | ||
__default-value__org.eclipse.emf.ecore.resource.ResourceSet = null | ||
__default-value__scala.Short = 0 | ||
__default-value__scala.Short = 0 | ||
__default-value__java.lang.String = "" | ||
__default-value__org.eclipse.emf.common.util.TreeIterator = null |
54 changes: 54 additions & 0 deletions
54
...k.pim.ecore.gen.scala/src/org/obeonetwork/pim/ecore/gen/scala/properties/types.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
################################################################################ | ||
## Copyright (c) 2012 Obeo. | ||
## All rights reserved. This program and the accompanying materials | ||
## are made available under the terms of the Eclipse Public License v1.0 | ||
## which accompanies this distribution, and is available at | ||
## http://www.eclipse.org/legal/epl-v10.html | ||
## | ||
## Contributors: | ||
## Obeo - initial API and implementation | ||
################################################################################ | ||
__type-convertion__java.math.BigDecimal = scala.math.BigDecimal | ||
__type-convertion__java.math.BigInteger = scala.math.BigInt | ||
__type-convertion__boolean = scala.Boolean | ||
__type-convertion__java.lang.Boolean = scala.Boolean | ||
__type-convertion__byte = scala.Byte | ||
__type-convertion__byte[] = Array[Byte] | ||
__type-convertion__java.lang.Byte = scala.Byte | ||
__type-convertion__char = scala.Char | ||
__type-convertion__java.lang.Character = java.lang.Character | ||
__type-convertion__java.util.Date = java.util.Date | ||
__type-convertion__org.eclipse.emf.common.util.DiagnosticChain = org.eclipse.emf.common.util.DiagnosticChain | ||
__type-convertion__double = scala.Double | ||
__type-convertion__java.lang.Double = scala.Double | ||
__type-convertion__org.eclipse.emf.common.util.EList = scala.collection.mutable.List | ||
__type-convertion__org.eclipse.emf.common.util.Enumerator = org.eclipse.emf.common.util.Enumerator | ||
__type-convertion__org.eclipse.emf.ecore.util.FeatureMap = org.eclipse.emf.ecore.util.FeatureMap | ||
__type-convertion__org.eclipse.emf.ecore.util.FeatureMap$Entry = org.eclipse.emf.ecore.util.FeatureMap$Entry | ||
__type-convertion__float = scala.Float | ||
__type-convertion__java.lang.Float = scala.Float | ||
__type-convertion__int = scala.Int | ||
__type-convertion__java.lang.Integer = java.lang.Integer | ||
__type-convertion__java.lang.reflect.InvocationTargetException = java.lang.reflect.InvocationTargetException | ||
__type-convertion__java.lang.Class = java.lang.Class | ||
__type-convertion__java.lang.Object = java.lang.Object | ||
__type-convertion__long = scala.Long | ||
__type-convertion__java.lang.Long = scala.Long | ||
__type-convertion__java.util.Map = scala.collection.mutable.Map | ||
__type-convertion__org.eclipse.emf.ecore.resource.Resource = org.eclipse.emf.ecore.resource.Resource | ||
__type-convertion__org.eclipse.emf.ecore.resource.ResourceSet = org.eclipse.emf.ecore.resource.ResourceSet | ||
__type-convertion__short = scala.Short | ||
__type-convertion__java.lang.Short = scala.Short | ||
__type-convertion__java.lang.String = java.lang.String | ||
__type-convertion__org.eclipse.emf.common.util.TreeIterator = org.eclipse.emf.common.util.TreeIterator | ||
|
||
__package-convertion__scala = | ||
__package-convertion__java.lang = | ||
__package-convertion__org.eclipse.emf.common.util = org.eclipse.emf.common.util | ||
__package-convertion__org.eclipse.emf.ecore.resource = org.eclipse.emf.ecore.resource | ||
__package-convertion__org.eclipse.emf.ecore.util = org.eclipse.emf.ecore.util | ||
__package-convertion__scala.collection.mutable = scala.collection.mutable | ||
__package-convertion__java.lang.reflect = java.lang.reflect | ||
__package-convertion__java.util = java.util | ||
__package-convertion__scala.math = scala.math | ||
|
Oops, something went wrong.