Search in sources :

Example 6 with IInfo

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

the class IOUtils method getWithFilter.

/**
 * @param qualifier
 * @param initialsToInfo this is where we are going to get the info from (currently: inner or top level list)
 * @param toks (out) the tokens will be added to this list
 * @return
 */
protected void getWithFilter(String qualifier, SortedMap<String, Set<IInfo>> initialsToInfo, Collection<IInfo> toks, Filter filter, boolean useLowerCaseQual) {
    String initials = getInitials(qualifier);
    String qualToCompare = qualifier;
    if (useLowerCaseQual) {
        qualToCompare = qualifier.toLowerCase();
    }
    // get until the end of the alphabet
    SortedMap<String, Set<IInfo>> subMap = initialsToInfo.subMap(initials, initials + "\uffff\uffff\uffff\uffff");
    for (Set<IInfo> listForInitials : subMap.values()) {
        for (IInfo info : listForInitials) {
            if (filter.doCompare(qualToCompare, info)) {
                toks.add(info);
            }
        }
    }
}
Also used : IInfo(org.python.pydev.core.IInfo) HashSet(java.util.HashSet) Set(java.util.Set)

Example 7 with IInfo

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

the class IOUtils method getAllModulesWithTokens.

/**
 * @return a set with the module names that have tokens.
 */
public Set<String> getAllModulesWithTokens() {
    HashSet<String> ret = new HashSet<String>();
    synchronized (lock) {
        Set<Entry<String, Set<IInfo>>> entrySet = this.topLevelInitialsToInfo.entrySet();
        for (Entry<String, Set<IInfo>> entry : entrySet) {
            Set<IInfo> value = entry.getValue();
            for (IInfo info : value) {
                ret.add(info.getDeclaringModuleName());
            }
        }
        entrySet = this.innerInitialsToInfo.entrySet();
        for (Entry<String, Set<IInfo>> entry : entrySet) {
            Set<IInfo> value = entry.getValue();
            for (IInfo info : value) {
                ret.add(info.getDeclaringModuleName());
            }
        }
    }
    return ret;
}
Also used : IInfo(org.python.pydev.core.IInfo) ASTEntry(org.python.pydev.parser.visitors.scope.ASTEntry) Entry(java.util.Map.Entry) HashSet(java.util.HashSet) Set(java.util.Set) HashSet(java.util.HashSet)

Example 8 with IInfo

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

the class AbstractInfo method equals.

@Override
public boolean equals(Object obj) {
    if (!(obj instanceof IInfo)) {
        return false;
    }
    IInfo otherInfo = (IInfo) obj;
    if (otherInfo.getType() != getType()) {
        return false;
    }
    if (!otherInfo.getDeclaringModuleName().equals(this.moduleDeclared)) {
        return false;
    }
    if (!otherInfo.getName().equals(this.name)) {
        return false;
    }
    // if one of them is null, the other must also be null...
    String otherPath = otherInfo.getPath();
    String myPath = getPath();
    if ((otherPath == null || myPath == null)) {
        if (otherPath != myPath) {
            // one of them is not null
            return false;
        }
        // both are null
        return true;
    }
    // they're not null
    if (!otherPath.equals(myPath)) {
        return false;
    }
    return true;
}
Also used : IInfo(org.python.pydev.core.IInfo)

Example 9 with IInfo

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

the class InfoStrFactory method infoToString.

/**
 * @param iInfo
 * @return
 */
public static String infoToString(List<IInfo> iInfo) {
    HashMap<String, Integer> map = new HashMap<String, Integer>();
    FastStringBuffer infos = new FastStringBuffer();
    int next = 0;
    map.put(null, next);
    next++;
    for (Iterator<IInfo> it = iInfo.iterator(); it.hasNext(); ) {
        IInfo info = it.next();
        infos.append("&&");
        // 0
        infos.append(info.getType());
        // 1
        next = add(map, infos, next, info.getName());
        // 2
        next = add(map, infos, next, info.getDeclaringModuleName());
        // 3
        next = add(map, infos, next, info.getPath());
        // 4
        next = add(map, infos, next, info.getFile());
        infos.append('|');
        // 5
        infos.append(info.getLine());
        infos.append('|');
        // 6
        infos.append(info.getCol());
    }
    FastStringBuffer header = new FastStringBuffer("INFOS:", map.size() * 30);
    Set<Entry<String, Integer>> entrySet = map.entrySet();
    // null is always 0 (not written to header)
    header.append(infos);
    header.append('\n');
    map.remove(null);
    for (Entry<String, Integer> entry : entrySet) {
        header.append(entry.getKey());
        header.append("=");
        header.append(entry.getValue());
        header.append("\n");
    }
    return header.toString();
}
Also used : IInfo(org.python.pydev.core.IInfo) Entry(java.util.Map.Entry) FastStringBuffer(org.python.pydev.shared_core.string.FastStringBuffer) HashMap(java.util.HashMap)

Example 10 with IInfo

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

the class GlobalsTwoPanelElementSelector2 method fillContentProvider.

/**
 * This is the place where we put all the info in the content provider. Note that here we must add
 * ALL the info -- later, we'll filter it based on the active working set.
 */
