}
}
//not found... check as local imports
List<IToken> localImportedModules = scopeVisitor.scope.getLocalImportedModules(line, col, this.name);
ICodeCompletionASTManager astManager = nature.getAstManager();
int lenImportedModules = localImportedModules.size();
for (int i = 0; i < lenImportedModules; i++) {
IToken tok = localImportedModules.get(i);
String importRep = tok.getRepresentation();
if (importRep.equals(actTok) || actTok.startsWith(importRep + ".")) {
Tuple3<IModule, String, IToken> o = astManager.findOnImportedMods(new IToken[] { tok },
state.getCopyWithActTok(actTok), this.getName(), this);
if (o != null && o.o1 instanceof SourceModule) {
ICompletionState copy = state.getCopy();
copy.setActivationToken(o.o2);
findDefinitionsFromModAndTok(nature, toRet, null, (SourceModule) o.o1, copy);
}
if (toRet.size() > 0) {
return (Definition[]) toRet.toArray(new Definition[0]);
}
}
}
//ok, not assign nor import, let's check if it is some self (we do not check for only 'self' because that would map to a
//local (which has already been covered).
if (actTok.startsWith("self.")) {
//ok, it is some self, now, that is only valid if we are in some class definition
ClassDef classDef = (ClassDef) scopeVisitor.scope.getClassDef();
if (classDef != null) {
//ok, we are in a class, so, let's get the self completions
String classRep = NodeUtils.getRepresentationString(classDef);
IToken[] globalTokens = getGlobalTokens(new CompletionState(line - 1, col - 1, classRep, nature, "",
state), //use the old state as the cache
astManager);
String withoutSelf = actTok.substring(5);
for (IToken token : globalTokens) {
if (token.getRepresentation().equals(withoutSelf)) {
String parentPackage = token.getParentPackage();
IModule module = astManager.getModule(parentPackage, nature, true);
if (token instanceof SourceToken
&& (module != null || this.name == null || this.name.equals(parentPackage))) {
if (module == null) {
module = this;
}
SimpleNode ast2 = ((SourceToken) token).getAst();
Tuple<Integer, Integer> def = getLineColForDefinition(ast2);
FastStack<SimpleNode> stack = new FastStack<SimpleNode>(5);
if (module instanceof SourceModule) {
stack.push(((SourceModule) module).getAst());
}
stack.push(classDef);
ILocalScope scope = new LocalScope(stack);
return new Definition[] { new Definition(def.o1, def.o2, token.getRepresentation(), ast2,
scope, module) };
} else {
return new Definition[0];
}
}
}
}
}
//ok, it is not an assign, so, let's search the global tokens (and imports)
String tok = actTok;
SourceModule mod = this;
Tuple3<IModule, String, IToken> o = astManager.findOnImportedMods(state.getCopyWithActTok(actTok), this);
if (o != null) {
if (o.o1 instanceof SourceModule) {
mod = (SourceModule) o.o1;
tok = o.o2;