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