use of org.python.pydev.ast.interpreter_managers.InterpreterInfo in project Pydev by fabioz.
the class CodeCompletionTestsBase method getDefaultInterpreterInfo.
/**
* @return the default interpreter info for the current manager
*/
protected InterpreterInfo getDefaultInterpreterInfo() {
IInterpreterManager iMan = getInterpreterManager();
InterpreterInfo info;
try {
info = (InterpreterInfo) iMan.getDefaultInterpreterInfo(false);
} catch (MisconfigurationException e) {
throw new RuntimeException(e);
}
return info;
}
use of org.python.pydev.ast.interpreter_managers.InterpreterInfo in project Pydev by fabioz.
the class CodeCompletionTestsBase method checkSize.
/**
* checks if the size of the system modules manager and the project moule manager are coherent
* (we must have more modules in the system than in the project)
*/
protected void checkSize() {
try {
IInterpreterManager iMan = getInterpreterManager();
InterpreterInfo info = (InterpreterInfo) iMan.getDefaultInterpreterInfo(false);
assertTrue(info.getModulesManager().getSize(true) > 0);
int size = ((ASTManager) nature.getAstManager()).getSize();
assertTrue("Interpreter size:" + info.getModulesManager().getSize(true) + " should be smaller than project size:" + size + " " + "(because it contains system+project info)", info.getModulesManager().getSize(true) < size);
size = ((ASTManager) nature2.getAstManager()).getSize();
assertTrue("Interpreter size:" + info.getModulesManager().getSize(true) + " should be smaller than project size:" + size + " " + "(because it contains system+project info)", info.getModulesManager().getSize(true) < size);
} catch (MisconfigurationException e) {
throw new RuntimeException(e);
}
}
use of org.python.pydev.ast.interpreter_managers.InterpreterInfo in project Pydev by fabioz.
the class SyncSystemModulesManagerTest method setupEnv.
private void setupEnv(boolean setupInitialInfoProperly) throws MisconfigurationException {
Collection<String> pythonpath = new ArrayList<String>();
pythonpath.add(libDir.toString());
final InterpreterInfo info = new InterpreterInfo("2.6", TestDependent.PYTHON2_EXE, pythonpath);
IEclipsePreferences preferences = createPreferenceStore();
final PythonInterpreterManager manager = new PythonInterpreterManager(preferences);
InterpreterManagersAPI.setPythonInterpreterManager(manager);
manager.setInfos(new IInterpreterInfo[] { info }, null, null);
AdditionalSystemInterpreterInfo additionalInfo = new AdditionalSystemInterpreterInfo(manager, info.getExecutableOrJar());
AdditionalSystemInterpreterInfo.setAdditionalSystemInfo(manager, info.getExecutableOrJar(), additionalInfo);
// Don't load it (otherwise it'll get the 'proper' info).
if (setupInitialInfoProperly) {
InterpreterInfo infoOnManager = manager.getInterpreterInfo(info.getExecutableOrJar(), null);
assertEquals(infoOnManager.getPythonPath(), info.getPythonPath());
NullProgressMonitor monitor = new NullProgressMonitor();
info.restorePythonpath(monitor);
AdditionalSystemInterpreterInfo.recreateAllInfo(manager, info.getExecutableOrJar(), monitor);
final ISystemModulesManager modulesManager = info.getModulesManager();
assertEquals(3, modulesManager.getSize(false));
assertEquals(3, infoOnManager.getModulesManager().getSize(false));
additionalInfo = (AdditionalSystemInterpreterInfo) AdditionalSystemInterpreterInfo.getAdditionalSystemInfo(manager, info.getExecutableOrJar());
Collection<IInfo> allTokens = additionalInfo.getAllTokens();
assertEquals(3, additionalInfo.getAllTokens().size());
} else {
final ISystemModulesManager modulesManager = info.getModulesManager();
assertEquals(0, modulesManager.getSize(false));
assertEquals(0, additionalInfo.getAllTokens().size());
}
}
use of org.python.pydev.ast.interpreter_managers.InterpreterInfo in project Pydev by fabioz.
the class SyncSystemModulesManagerTest method checkSynchronize.
private void checkSynchronize(SyncSystemModulesManager synchManager, final DataAndImageTreeNode root, ManagerInfoToUpdate managerToNameToInfo) {
// Ok, all is Ok in the PYTHONPATH, so, check if something changed inside the interpreter info
// and not on the PYTHONPATH.
assertFalse(root.hasChildren());
InterpreterInfoBuilder builder = new InterpreterInfoBuilder();
synchManager.synchronizeManagerToNameToInfoPythonpath(null, managerToNameToInfo, builder);
Tuple<IInterpreterManager, IInterpreterInfo>[] managerAndInfos = managerToNameToInfo.getManagerAndInfos();
for (Tuple<IInterpreterManager, IInterpreterInfo> tuple : managerAndInfos) {
InterpreterInfo interpreterInfo = (InterpreterInfo) tuple.o2;
assertEquals(3, interpreterInfo.getModulesManager().getSize(false));
}
}
use of org.python.pydev.ast.interpreter_managers.InterpreterInfo in project Pydev by fabioz.
the class SyncSystemModulesManagerTest method testUpdateWhenEggIsAdded.
public void testUpdateWhenEggIsAdded() throws Exception {
setupEnv(true);
SyncSystemModulesManager synchManager = new SyncSystemModulesManager();
final DataAndImageTreeNode root = new DataAndImageTreeNode(null, null, null);
Map<IInterpreterManager, Map<String, IInterpreterInfo>> managerToNameToInfoMap = InterpreterManagersAPI.getInterpreterManagerToInterpreterNameToInfo();
ManagerInfoToUpdate managerToNameToInfo = new ManagerInfoToUpdate(managerToNameToInfoMap);
checkUpdateStructures(synchManager, root, managerToNameToInfo);
checkSynchronize(synchManager, root, managerToNameToInfo);
root.clear();
managerToNameToInfo = new ManagerInfoToUpdate(InterpreterManagersAPI.getInterpreterManagerToInterpreterNameToInfo());
synchManager.updateStructures(null, root, managerToNameToInfo, new SyncSystemModulesManager.CreateInterpreterInfoCallback() {
@Override
public IInterpreterInfo createInterpreterInfo(IInterpreterManager manager, String executable, IProgressMonitor monitor) {
Collection<String> pythonpath = new ArrayList<String>();
pythonpath.add(libDir.toString());
pythonpath.add(libZipFile.toString());
final InterpreterInfo info = new InterpreterInfo("2.6", TestDependent.PYTHON2_EXE, pythonpath);
return info;
}
});
assertTrue(root.hasChildren());
List<TreeNode> selectElements = new ArrayList<>();
selectElements.addAll(root.flattenChildren());
synchManager.applySelectedChangesToInterpreterInfosPythonpath(root, selectElements, null);
List<IInterpreterInfo> allInterpreterInfos = InterpreterManagersAPI.getAllInterpreterInfos();
for (IInterpreterInfo interpreterInfo : allInterpreterInfos) {
assertEquals(4, interpreterInfo.getModulesManager().getSize(false));
AdditionalSystemInterpreterInfo additionalInfo = (AdditionalSystemInterpreterInfo) AdditionalSystemInterpreterInfo.getAdditionalSystemInfo(interpreterInfo.getModulesManager().getInterpreterManager(), interpreterInfo.getExecutableOrJar());
Collection<IInfo> allTokens = additionalInfo.getAllTokens();
assertEquals(4, additionalInfo.getAllTokens().size());
}
}
Aggregations