mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-28752 Show full origin when suggesting symbols from existing "from" imports
This commit is contained in:
@@ -154,7 +154,7 @@ public class ImportCandidateHolder implements Comparable<ImportCandidateHolder>
|
||||
sb.append(StringUtil.repeat(".", fromImportStatement.getRelativeLevel()));
|
||||
final PyReferenceExpression source = fromImportStatement.getImportSource();
|
||||
if (source != null) {
|
||||
sb.append(source.getReferencedName());
|
||||
sb.append(source.asQualifiedName());
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
class ClassA:
|
||||
pass
|
||||
|
||||
|
||||
class ClassB:
|
||||
pass
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
from foo.bar.baz import ClassA
|
||||
|
||||
print(ClassA, <error descr="Unresolved reference 'ClassB'">Cla<caret>ssB</error>)
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
from foo.bar.baz import ClassA, ClassB
|
||||
|
||||
print(ClassA, ClassB)
|
||||
@@ -100,7 +100,7 @@ public class PyAddImportQuickFixTest extends PyQuickFixTestCase {
|
||||
public void testExistingImportsAlwaysSuggestedFirstEvenIfLonger() {
|
||||
doMultiFileAutoImportTest("Import", quickfix -> {
|
||||
final List<String> candidates = ContainerUtil.map(quickfix.getCandidates(), c -> c.getPresentableText("ClassB"));
|
||||
assertOrderedEquals(candidates, "ClassB from path", "short.ClassB");
|
||||
assertOrderedEquals(candidates, "ClassB from long.pkg.path", "short.ClassB");
|
||||
return false;
|
||||
});
|
||||
}
|
||||
@@ -114,6 +114,11 @@ public class PyAddImportQuickFixTest extends PyQuickFixTestCase {
|
||||
});
|
||||
}
|
||||
|
||||
// PY-28752
|
||||
public void testFullFromImportSourceNameInSuggestion() {
|
||||
doMultiFileAutoImportTest("Import 'ClassB from foo.bar.baz'");
|
||||
}
|
||||
|
||||
private void doMultiFileAutoImportTest(@NotNull String hintPrefix) {
|
||||
doMultiFileAutoImportTest(hintPrefix, null);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user