org.eclipse.xtext.ui.editor.doubleClicking
Class LexerTokenAndCharacterPairAwareStrategy

java.lang.Object
  extended by org.eclipse.jface.text.DefaultTextDoubleClickStrategy
      extended by org.eclipse.xtext.ui.editor.doubleClicking.AbstractWordAwareDoubleClickStrategy
          extended by org.eclipse.xtext.ui.editor.doubleClicking.LexerTokenAndCharacterPairAwareStrategy
All Implemented Interfaces:
org.eclipse.jface.text.ITextDoubleClickStrategy

public class LexerTokenAndCharacterPairAwareStrategy
extends AbstractWordAwareDoubleClickStrategy

This implementation uses the tokens of an Xtext document to identify words in the document. Thereby it recognizes keywords that consist only of characters that are no letters, e.g. += or ?=. Furthermore it will select the contents of a brace pair if the opening or closing peer is clicked. Tokens with a length of one character have a lower priority in case a token boundary is selected.

Author:
Sebastian Zarnekow - Initial contribution and API

Constructor Summary
LexerTokenAndCharacterPairAwareStrategy()
           
 
Method Summary
protected  org.eclipse.jface.text.IRegion findExtendedDoubleClickSelection(org.eclipse.jface.text.IDocument document, int offset)
          Tries to find a suitable double click selection for the given offset.
protected  org.eclipse.jface.text.IRegion findWord(org.eclipse.jface.text.IDocument document, int offset)
          Tries to find the word at the given offset.
protected  org.eclipse.jface.text.source.ICharacterPairMatcher getCharacterPairMatcher()
           
 
Methods inherited from class org.eclipse.xtext.ui.editor.doubleClicking.AbstractWordAwareDoubleClickStrategy
createBreakIterator
 
Methods inherited from class org.eclipse.jface.text.DefaultTextDoubleClickStrategy
doubleClicked
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LexerTokenAndCharacterPairAwareStrategy

public LexerTokenAndCharacterPairAwareStrategy()
Method Detail

findWord

protected org.eclipse.jface.text.IRegion findWord(org.eclipse.jface.text.IDocument document,
                                                  int offset)
Description copied from class: org.eclipse.jface.text.DefaultTextDoubleClickStrategy
Tries to find the word at the given offset.

Overrides:
findWord in class AbstractWordAwareDoubleClickStrategy
Parameters:
document - the document
offset - the offset
Returns:
the word or null if none

findExtendedDoubleClickSelection

protected org.eclipse.jface.text.IRegion findExtendedDoubleClickSelection(org.eclipse.jface.text.IDocument document,
                                                                          int offset)
Description copied from class: org.eclipse.jface.text.DefaultTextDoubleClickStrategy
Tries to find a suitable double click selection for the given offset.

Note: This method must return null if it simply selects the word at the given offset.

Overrides:
findExtendedDoubleClickSelection in class org.eclipse.jface.text.DefaultTextDoubleClickStrategy
Parameters:
document - the document
offset - the offset
Returns:
the selection or null if none to indicate simple word selection

getCharacterPairMatcher

protected org.eclipse.jface.text.source.ICharacterPairMatcher getCharacterPairMatcher()