Improve javadoc for PointInImport and clean up a bit in ResolveImportUtil

This commit is contained in:
Mikhail Golubev
2014-11-14 16:25:30 +03:00
parent 96828f7ecd
commit 8a75043458
2 changed files with 8 additions and 7 deletions
@@ -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,...
}