Search in sources :

Example 1 with RefactorerFindReferences

use of com.python.pydev.analysis.refactoring.refactorer.RefactorerFindReferences in project Pydev by fabioz.

the class ClassHierarchySearchTest method assertIsIn.

private HierarchyNodeModel assertIsIn(String name, String modName, List<HierarchyNodeModel> parents) {
    FastStringBuffer available = new FastStringBuffer();
    for (HierarchyNodeModel model : parents) {
        available.append(model.name).append(" - ").append(model.moduleName);
        if (model.name.equals(name)) {
            if (modName == null) {
                return model;
            } else if (model.moduleName.equals(modName) || model.moduleName.startsWith(modName)) {
                return model;
            }
        }
    }
    try {
        RefactorerFindReferences references = new RefactorerFindReferences();
        RefactoringRequest request = new RefactoringRequest(null, null, nature);
        request.qualifier = name;
        List<Tuple<List<ModulesKey>, IPythonNature>> findPossibleReferences = references.findPossibleReferences(request);
        String errorMsg = "Unable to find node with name:" + name + " mod:" + modName + "\nAvailable:" + available + "\n\nPythonpath: " + nature.getPythonPathNature().getOnlyProjectPythonPathStr(true) + "\n" + "Found possible references: " + StringUtils.join("\n", findPossibleReferences);
        fail(errorMsg);
    } catch (CoreException e) {
        throw new RuntimeException(e);
    }
    return null;
}
Also used : FastStringBuffer(org.python.pydev.shared_core.string.FastStringBuffer) CoreException(org.eclipse.core.runtime.CoreException) RefactoringRequest(org.python.pydev.ast.refactoring.RefactoringRequest) ModulesKey(org.python.pydev.core.ModulesKey) RefactorerFindReferences(com.python.pydev.analysis.refactoring.refactorer.RefactorerFindReferences) HierarchyNodeModel(org.python.pydev.ast.refactoring.HierarchyNodeModel) Tuple(org.python.pydev.shared_core.structure.Tuple)

Aggregations

RefactorerFindReferences (com.python.pydev.analysis.refactoring.refactorer.RefactorerFindReferences)1 CoreException (org.eclipse.core.runtime.CoreException)1 HierarchyNodeModel (org.python.pydev.ast.refactoring.HierarchyNodeModel)1 RefactoringRequest (org.python.pydev.ast.refactoring.RefactoringRequest)1 ModulesKey (org.python.pydev.core.ModulesKey)1 FastStringBuffer (org.python.pydev.shared_core.string.FastStringBuffer)1 Tuple (org.python.pydev.shared_core.structure.Tuple)1