// Without an underlying model, we have to rescan the line to
// figure out exactly
// what the current matching rule was, so we know what kind of
// token we're dealing with.
IRegion lineRegion = document.getLineInformationOfOffset(offset);
WodScanner scanner = WodScanner.newWODScanner();
scanner.setRange(document, lineRegion.getOffset(), lineRegion.getLength());
boolean foundToken = false;
RulePosition rulePosition = null;
while (!foundToken && (rulePosition = scanner.nextRulePosition()) != null) {
int tokenOffset = rulePosition.getTokenOffset();
if (offset == lineRegion.getOffset() && offset == tokenOffset) {
foundToken = true;
} else if (offset > tokenOffset && offset <= rulePosition.getTokenEndOffset()) {
foundToken = true;
}
}
// We can't reliably use rulePosition here because it might be
// null ...
int tokenOffset = scanner.getTokenOffset();
int tokenLength = scanner.getTokenLength();
IRule rule = (rulePosition == null) ? null : rulePosition.getRule();
// If you make a completion request in the middle of whitespace,
// we don't want to select the whitespace, so zero out the
// whitespace token offsets.
if (rule instanceof WhitespaceRule) {