diff --git a/python/resources/inspectionDescriptions/CythonUsageBeforeDeclarationInspection.html b/python/resources/inspectionDescriptions/CythonUsageBeforeDeclarationInspection.html
new file mode 100644
index 000000000000..97e4a1e2af14
--- /dev/null
+++ b/python/resources/inspectionDescriptions/CythonUsageBeforeDeclarationInspection.html
@@ -0,0 +1,5 @@
+
+
+This inspection warns about Cython variables being referenced before declaration.
+
+
\ No newline at end of file
diff --git a/python/src/com/jetbrains/python/psi/impl/PyFromImportStatementImpl.java b/python/src/com/jetbrains/python/psi/impl/PyFromImportStatementImpl.java
index 4892fa6fc060..34bb81b07c21 100644
--- a/python/src/com/jetbrains/python/psi/impl/PyFromImportStatementImpl.java
+++ b/python/src/com/jetbrains/python/psi/impl/PyFromImportStatementImpl.java
@@ -23,6 +23,7 @@ import com.intellij.psi.*;
import com.intellij.psi.scope.DelegatingScopeProcessor;
import com.intellij.psi.scope.PsiScopeProcessor;
import com.intellij.psi.stubs.IStubElementType;
+import com.intellij.psi.tree.IElementType;
import com.intellij.psi.util.QualifiedName;
import com.intellij.util.ArrayUtil;
import com.jetbrains.python.PyElementTypes;
@@ -91,15 +92,22 @@ public class PyFromImportStatementImpl extends PyBaseElementImpl new PyImportElement[count]);
+ return stub.getChildrenByType(importElementType, count -> new PyImportElement[count]);
}
List result = new ArrayList<>();
- final ASTNode importKeyword = getNode().findChildByType(PyTokenTypes.IMPORT_KEYWORD);
+ final ASTNode importKeyword = getNode().findChildByType(importKeywordToken);
if (importKeyword != null) {
for (ASTNode node = importKeyword.getTreeNext(); node != null; node = node.getTreeNext()) {
- if (node.getElementType() == PyElementTypes.IMPORT_ELEMENT) {
+ if (node.getElementType() == importElementType) {
result.add((PyImportElement)node.getPsi());
}
}
diff --git a/python/testSrc/com/jetbrains/python/fixtures/PyResolveTestCase.java b/python/testSrc/com/jetbrains/python/fixtures/PyResolveTestCase.java
index 9eb4261502f6..06164cdeb3cd 100644
--- a/python/testSrc/com/jetbrains/python/fixtures/PyResolveTestCase.java
+++ b/python/testSrc/com/jetbrains/python/fixtures/PyResolveTestCase.java
@@ -114,6 +114,8 @@ public abstract class PyResolveTestCase extends PyTestCase {
}
public static int findMarkerOffset(final PsiFile psiFile) {
+ // TODO: harmonize with CythonResolveTest synax
+ // TODO: check and fix work with single letter identifiers
Document document = PsiDocumentManager.getInstance(psiFile.getProject()).getDocument(psiFile);
assert document != null;
int offset = -1;