public LineRange getSelection() {
   if (sourceViewer != null) {
     TextSelection selection = (TextSelection) sourceViewer.getSelection();
     return new LineRange(
         selection.getStartLine() + 1, selection.getEndLine() - selection.getStartLine());
   }
   return null;
 }
Пример #2
0
 /** {@inheritDoc} */
 public void run() {
   IDocument document = viewer.getDocument();
   ISelection selection = viewer.getSelection();
   TextSelection textSelection;
   if (selection instanceof TextSelection) {
     textSelection = (TextSelection) selection;
     boolean isCommented = isCommented(document, textSelection);
     if (isCommented) {
       viewer.doOperation(ITextOperationTarget.STRIP_PREFIX);
     } else {
       viewer.doOperation(ITextOperationTarget.PREFIX);
     }
   }
 }