Completion Contributor for Scala

Hi friends,

I want to implement a plugin to suggest next child or attribute for XML tags  for scala language. as an example if developer type <name> i have to suggest child tag <firstName> to editor. I can get next sibling and Childs using an xsd. but don't know how to know the position of curser (inside a xml tag or value) and to give sugestions based on the token. h have tried many ways with completion contributor and reference contributor. but still unable to find a success way. please help me with this if you can?

5 comments
Comment actions Permalink

Hello Hasintha,

CompletionParameters.getOriginalPosition() returns the current element.

you could look up parent elements with
currentElement.getContext().getParent().getText();

something like this.

1
Comment actions Permalink

thank you Imants Cekusins.
if you have please send me an example code for getting text from .scala file and to send String as completion to .scala editor.
as i am new to this i was unable to identify some advanced concepts related to completion contributor

0
Comment actions Permalink

why not start with a tutorial:

http://www.jetbrains.org/intellij/sdk/docs/tutorials/custom_language_support/completion_contributor.html

these parameters are important:

CompletionParameters parameters,  - info about current element
CompletionResultSet resultSet    - completion suggestions (you need to populate this with the data)

Getting data from project files is a large topic.

I do not work with Scala so no ready answers from me. You'd need to look at Scala plugin code and also find out how to call Scala plugin methods from your plugin.

0
Comment actions Permalink

:)

you are welcome

0

Please sign in to leave a comment.