mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
fixed resolve to the keyword argument introduced in 8b9e7981df
needed for PY-15366 No completion for matplotlib figure
This commit is contained in:
@@ -24,7 +24,6 @@ import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.NonPhysicalFileSystem;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
@@ -108,7 +107,7 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression {
|
||||
Map<String, PsiElement> localDeclarations,
|
||||
MultiMap<String, PsiElement> ambiguousDeclarations,
|
||||
List<PsiElement> nameDefiners) {
|
||||
if (child instanceof PsiNamedElement) {
|
||||
if (child instanceof PyTargetExpression || child instanceof PyFunction || child instanceof PyClass) {
|
||||
final String name = ((PsiNamedElement)child).getName();
|
||||
localDeclarations.put(name, child);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
from a import A
|
||||
|
||||
print(A())
|
||||
# <ref>
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
|
||||
class A:
|
||||
pass
|
||||
|
||||
def foo(A=1):
|
||||
pass
|
||||
|
||||
foo(A=2)
|
||||
|
||||
@@ -15,7 +15,9 @@
|
||||
*/
|
||||
package com.jetbrains.python;
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.PsiFileImpl;
|
||||
import com.jetbrains.python.fixtures.PyMultiFileResolveTestCase;
|
||||
import com.jetbrains.python.fixtures.PyTestCase;
|
||||
import com.jetbrains.python.psi.*;
|
||||
@@ -383,4 +385,21 @@ public class PyMultiFileResolveTest extends PyMultiFileResolveTestCase {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void testKeywordArgument() {
|
||||
final PsiFile file = prepareFile();
|
||||
final PsiManager psiManager = myFixture.getPsiManager();
|
||||
final VirtualFile dir = myFixture.findFileInTempDir("a.py");
|
||||
final PsiFile psiFile = psiManager.findFile(dir);
|
||||
//noinspection ConstantConditions we need to unstub a.py here
|
||||
((PsiFileImpl)psiFile).calcTreeElement();
|
||||
final PsiElement element;
|
||||
try {
|
||||
element = doResolve(file);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
assertResolveResult(element, PyClass.class, "A");
|
||||
}
|
||||
}
|
||||
@@ -60,7 +60,7 @@ public abstract class PyMultiFileResolveTestCase extends PyResolveTestCase {
|
||||
PsiDocumentManager.getInstance(myFixture.getProject()).commitAllDocuments();
|
||||
}
|
||||
|
||||
private PsiFile prepareFile() {
|
||||
protected PsiFile prepareFile() {
|
||||
prepareTestDirectory();
|
||||
VirtualFile sourceFile = null;
|
||||
for (String ext : new String[]{".py", ".pyx"}) {
|
||||
|
||||
Reference in New Issue
Block a user