Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » customize ContentAssist(prevent items from being displayed)
customize ContentAssist [message #902814] Mon, 20 August 2012 15:06 Go to next message
Robert Wild is currently offline Robert Wild
Messages: 33
Registered: August 2012
Member
Hi everyone,

With my dsl and the default implementation, ContentAssist suggests some items which are syntactically invalid. As stated in (http://www.eclipse.org/forums/index.php/t/369336/) I obviously have to redo the validation semantics for ContentAssist.

The documentation talks about how entries can be added to ContentAssist. But how do you prevent that. The entries don't seem to be created by the complete{TypeName}_{FeatureName}()-Methods in Abstract<lang>ProposalProvider but by AbstractJavaBasedContentProposalProvider.createProposals(...). But overriding and modifying this method doesn't work because it uses private fields.

What ist the correct way to filter or remove completion proposals?

Any help would be appreciated since I'm tired of debugging and guessing. Is there any other documentation source than http://www.eclipse.org/Xtext/documentation.html ?
Re: customize ContentAssist [message #902839 is a reply to message #902814] Mon, 20 August 2012 18:00 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6384
Registered: July 2009
Senior Member
Hi,

a cannot reproduce your complaints.

there is a completeItemSet_items
which calls lookupCrossReference without a filter. simply call lookupcrossreference with a filter in your subclass

~Christian
Re: customize ContentAssist [message #902840 is a reply to message #902814] Mon, 20 August 2012 18:01 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6384
Registered: July 2009
Senior Member
Hi,

a cannot reproduce your complaints.

there is a completeItemSet_items
which calls lookupCrossReference without a filter. simply call lookupcrossreference with a filter in your subclass

~Christian
Re: customize ContentAssist [message #902841 is a reply to message #902814] Mon, 20 August 2012 18:01 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6384
Registered: July 2009
Senior Member
Hi,

a cannot reproduce your complaints.

there is a completeItemSet_items
which calls lookupCrossReference without a filter. simply call lookupcrossreference with a filter in your subclass

~Christian
Re: customize ContentAssist [message #902842 is a reply to message #902814] Mon, 20 August 2012 18:01 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6384
Registered: July 2009
Senior Member
Hi,

a cannot reproduce your complaints.

there is a completeItemSet_items
which calls lookupCrossReference without a filter. simply call lookupcrossreference with a filter in your subclass

~Christian
Re: customize ContentAssist [message #902980 is a reply to message #902842] Tue, 21 August 2012 13:56 Go to previous messageGo to next message
Robert Wild is currently offline Robert Wild
Messages: 33
Registered: August 2012
Member
That's what I tried. I've overidden all methods from Abstract<lang>ProposalProvider and removed all of the method contents. Those were references to completeRuleCall() and lookupCrossReference(). I thought when all of them are gone, no proposals will be provided. But I still get all the proposals I got before.

It seems the proposals are finally added in AbstractContentProposalProvider.createProposals(), so I tried to track back who triggered the call. And interestingly there's no code in the call stack that I can modify.

Here's the callstack from one of many executions of createProposals. The language is called TopologyDSL by the way.
Thread [main] (Suspended (breakpoint at line 107 in AbstractContentProposalProvider))	
	TopologyDSLProposalProvider(AbstractContentProposalProvider).createProposals(ContentAssistContext, ICompletionProposalAcceptor) line: 107	
	TopologyDSLProposalProvider(AbstractJavaBasedContentProposalProvider).createProposals(ContentAssistContext, ICompletionProposalAcceptor) line: 246	
	CompletionProposalComputer.exec(XtextResource) line: 51	
	CompletionProposalComputer.exec(Object) line: 1	
	XtextDocument$XtextDocumentLocker(AbstractReadWriteAcces<P>).readOnly(IUnitOfWork<T,P>) line: 32	
	XtextDocument.readOnly(IUnitOfWork<T,XtextResource>) line: 78	
	XtextContentAssistProcessor.computeCompletionProposals(ITextViewer, int) line: 69	
	ContentAssistant.computeCompletionProposals(ITextViewer, int) line: 1830	
	CompletionProposalPopup.computeProposals(int) line: 556	
	CompletionProposalPopup.access$16(CompletionProposalPopup, int) line: 553	
	CompletionProposalPopup$2.run() line: 488	
	BusyIndicator.showWhile(Display, Runnable) line: 70	
	CompletionProposalPopup.showProposals(boolean) line: 482	
	ContentAssistant.showPossibleCompletions() line: 1656	
	XtextSourceViewer(SourceViewer).doOperation(int) line: 930	
	XtextSourceViewer(ProjectionViewer).doOperation(int) line: 1535	
	ContentAssistAction$1.run() line: 82	
	BusyIndicator.showWhile(Display, Runnable) line: 70	
	ContentAssistAction.run() line: 80	
	ContentAssistAction(Action).runWithEvent(Event) line: 498	
	ActionHandler.execute(Map) line: 185	
	LegacyHandlerWrapper.execute(ExecutionEvent) line: 109	
	Command.executeWithChecks(ExecutionEvent) line: 476	
	ParameterizedCommand.executeWithChecks(Object, Object) line: 508	
	HandlerService.executeCommand(ParameterizedCommand, Event) line: 169	
	WorkbenchKeyboard.executeCommand(Binding, Event) line: 468	
	WorkbenchKeyboard.press(List, Event) line: 786	
	WorkbenchKeyboard.processKeyEvent(List, Event) line: 885	
	WorkbenchKeyboard.filterKeySequenceBindings(Event) line: 567	
	WorkbenchKeyboard.access$3(WorkbenchKeyboard, Event) line: 508	
	WorkbenchKeyboard$KeyDownFilter.handleEvent(Event) line: 123	
	EventTable.sendEvent(Event) line: 84	
	Display.filterEvent(Event) line: 1262	
	StyledText(Widget).sendEvent(Event) line: 1052	
	StyledText(Widget).sendEvent(int, Event, boolean) line: 1077	
	StyledText(Widget).sendEvent(int, Event) line: 1062	
	StyledText(Widget).sendKeyEvent(int, int, long, long, Event) line: 1104	
	StyledText(Widget).sendKeyEvent(int, int, long, long) line: 1100	
	StyledText(Widget).wmChar(long, long, long) line: 1509	
	StyledText(Control).WM_CHAR(long, long) line: 4640	
	StyledText(Canvas).WM_CHAR(long, long) line: 345	
	StyledText(Control).windowProc(long, int, long, long) line: 4528	
	StyledText(Canvas).windowProc(long, int, long, long) line: 341	
	Display.windowProc(long, long, long, long) line: 4972	
	OS.DispatchMessageW(MSG) line: not available [native method]	
	OS.DispatchMessage(MSG) line: 2531	
	Display.readAndDispatch() line: 3752	
	Workbench.runEventLoop(Window$IExceptionHandler, Display) line: 2701	
	Workbench.runUI() line: 2665	
	Workbench.access$4(Workbench) line: 2499	
	Workbench$7.run() line: 679	
	Realm.runWithDefault(Realm, Runnable) line: 332	
	Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 668	
	PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 149	
	IDEApplication.start(IApplicationContext) line: 123	
	EclipseAppHandle.run(Object) line: 196	
	EclipseAppLauncher.runApplication(Object) line: 110	
	EclipseAppLauncher.start(Object) line: 79	
	EclipseStarter.run(Object) line: 344	
	EclipseStarter.run(String[], Runnable) line: 179	
	NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]	
	NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39	
	DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25	
	Method.invoke(Object, Object...) line: 597	
	Main.invokeFramework(String[], URL[]) line: 622	
	Main.basicRun(String[]) line: 577	
	Main.run(String[]) line: 1410	
	Main.main(String[]) line: 1386	


All of this is part of a non-trivial project I inherited. The original author also doesn't know what exactly goes on here. Any help would be greatly appreciated.

Regards
Robert
Re: customize ContentAssist [message #902992 is a reply to message #902980] Tue, 21 August 2012 14:33 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6384
Registered: July 2009
Senior Member
Hi can you share a simple sample grammar and proposalprovider that
reproduce the problem?

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de
Re: customize ContentAssist [message #903123 is a reply to message #902992] Wed, 22 August 2012 06:55 Go to previous messageGo to next message
Robert Wild is currently offline Robert Wild
Messages: 33
Registered: August 2012
Member
Using the mydsl example:
Is this the correct way to build filters for the ProposalProvider?
public class MyDslProposalProvider extends AbstractMyDslProposalProvider {
	public void completeModel_Greetings(EObject model, Assignment assignment, ContentAssistContext context,
			ICompletionProposalAcceptor acceptor) {
		if (false) {
			completeRuleCall(((RuleCall) assignment.getTerminal()), context, acceptor);
		}
	}

	public void completeGreeting_Name(EObject model, Assignment assignment, ContentAssistContext context,
			ICompletionProposalAcceptor acceptor) {
		if (false) {
			completeRuleCall(((RuleCall) assignment.getTerminal()), context, acceptor);
		}
	}
}

Without the if clause the completeRuleCall statements actually add the proposals to the acceptor. With it the same proposals are added anyway. Why is that? Is that supposed to happen? What is the correct way of doing this?
Re: customize ContentAssist [message #903126 is a reply to message #903123] Wed, 22 August 2012 07:17 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6384
Registered: July 2009
Senior Member
Hi I still do not get your point - if you leave the methods empty
(don't call anything not even super) everything should be fine. What
is the unwanted proposal you get?

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de
Re: customize ContentAssist [message #903130 is a reply to message #903126] Wed, 22 August 2012 07:38 Go to previous messageGo to next message
Robert Wild is currently offline Robert Wild
Messages: 33
Registered: August 2012
Member
In this example I wanted the ContentAssist not to display anything. But it doesn't do that, even if I leave the methods empty. Just to test how to exclude proposals I wanted to exclude everything.
Re: customize ContentAssist [message #903133 is a reply to message #903130] Wed, 22 August 2012 07:41 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6384
Registered: July 2009
Senior Member
Don't forget completekeyword ;-)

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de
Re: customize ContentAssist [message #903156 is a reply to message #903133] Wed, 22 August 2012 09:28 Go to previous messageGo to next message
Robert Wild is currently offline Robert Wild
Messages: 33
Registered: August 2012
Member
ok, when I override completeKeyword the Keyword won't be displayed. So far so good. But after a keyword the content assist still proposes Name although completeGreeting_Name() has an empty implementation. It is called and does nothing but still the proposal is somehow displayed. How can I get rid of that?
Re: customize ContentAssist [message #903162 is a reply to message #903156] Wed, 22 August 2012 10:42 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6384
Registered: July 2009
Senior Member
Did you override completeID too?

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de
Re: customize ContentAssist [message #903178 is a reply to message #903162] Wed, 22 August 2012 12:25 Go to previous message
Robert Wild is currently offline Robert Wild
Messages: 33
Registered: August 2012
Member
ok, now I'm able to filter all proposals in the mydsl example. In my project there are some more methods I'll need to override, but I guess I'm gonna find them in ProposalProvider's parent classes.

Thanks for your help.

Previous Topic:Arithmetics example can't serialize Definition references
Next Topic:xtext compatibility error with type from imported package
Goto Forum:
  


Current Time: Thu Oct 23 06:03:50 GMT 2014

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

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