Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » using IXtextEObjectSearch.findMatches(resourceDescriptions going empty)
using IXtextEObjectSearch.findMatches [message #708726] Wed, 03 August 2011 05:54 Go to next message
Chetan Kumar is currently offline Chetan KumarFriend
Messages: 44
Registered: July 2009
Member
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 #708746 is a reply to message #708726] Wed, 03 August 2011 06:13 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
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 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
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 #709406 is a reply to message #708748] Wed, 03 August 2011 22:19 Go to previous message
Chetan Kumar is currently offline Chetan KumarFriend
Messages: 44
Registered: July 2009
Member
Thanks Sebastian.

Apart from LinkingService, if I want to have a search feature for my dsl, can't I reuse IXtextEObjectSearch implementation ?

+ Chetan
Previous Topic:Custom validation of Java Language
Next Topic:(no subject)
Goto Forum:
  


Current Time: Sat Apr 27 03:09:15 GMT 2024

Powered by FUDForum. Page generated in 0.02921 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top