Skip to main content



      Home
Home » Modeling » TMF (Xtext) » using IXtextEObjectSearch.findMatches(resourceDescriptions going empty)
using IXtextEObjectSearch.findMatches [message #708726] Wed, 03 August 2011 01:54 Go to next message
Eclipse UserFriend
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 02:13 Go to previous messageGo to next message
Eclipse UserFriend
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 02:13 Go to previous messageGo to next message
Eclipse UserFriend
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 18:19 Go to previous message
Eclipse UserFriend
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 Jul 26 23:45:00 EDT 2025

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

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

Back to the top