0

I want to implement a action listener when click on intellij editor listner should be able to get the content of the editor.(what already typed in editor). i have implement a method with TypedActionHaqndler but it provides letter when type in editor.(http://www.jetbrains.org/intellij/sdk/docs/tutorials/editor_basics/editor_events.html). is there any way to get the action when click on editor. please help if you know.

yole
  • 92,896
  • 20
  • 260
  • 197
  • What do you want your plugin to do? Most likely, adding a mouse listener to the editor is not the right way to implement your plugin. – yole Feb 01 '16 at 13:01
  • I want to detect annotations when user click on the editor. as an example @RootNode("Parent") – Hasintha Samith Randika Feb 01 '16 at 16:45
  • And what do you want to do next? – yole Feb 01 '16 at 16:48
  • I want to detect annotations when user click on the editor. as an example @RootNode("Parent") public class test{ } plugin need to provide suggestions based on an XSD. That part is working now i wantto limit suggestions by giving a root node for a given class as above. so i planned to get editor click event and get text content of editor and parse it to get available annotations. but i dont know how to detect editor click event TypedActionHandler did not give required functionality. – Hasintha Samith Randika Feb 01 '16 at 16:52
  • I still don't understand. How is the user initially invoking your plugin? – yole Feb 01 '16 at 17:45
  • plugin is a completion contributor for scala. when you select an xsd plugin will generate a xml dom structure. then completions provide by observing completion parameters. my requirement is to get the content of editor when user click on intellij editor. that's all i need. as an example assume a file called hsr.cala open in editor. when you click on editor plugin want to know which file you clicked and its text content up to cursor position. thanks yole for your helps and active contribution. and is there any way to get editor click event? – Hasintha Samith Randika Feb 01 '16 at 18:20
  • Refer this question for more details about plugin http://stackoverflow.com/questions/34328133/intellij-completion-contributor – Hasintha Samith Randika Feb 01 '16 at 18:22
  • If you're writing a CompletionContributor, you already have access to the active editor through CompletionParameters.getEditor() and to the caret offset via CompletionParameters.getOffset(). Isn't that enough for you? – yole Feb 01 '16 at 18:26
  • Thank you yole. i think it can be done with Parameters.getEditor method. – Hasintha Samith Randika Feb 02 '16 at 03:24

1 Answers1

1

In a CompletionContributor, use CompletionParameters.getEditor() to obtain the editor in which the completion was invoked and CompletionParameters.getOffset() to get the caret offset.

yole
  • 92,896
  • 20
  • 260
  • 197