IModuleResolver mr) {
assertTrue(isInRange(0, offset, parseResult.source.length()));
TokenAtOffsetResult tokenAtOffsetResult = parseResult.findTokenAtOffset(offset);
IToken tokenAtOffsetLeft = tokenAtOffsetResult.atLeft;
IToken tokenAtOffsetRight = tokenAtOffsetResult.atRight;
if(tokenAtOffsetResult.isSingleToken()
&& isInsideRange(tokenAtOffsetLeft.getStartPos(), offset, tokenAtOffsetLeft.getEndPos())
&& canCompleteInsideToken(tokenAtOffsetLeft)
) {
return new CompletionSearchResult(ECompletionResultStatus.INVALID_TOKEN_LOCATION);
}
if(tokenAtOffsetLeft != null
&& tokenAtOffsetLeft.getType().getGroupingToken() == DeeTokens.GROUP_FLOAT
&& tokenAtOffsetLeft.getSourceValue().endsWith(".")) {
return new CompletionSearchResult(ECompletionResultStatus.INVALID_TOKEN_LOCATION_FLOAT);
}
final IToken nameToken;
if(tokenAtOffsetLeft != null && tokenAtOffsetLeft.getType().isAlphaNumeric()) {
nameToken = tokenAtOffsetLeft;
} else if(tokenAtOffsetRight != null && tokenAtOffsetRight.getType().isAlphaNumeric()) {
nameToken = tokenAtOffsetRight;
} else {
nameToken = null;
}
Module module = parseResult.getModuleNode();
ASTNode nodeAtOffset = new ASTNodeFinderExtension(module, offset, true).match;
assertTrue(nodeAtOffset.getSourceRange().contains(offset));
if(nodeAtOffset instanceof CommonQualifiedReference) {
CommonQualifiedReference namedRef = (CommonQualifiedReference) nodeAtOffset;
assertTrue(nameToken == null);
if(offset <= namedRef.getDotOffset()) {
nodeAtOffset = namedRef.getParent();
}
PrefixSearchOptions searchOptions = new PrefixSearchOptions();
return performCompletionSearch(offset, mr, module, nodeAtOffset, searchOptions);
} else if(nodeAtOffset instanceof RefModule) {
RefModule refModule = (RefModule) nodeAtOffset;
// RefModule has a specialized way to setup prefix len things
String source = parseResult.source;
PrefixSearchOptions searchOptions = codeCompletionRefModule(offset, tokenAtOffsetRight, source, refModule);
return performCompletionSearch(offset, mr, module, nodeAtOffset, searchOptions);
}
if(nameToken != null) {
assertTrue(nameToken.getSourceRange().contains(offset));
PrefixSearchOptions searchOptions = new PrefixSearchOptions();
String searchPrefix = nameToken.getSourceValue().substring(0, offset - nameToken.getStartPos());
int rplLen = nameToken.getEndPos() - offset;
searchOptions.setPrefixSearchOptions(searchPrefix, rplLen);
// Because of some parser limitations, in some cases nodeForNameLookup needs to be corrected,
// such that it won't be the same as nodeForNameLookup
ASTNode nodeForNameLookup = getStartingNodeForNameLookup(nameToken.getStartPos(), module);
return performCompletionSearch(offset, mr, module, nodeForNameLookup, searchOptions);
} else {
PrefixSearchOptions searchOptions = new PrefixSearchOptions();