Search in sources :

Example 6 with ISystemModulesManager

use of org.python.pydev.core.ISystemModulesManager in project Pydev by fabioz.

the class ProjectModulesManager method getBuiltins.

/**
 * @see org.python.pydev.core.IProjectModulesManager#getBuiltins()
 */
@Override
public String[] getBuiltins() {
    String[] builtins = null;
    ISystemModulesManager systemModulesManager = getSystemModulesManager();
    if (systemModulesManager != null) {
        builtins = systemModulesManager.getBuiltins();
    }
    return builtins;
}
Also used : ISystemModulesManager(org.python.pydev.core.ISystemModulesManager)

Example 7 with ISystemModulesManager

use of org.python.pydev.core.ISystemModulesManager in project Pydev by fabioz.

the class CompiledModule method getCached.

/**
 * Gets cached information for the given name. Could be a dotted or non-dotted name.
 */
private static Tuple<File, IToken[]> getCached(String name, IModulesManager manager) {
    ISystemModulesManager systemModulesManager = manager.getSystemModulesManager();
    File f = getCacheFile(name, systemModulesManager);
    if (f != null && f.exists()) {
        try {
            IToken[] toks = null;
            File file = null;
            try (FileInputStream fin = new FileInputStream(f)) {
                try (InputStream in = new BufferedInputStream(new GZIPInputStream(fin))) {
                    try (ObjectInputStream stream = new ObjectInputStream(in)) {
                        ObjectsInternPool.ObjectsPoolMap map = new ObjectsInternPool.ObjectsPoolMap();
                        @SuppressWarnings("unused") Object // we already have the name set (so, it's only there for completeness).
                        _name = stream.readObject();
                        file = (File) stream.readObject();
                        int size = stream.readInt();
                        toks = new IToken[size];
                        IPythonNature nature = systemModulesManager.getNature();
                        for (int i = 0; i < size; i++) {
                            // Note intern (we probably have many empty strings -- or the same for parentPackage)
                            String rep = ObjectsInternPool.internLocal(map, (String) stream.readObject());
                            int type = stream.readInt();
                            String args = ObjectsInternPool.internLocal(map, (String) stream.readObject());
                            String parentPackage = ObjectsInternPool.internLocal(map, (String) stream.readObject());
                            toks[i] = new CompiledToken(rep, "", args, parentPackage, type, nature);
                        }
                        for (int i = 0; i < size; i++) {
                            toks[i].setDocStr(ObjectsInternPool.internLocal(map, (String) stream.readObject()));
                        }
                    }
                }
            }
            return new Tuple<File, IToken[]>(file, toks);
        } catch (Exception e) {
            // Unable to read: just log it
            Log.log("Unable to read contents from: " + f, e);
        }
    }
    return null;
}
Also used : GZIPInputStream(java.util.zip.GZIPInputStream) BufferedInputStream(java.io.BufferedInputStream) ObjectInputStream(java.io.ObjectInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) IPythonNature(org.python.pydev.core.IPythonNature) FileInputStream(java.io.FileInputStream) CoreException(org.eclipse.core.runtime.CoreException) PythonNatureWithoutProjectException(org.python.pydev.core.PythonNatureWithoutProjectException) IOException(java.io.IOException) MisconfigurationException(org.python.pydev.core.MisconfigurationException) GZIPInputStream(java.util.zip.GZIPInputStream) ISystemModulesManager(org.python.pydev.core.ISystemModulesManager) IToken(org.python.pydev.core.IToken) BufferedInputStream(java.io.BufferedInputStream) ObjectsInternPool(org.python.pydev.core.ObjectsInternPool) File(java.io.File) Tuple(org.python.pydev.shared_core.structure.Tuple) ObjectInputStream(java.io.ObjectInputStream)

Example 8 with ISystemModulesManager

use of org.python.pydev.core.ISystemModulesManager in project Pydev by fabioz.

the class InterpreterGroup method calculateChildren.

