mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Groovy: Fix parenthesizing of ranges in ForToEachIntention
closes https://github.com/JetBrains/intellij-community/pull/2271 GitOrigin-RevId: a8ad04ce835e30ba06d8bc4a45c7f3d9d032087b
This commit is contained in:
committed by
intellij-monorepo-bot
parent
3b98b54289
commit
3d42a6ea9a
+2
@@ -8,6 +8,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.GrRangeExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.*;
|
||||
|
||||
@@ -129,6 +130,7 @@ public final class ParenthesesUtils {
|
||||
public static int getPrecedence(GrExpression expr) {
|
||||
if (expr instanceof GrUnaryExpression) return ((GrUnaryExpression)expr).isPostfix() ? POSTFIX_PRECEDENCE : PREFIX_PRECEDENCE;
|
||||
if (expr instanceof GrTypeCastExpression) return TYPE_CAST_PRECEDENCE;
|
||||
if (expr instanceof GrRangeExpression) return RANGE_PRECEDENCE;
|
||||
if (expr instanceof GrConditionalExpression) return CONDITIONAL_PRECEDENCE;
|
||||
if (expr instanceof GrSafeCastExpression) return SAFE_CAST_PRECEDENCE;
|
||||
if (expr instanceof GrAssignmentExpression) return ASSIGNMENT_PRECEDENCE;
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.plugins.groovy.intentions.closure.forToEach;
|
||||
|
||||
import org.jetbrains.plugins.groovy.intentions.GrIntentionTestCase;
|
||||
import org.jetbrains.plugins.groovy.intentions.closure.ForToEachIntention;
|
||||
import org.jetbrains.plugins.groovy.util.TestUtils;
|
||||
|
||||
class ForToEachIntentionTest extends GrIntentionTestCase {
|
||||
|
||||
ForToEachIntentionTest() {
|
||||
super(ForToEachIntention.class)
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return TestUtils.testDataPath + "intentions/ForToEach/"
|
||||
}
|
||||
|
||||
void testForToEachOnRangeWithoutParentheses() {
|
||||
doTest(true)
|
||||
}
|
||||
|
||||
void testForToEachOnRangeWithParentheses() {
|
||||
doTest(true)
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
f<caret>or (i in (0..<10)) {
|
||||
println i
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
(0..<10).each { i ->
|
||||
println i
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
f<caret>or (i in 0..<10) {
|
||||
println i
|
||||
}
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
(0..<10).each { i ->
|
||||
println i
|
||||
}
|
||||
Reference in New Issue
Block a user