Java Code Examples for org.eclipse.emf.ecore.EReference#isResolveProxies()

The following examples show how to use org.eclipse.emf.ecore.EReference#isResolveProxies() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultResourceDescriptionStrategy.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
protected boolean isIndexable(EReference eReference) {
	return (!eReference.isContainment() || eReference.isResolveProxies()) 
			&& !eReference.isDerived() 
			&& !eReference.isVolatile()
			&& !eReference.isTransient() 
			&& (!eReference.isContainer() || eReference.isResolveProxies());
}
 
Example 2
Source File: CrossReferenceSerializer.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @since 2.11
 */
protected EObject handleProxy(EObject proxy, EObject semanticObject, EReference reference) {
	if (reference != null && reference.isResolveProxies()) {
		if (reference.isMany()) {
			@SuppressWarnings("unchecked")
			EList<? extends EObject> list = (EList<? extends EObject>) semanticObject.eGet(reference);
			int index = list.indexOf(proxy);
			if (index >= 0)
				return list.get(index);
		} else {
			return (EObject) semanticObject.eGet(reference, true);
		}
	}
	return EcoreUtil.resolve(proxy, semanticObject);
}
 
Example 3
Source File: LazyLinker.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
private void installProxies(EObject obj, IDiagnosticProducer producer,
		Multimap<EStructuralFeature.Setting, INode> settingsToLink, ICompositeNode parentNode, boolean dontCheckParent) {
	final EClass eClass = obj.eClass();
	if (eClass.getEAllReferences().size() - eClass.getEAllContainments().size() == 0)
		return;

	for (INode node = parentNode.getFirstChild(); node != null; node = node.getNextSibling()) {
		EObject grammarElement = node.getGrammarElement();
		if (grammarElement instanceof CrossReference && hasLeafNodes(node)) {
			producer.setNode(node);
			CrossReference crossReference = (CrossReference) grammarElement;
			final EReference eRef = GrammarUtil.getReference(crossReference, eClass);
			if (eRef == null) {
				ParserRule parserRule = GrammarUtil.containingParserRule(crossReference);
				final String feature = GrammarUtil.containingAssignment(crossReference).getFeature();
				throw new IllegalStateException("Couldn't find EReference for crossreference '"+eClass.getName()+"::"+feature+"' in parser rule '"+parserRule.getName()+"'.");
			}
			if (!eRef.isResolveProxies() /*|| eRef.getEOpposite() != null see https://bugs.eclipse.org/bugs/show_bug.cgi?id=282486*/) {
				final EStructuralFeature.Setting setting = ((InternalEObject) obj).eSetting(eRef);
				settingsToLink.put(new SettingDelegate(setting), node);
			} else {
				createAndSetProxy(obj, node, eRef);
				afterCreateAndSetProxy(obj, node, eRef, crossReference, producer);
			}
		} else if (grammarElement instanceof RuleCall && node instanceof ICompositeNode) {
			RuleCall ruleCall = (RuleCall) grammarElement;
			AbstractRule calledRule = ruleCall.getRule();
			if (calledRule instanceof ParserRule && ((ParserRule) calledRule).isFragment()) {
				installProxies(obj, producer, settingsToLink, (ICompositeNode) node, true);
			}
		}
	}
	if (!dontCheckParent && shouldCheckParentNode(parentNode)) {
		installProxies(obj, producer, settingsToLink, parentNode.getParent(), dontCheckParent);
	}
}
 
Example 4
Source File: Bpmn2ResourceImpl.java    From fixflow with Apache License 2.0 5 votes vote down vote up
/**
 * Overridden to be able to convert QName references in attributes to URIs during load.
 * @param ids
 *  In our case the parameter will contain exactly one QName that we resolve to URI.
 */
@Override
protected void setValueFromId(EObject object, EReference eReference, String ids) {
    super.setValueFromId(
            object,
            eReference,
            eReference.isResolveProxies() ? ((QNameURIHandler) uriHandler)
                    .convertQNameToUri(ids) : ids);
}