mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -2280,7 +2280,7 @@ def is_mac_skipped_module(path, f):
|
||||
return 0
|
||||
|
||||
def is_skipped_module(path, f):
|
||||
return is_mac_skipped_module(path, f) or is_posix_skipped_module(path, f[:f.rindex('.')])
|
||||
return is_mac_skipped_module(path, f) or is_posix_skipped_module(path, f[:f.rindex('.')]) or 'pynestkernel' in path
|
||||
|
||||
|
||||
def is_module(d, root):
|
||||
|
||||
@@ -88,6 +88,8 @@
|
||||
<declarationRangeHandler key="com.jetbrains.python.psi.PyFunction"
|
||||
implementationClass="com.jetbrains.python.codeInsight.PyDeclarationRangeHandler"/>
|
||||
|
||||
<targetElementEvaluator language="Python" implementationClass="com.jetbrains.python.codeInsight.PyTargetElementEvaluator"/>
|
||||
|
||||
<!-- Run/Debug -->
|
||||
<applicationService serviceInterface="com.jetbrains.python.run.PyRunConfigurationFactory"
|
||||
serviceImplementation="com.jetbrains.python.run.PyRunConfigurationFactoryImpl"/>
|
||||
@@ -569,6 +571,7 @@
|
||||
<xml.zenCodingGenerator implementation="com.jetbrains.django.lang.template.DjangoTemplateZenCodingGenerator"/>
|
||||
|
||||
<xml.elementDescriptorProvider implementation="com.jetbrains.django.lang.template.DjangoTemplateDescriptorProvider"/>
|
||||
<xml.util.htmlDoctypeProvider implementation="com.jetbrains.django.lang.template.DjangoHtmlDoctypeProvider"/>
|
||||
|
||||
<completion.contributor language="DjangoTemplate"
|
||||
implementationClass="com.jetbrains.django.lang.template.editor.DjangoTemplateCompletionContributor"/>
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.jetbrains.python.codeInsight;
|
||||
|
||||
import com.intellij.codeInsight.TargetElementEvaluator;
|
||||
import com.intellij.codeInsight.TargetElementUtilBase;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.jetbrains.python.codeInsight.controlflow.ScopeOwner;
|
||||
import com.jetbrains.python.psi.PyReferenceExpression;
|
||||
import com.jetbrains.python.psi.resolve.PyResolveContext;
|
||||
import com.jetbrains.python.psi.resolve.QualifiedResolveResult;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class PyTargetElementEvaluator implements TargetElementEvaluator {
|
||||
@Override
|
||||
public boolean includeSelfInGotoImplementation(@NotNull PsiElement element) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public PsiElement getElementByReference(PsiReference ref, int flags) {
|
||||
if ((flags & TargetElementUtilBase.ELEMENT_NAME_ACCEPTED) == 0){
|
||||
return null;
|
||||
}
|
||||
final PsiElement element = ref.getElement();
|
||||
PsiElement result = ref.resolve();
|
||||
if (result instanceof PyReferenceExpression &&
|
||||
PsiTreeUtil.getParentOfType(element, ScopeOwner.class) == PsiTreeUtil.getParentOfType(result, ScopeOwner.class)) {
|
||||
QualifiedResolveResult resolveResult = ((PyReferenceExpression)result).followAssignmentsChain(PyResolveContext.noImplicits());
|
||||
PsiElement finalResult = resolveResult.getElement();
|
||||
if (PsiTreeUtil.getParentOfType(element, ScopeOwner.class) == PsiTreeUtil.getParentOfType(finalResult, ScopeOwner.class)) {
|
||||
return finalResult;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+8
-1
@@ -236,6 +236,13 @@ public class PyKeywordCompletionContributor extends CompletionContributor {
|
||||
.inside(PyWithStatement.class)
|
||||
);
|
||||
|
||||
private static final PsiElementPattern.Capture<PsiElement> IN_EXCEPT_AFTER_REF =
|
||||
psiElement().afterLeaf(psiElement()
|
||||
.withElementType(PyTokenTypes.IDENTIFIER)
|
||||
.inside(PyReferenceExpression.class)
|
||||
.inside(PyExceptPart.class)
|
||||
);
|
||||
|
||||
private static final PsiElementPattern.Capture<PsiElement> IN_COND_STMT =
|
||||
psiElement().inside(psiElement(PyStatementList.class).inside(psiElement(PyConditionalStatementPart.class)));
|
||||
|
||||
@@ -526,7 +533,7 @@ public class PyKeywordCompletionContributor extends CompletionContributor {
|
||||
extend(
|
||||
CompletionType.BASIC, psiElement()
|
||||
.withLanguage(PythonLanguage.getInstance())
|
||||
.andOr(IN_IMPORT_AFTER_REF, IN_WITH_AFTER_REF)
|
||||
.andOr(IN_IMPORT_AFTER_REF, IN_WITH_AFTER_REF, IN_EXCEPT_AFTER_REF)
|
||||
.andNot(AFTER_QUALIFIER)
|
||||
,
|
||||
new PyKeywordCompletionProvider("as")
|
||||
|
||||
@@ -498,7 +498,7 @@ public class PyPackageManagerImpl extends PyPackageManager {
|
||||
if (binaryFile != null) {
|
||||
final ProjectJdkImpl tmpSdk = new ProjectJdkImpl("", PythonSdkType.getInstance());
|
||||
tmpSdk.setHomePath(path);
|
||||
final PyPackageManagerImpl manager = (PyPackageManagerImpl)PyPackageManagers.getInstance().forSdk(tmpSdk);
|
||||
final PyPackageManagerImpl manager = new PyPackageManagerImpl(tmpSdk);
|
||||
manager.installManagement(DISTRIBUTE);
|
||||
manager.installManagement(PIP);
|
||||
}
|
||||
|
||||
@@ -648,6 +648,9 @@ public class PyUtil {
|
||||
if (turnDirIntoInit(directory) != null) {
|
||||
return true;
|
||||
}
|
||||
if (LanguageLevel.forFile(directory.getVirtualFile()).isAtLeast(LanguageLevel.PYTHON33)) {
|
||||
return true;
|
||||
}
|
||||
return hasNamespacePackageFile(directory);
|
||||
}
|
||||
|
||||
|
||||
@@ -215,7 +215,10 @@ public class PyReferenceImpl implements PsiReferenceEx, PsiPolyVariantReference
|
||||
final ScopeOwner owner = ScopeUtil.getScopeOwner(uexpr);
|
||||
if (owner != null) {
|
||||
final Scope scope = ControlFlowCache.getScope(owner);
|
||||
if (owner == originalOwner && !scope.isGlobal(referencedName)) {
|
||||
if (uexpr == originalOwner && originalOwner instanceof PyClass) {
|
||||
uexpr = null;
|
||||
}
|
||||
else if (owner == originalOwner && !scope.isGlobal(referencedName)) {
|
||||
final ResolveResultList latest = resolveToLatestDefs(owner, myElement, referencedName);
|
||||
if (!latest.isEmpty()) {
|
||||
return latest;
|
||||
|
||||
@@ -112,19 +112,7 @@ public class VirtualEnvSdkFlavor extends CPythonSdkFlavor {
|
||||
@Override
|
||||
public boolean isValidSdkPath(@NotNull File file) {
|
||||
if (!super.isValidSdkPath(file)) return false;
|
||||
File bin = file.getParentFile();
|
||||
if (bin != null) {
|
||||
File[] children = bin.listFiles();
|
||||
if (children != null) {
|
||||
for (File f : children) {
|
||||
//is it good enough to determine virtual env?
|
||||
if (f.getName().equals("activate_this.py")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return PythonSdkType.getVirtualEnvRoot(file.getPath()) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
class C:
|
||||
print(<error descr="Unresolved reference 'C'">C</error>) #fail
|
||||
def f(self):
|
||||
print(C) #pass
|
||||
@@ -0,0 +1,3 @@
|
||||
def cover(lab=1):
|
||||
lab += 1
|
||||
return l<caret>ab
|
||||
@@ -0,0 +1,3 @@
|
||||
def cover(bar=1):
|
||||
bar += 1
|
||||
return bar
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
from p1.m1 import foo
|
||||
|
||||
foo()
|
||||
#<ref>
|
||||
@@ -0,0 +1,2 @@
|
||||
def foo():
|
||||
pass
|
||||
@@ -0,0 +1,4 @@
|
||||
import p1
|
||||
|
||||
p1
|
||||
#<ref>
|
||||
@@ -0,0 +1,2 @@
|
||||
def foo():
|
||||
pass
|
||||
@@ -404,6 +404,29 @@ public class PyMultiFileResolveTest extends PyResolveTestCase {
|
||||
assertResolvesTo(PyFunction.class, "foo");
|
||||
}
|
||||
|
||||
// PY-7156
|
||||
public void testPython33NamespacePackage() {
|
||||
setLanguageLevel(LanguageLevel.PYTHON33);
|
||||
try {
|
||||
final PsiElement element = doResolve();
|
||||
assertInstanceOf(element, PyImportedModule.class);
|
||||
final PyImportedModule module = (PyImportedModule)element;
|
||||
assertEquals("p1", module.getImportedPrefix().toString());
|
||||
} finally {
|
||||
setLanguageLevel(null);
|
||||
}
|
||||
}
|
||||
|
||||
// PY-7156
|
||||
public void testFromPython33NamespacePackageImport() {
|
||||
setLanguageLevel(LanguageLevel.PYTHON33);
|
||||
try {
|
||||
assertResolvesTo(PyFunction.class, "foo");
|
||||
} finally {
|
||||
setLanguageLevel(null);
|
||||
}
|
||||
}
|
||||
|
||||
private void prepareTestDirectory() {
|
||||
final String testName = getTestName(true);
|
||||
myFixture.copyDirectoryToProject(testName, "");
|
||||
|
||||
@@ -523,12 +523,14 @@ public class PythonCompletionTest extends PyTestCase {
|
||||
}
|
||||
|
||||
public void testTypeMembers() { // PY-5311
|
||||
myFixture.configureByText(PythonFileType.INSTANCE, "a = 'string'\n" +
|
||||
"a.<caret>");
|
||||
assertFalse(doTestByText("a = 'string'\n" +
|
||||
"a.<caret>").contains("mro"));
|
||||
}
|
||||
|
||||
private List<String> doTestByText(String text) {
|
||||
myFixture.configureByText(PythonFileType.INSTANCE, text);
|
||||
myFixture.completeBasic();
|
||||
final List<String> strings = myFixture.getLookupElementStrings();
|
||||
assertFalse(strings.contains("mro"));
|
||||
return myFixture.getLookupElementStrings();
|
||||
}
|
||||
|
||||
public void testDunderAllReference() { // PY-5502
|
||||
@@ -588,4 +590,16 @@ public class PythonCompletionTest extends PyTestCase {
|
||||
public void testUnknownNewReturnType() { // PY-6671
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testAsInWith() { // PY-3701
|
||||
setLanguageLevel(LanguageLevel.PYTHON27);
|
||||
assertTrue(doTestByText("with foo <caret>").contains("as"));
|
||||
}
|
||||
|
||||
public void testAsInExcept() { // PY-1846
|
||||
setLanguageLevel(LanguageLevel.PYTHON27);
|
||||
assertTrue(doTestByText("try:\n" +
|
||||
" pass\n" +
|
||||
"except IOError <caret>").contains("as"));
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -180,6 +180,11 @@ public class PyUnresolvedReferencesInspectionTest extends PyTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-5995
|
||||
public void testClassInClassBody() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
myFixture.configureByFile(TEST_DIRECTORY + getTestName(true) + ".py");
|
||||
myFixture.enableInspections(PyUnresolvedReferencesInspection.class);
|
||||
|
||||
@@ -87,6 +87,10 @@ public class PyRenameTest extends PyTestCase {
|
||||
doTest("bar");
|
||||
}
|
||||
|
||||
public void testRenameAugAssigned() { // PY-3698
|
||||
doTest("bar");
|
||||
}
|
||||
|
||||
public void testRenameProperty() { // PY-5948
|
||||
setLanguageLevel(LanguageLevel.PYTHON26);
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user