Extract JetProperty#hasInitializer() and use it where appropriate
This commit is contained in:
+1
-1
@@ -84,7 +84,7 @@ public class AlternativeFieldSignatureData extends ElementAlternativeSignatureDa
|
||||
throw new AlternativeSignatureMismatchException("Wrong mutability in annotation for field");
|
||||
}
|
||||
|
||||
if (altProperty.getInitializer() != null) {
|
||||
if (altProperty.hasInitializer()) {
|
||||
throw new AlternativeSignatureMismatchException("Default value is not expected in annotation for field");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,6 +168,10 @@ public class JetProperty extends JetTypeParameterListOwnerStub<PsiJetPropertyStu
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean hasInitializer() {
|
||||
return getInitializer() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public JetExpression getInitializer() {
|
||||
@@ -175,7 +179,7 @@ public class JetProperty extends JetTypeParameterListOwnerStub<PsiJetPropertyStu
|
||||
}
|
||||
|
||||
public boolean hasDelegateExpressionOrInitializer() {
|
||||
return getDelegateExpressionOrInitializer() != null;
|
||||
return hasDelegateExpression() || hasInitializer();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+1
-1
@@ -67,7 +67,7 @@ public class ConvertMemberToExtension extends BaseIntentionAction {
|
||||
) {
|
||||
JetCallableDeclaration declaration = getTarget(editor, file);
|
||||
if (declaration instanceof JetProperty) {
|
||||
if (((JetProperty) declaration).getInitializer() != null) return false;
|
||||
if (((JetProperty) declaration).hasInitializer()) return false;
|
||||
}
|
||||
return declaration != null
|
||||
&& declaration.getParent() instanceof JetClassBody
|
||||
|
||||
@@ -42,7 +42,7 @@ public class DeclarationUtils {
|
||||
}
|
||||
|
||||
public static boolean checkSplitProperty(@NotNull JetProperty property) {
|
||||
return property.getInitializer() != null && property.isLocal();
|
||||
return property.hasInitializer() && property.isLocal();
|
||||
}
|
||||
|
||||
public static final Predicate<PsiElement> SKIP_DELIMITERS = new Predicate<PsiElement>() {
|
||||
@@ -68,7 +68,7 @@ public class DeclarationUtils {
|
||||
}
|
||||
|
||||
if (property == null) return null;
|
||||
if (property.getInitializer() != null) return null;
|
||||
if (property.hasInitializer()) return null;
|
||||
if (!JetPsiUtil.isOrdinaryAssignment(initializer)) return null;
|
||||
|
||||
JetBinaryExpression assignment = (JetBinaryExpression) initializer;
|
||||
|
||||
@@ -42,7 +42,7 @@ public class RemovePartsFromPropertyFix extends JetIntentionAction<JetProperty>
|
||||
}
|
||||
|
||||
private RemovePartsFromPropertyFix(@NotNull JetProperty element) {
|
||||
this(element, element.getInitializer() != null,
|
||||
this(element, element.hasInitializer(),
|
||||
element.getGetter() != null && element.getGetter().getBodyExpression() != null,
|
||||
element.getSetter() != null && element.getSetter().getBodyExpression() != null);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user