Reputation: 23
I am implementing an Eclipse plugin for C programmers. I can't find a way to get the variable that the user already highlited.(The user will highlight a variable in the editor and I need to know which variable it is/variable's name/location of this variable in the editor, like line number..) Can anyone help to achieve that ?
Upvotes: 2
Views: 59
Reputation: 38
Well after searching in some links, I achvieved that by using the ISelectionProvider and ITextSelection Interfaces. Here a code to get the name of the highlighted variable :
ISelectionProvider selProvider = textEditor.getSelectionProvider();
ITextSelection txtSel = (ITextSelection) selProvider.getSelection();
String varName = txtSel.getText();
Upvotes: 1