Extract DescriptorUtils.getContainingModule()
This commit is contained in:
@@ -68,4 +68,4 @@ public fun JetType?.safeType(expression: JetExpression): JetType {
|
|||||||
return ErrorUtils.createErrorType("Type for " + expression.getText())
|
return ErrorUtils.createErrorType("Type for " + expression.getText())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun JetScope.getModule(): ModuleDescriptor = DescriptorUtils.getParentOfType(this.getContainingDeclaration(), javaClass<ModuleDescriptor>())!!
|
private fun JetScope.getModule(): ModuleDescriptor = DescriptorUtils.getContainingModule(this.getContainingDeclaration())
|
||||||
|
|||||||
@@ -148,10 +148,7 @@ public class DescriptorUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean areInSameModule(@NotNull DeclarationDescriptor first, @NotNull DeclarationDescriptor second) {
|
public static boolean areInSameModule(@NotNull DeclarationDescriptor first, @NotNull DeclarationDescriptor second) {
|
||||||
ModuleDescriptor parentModule = getParentOfType(first, ModuleDescriptor.class, false);
|
return getContainingModule(first).equals(getContainingModule(second));
|
||||||
ModuleDescriptor fromModule = getParentOfType(second, ModuleDescriptor.class, false);
|
|
||||||
assert parentModule != null && fromModule != null;
|
|
||||||
return parentModule.equals(fromModule);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -194,6 +191,13 @@ public class DescriptorUtils {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static ModuleDescriptor getContainingModule(@NotNull DeclarationDescriptor descriptor) {
|
||||||
|
ModuleDescriptor module = getParentOfType(descriptor, ModuleDescriptor.class, false);
|
||||||
|
assert module != null : "Descriptor without a containing module: " + descriptor;
|
||||||
|
return module;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isAncestor(
|
public static boolean isAncestor(
|
||||||
@Nullable DeclarationDescriptor ancestor,
|
@Nullable DeclarationDescriptor ancestor,
|
||||||
@NotNull DeclarationDescriptor declarationDescriptor,
|
@NotNull DeclarationDescriptor declarationDescriptor,
|
||||||
|
|||||||
Reference in New Issue
Block a user