mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[groovy] 'for': make GrTraditionalForClause#getUpdate return GrExpressionList (IDEA-188433)
This commit is contained in:
+5
-20
@@ -1,34 +1,19 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.groovy.lang.psi.api.statements.clauses;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.GrExpressionList;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrCondition;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
|
||||
/**
|
||||
* @author ven
|
||||
*/
|
||||
public interface GrTraditionalForClause extends GrForClause {
|
||||
|
||||
@Nullable
|
||||
GrCondition getInitialization();
|
||||
|
||||
|
||||
@Nullable
|
||||
GrExpression getCondition();
|
||||
|
||||
@Nullable
|
||||
GrExpression getUpdate();
|
||||
GrExpressionList getUpdate();
|
||||
}
|
||||
|
||||
+7
-4
@@ -1,12 +1,13 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
package org.jetbrains.plugins.groovy.lang.psi.impl.statements.clauses;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.GrExpressionList;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrCondition;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.clauses.GrTraditionalForClause;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
@@ -14,6 +15,8 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameterList;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiElementImpl;
|
||||
|
||||
import static com.intellij.util.ObjectUtils.tryCast;
|
||||
|
||||
/**
|
||||
* @author ilyas
|
||||
*/
|
||||
@@ -47,10 +50,10 @@ public class GrTraditionalForClauseImpl extends GroovyPsiElementImpl implements
|
||||
return condition instanceof GrExpression ? (GrExpression)condition : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public GrExpression getUpdate() {
|
||||
final GrCondition condition = getConditionInner(2);
|
||||
return condition instanceof GrExpression ? (GrExpression)condition : null;
|
||||
public GrExpressionList getUpdate() {
|
||||
return tryCast(getLastChild(), GrExpressionList.class);
|
||||
}
|
||||
|
||||
private GrCondition getConditionInner(final int i) {
|
||||
|
||||
+3
-2
@@ -13,6 +13,7 @@ import org.jetbrains.plugins.groovy.codeInspection.noReturnMethod.MissingReturnI
|
||||
import org.jetbrains.plugins.groovy.codeInspection.utils.ControlFlowUtils;
|
||||
import org.jetbrains.plugins.groovy.lang.lexer.TokenSets;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.GrExpressionList;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrCondition;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrListOrMap;
|
||||
@@ -410,7 +411,7 @@ public class CodeBlockGenerator extends Generator {
|
||||
final GrTraditionalForClause cl = (GrTraditionalForClause)clause;
|
||||
final GrCondition initialization = cl.getInitialization();
|
||||
final GrExpression condition = cl.getCondition();
|
||||
final GrExpression update = cl.getUpdate();
|
||||
final GrExpressionList update = cl.getUpdate();
|
||||
|
||||
if (initialization instanceof GrParameter) {
|
||||
StringBuilder partBuilder = new StringBuilder();
|
||||
@@ -450,7 +451,7 @@ public class CodeBlockGenerator extends Generator {
|
||||
}
|
||||
}
|
||||
|
||||
private static void genForPart(StringBuilder builder, GrExpression part, final ExpressionContext context) {
|
||||
private static void genForPart(StringBuilder builder, GroovyPsiElement part, final ExpressionContext context) {
|
||||
genForPart(builder, part, new ExpressionGenerator(new StringBuilder(), context));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user