@Override
protected void calculateChildren() {
    Iterator<String> forcedLibsIterator = this.interpreterInfo.forcedLibsIterator();
    while (forcedLibsIterator.hasNext()) {
        addChild(new ForcedLibGroup(this, this.interpreterInfo, forcedLibsIterator.next()));
    }
    ISystemModulesManager modulesManager = this.interpreterInfo.getModulesManager();
    Set<String> allModuleNames = modulesManager.getAllModuleNames(false, "");
    for (String moduleName : allModuleNames) {
        addChild(new LeafElement(this, moduleName));
    }
}
Also used : ISystemModulesManager(org.python.pydev.core.ISystemModulesManager)

Example 9 with ISystemModulesManager

use of org.python.pydev.core.ISystemModulesManager in project Pydev by fabioz.

the class InterpreterInfoBuilder method syncInfoToPythonPath.

public BuilderResult syncInfoToPythonPath(IProgressMonitor monitor, InterpreterInfo info, AbstractAdditionalDependencyInfo additionalInfo) {
    ISystemModulesManager modulesManager = info.getModulesManager();
    PythonPathHelper pythonPathHelper = (PythonPathHelper) modulesManager.getPythonPathHelper();
    if (pythonPathHelper == null) {
        // Is this even possible?
        pythonPathHelper = new PythonPathHelper();
    }
    // Just making sure it's consistent at this point.
    pythonPathHelper.setPythonPath(info.libs);
    return this.syncInfoToPythonPath(monitor, pythonPathHelper, additionalInfo, modulesManager, info);
}
Also used : ISystemModulesManager(org.python.pydev.core.ISystemModulesManager) PythonPathHelper(org.python.pydev.ast.codecompletion.revisited.PythonPathHelper)

Example 10 with ISystemModulesManager

use of org.python.pydev.core.ISystemModulesManager in project Pydev by fabioz.

the class InterpreterInfoBuilder method syncInfoToPythonPath.

@Override
public BuilderResult syncInfoToPythonPath(IProgressMonitor monitor, InterpreterInfo info) {
    ISystemModulesManager modulesManager = info.getModulesManager();
    IInterpreterManager manager = modulesManager.getInterpreterManager();
    AbstractAdditionalDependencyInfo additionalInfo;
    try {
        additionalInfo = AdditionalSystemInterpreterInfo.getAdditionalSystemInfo(manager, info.getExecutableOrJar());
    } catch (MisconfigurationException e) {
        Log.log(e);
        return BuilderResult.OK;
    }
    return this.syncInfoToPythonPath(monitor, info, additionalInfo);
}
Also used : ISystemModulesManager(org.python.pydev.core.ISystemModulesManager) MisconfigurationException(org.python.pydev.core.MisconfigurationException) AbstractAdditionalDependencyInfo(com.python.pydev.analysis.additionalinfo.AbstractAdditionalDependencyInfo) IInterpreterManager(org.python.pydev.core.IInterpreterManager)

Aggregations

ISystemModulesManager (org.python.pydev.core.ISystemModulesManager)16 IInterpreterInfo (org.python.pydev.core.IInterpreterInfo)6 MisconfigurationException (org.python.pydev.core.MisconfigurationException)6 ArrayList (java.util.ArrayList)5 File (java.io.File)4 CoreException (org.eclipse.core.runtime.CoreException)3 InterpreterInfo (org.python.pydev.ast.interpreter_managers.InterpreterInfo)3 IModule (org.python.pydev.core.IModule)3 IModulesManager (org.python.pydev.core.IModulesManager)3 IPythonNature (org.python.pydev.core.IPythonNature)3 PythonNatureWithoutProjectException (org.python.pydev.core.PythonNatureWithoutProjectException)3 AbstractAdditionalDependencyInfo (com.python.pydev.analysis.additionalinfo.AbstractAdditionalDependencyInfo)2 AdditionalSystemInterpreterInfo (com.python.pydev.analysis.additionalinfo.AdditionalSystemInterpreterInfo)2 IOException (java.io.IOException)2 IProject (org.eclipse.core.resources.IProject)2 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)2 PythonPathHelper (org.python.pydev.ast.codecompletion.revisited.PythonPathHelper)2 PythonInterpreterManager (org.python.pydev.ast.interpreter_managers.PythonInterpreterManager)2 IInfo (org.python.pydev.core.IInfo)2 IProjectModulesManager (org.python.pydev.core.IProjectModulesManager)2