Ejemplo n.º 1
0
  /** @param version IPythonNature.PYTHON_VERSION_XXX */
  protected ModuleAdapter createModuleAdapterFromDataSource(String version) throws Throwable {
    codeCompletionTestsBase.restorePythonPath(
        REF.getFileAbsolutePath(data.file.getParentFile()), true);
    PythonModuleManager pythonModuleManager =
        new PythonModuleManager(CodeCompletionTestsBase.nature);
    if (version != null) {
      // As the files will be found in the system, we need to set the system modules manager info.
      IModulesManager modulesManager = pythonModuleManager.getIModuleManager();
      SystemModulesManager systemModulesManager =
          (SystemModulesManager) modulesManager.getSystemModulesManager();
      systemModulesManager.setInfo(new InterpreterInfo(version, "", new ArrayList<String>()));

      CodeCompletionTestsBase.nature.setVersion(version, null);
    }
    ModuleAdapter module =
        VisitorFactory.createModuleAdapter(
            pythonModuleManager,
            data.file,
            new Document(data.source),
            CodeCompletionTestsBase.nature,
            CodeCompletionTestsBase.nature);
    return module;
  }
Ejemplo n.º 2
0
 public static ModuleAdapter createModuleAdapter(
     PythonModuleManager pythonModuleManager, File file, IDocument doc, IPythonNature nature)
     throws Throwable {
   if (file != null && file.exists()) {
     if (pythonModuleManager != null) {
       IModulesManager modulesManager = pythonModuleManager.getIModuleManager();
       if (modulesManager != null) {
         String modName = modulesManager.resolveModule(REF.getFileAbsolutePath(file));
         if (modName != null) {
           IModule module = modulesManager.getModule(modName, nature, true);
           if (module instanceof ISourceModule) {
             SourceModule iSourceModule = (SourceModule) module;
             if (iSourceModule.parseError != null) {
               throw iSourceModule.parseError;
             }
             return new ModuleAdapter(pythonModuleManager, ((ISourceModule) module), nature, doc);
           }
         }
       }
     }
   }
   return new ModuleAdapter(pythonModuleManager, file, doc, getRootNode(doc), nature);
 }
Ejemplo n.º 3
0
 @Override
 protected void tearDown() throws Exception {
   PythonModuleManager.setTesting(false);
   codeCompletionTestsBase.tearDown();
 }
Ejemplo n.º 4
0
 @Override
 protected void setUp() throws Exception {
   PythonModuleManager.setTesting(true);
   codeCompletionTestsBase.setUp();
 }