/** * returns the choices list of structural features for the passed eclass * @param eClass the eclass to get features from * @return List oclchoices list for structural features */ protected List<Choice> getPropertyChoices(EClassifier eClass) { List<Choice> result = super.getPropertyChoices(eClass); for (Entry<String, EReference> hiddenOppositeNameAndForwardProperty : ((EnvironmentWithHiddenOpposites) getEnvironment()) .getHiddenOppositeProperties(eClass).entrySet()) { result.add(createChoice(hiddenOppositeNameAndForwardProperty .getKey(), NLS .bind(OCLMessages.HiddenOppositeOf, getDescription(hiddenOppositeNameAndForwardProperty .getValue())), ChoiceKind.PROPERTY, hiddenOppositeNameAndForwardProperty.getValue())); } return result; }
private OppositePropertyCallExp createOppositePropertyCallExp( SimpleNameCS simpleNameCS, EnvironmentWithHiddenOpposites env, OCLExpression<EClassifier> source, EClassifier owner, String simpleName, EReference property) { OppositePropertyCallExp result; TRACE("variableExpCS", "Opposite Property: " + simpleName);//$NON-NLS-2$//$NON-NLS-1$ // The following cast is permissible because opposite property calls can only occur in // environments that have factories implementing OCLFactoryWithHiddenOpposite, e.g., // the OCLFactory implementation for OCLEcore. result = ((OCLFactoryWithHiddenOpposite) oclFactory).createOppositePropertyCallExp(); initASTMapping(env, result, simpleNameCS, null); result.setReferredOppositeProperty(property); EClassifier propertyType = env.getOppositePropertyType(owner, property); initASTMapping(env, propertyType, simpleNameCS, property); result.setType(propertyType); if (source != null) { result.setSource(source); } else { Variable<EClassifier, EParameter> implicitSource = env.lookupImplicitSourceForOppositeProperty(simpleName); VariableExp<EClassifier, EParameter> src = createVariableExp(env, simpleNameCS, implicitSource); result.setSource(src); } initPropertyPositions(result, simpleNameCS); return result; }
/** * @since 3.1 */ protected EReference lookupOppositeProperty(CSTNode cstNode, EnvironmentWithHiddenOpposites env, EClassifier owner, String name) { try { EReference property = env.lookupOppositeProperty(owner, name); if (cstNode != null) { cstNode.setAst(property); } return property; } catch (LookupException e) { ERROR(cstNode, null, e.getMessage()); return e.getAmbiguousMatches().isEmpty() ? null : (EReference) e.getAmbiguousMatches().get(0); } }