Page 1 of 1

How to customize "Show Definition" (or Quick Assist) feature for my own framework?

Posted: Wed Feb 14, 2018 11:40 am
by serioadamo97
For example, in XSLT we have following code:

Code: Select all


    <xsl:template match="/">
<xsl:call-template name="foo"/>
</xsl:template>

<xsl:template name="foo">
<foo></foo>
</xsl:template>
When we place the cursor inside "foo" , we can click "Show Definition" button (or use Quick Assist) and then the cursor will jump to definition.

My question is how to customize "Show Definition" (or Quick Assist) feature for my own framework?

I know that using ID/IDREF(https://www.oxygenxml.com/doc/versions/ ... odes2.html) can implement this feature. But ID/IDREF has a lot of restrictions.(eg: D/IDREF must be unique globally and it does not support scoping-based symbol find.)

Thanks.

Re: How to customize "Show Definition" (or Quick Assist) feature for my own framework?

Posted: Thu Feb 15, 2018 5:51 pm
by adrian
Hi,
My question is how to customize "Show Definition" (or Quick Assist) feature for my own framework?
In short you can't, it's not customizable, there's no API to redefine its behavior.
The implementation is completely different for each specialized editor. For XML files "Show Definition" will go to the schema and show you where that element or attribute is declared. For XSL it's implemented differently and shows the definition of the respective variable, template or function.

Regards,
Adrian

Re: How to customize "Show Definition" (or Quick Assist) feature for my own framework?

Posted: Thu Feb 15, 2018 8:50 pm
by serioadamo97
adrian wrote:Hi,
My question is how to customize "Show Definition" (or Quick Assist) feature for my own framework?
In short you can't, it's not customizable, there's no API to redefine its behavior.
The implementation is completely different for each specialized editor. For XML files "Show Definition" will go to the schema and show you where that element or attribute is declared. For XSL it's implemented differently and shows the definition of the respective variable, template or function.

Regards,
Adrian
Hi Adrian,
Thanks for your answer.

I found some document on oxygenxml website:
https://www.oxygenxml.com/doc/versions/ ... inder.html

It says that :
The link target reference finder represents the support for finding references from links that indicate specific elements inside an XML document.

Is this can implement this feature? (Or I understand what it meant?)

Re: How to customize "Show Definition" (or Quick Assist) feature for my own framework?

Posted: Fri Feb 16, 2018 12:29 pm
by Radu
Hi,

Adrian asked me to help you with this.
So if you implement a workspace access plugin for Oxygen:

https://www.oxygenxml.com/doc/versions/ ... lugin.html

You can add a menus and toolbars customizer:

Code: Select all

ro.sync.exml.workspace.api.standalone.StandalonePluginWorkspace.addMenusAndToolbarsContributorCustomizer(MenusAndToolbarsContributorCustomizer)
https://www.oxygenxml.com/InstData/Edit ... mizer.html

which allows you to customize the popup menu for the text page:

customizeTextPopUpMenu(javax.swing.JPopupMenu popUp, WSTextEditorPage textPage)

If the opened document is XML, the "textPage" can actually be cast to ro.sync.exml.workspace.api.editor.page.text.xml.WSXMLTextEditorPage which gives you access to more API (for example execute XPath expressions).
You also have access to the caret offset WSTextBasedEditorPage.getCaretOffset() and even to the Swing JTextArea "WSTextEditorPage.getTextComponent()".
So you could try to add a contextual menu action which when pressed could look in the current document and then try to open another document at another location using an API like "ro.sync.exml.workspace.api.Workspace.open(URL)".
If that URL contains a custom anchor inside it like:

"file:/.../test.xml#myCustomAnchor"

then the job of finding the place in the opened XML document is then delegated to the link target element finder for which you already found a resource:

https://www.oxygenxml.com/doc/versions/ ... inder.html

Regards,
Radu

Re: How to customize "Show Definition" (or Quick Assist) feature for my own framework?

Posted: Sun Mar 04, 2018 4:19 pm
by serioadamo97
Thanks, it works.
But finally, I used the XPath expression instead of developing extra plug-ins to implement the feature of Show Definition.

Re: How to customize "Show Definition" (or Quick Assist) feature for my own framework?

Posted: Mon Mar 05, 2018 9:50 am
by Radu
Hi,

Sure, however it suits you better.

Regards,
Radu