Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix invalid completion in callable expression #130

Merged
merged 4 commits into from
May 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
<idea-plugin url="https://github.com/koxudaxi/pydantic-pycharm-plugin">
<id>com.koxudaxi.pydantic</id>
<name>Pydantic</name>
<version>0.1.6</version>
<version>0.1.7</version>
<vendor email="koaxudai@gmail.com">Koudai Aono @koxudaxi</vendor>
<change-notes><![CDATA[
<h2>version 0.1.7</h2>
<p>BugFixes</p>
<ul>
<li>Fix invalid completion in callable expression [#130] </li>
</ul>
<h2>version 0.1.6</h2>
<p>Features</p>
<ul>
Expand Down
2 changes: 2 additions & 0 deletions src/com/koxudaxi/pydantic/PydanticCompletionContributor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ class PydanticCompletionContributor : CompletionContributor() {
override val icon: Icon = AllIcons.Nodes.Parameter

override fun addCompletions(parameters: CompletionParameters, context: ProcessingContext, result: CompletionResultSet) {
if (parameters.position.text == "." || parameters.position.prevSibling?.text == ".") return
val pyArgumentList = parameters.position.parent?.parent as? PyArgumentList ?: return

val typeEvalContext = parameters.getTypeEvalContext()
val pyClassType = (pyArgumentList.parent as? PyCallExpression)?.let { typeEvalContext.getType(it) } as? PyClassType
?: return
Expand Down
14 changes: 14 additions & 0 deletions testData/completion/keywordArgumentDot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from builtins import *

from pydantic import BaseModel


class A(BaseModel):
abc: str
cde: str
efg: str

class B(A):
hij: str

A(B.<caret>)
14 changes: 14 additions & 0 deletions testData/completion/keywordArgumentDotName.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from builtins import *

from pydantic import BaseModel


class A(BaseModel):
abc: str
cde: str
efg: str

class B(A):
hij: str

A(B.hi<caret>)
12 changes: 12 additions & 0 deletions testSrc/com/koxudaxi/pydantic/PydanticCompletionTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ open class PydanticCompletionTest : PydanticTestCase() {
)
}

fun testKeywordArgumentDot() {
doFieldTest(
listOf(Pair("___slots__", "BaseModel"))
)
}

fun testKeywordArgumentDotName() {
doFieldTest(
emptyList()
)
}

fun testKeywordArgumentIgnore() {
doFieldTest(
listOf(
Expand Down