// System.err.println("completeAttributeOperation_Key assignment to feature: " + assignment.getFeature() +
// " model: " + model.eClass().getName() + " Text: " + context.getCurrentNode().getText());
// super.completeAttributeOperation_Key(model, assignment, context, acceptor);
// Proposal for AttributeOperation depends on context (the resource body)
ResourceBody resourceBody = null;
if(model.eClass() == PPPackage.Literals.RESOURCE_BODY) {
// The model is a resource body if an AttributeOperation has not yet been detected by the grammar
resourceBody = (ResourceBody) model;
}
else if(model.eClass() == PPPackage.Literals.ATTRIBUTE_OPERATION) {
// The grammar is lenient with (=> value) being optional (or it is impossible to
// get a ResourceBody context). Special handling is required to avoid producing a
// new list o suggestions for the op position (as the grammar thinks a property name OR and op can
// follow).
resourceBody = (ResourceBody) model.eContainer().eContainer();
// If the current caret position is after the end of the key (+1), do not offer any values
String key = ((AttributeOperation) model).getKey();
if(key != null && key.length() > 0 //
&& context.getOffset() > NodeModelUtils.getNode(model).getOffset() + key.length())
return;
}
else
// can not determine a context
return;
// INode lastCompleteNode = context.getLastCompleteNode();
// EObject ge = lastCompleteNode.getGrammarElement();
// if(ge instanceof RuleCall) {
// RuleCall lastCompletedRuleCall = (RuleCall) ge;
// System.err.println(lastCompletedRuleCall.getRule().getName());
// }
// if(context.getCurrentNode() instanceof HiddenLeafNode) {
// PPGrammarAccess ppga = (PPGrammarAccess) grammarAccess;
// if(ppga.getWSRule() == context.getCurrentNode().getGrammarElement())
// return;
// }
try {
// figure out the shape of the resource
ResourceExpression resourceExpr = (ResourceExpression) resourceBody.eContainer();
ClassifierAdapter adapter = ClassifierAdapterFactory.eINSTANCE.adapt(resourceExpr);
int resourceType = adapter.getClassifier();
// If resource is good, and not 'class', then it must have a known reference type.
// the resource type - also requires getting the type name from the override's expression).
if(resourceType == RESOURCE_IS_CLASSPARAMS) {
// resource is pp: class { classname : parameter => value }
// Find parameters for the class
// Find the class
final String className = stringConstantEvaluator.doToString(resourceBody.getNameExpr());
if(className == null)
return; // not a static expression
// Need the class to get its full name
ppFinder.configure(model.eResource());
List<IEObjectDescription> descs = ppFinder.findHostClasses(resourceBody, className, null).getAdjusted();