@Override
protected void fillContentProvider(AbstractContentProvider contentProvider, ItemsFilter itemsFilter, IProgressMonitor progressMonitor) throws CoreException {
    if (itemsFilter instanceof InfoFilter) {
        if (progressMonitor != null) {
            progressMonitor.beginTask("Searching...", this.additionalInfo.size());
        }
        for (AbstractAdditionalTokensInfo additionalInfo : this.additionalInfo) {
            if (progressMonitor != null) {
                if (progressMonitor.isCanceled()) {
                    return;
                } else {
                    progressMonitor.worked(1);
                }
            }
            // no duplicates
            Collection<IInfo> allTokens = new HashSet<IInfo>(additionalInfo.getAllTokens());
            for (IInfo iInfo : allTokens) {
                contentProvider.add(new AdditionalInfoAndIInfo(additionalInfo, iInfo), itemsFilter);
            }
            // Also show to the user the modules available as globals (2.2.3)
            IModulesManager modulesManager = null;
            try {
                if (additionalInfo instanceof AdditionalProjectInterpreterInfo) {
                    AdditionalProjectInterpreterInfo projectInterpreterInfo = (AdditionalProjectInterpreterInfo) additionalInfo;
                    IProject project = projectInterpreterInfo.getProject();
                    PythonNature nature = PythonNature.getPythonNature(project);
                    if (nature != null) {
                        ICodeCompletionASTManager astManager = nature.getAstManager();
                        if (astManager != null) {
                            modulesManager = astManager.getModulesManager();
                        }
                    }
                } else if (additionalInfo instanceof AdditionalSystemInterpreterInfo) {
                    AdditionalSystemInterpreterInfo systemInterpreterInfo = (AdditionalSystemInterpreterInfo) additionalInfo;
                    IInterpreterInfo defaultInterpreterInfo = systemInterpreterInfo.getManager().getDefaultInterpreterInfo(false);
                    modulesManager = defaultInterpreterInfo.getModulesManager();
                }
            } catch (Throwable e) {
                Log.log(e);
            }
            if (modulesManager != null) {
                SortedMap<ModulesKey, ModulesKey> allDirectModulesStartingWith = modulesManager.getAllDirectModulesStartingWith("");
                Collection<ModulesKey> values = allDirectModulesStartingWith.values();
                for (ModulesKey modulesKey : values) {
                    contentProvider.add(new AdditionalInfoAndIInfo(additionalInfo, new ModInfo(modulesKey.name, modulesManager.getNature(), modulesKey.file != null ? modulesKey.file.toString() : null, 1, 1)), itemsFilter);
                }
            }
        }
    }
    if (progressMonitor != null) {
        progressMonitor.done();
    }
}
Also used : IPythonNature(org.python.pydev.core.IPythonNature) PythonNature(org.python.pydev.plugin.nature.PythonNature) IModulesManager(org.python.pydev.core.IModulesManager) IProject(org.eclipse.core.resources.IProject) AdditionalSystemInterpreterInfo(com.python.pydev.analysis.additionalinfo.AdditionalSystemInterpreterInfo) AdditionalInfoAndIInfo(com.python.pydev.analysis.additionalinfo.AdditionalInfoAndIInfo) IInfo(org.python.pydev.core.IInfo) AdditionalProjectInterpreterInfo(com.python.pydev.analysis.additionalinfo.AdditionalProjectInterpreterInfo) ICodeCompletionASTManager(org.python.pydev.core.ICodeCompletionASTManager) IInterpreterInfo(org.python.pydev.core.IInterpreterInfo) AdditionalInfoAndIInfo(com.python.pydev.analysis.additionalinfo.AdditionalInfoAndIInfo) ModulesKey(org.python.pydev.core.ModulesKey) AbstractAdditionalTokensInfo(com.python.pydev.analysis.additionalinfo.AbstractAdditionalTokensInfo) ModInfo(com.python.pydev.analysis.additionalinfo.ModInfo) HashSet(java.util.HashSet)

Aggregations

IInfo (org.python.pydev.core.IInfo)33 ArrayList (java.util.ArrayList)12 MisconfigurationException (org.python.pydev.core.MisconfigurationException)10 HashSet (java.util.HashSet)8 AbstractAdditionalTokensInfo (com.python.pydev.analysis.additionalinfo.AbstractAdditionalTokensInfo)6 Set (java.util.Set)6 FastStringBuffer (org.python.pydev.shared_core.string.FastStringBuffer)6 AdditionalSystemInterpreterInfo (com.python.pydev.analysis.additionalinfo.AdditionalSystemInterpreterInfo)5 ItemPointer (org.python.pydev.ast.item_pointer.ItemPointer)5 ICodeCompletionASTManager (org.python.pydev.core.ICodeCompletionASTManager)5 Entry (java.util.Map.Entry)4 IPythonNature (org.python.pydev.core.IPythonNature)4 Document (org.eclipse.jface.text.Document)3 CompareContext (org.python.pydev.ast.codecompletion.ProposalsComparator.CompareContext)3 SourceModule (org.python.pydev.ast.codecompletion.revisited.modules.SourceModule)3 InterpreterInfo (org.python.pydev.ast.interpreter_managers.InterpreterInfo)3 IInterpreterInfo (org.python.pydev.core.IInterpreterInfo)3 AbstractAdditionalDependencyInfo (com.python.pydev.analysis.additionalinfo.AbstractAdditionalDependencyInfo)2 AdditionalInfoAndIInfo (com.python.pydev.analysis.additionalinfo.AdditionalInfoAndIInfo)2 AdditionalProjectInterpreterInfo (com.python.pydev.analysis.additionalinfo.AdditionalProjectInterpreterInfo)2