/** * @param findInfo * @see * org.python.pydev.editor.codecompletion.revisited.modules.AbstractModule#findDefinition(java.lang.String, * int, int) */ public Definition[] findDefinition( ICompletionState state, int line, int col, IPythonNature nature) throws Exception { String token = state.getActivationToken(); if (TRACE_COMPILED_MODULES) { System.out.println("CompiledModule.findDefinition:" + token); } Definition[] found = this.definitionsFoundCache.getObj(token); if (found != null) { if (TRACE_COMPILED_MODULES) { System.out.println("CompiledModule.findDefinition: found in cache."); } return found; } AbstractShell shell = AbstractShell.getServerShell(nature, AbstractShell.COMPLETION_SHELL); synchronized (shell) { Tuple<String[], int[]> def = shell.getLineCol( this.name, token, nature .getAstManager() .getModulesManager() .getCompletePythonPath( nature.getProjectInterpreter(), nature.getRelatedInterpreterManager())); // default if (def == null) { if (TRACE_COMPILED_MODULES) { System.out.println("CompiledModule.findDefinition:" + token + " = empty"); } this.definitionsFoundCache.add(token, EMPTY_DEFINITION); return EMPTY_DEFINITION; } String fPath = def.o1[0]; if (fPath.equals("None")) { if (TRACE_COMPILED_MODULES) { System.out.println("CompiledModule.findDefinition:" + token + " = None"); } Definition[] definition = new Definition[] {new Definition(def.o2[0], def.o2[1], token, null, null, this)}; this.definitionsFoundCache.add(token, definition); return definition; } File f = new File(fPath); String foundModName = nature.resolveModule(f); String foundAs = def.o1[1]; IModule mod; if (foundModName == null) { // this can happen in a case where we have a definition that's found from a compiled file // which actually // maps to a file that's outside of the pythonpath known by Pydev. String n = FullRepIterable.getFirstPart(f.getName()); mod = AbstractModule.createModule(n, f, nature, true); } else { mod = nature.getAstManager().getModule(foundModName, nature, true); } if (TRACE_COMPILED_MODULES) { System.out.println("CompiledModule.findDefinition: found at:" + mod.getName()); } int foundLine = def.o2[0]; if (foundLine == 0 && foundAs != null && foundAs.length() > 0 && mod != null && state.canStillCheckFindSourceFromCompiled(mod, foundAs)) { // TODO: The nature (and so the grammar to be used) must be defined by the file we'll parse // (so, we need to know the system modules manager that actually created it to know the // actual nature) IModule sourceMod = AbstractModule.createModuleFromDoc( mod.getName(), f, new Document(REF.getFileContents(f)), nature, true); if (sourceMod instanceof SourceModule) { Definition[] definitions = (Definition[]) sourceMod.findDefinition(state.getCopyWithActTok(foundAs), -1, -1, nature); if (definitions.length > 0) { this.definitionsFoundCache.add(token, definitions); return definitions; } } } if (mod == null) { mod = this; } int foundCol = def.o2[1]; if (foundCol < 0) { foundCol = 0; } if (TRACE_COMPILED_MODULES) { System.out.println("CompiledModule.findDefinition: found compiled at:" + mod.getName()); } Definition[] definitions = new Definition[] {new Definition(foundLine + 1, foundCol + 1, token, null, null, mod)}; this.definitionsFoundCache.add(token, definitions); return definitions; } }