Skip to content

Commit

Permalink
Show abstract classes and interface for lookups
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinLoeper committed Aug 31, 2017
1 parent 87ec64a commit 331929d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class KampRuleLanguageJvmModelInferrer extends AbstractModelInferrer {
body = '''
«LookupUtil».lookupMarkedObjectsWithLookupMethod(version, «typeRef(rule.source.metaclass.instanceTypeName)».class, «getReturnType(rule.lookups.last)».class, «rule.getClassName»::«rule.getLookupMethodName(rule.lookups.last)»)
.forEach((result) -> {
«typeRef(Collection, typeRef(rule.modificationMark.target.qualifiedName))»changePropagationSteps = registry.getSubtypes(«rule.modificationMark.target.qualifiedName».class);
«typeRef(Collection, typeRef(rule.modificationMark.target.qualifiedName))» changePropagationSteps = registry.getSubtypes(«rule.modificationMark.target.qualifiedName».class);
if(changePropagationSteps.isEmpty()) {
throw new UnsupportedOperationException("The ChangePropagationAnalysis does not provide the requested ChangePropagationStep.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import tools.vitruv.dsls.mirbase.scoping.MirBaseScopeProviderDelegate
import static tools.vitruv.dsls.mirbase.mirBase.MirBasePackage.Literals.*

import static extension edu.kit.ipd.sdq.kamp.ruledsl.util.KampRuleLanguageEcoreUtil.*
import tools.vitruv.dsls.mirbase.mirBase.MetamodelImport
import org.eclipse.emf.ecore.EcorePackage
import org.eclipse.xtext.scoping.impl.SimpleScope

class KampRuleLanguageScopeProviderDelegate extends MirBaseScopeProviderDelegate {
override getScope(EObject context, EReference reference) {
Expand All @@ -37,10 +40,31 @@ class KampRuleLanguageScopeProviderDelegate extends MirBaseScopeProviderDelegate
// }
// }
// }

if (reference.equals(METACLASS_REFERENCE__METACLASS))
return createQualifiedEClassScope((context as MetaclassReference).metamodel, true, false);

return super.getScope(context, reference)
}

// copied from MirBaseScopeProviderDelegate
private def createQualifiedEClassScope(MetamodelImport metamodelImport, boolean includeAbstract, boolean includeEObject) {
val classifierDescriptions =
if (metamodelImport === null || metamodelImport.package === null) {
if (includeEObject) {
#[createEObjectDescription(EcorePackage.Literals.EOBJECT, false)];
} else {
#[];
}
} else {
collectObjectDescriptions(metamodelImport.package,
true, includeAbstract, metamodelImport.useQualifiedNames)
}

var resultScope = new SimpleScope(IScope.NULLSCOPE, classifierDescriptions)
return resultScope
}

/**
* Creates a scope for {@link EReference EReferences} of {@source sourceEClass}.
*
Expand Down

0 comments on commit 331929d

Please sign in to comment.