Add utility method for getting class from constructor parameter
This commit is contained in:
@@ -197,8 +197,9 @@ public class JetPsiUtil {
|
||||
firstPart = getFQName((JetNamedDeclaration) parent);
|
||||
}
|
||||
else if (namedDeclaration instanceof JetParameter) {
|
||||
if (((JetParameter) namedDeclaration).getValOrVarNode() != null && parent != null && parent.getParent() instanceof JetClassOrObject) {
|
||||
firstPart = getFQName((JetClassOrObject) parent.getParent());
|
||||
JetClass constructorClass = getClassIfParameterIsProperty((JetParameter) namedDeclaration);
|
||||
if (constructorClass != null) {
|
||||
firstPart = getFQName(constructorClass);
|
||||
}
|
||||
}
|
||||
else if (parent instanceof JetObjectDeclaration) {
|
||||
@@ -574,6 +575,18 @@ public class JetPsiUtil {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static JetClass getClassIfParameterIsProperty(@NotNull JetParameter jetParameter) {
|
||||
if (jetParameter.getValOrVarNode() != null) {
|
||||
PsiElement parent = jetParameter.getParent();
|
||||
if (parent instanceof JetParameterList && parent.getParent() instanceof JetClass) {
|
||||
return (JetClass) parent.getParent();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static IElementType getOperation(@NotNull JetExpression expression) {
|
||||
if (expression instanceof JetQualifiedExpression) {
|
||||
|
||||
@@ -196,8 +196,11 @@ public class LightClassUtil {
|
||||
|
||||
@Nullable
|
||||
private static PsiClass getWrappingClass(@NotNull JetDeclaration declaration) {
|
||||
if (declaration instanceof JetParameter && declaration.getParent().getParent() instanceof JetClass) {
|
||||
return getPsiClass((JetClassOrObject) declaration.getParent().getParent());
|
||||
if (declaration instanceof JetParameter) {
|
||||
JetClass constructorClass = JetPsiUtil.getClassIfParameterIsProperty((JetParameter) declaration);
|
||||
if (constructorClass != null) {
|
||||
return getPsiClass(constructorClass);
|
||||
}
|
||||
}
|
||||
|
||||
if (declaration instanceof JetPropertyAccessor) {
|
||||
|
||||
Reference in New Issue
Block a user