pass foothold to PyCanonicalPathProvider; javadoc

This commit is contained in:
Dmitry Jemerov
2012-08-15 13:03:28 +02:00
parent 116a4e2ff5
commit 79a71c19f5
3 changed files with 14 additions and 3 deletions
@@ -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);
}
@@ -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;
}