break;
case META: {
PPTypeInfo info = helper.getMetaTypeInfo(uri.path(), new InputStreamReader(inputStream));
MetaType type = PPTPFactory.eINSTANCE.createMetaType();
type.setName(info.getTypeName());
type.setDocumentation(info.getDocumentation());
for(Map.Entry<String, PPTypeInfo.Entry> entry : info.getParameters().entrySet()) {
Parameter parameter = PPTPFactory.eINSTANCE.createParameter();
parameter.setName(entry.getKey());
parameter.setDocumentation(entry.getValue().documentation);
parameter.setRequired(entry.getValue().isRequired());
type.getParameters().add(parameter);
}
// TODO: Scan the puppet source for providers for the type
// This is a CHEAT -
// https://github.com/puppetlabs/geppetto/issues/37
Parameter p = PPTPFactory.eINSTANCE.createParameter();
p.setName("provider");
p.setDocumentation("");
p.setRequired(false);
type.getParameters().add(p);
getContents().add(type);
break;
}
case TYPEFRAGMENT: {
for(PPTypeInfo type : helper.getTypeFragments(uri.path(), new InputStreamReader(inputStream))) {
TypeFragment fragment = PPTPFactory.eINSTANCE.createTypeFragment();
fragment.setName(type.getTypeName());
// add the properties (will typically load just one).
for(Map.Entry<String, PPTypeInfo.Entry> entry : type.getProperties().entrySet()) {
Property property = PPTPFactory.eINSTANCE.createProperty();
property.setName(entry.getKey());
property.setDocumentation(entry.getValue().documentation);
property.setRequired(entry.getValue().isRequired());
fragment.getProperties().add(property);
}
// add the parameters (will typically load just one).
for(Map.Entry<String, PPTypeInfo.Entry> entry : type.getParameters().entrySet()) {
Parameter parameter = PPTPFactory.eINSTANCE.createParameter();
parameter.setName(entry.getKey());
parameter.setDocumentation(entry.getValue().documentation);
parameter.setRequired(entry.getValue().isRequired());
fragment.getParameters().add(parameter);