customize ContentAssist [message #902814] |
Mon, 20 August 2012 11:06  |
Eclipse User |
|
|
|
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 #902980 is a reply to message #902842] |
Tue, 21 August 2012 09:56   |
Eclipse User |
|
|
|
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 #903123 is a reply to message #902992] |
Wed, 22 August 2012 02:55   |
Eclipse User |
|
|
|
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 #903178 is a reply to message #903162] |
Wed, 22 August 2012 08:25  |
Eclipse User |
|
|
|
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.
|
|
|
Powered by
FUDForum. Page generated in 0.26589 seconds