Name n = (Name) d.bases[i];
state.setActivationToken(n.id);
IToken[] completions;
try {
ICodeCompletionASTManager astManager = request.nature.getAstManager();
IModule module = request.getModule();
if (module != null) {
completions = astManager.getCompletionsForModule(module, state, true, true);
for (int j = 0; j < completions.length; j++) {
theList.add(completions[j]);
}
}
} catch (CompletionRecursionException e) {
//ok...
}
}
}
} else {
//ok, get the completions for the class, only thing we have to take care now is that we may
//not have only 'self' for completion, but something like self.foo.
//so, let's analyze our activation token to see what should we do.
String trimmed = request.activationToken.replace('.', ' ').trim();
String[] actTokStrs = trimmed.split(" ");
if (actTokStrs.length == 0 || (!actTokStrs[0].equals("self") && !actTokStrs[0].equals("cls"))) {
throw new AssertionError(
"We need to have at least one token (self or cls) for doing completions in the class.");
}
if (actTokStrs.length == 1) {
//ok, it's just really self, let's get on to get the completions
state.setActivationToken(NodeUtils.getNameFromNameTok((NameTok) d.name));
try {
ICodeCompletionASTManager astManager = request.nature.getAstManager();
IModule module = request.getModule();
IToken[] completions = astManager.getCompletionsForModule(module, state, true, true);
for (int j = 0; j < completions.length; j++) {
theList.add(completions[j]);
}
} catch (CompletionRecursionException e) {
//ok
}
} else {
//it's not only self, so, first we have to get the definition of the token
//the first one is self, so, just discard it, and go on, token by token to know what is the last
//one we are completing (e.g.: self.foo.bar)
int line = request.doc.getLineOfOffset(request.documentOffset);
IRegion region = request.doc.getLineInformationOfOffset(request.documentOffset);
int col = request.documentOffset - region.getOffset();
//ok, try our best shot at getting the module name of the current buffer used in the request.
IModule module = request.getModule();
AbstractASTManager astMan = ((AbstractASTManager) request.nature.getAstManager());
theList.addAll(new AssignAnalysis().getAssignCompletions(astMan, module, new CompletionState(
line, col, request.activationToken, request.nature, request.qualifier)).completions);
}