Commit d0c45562 authored by seinturi's avatar seinturi

Add a field in ComponentDesc to reference the code element that is the source...

Add a field in ComponentDesc to reference the code element that is the source for this component definition.
parent 31ec8fae
......@@ -43,13 +43,14 @@ public class ComponentDescFactoryClassGenerator
extends org.objectweb.fractal.juliac.desc.ComponentDescFactoryClassGenerator {
public ComponentDescFactoryClassGenerator(
Juliac jc, ComponentDesc cdesc, String targetname ) {
Juliac jc, ComponentDesc<?> cdesc, String targetname ) {
super(jc,cdesc,targetname);
}
@Override
protected void generateAttributes( ComponentDesc cdesc, PrintWriter pw ) {
protected void generateAttributes(
ComponentDesc<?> cdesc, PrintWriter pw ) {
String id = cdesc.getID();
Set<String> names = cdesc.getAttributeNames();
......
......@@ -126,7 +126,7 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> {
@Override
protected SourceCodeGeneratorItf getComponentDescFactoryClassGenerator(
ComponentDesc cdesc, String targetname ) {
ComponentDesc<?> cdesc, String targetname ) {
return new ComponentDescFactoryClassGenerator(jc,cdesc,targetname);
}
......@@ -200,7 +200,7 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> {
/**
* Transform the specified {@link Composite} to {@link ComponentDesc}.
*/
protected ComponentDesc toComponentDesc( Composite composite )
protected ComponentDesc<Composite> toComponentDesc( Composite composite )
throws IOException {
/*
......@@ -218,19 +218,20 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> {
String controllerDesc =
name.startsWith(MEMBRANE_PKG_NAME) ? "mComposite" : "scaComposite";
ComponentDesc cdesc =
new ComponentDesc(id,name,name,ct,controllerDesc,null);
ComponentDesc<Composite> cdesc =
new ComponentDesc<Composite>(
id,name,name,ct,controllerDesc,null,composite);
/*
* Subcomponents.
*/
EList<Component> subs = composite.getComponent();
Map<String,ComponentDesc> subcdescs =
new HashMap<String,ComponentDesc>();
Map<String,ComponentDesc<?>> subcdescs =
new HashMap<String,ComponentDesc<?>>();
String subControllerDesc =
name.startsWith(MEMBRANE_PKG_NAME) ? "mPrimitive" : "scaPrimitive";
for (Component sub : subs) {
ComponentDesc subcdesc =
ComponentDesc<?> subcdesc =
handleComponent(name,sub,subControllerDesc);
handleProperties(sub,subcdesc);
cdesc.addSubComponent(subcdesc);
......@@ -283,7 +284,7 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> {
}
// Declared protected to enable extension in frascati-tinfi-osgi-scaadl
protected ComponentDesc handleComponent(
protected ComponentDesc<?> handleComponent(
String compositeName, Component sub, String controllerDesc )
throws IOException {
......@@ -293,7 +294,7 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> {
String name = sub.getName();
ComponentType subct = ecore2fractal(sub);
Implementation implementation = sub.getImplementation();
ComponentDesc cdesc = null;
ComponentDesc<?> cdesc = null;
if( implementation instanceof JavaImplementation ) {
......@@ -305,8 +306,8 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> {
String id = "C"+(compidx++);
cdesc =
new ComponentDesc(
id,name,name,subct,controllerDesc,contentDesc);
new ComponentDesc<JavaImplementation>(
id,name,name,subct,controllerDesc,contentDesc,jimpl);
}
else if( implementation instanceof SCAImplementation ) {
......@@ -344,8 +345,8 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> {
}
private void handleExport(
ComponentDesc cdesc, String compositeName,
Service service, Map<String,ComponentDesc> subcdescs )
ComponentDesc<?> cdesc, String compositeName,
Service service, Map<String,ComponentDesc<?>> subcdescs )
throws IOException {
String serviceName = service.getName();
......@@ -367,7 +368,7 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> {
throw new IOException(msg);
}
ComponentDesc target = subcdescs.get(promotes[0]);
ComponentDesc<?> target = subcdescs.get(promotes[0]);
if( target == null ) {
final String msg =
"No such target component "+promotes[0]+
......@@ -379,8 +380,8 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> {
}
private void handleImport(
ComponentDesc cdesc, String compositeName,
Reference reference, Map<String,ComponentDesc> subcdescs )
ComponentDesc<?> cdesc, String compositeName,
Reference reference, Map<String,ComponentDesc<?>> subcdescs )
throws IOException {
String referenceName = reference.getName();
......@@ -395,7 +396,7 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> {
throw new IOException(msg);
}
ComponentDesc src = subcdescs.get(prs[0]);
ComponentDesc<?> src = subcdescs.get(prs[0]);
if( src == null ) {
final String msg =
"No such source component "+prs[0]+
......@@ -408,7 +409,7 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> {
}
}
private void handleWire( Wire wire, Map<String,ComponentDesc> subcdescs )
private void handleWire( Wire wire, Map<String,ComponentDesc<?>> subcdescs )
throws IOException {
// Wire source
......@@ -418,7 +419,7 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> {
final String msg = "Illegal source '"+source+"' in wire "+wire;
throw new IOException(msg);
}
ComponentDesc clt = subcdescs.get(sources[0]);
ComponentDesc<?> clt = subcdescs.get(sources[0]);
if( clt == null ) {
final String msg =
"No such source component '"+sources[0]+"' in wire "+wire;
......@@ -447,7 +448,7 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> {
final String msg = "Illegal target '"+target+"' in wire "+wire;
throw new IOException(msg);
}
ComponentDesc srv = subcdescs.get(targets[0]);
ComponentDesc<?> srv = subcdescs.get(targets[0]);
if( srv == null ) {
final String msg =
"No such target component '"+targets[0]+"' in wire "+wire;
......@@ -488,11 +489,11 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> {
private void handleInternal(
String compositeName, Component sub,
Map<String,ComponentDesc> subcdescs )
Map<String,ComponentDesc<?>> subcdescs )
throws IOException {
String name = sub.getName();
ComponentDesc clt = subcdescs.get(name);
ComponentDesc<?> clt = subcdescs.get(name);
EList<ComponentReference> references = sub.getReference();
for (ComponentReference reference : references) {
......@@ -524,7 +525,7 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> {
compositeName;
throw new IOException(msg);
}
ComponentDesc srv = subcdescs.get(targs[0]);
ComponentDesc<?> srv = subcdescs.get(targs[0]);
if( srv == null ) {
final String msg =
"No such target component "+targs[0]+
......@@ -543,15 +544,15 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> {
}
private void createBinding(
BindingType bindingType, ComponentDesc clt, String cltItfName,
ComponentDesc srv, String srvItfName ) {
BindingType bindingType, ComponentDesc<?> clt, String cltItfName,
ComponentDesc<?> srv, String srvItfName ) {
BindingDesc bdesc =
new BindingDesc(bindingType,clt,cltItfName,srv,srvItfName);
clt.putBinding(cltItfName,bdesc);
}
private void handleProperties( Component sub, ComponentDesc cdesc ) {
private void handleProperties( Component sub, ComponentDesc<?> cdesc ) {
EList<PropertyValue> propvalues = sub.getProperty();
for (PropertyValue propvalue : propvalues) {
handleProperty(cdesc,propvalue);
......@@ -559,7 +560,7 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> {
}
private void handleProperty(
ComponentDesc cdesc, PropertyValue propvalue )
ComponentDesc<?> cdesc, PropertyValue propvalue )
throws IllegalArgumentException {
String name = propvalue.getName();
......
......@@ -65,9 +65,9 @@ public class EMFParserSupportImplTestCase {
@Test
public void testPropertyClass() throws IOException {
ComponentDesc cdesc = emfps.parse("Property",null);
List<ComponentDesc> subs = cdesc.getSubComponents();
ComponentDesc sub = subs.get(0);
ComponentDesc<?> cdesc = emfps.parse("Property",null);
List<ComponentDesc<?>> subs = cdesc.getSubComponents();
ComponentDesc<?> sub = subs.get(0);
AttributeDesc adesc = sub.getAttribute("classprop");
String type = adesc.getType();
String value = adesc.getValue();
......
......@@ -135,7 +135,7 @@ public class TinfiParserSupportImpl implements ADLParserSupportItf {
* @param context contextual information
* @return the model of the specified ADL
*/
public ComponentDesc parse( String adl, Map<Object,Object> context )
public ComponentDesc<?> parse( String adl, Map<Object,Object> context )
throws IOException {
// Not relevant for this ADL parser
throw new UnsupportedOperationException();
......@@ -373,7 +373,7 @@ public class TinfiParserSupportImpl implements ADLParserSupportItf {
* @param targetname the fully-qualified name of the factory class
* @since 2.5
*/
public void generate( ComponentDesc cdesc, String targetname )
public void generate( ComponentDesc<?> cdesc, String targetname )
throws IOException {
// Not relevant for this ADL parser
throw new UnsupportedOperationException();
......
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