mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[groovy] clean up GrOperatorExpression interface
Add `getOperation()`: `getOperation` differs from `getOperationTokenType` in that the former should return actual operation type which will be used for resolve/inference while the latter is just a shorthand for obtaining token type of `getOperationToken`. In case of binary expression it is the same as `getOperationTokenType`, in case of assignment expression there corresponding operator type is returned. Pull down getOperationToken() and getOperationTokenType(): there two methods aren't used via GrOperatorExpression and they should not.
This commit is contained in:
+8
@@ -4,6 +4,8 @@
|
||||
|
||||
package org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -18,6 +20,12 @@ import org.jetbrains.annotations.Nullable;
|
||||
*/
|
||||
public interface GrAssignmentExpression extends GrOperatorExpression {
|
||||
|
||||
@NotNull
|
||||
PsiElement getOperationToken();
|
||||
|
||||
@NotNull
|
||||
IElementType getOperationTokenType();
|
||||
|
||||
@NotNull
|
||||
GrExpression getLValue();
|
||||
|
||||
|
||||
+9
-13
@@ -1,21 +1,11 @@
|
||||
/*
|
||||
* 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-2017 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.expressions;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -35,4 +25,10 @@ public interface GrBinaryExpression extends GrOperatorExpression {
|
||||
*/
|
||||
@Nullable
|
||||
GrExpression getRightOperand();
|
||||
|
||||
@NotNull
|
||||
PsiElement getOperationToken();
|
||||
|
||||
@NotNull
|
||||
IElementType getOperationTokenType();
|
||||
}
|
||||
|
||||
+3
-20
@@ -1,24 +1,10 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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-2017 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.expressions;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiType;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyPolyVariantReference;
|
||||
|
||||
@@ -30,9 +16,6 @@ public interface GrOperatorExpression extends GrExpression, GroovyPolyVariantRef
|
||||
@Nullable
|
||||
PsiType getRightType();
|
||||
|
||||
@NotNull
|
||||
PsiElement getOperationToken();
|
||||
|
||||
@NotNull
|
||||
IElementType getOperationTokenType();
|
||||
@Nullable
|
||||
IElementType getOperation();
|
||||
}
|
||||
|
||||
+4
-14
@@ -1,17 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 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-2017 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;
|
||||
|
||||
@@ -42,7 +30,9 @@ abstract public class GrOperatorExpressionImpl extends GrExpressionImpl implemen
|
||||
return TypeInferenceHelper.getCurrentContext().getExpressionType(this, GrBinaryExpressionTypeCalculators::computeType);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public abstract PsiElement getOperationToken();
|
||||
|
||||
@NotNull
|
||||
public IElementType getOperationTokenType() {
|
||||
return getOperationToken().getNode().getElementType();
|
||||
|
||||
+7
-1
@@ -65,12 +65,18 @@ public class GrAssignmentExpressionImpl extends GrOperatorExpressionImpl impleme
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiElement getOperationToken() {
|
||||
return findNotNullChildByType(TokenSets.ASSIGNMENTS);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IElementType getOperation() {
|
||||
return TokenSets.ASSIGNMENTS_TO_OPERATORS.get(getOperationTokenType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOperatorAssignment() {
|
||||
return getOperationTokenType() != GroovyTokenTypes.mASSIGN;
|
||||
|
||||
+7
-13
@@ -1,17 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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-2017 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.expressions;
|
||||
@@ -115,6 +103,12 @@ public abstract class GrBinaryExpressionImpl extends GrOperatorExpressionImpl im
|
||||
return findNotNullChildByType(TokenSets.BINARY_OP_SET);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IElementType getOperation() {
|
||||
return getOperationTokenType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(GroovyElementVisitor visitor) {
|
||||
visitor.visitBinaryExpression(this);
|
||||
|
||||
+5
-5
@@ -1,6 +1,6 @@
|
||||
// Copyright 2000-2017 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.
|
||||
/*
|
||||
* Copyright 2000-2017 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.expressions.binaryCalculators;
|
||||
|
||||
import com.intellij.psi.PsiType;
|
||||
@@ -71,8 +71,8 @@ public class GrBinaryExpressionTypeCalculators {
|
||||
|
||||
@Nullable
|
||||
public static PsiType computeType(@NotNull GrOperatorExpression e) {
|
||||
final Function<GrOperatorExpression, PsiType> function = MAP.get(e.getOperationTokenType());
|
||||
assert function != null : e.getOperationTokenType();
|
||||
final Function<GrOperatorExpression, PsiType> function = MAP.get(e.getOperation());
|
||||
assert function != null : e.getOperation();
|
||||
return function.fun(e);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user