diff --git a/python/testData/pyi/lineMarkers/FromStubPackage/pkg-stubs/__init__.pyi b/python/testData/pyi/lineMarkers/FromStubPackage/pkg-stubs/__init__.pyi new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/python/testData/pyi/lineMarkers/FromStubPackage/pkg-stubs/foo.pyi b/python/testData/pyi/lineMarkers/FromStubPackage/pkg-stubs/foo.pyi new file mode 100644 index 000000000000..36a173b06914 --- /dev/null +++ b/python/testData/pyi/lineMarkers/FromStubPackage/pkg-stubs/foo.pyi @@ -0,0 +1 @@ +def bar(a: str, b: str) -> str: ... \ No newline at end of file diff --git a/python/testData/pyi/lineMarkers/FromStubPackage/pkg/__init__.py b/python/testData/pyi/lineMarkers/FromStubPackage/pkg/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/python/testData/pyi/lineMarkers/FromStubPackage/pkg/foo.py b/python/testData/pyi/lineMarkers/FromStubPackage/pkg/foo.py new file mode 100644 index 000000000000..3262c3a1922f --- /dev/null +++ b/python/testData/pyi/lineMarkers/FromStubPackage/pkg/foo.py @@ -0,0 +1,2 @@ +def bar(a: str, b: str): + return a + b \ No newline at end of file diff --git a/python/testData/pyi/lineMarkers/FromStubPackage/pkg/py.typed b/python/testData/pyi/lineMarkers/FromStubPackage/pkg/py.typed new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/python/testData/pyi/lineMarkers/ToStubPackage/pkg-stubs/__init__.pyi b/python/testData/pyi/lineMarkers/ToStubPackage/pkg-stubs/__init__.pyi new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/python/testData/pyi/lineMarkers/ToStubPackage/pkg-stubs/foo.pyi b/python/testData/pyi/lineMarkers/ToStubPackage/pkg-stubs/foo.pyi new file mode 100644 index 000000000000..36a173b06914 --- /dev/null +++ b/python/testData/pyi/lineMarkers/ToStubPackage/pkg-stubs/foo.pyi @@ -0,0 +1 @@ +def bar(a: str, b: str) -> str: ... \ No newline at end of file diff --git a/python/testData/pyi/lineMarkers/ToStubPackage/pkg/__init__.py b/python/testData/pyi/lineMarkers/ToStubPackage/pkg/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/python/testData/pyi/lineMarkers/ToStubPackage/pkg/foo.py b/python/testData/pyi/lineMarkers/ToStubPackage/pkg/foo.py new file mode 100644 index 000000000000..3262c3a1922f --- /dev/null +++ b/python/testData/pyi/lineMarkers/ToStubPackage/pkg/foo.py @@ -0,0 +1,2 @@ +def bar(a: str, b: str): + return a + b \ No newline at end of file diff --git a/python/testData/pyi/lineMarkers/ToStubPackage/pkg/py.typed b/python/testData/pyi/lineMarkers/ToStubPackage/pkg/py.typed new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/python/testSrc/com/jetbrains/python/pyi/PyiRelatedItemLineMarkerTest.kt b/python/testSrc/com/jetbrains/python/pyi/PyiRelatedItemLineMarkerTest.kt index fdd85fe65187..10ef8fcab93d 100644 --- a/python/testSrc/com/jetbrains/python/pyi/PyiRelatedItemLineMarkerTest.kt +++ b/python/testSrc/com/jetbrains/python/pyi/PyiRelatedItemLineMarkerTest.kt @@ -49,6 +49,13 @@ class PyiRelatedItemLineMarkerTest : PyTestCase() { assertMarker("function", false) } + fun testToStubPackage() { + myFixture.copyDirectoryToProject(getTestName(false), "") + myFixture.configureByFile("pkg/foo.py") + + assertEquals("Has stub item in foo.pyi", getMarkersInCurrentFile ("bar").singleOrNull()?.lineMarkerTooltip) + } + // stub -> runtime fun testNoSimilarClassForMethodStub() { @@ -83,6 +90,13 @@ class PyiRelatedItemLineMarkerTest : PyTestCase() { assertMarker("foo", true) } + fun testFromStubPackage() { + myFixture.copyDirectoryToProject(getTestName(false), "") + myFixture.configureByFile("pkg-stubs/foo.pyi") + + assertEquals("Stub for item in foo.py", getMarkersInCurrentFile ("bar").singleOrNull()?.lineMarkerTooltip) + } + override fun getTestDataPath(): String { return super.getTestDataPath() + "/pyi/lineMarkers" } @@ -99,15 +113,23 @@ class PyiRelatedItemLineMarkerTest : PyTestCase() { private fun getMarkers(elementName: String, pyi: Boolean): List> { myFixture.copyDirectoryToProject(getTestName(false), "") myFixture.configureByFile(if (pyi) "b.pyi" else "a.py") + return getMarkersInCurrentFile(elementName) + } + private fun getMarkersInCurrentFile(elementName: String): List> { val functions = PsiTreeUtil.findChildrenOfType(myFixture.file, PyFunction::class.java) functions.forEach { assertEquals(elementName, it.name) } assertNotEmpty(functions) myFixture.doHighlighting() - return DaemonCodeAnalyzerImpl + val result = DaemonCodeAnalyzerImpl .getLineMarkers(myFixture.editor.document, myFixture.project) .filter { PsiTreeUtil.getParentOfType(it.element, PsiNameIdentifierOwner::class.java)?.name == elementName } + + assertProjectFilesNotParsed(myFixture.file) + assertSdkRootsNotParsed(myFixture.file) + + return result } } \ No newline at end of file