PSI: Make JetPostfixExpression.getBaseExpression() nullable
#KT-7761 Fixed
This commit is contained in:
@@ -174,7 +174,7 @@ class PartialBodyResolveFilter(
|
||||
expression.acceptChildren(this)
|
||||
|
||||
if (expression.getOperationToken() == JetTokens.EXCLEXCL) {
|
||||
addIfCanBeSmartCast(expression.getBaseExpression())
|
||||
addIfCanBeSmartCast(expression.getBaseExpression() ?: return)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -40,6 +40,7 @@ public class OperatorToFunctionIntention : JetSelfTargetingIntention<JetExpressi
|
||||
private fun isApplicablePostfix(element: JetPostfixExpression, caretOffset: Int): Boolean {
|
||||
val opRef = element.getOperationReference()
|
||||
if (!opRef.getTextRange().containsOffset(caretOffset)) return false
|
||||
if (element.getBaseExpression() == null) return false
|
||||
return when (opRef.getReferencedNameElementType()) {
|
||||
JetTokens.PLUSPLUS, JetTokens.MINUSMINUS -> true
|
||||
else -> false
|
||||
@@ -98,7 +99,7 @@ public class OperatorToFunctionIntention : JetSelfTargetingIntention<JetExpressi
|
||||
|
||||
private fun convertPostFix(element: JetPostfixExpression): JetExpression {
|
||||
val op = element.getOperationReference().getReferencedNameElementType()
|
||||
val base = element.getBaseExpression().getText()
|
||||
val base = element.getBaseExpression()!!.getText()
|
||||
|
||||
val call = when (op) {
|
||||
JetTokens.PLUSPLUS -> "inc()"
|
||||
|
||||
@@ -224,7 +224,12 @@ public class JetNameSuggester {
|
||||
return matcher.replaceAll("");
|
||||
}
|
||||
|
||||
private static void addNamesForExpression(final ArrayList<String> result, JetExpression expression, final JetNameValidator validator) {
|
||||
private static void addNamesForExpression(
|
||||
final ArrayList<String> result,
|
||||
@Nullable JetExpression expression,
|
||||
final JetNameValidator validator) {
|
||||
if (expression == null) return;
|
||||
|
||||
expression.accept(new JetVisitorVoid() {
|
||||
@Override
|
||||
public void visitQualifiedExpression(@NotNull JetQualifiedExpression expression) {
|
||||
|
||||
+5
-2
@@ -37,11 +37,14 @@ import org.jetbrains.kotlin.resolve.bindingContextUtil.isUsedAsStatement
|
||||
|
||||
public class DoubleBangToIfThenIntention : JetSelfTargetingRangeIntention<JetPostfixExpression>(javaClass(), "Replace '!!' expression with 'if' expression") {
|
||||
override fun applicabilityRange(element: JetPostfixExpression): TextRange? {
|
||||
return if (element.getOperationToken() == JetTokens.EXCLEXCL) element.getOperationReference().getTextRange() else null
|
||||
return if (element.getOperationToken() == JetTokens.EXCLEXCL && element.getBaseExpression() != null)
|
||||
element.getOperationReference().getTextRange()
|
||||
else
|
||||
null
|
||||
}
|
||||
|
||||
override fun applyTo(element: JetPostfixExpression, editor: Editor) {
|
||||
val base = JetPsiUtil.safeDeparenthesize(element.getBaseExpression())
|
||||
val base = JetPsiUtil.safeDeparenthesize(element.getBaseExpression()!!)
|
||||
val expressionText = formatForUseInExceptionArgument(base.getText()!!)
|
||||
|
||||
val defaultException = JetPsiFactory(element).createExpression("throw NullPointerException()")
|
||||
|
||||
@@ -168,7 +168,7 @@ public class ExclExclCallFix implements IntentionAction {
|
||||
PsiElement parent = exclExclElement.getParent();
|
||||
if (parent != null) {
|
||||
PsiElement operationParent = parent.getParent();
|
||||
if (operationParent instanceof JetPostfixExpression) {
|
||||
if (operationParent instanceof JetPostfixExpression && ((JetPostfixExpression) operationParent).getBaseExpression() != null) {
|
||||
return (JetPostfixExpression) operationParent;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user