Search in sources :

Example 26 with InterpreterInfo

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;
}
Also used : MisconfigurationException(org.python.pydev.core.MisconfigurationException) InterpreterInfo(org.python.pydev.ast.interpreter_managers.InterpreterInfo) IInterpreterInfo(org.python.pydev.core.IInterpreterInfo) IInterpreterManager(org.python.pydev.core.IInterpreterManager)

Example 27 with InterpreterInfo

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);
    }
}
Also used : MisconfigurationException(org.python.pydev.core.MisconfigurationException) InterpreterInfo(org.python.pydev.ast.interpreter_managers.InterpreterInfo) IInterpreterInfo(org.python.pydev.core.IInterpreterInfo) IInterpreterManager(org.python.pydev.core.IInterpreterManager)

Example 28 with InterpreterInfo

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());
    }
}
Also used : IInfo(org.python.pydev.core.IInfo) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ISystemModulesManager(org.python.pydev.core.ISystemModulesManager) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) PythonInterpreterManager(org.python.pydev.ast.interpreter_managers.PythonInterpreterManager) ArrayList(java.util.ArrayList) InterpreterInfo(org.python.pydev.ast.interpreter_managers.InterpreterInfo) AdditionalSystemInterpreterInfo(com.python.pydev.analysis.additionalinfo.AdditionalSystemInterpreterInfo) IInterpreterInfo(org.python.pydev.core.IInterpreterInfo) AdditionalSystemInterpreterInfo(com.python.pydev.analysis.additionalinfo.AdditionalSystemInterpreterInfo)

Example 29 with InterpreterInfo

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));
    }
}
Also used : IInterpreterInfo(org.python.pydev.core.IInterpreterInfo) InterpreterInfo(org.python.pydev.ast.interpreter_managers.InterpreterInfo) AdditionalSystemInterpreterInfo(com.python.pydev.analysis.additionalinfo.AdditionalSystemInterpreterInfo) IInterpreterInfo(org.python.pydev.core.IInterpreterInfo) IInterpreterManager(org.python.pydev.core.IInterpreterManager) Tuple(org.python.pydev.shared_core.structure.Tuple)

Example 30 with InterpreterInfo

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());
    }
}
Also used : ArrayList(java.util.ArrayList) DataAndImageTreeNode(org.python.pydev.shared_core.structure.DataAndImageTreeNode) IInterpreterManager(org.python.pydev.core.IInterpreterManager) SyncSystemModulesManager(org.python.pydev.ast.codecompletion.revisited.SyncSystemModulesManager) AdditionalSystemInterpreterInfo(com.python.pydev.analysis.additionalinfo.AdditionalSystemInterpreterInfo) IInfo(org.python.pydev.core.IInfo) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IInterpreterInfo(org.python.pydev.core.IInterpreterInfo) DataAndImageTreeNode(org.python.pydev.shared_core.structure.DataAndImageTreeNode) TreeNode(org.python.pydev.shared_core.structure.TreeNode) Collection(java.util.Collection) InterpreterInfo(org.python.pydev.ast.interpreter_managers.InterpreterInfo) AdditionalSystemInterpreterInfo(com.python.pydev.analysis.additionalinfo.AdditionalSystemInterpreterInfo) IInterpreterInfo(org.python.pydev.core.IInterpreterInfo) HashMap(java.util.HashMap) Map(java.util.Map) ManagerInfoToUpdate(org.python.pydev.ast.codecompletion.revisited.ManagerInfoToUpdate)

Aggregations

InterpreterInfo (org.python.pydev.ast.interpreter_managers.InterpreterInfo)34 IInterpreterInfo (org.python.pydev.core.IInterpreterInfo)27 IInterpreterManager (org.python.pydev.core.IInterpreterManager)13 ArrayList (java.util.ArrayList)11 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)9 AdditionalSystemInterpreterInfo (com.python.pydev.analysis.additionalinfo.AdditionalSystemInterpreterInfo)7 HashMap (java.util.HashMap)5 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)5 File (java.io.File)4 Collection (java.util.Collection)4 HashSet (java.util.HashSet)4 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)4 PythonInterpreterManager (org.python.pydev.ast.interpreter_managers.PythonInterpreterManager)4 MisconfigurationException (org.python.pydev.core.MisconfigurationException)4 DataAndImageTreeNode (org.python.pydev.shared_core.structure.DataAndImageTreeNode)4 TreeNode (org.python.pydev.shared_core.structure.TreeNode)4 Tuple (org.python.pydev.shared_core.structure.Tuple)4 Map (java.util.Map)3 SyncSystemModulesManager (org.python.pydev.ast.codecompletion.revisited.SyncSystemModulesManager)3 IInfo (org.python.pydev.core.IInfo)3