Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » "Greedy" Content Assist
"Greedy" Content Assist [message #629499] Tue, 28 September 2010 13:57 Go to next message
Christoph ZwickerFriend
Messages: 16
Registered: April 2010
Junior Member
Hi,

I have a problem with the behavior of the content assist handler provided in the org.eclipse.xtext.ui plugin. The "activeWhen" element only checks for activeEditor, which stays set (I believe) even when another part is activated (which may also provide content assist). Due to this, the command is handled by org.eclipse.xtext.ui.editor.handler.ContentAssistHandler and org.eclipse.jface.fieldassist.ContentProposalAdapter does not get a shot at the event (at least that's what I figure from a 30' read through the sources).

Is there a reason why the handler is not activated only when the editor is "really" active?

Thanks,
Chris
Re: "Greedy" Content Assist [message #629523 is a reply to message #629499] Tue, 28 September 2010 14:55 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Christoph,

thanks for pointing this out. The docs are clear about it - the active
editor is not necessarily the active part. Would you please file a ticket?
As a workaround you could modify the expression in your own plugin.xml.
It will not be overwritten.

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 28.09.10 15:57, schrieb Christoph Zwicker:
> Hi,
>
> I have a problem with the behavior of the content assist handler
> provided in the org.eclipse.xtext.ui plugin. The "activeWhen" element
> only checks for activeEditor, which stays set (I believe) even when
> another part is activated (which may also provide content assist). Due
> to this, the command is handled by
> org.eclipse.xtext.ui.editor.handler.ContentAssistHandler and
> org.eclipse.jface.fieldassist.ContentProposalAdapter does not get a shot
> at the event (at least that's what I figure from a 30' read through the
> sources).
>
> Is there a reason why the handler is not activated only when the editor
> is "really" active?
>
> Thanks,
> Chris
Re: "Greedy" Content Assist [message #629537 is a reply to message #629523] Tue, 28 September 2010 15:54 Go to previous messageGo to next message
Christoph ZwickerFriend
Messages: 16
Registered: April 2010
Junior Member
Done, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=326435

Thanks,
Chris
Re: "Greedy" Content Assist [message #629961 is a reply to message #629523] Thu, 30 September 2010 06:56 Go to previous messageGo to next message
Christoph ZwickerFriend
Messages: 16
Registered: April 2010
Junior Member
Hi Sebastian,

I tried to deactivate the handler by adding a version referencing "activePart" instead of "activeEditor" to my own plugin.xml, but there is no effect, the handler stays active. Eclipse seems to treat both handlers as possible candidates and checks each one's condition. When both match, one of them wins and the handler is active. On the other hand, if my handler does not match, the original one still does and the handler stays active...

Thanks,
Chris
Re: "Greedy" Content Assist [message #630009 is a reply to message #629961] Thu, 30 September 2010 11:02 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Chris,

did you try the activePartID selector?

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 30.09.10 08:56, schrieb Christoph Zwicker:
> Hi Sebastian,
>
> I tried to deactivate the handler by adding a version referencing
> "activePart" instead of "activeEditor" to my own plugin.xml, but there
> is no effect, the handler stays active. Eclipse seems to treat both
> handlers as possible candidates and checks each one's condition. When
> both match, one of them wins and the handler is active. On the other
> hand, if my handler does not match, the original one still does and the
> handler stays active...
>
> Thanks,
> Chris
Re: "Greedy" Content Assist [message #630010 is a reply to message #630009] Thu, 30 September 2010 11:11 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Chris,

never mind my prev. post. What I had in mind was something like:

<extension point="org.eclipse.core.expressions.definitions">
<definition id="org.eclipse.xtext.Xtext.Editor.opened">
<and>
<reference
definitionId="isActiveEditorAnInstanceOfXtextEditor"/>
<with variable="activePart">
<test
property="org.eclipse.xtext.ui.editor.XtextEditor.languageName "
value="<org.company.MyDsl>"
forcePluginActivation="true"/>
</with>
</and>
</definition>
</extension>

Regards,
Sebastian

Am 30.09.10 13:02, schrieb Sebastian Zarnekow:
> Hi Chris,
>
> did you try the activePartID selector?
>
> Regards,
> Sebastian
Re: "Greedy" Content Assist [message #630590 is a reply to message #630010] Mon, 04 October 2010 10:18 Go to previous messageGo to next message
Christoph ZwickerFriend
Messages: 16
Registered: April 2010
Junior Member
Hi Sebastian

I just added the following:
<definition id="isActiveEditorAnInstanceOfXtextEditor">
  <with variable="activePart">
    <adapt type="org.eclipse.xtext.ui.editor.XtextEditor"/>
  </with>
</definition>

Works now, thanks!
Re: "Greedy" Content Assist [message #630604 is a reply to message #630590] Mon, 04 October 2010 11:02 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Christoph,

this will likely use the wrong proposal provider if you have more than
one language in your IDE as it ignores the language identifier.

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 04.10.10 12:18, schrieb Christoph Zwicker:
> Hi Sebastian
>
> I just added the following:
> <definition id="isActiveEditorAnInstanceOfXtextEditor">
> <with variable="activePart">
> <adapt type="org.eclipse.xtext.ui.editor.XtextEditor"/>
> </with>
> </definition>
>
> Works now, thanks!
Re: "Greedy" Content Assist [message #630607 is a reply to message #630604] Mon, 04 October 2010 11:32 Go to previous messageGo to next message
Christoph ZwickerFriend
Messages: 16
Registered: April 2010
Junior Member
Hi Sebastian

Why would that be the case (it isn't in my case, and so far, we are using seven different grammars)? The original definition from org.eclipse.xtext.ui is based solely on isActiveEditorAnInstanceOfXtextEditor as well (which is defined on "activeEditor" instead of "activePart") and the proposal provider used is bound in Abstract<Grammar>UiModule.bindIContentProposalProvider, so there should not be any mixup imho.

Also, for the grammar specific (static) handlers, the <plugin>.<grammar>.Editor.opened definition is used (which "extends" the isActiveEditorAnInstanceOfXtextEditor definition).

Greetz,
Chris
Re: "Greedy" Content Assist [message #669270 is a reply to message #630607] Mon, 09 May 2011 16:49 Go to previous message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
Hi

I found this old post.
since I have a similar issue, having embedded an editor in another editor (in the property view of the editor), and the content assist does not work, I'd like to try this solution, and would like to know whether the problem of multiple languages raised by Sebastian is actually an issue.

thanks in advance
Lorenzo


Previous Topic:Re: Change of IUnitOfWork behaviour in 2.0M7
Next Topic:Re: Change of IUnitOfWork behaviour in 2.0M7
Goto Forum:
  


Current Time: Thu Apr 18 12:03:22 GMT 2024

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

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

Back to the top