mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
pass foothold to PyCanonicalPathProvider; javadoc
This commit is contained in:
@@ -1,15 +1,25 @@
|
||||
package com.jetbrains.python.psi.resolve;
|
||||
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.jetbrains.python.psi.impl.PyQualifiedName;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Allows to provide a custom qualified name when a specific symbol is going to be imported into a specific file.
|
||||
*
|
||||
* @author yole
|
||||
*/
|
||||
public interface PyCanonicalPathProvider {
|
||||
ExtensionPointName<PyCanonicalPathProvider> EP_NAME = ExtensionPointName.create("Pythonid.canonicalPathProvider");
|
||||
|
||||
/**
|
||||
* Allows to provide a custom qualified name when a specific symbol is going to be imported into a specific file.
|
||||
*
|
||||
* @param qName the real qualified name of the symbol being imported.
|
||||
* @param foothold the location where the symbol is being imported.
|
||||
* @return the qualified name to use in the import statement, or null if no replacement is necessary.
|
||||
*/
|
||||
@Nullable
|
||||
PyQualifiedName getCanonicalPath(PyQualifiedName qName);
|
||||
PyQualifiedName getCanonicalPath(PyQualifiedName qName, PsiElement foothold);
|
||||
}
|
||||
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
package com.jetbrains.python.codeInsight.stdlib;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.jetbrains.python.psi.impl.PyQualifiedName;
|
||||
import com.jetbrains.python.psi.resolve.PyCanonicalPathProvider;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -13,7 +14,7 @@ import java.util.List;
|
||||
public class PyStdlibCanonicalPathProvider implements PyCanonicalPathProvider {
|
||||
@Nullable
|
||||
@Override
|
||||
public PyQualifiedName getCanonicalPath(PyQualifiedName qName) {
|
||||
public PyQualifiedName getCanonicalPath(PyQualifiedName qName, PsiElement foothold) {
|
||||
return restoreStdlibCanonicalPath(qName);
|
||||
}
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ public class QualifiedNameFinder {
|
||||
final PyQualifiedName qname = findShortestImportableQName(foothold != null ? foothold : symbol, virtualFile);
|
||||
if (qname != null) {
|
||||
for (PyCanonicalPathProvider provider : Extensions.getExtensions(PyCanonicalPathProvider.EP_NAME)) {
|
||||
final PyQualifiedName restored = provider.getCanonicalPath(qname);
|
||||
final PyQualifiedName restored = provider.getCanonicalPath(qname, foothold);
|
||||
if (restored != null) {
|
||||
return restored;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user