use of org.eclipse.xtext.linking.impl.LinkingHelper in project xtext-core by eclipse.
the class LazyLinkingResourceTest method testEObjectReference.
@Test
public void testEObjectReference() throws Exception {
final EAnnotation source = EcoreFactory.eINSTANCE.createEAnnotation();
final EObject referencedObject = XtextFactory.eINSTANCE.createGrammar();
LazyLinkingResource res = new LazyLinkingResource();
res.setLinkingHelper(new LinkingHelper() {
@Override
public String getCrossRefNodeAsString(INode node, boolean convert) {
return node.getText();
}
});
res.setEncoder(new LazyURIEncoder() {
@Override
public boolean isCrossLinkFragment(Resource res, String s) {
return "foo".equals(s);
}
@Override
public Triple<EObject, EReference, INode> decode(Resource res, String uriFragment) {
return Tuples.create((EObject) source, EcorePackage.Literals.EANNOTATION__REFERENCES, (INode) new LeafNode());
}
});
res.setLinkingService(new ILinkingService() {
@Override
public List<EObject> getLinkedObjects(EObject context, EReference reference, INode node) throws IllegalNodeException {
return Lists.newArrayList(referencedObject);
}
});
res.setDiagnosticMessageProvider(new LinkingDiagnosticMessageProvider());
assertEquals(referencedObject, res.getEObject("foo"));
}
Aggregations