-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
inline split transformation, not working possilbly because of TelluIo…
- Loading branch information
1 parent
78c730b
commit 654ab9e
Showing
8 changed files
with
421 additions
and
36 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
30 changes: 21 additions & 9 deletions
30
src/main/java/no/sintef/thingml/diversifier/strategies/Helper.java
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,25 +1,37 @@ | ||
package no.sintef.thingml.diversifier.strategies; | ||
|
||
import org.eclipse.emf.ecore.EObject; | ||
import org.eclipse.emf.ecore.util.EcoreUtil; | ||
import org.thingml.xtext.constraints.ThingMLHelpers; | ||
import org.thingml.xtext.helpers.TyperHelper; | ||
import org.thingml.xtext.thingML.InternalPort; | ||
import org.thingml.xtext.thingML.Port; | ||
import org.thingml.xtext.thingML.PrimitiveType; | ||
import org.thingml.xtext.thingML.Thing; | ||
import org.thingml.xtext.thingML.ThingMLFactory; | ||
import org.thingml.xtext.thingML.Type; | ||
|
||
public class Helper { | ||
public static Port createOrGetInternalPort(Thing thing) { | ||
Port result = null; | ||
|
||
public static InternalPort createOrGetInternalPort(Thing thing) { | ||
for (Port p : thing.getPorts()) { | ||
if (!(p instanceof InternalPort)) continue; | ||
if (p.getName().equals("diversified")) { | ||
result = p; | ||
break; | ||
return (InternalPort)p; | ||
} | ||
} | ||
if (result == null) { | ||
result = ThingMLFactory.eINSTANCE.createInternalPort(); | ||
result.setName("diversified"); | ||
thing.getPorts().add(result); | ||
} | ||
final InternalPort result = ThingMLFactory.eINSTANCE.createInternalPort(); | ||
result.setName("diversified"); | ||
thing.getPorts().add(result); | ||
return result; | ||
} | ||
|
||
public static PrimitiveType getPrimitiveType(Type t, EObject o) { | ||
for(Type ty : ThingMLHelpers.findContainingModel(o).getTypes()) { | ||
if (ty instanceof PrimitiveType && EcoreUtil.equals(TyperHelper.getBroadType(ty), t)) { | ||
return (PrimitiveType) ty; | ||
} | ||
} | ||
throw new NullPointerException("Cannot find Type " + t.getName() +"in the ThingML model containing " + o); | ||
} | ||
} |
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
Oops, something went wrong.