mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Improve javadoc for PointInImport and clean up a bit in ResolveImportUtil
This commit is contained in:
@@ -22,12 +22,14 @@ public enum PointInImport {
|
||||
NONE,
|
||||
|
||||
/**
|
||||
* The reference is inside import and refers to a module
|
||||
* The reference is inside import and it's either source qualifier in {@code from REFERENCE import ...}
|
||||
* or imported name itself in {@code import REFERENCE}.
|
||||
*/
|
||||
AS_MODULE,
|
||||
|
||||
/**
|
||||
* The reference is inside import and refers to a name imported from a module
|
||||
* The reference is inside import and refers to a name imported from a module, i.e. it's concrete imported name in
|
||||
* import statement of form {@code from somewhere import REFERENCE}, not the optional alias part.
|
||||
*/
|
||||
AS_NAME
|
||||
}
|
||||
|
||||
@@ -392,17 +392,16 @@ public class ResolveImportUtil {
|
||||
/**
|
||||
* @param element what we test (identifier, reference, import element, etc)
|
||||
* @return the how the element relates to an enclosing import statement, if any
|
||||
* @see com.jetbrains.python.psi.resolve.PointInImport
|
||||
*/
|
||||
@NotNull
|
||||
public static PointInImport getPointInImport(@NotNull PsiElement element) {
|
||||
PsiElement parent = PsiTreeUtil.getNonStrictParentOfType(
|
||||
element,
|
||||
PyImportElement.class, PyFromImportStatement.class
|
||||
);
|
||||
final PsiElement parent = PsiTreeUtil.getNonStrictParentOfType(element, PyImportElement.class, PyFromImportStatement.class);
|
||||
if (parent instanceof PyFromImportStatement) {
|
||||
return PointInImport.AS_MODULE; // from foo ...
|
||||
}
|
||||
if (parent instanceof PyImportElement) {
|
||||
PsiElement statement = parent.getParent();
|
||||
final PsiElement statement = parent.getParent();
|
||||
if (statement instanceof PyImportStatement) {
|
||||
return PointInImport.AS_MODULE; // import foo,...
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user