|
Re: using IXtextEObjectSearch.findMatches [message #708746 is a reply to message #708726] |
Wed, 03 August 2011 06:13 |
Sebastian Zarnekow Messages: 3118 Registered: July 2009 |
Senior Member |
|
|
Hi Chetan,
use scoping instead. That's the primary hook for things like this. The
default scope will finally delegate to the IResourceDescriptions but
will take all the stuff like visibility constraints, dirty state /
builder state context etc into account.
The IResourceDescriptions may return an empty iterable when it's queried
for the first time or right after a clean build.
Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
On 03.08.11 07:54, Chetan Kumar wrote:
> Hi,
>
> I am trying to use IXtextEObjectSearch.Default implementation to find
> instances at the project level. I've injected IXtextEObjectSearch into
> my implementation of ILinkingService using @Inject. However, in the
> injected search engine resourceDescriptions.getAllResourceDescriptions()
> returns empty and hence no objects are returned for a pattern (Open
> Model Element shows those objects for that same pattern). Is there any
> specific way to use IXtextEObjectSearch ? (or can it be injected into
> other classes at all ?)
>
> here's the class:
> public class TypeLinkingService extends DefaultLinkingService {
>
> @Inject
> private IXtextEObjectSearch searchEngine;
>
> @Override
> public List<EObject> getLinkedObjects(EObject context, EReference ref,
> AbstractNode node)
> throws IllegalNodeException {
> if(ref.getEType() == DomainmodelPackage.eINSTANCE.getType()) {
> // search
> String searchPattern = getCrossRefNodeAsString(node);
> Iterable<IEObjectDescription> matches =
> searchEngine.findMatches(searchPattern, "");
> List<EObject> objs = new ArrayList<EObject>();
> for (IEObjectDescription ieObjectDescription : matches) {
> objs.add(ieObjectDescription.getEObjectOrProxy());
> }
> return objs;
> }
> // TODO Auto-generated method stub
> return super.getLinkedObjects(context, ref, node);
> }
> }
>
> + Chetan
|
|
|
Re: using IXtextEObjectSearch.findMatches [message #708748 is a reply to message #708726] |
Wed, 03 August 2011 06:13 |
Sebastian Zarnekow Messages: 3118 Registered: July 2009 |
Senior Member |
|
|
Hi Chetan,
use scoping instead. That's the primary hook for things like this. The
default scope will finally delegate to the IResourceDescriptions but
will take all the stuff like visibility constraints, dirty state /
builder state context etc into account.
The IResourceDescriptions may return an empty iterable when it's queried
for the first time or right after a clean build.
Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
On 03.08.11 07:54, Chetan Kumar wrote:
> Hi,
>
> I am trying to use IXtextEObjectSearch.Default implementation to find
> instances at the project level. I've injected IXtextEObjectSearch into
> my implementation of ILinkingService using @Inject. However, in the
> injected search engine resourceDescriptions.getAllResourceDescriptions()
> returns empty and hence no objects are returned for a pattern (Open
> Model Element shows those objects for that same pattern). Is there any
> specific way to use IXtextEObjectSearch ? (or can it be injected into
> other classes at all ?)
>
> here's the class:
> public class TypeLinkingService extends DefaultLinkingService {
>
> @Inject
> private IXtextEObjectSearch searchEngine;
>
> @Override
> public List<EObject> getLinkedObjects(EObject context, EReference ref,
> AbstractNode node)
> throws IllegalNodeException {
> if(ref.getEType() == DomainmodelPackage.eINSTANCE.getType()) {
> // search
> String searchPattern = getCrossRefNodeAsString(node);
> Iterable<IEObjectDescription> matches =
> searchEngine.findMatches(searchPattern, "");
> List<EObject> objs = new ArrayList<EObject>();
> for (IEObjectDescription ieObjectDescription : matches) {
> objs.add(ieObjectDescription.getEObjectOrProxy());
> }
> return objs;
> }
> // TODO Auto-generated method stub
> return super.getLinkedObjects(context, ref, node);
> }
> }
>
> + Chetan
|
|
|
|
Powered by
FUDForum. Page generated in 0.04151 seconds