PY-19047 Fixed: Exception on interpreter indexing

PyResolveProcessor had a bug with resolving imports locally
This commit is contained in:
Semyon Proshev
2016-04-13 21:52:18 +03:00
parent 466c3be70e
commit c6f0a296e2
5 changed files with 18 additions and 3 deletions
@@ -23,7 +23,10 @@ import com.intellij.psi.ResolveState;
import com.intellij.psi.scope.PsiScopeProcessor;
import com.jetbrains.python.codeInsight.controlflow.ScopeOwner;
import com.jetbrains.python.codeInsight.dataflow.scope.ScopeUtil;
import com.jetbrains.python.psi.*;
import com.jetbrains.python.psi.PyFromImportStatement;
import com.jetbrains.python.psi.PyImportElement;
import com.jetbrains.python.psi.PyImportedNameDefiner;
import com.jetbrains.python.psi.PyUtil;
import com.jetbrains.python.psi.impl.ResolveResultList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -114,7 +117,7 @@ public class PyResolveProcessor implements PsiScopeProcessor {
if (importElement != null) {
return ResolveResultList.to(importElement.getElementNamed(myName, false));
}
else if (definer instanceof PyStarImportElement) {
else {
return Collections.emptyList();
}
}
@@ -0,0 +1,3 @@
from .func import func
m = func()
+2
View File
@@ -0,0 +1,2 @@
def func():
pass
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,6 +15,8 @@
*/
package com.jetbrains.python;
import com.intellij.psi.stubs.StubUpdatingIndex;
import com.intellij.util.indexing.FileBasedIndex;
import com.jetbrains.python.fixtures.PyTestCase;
import com.jetbrains.python.psi.stubs.PyModuleNameIndex;
@@ -41,4 +43,9 @@ public class PyIndexingTest extends PyTestCase {
assertDoesntContain(modules, "__init__");
assertDoesntContain(modules, "ModuleNameIndex_baz");
}
// PY-19047
public void testPy19047() {
FileBasedIndex.getInstance().scheduleRebuild(StubUpdatingIndex.INDEX_ID, new Throwable());
}
}