mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-21 05:51:25 +07:00
replace primitive == comparisons with .equals
This commit is contained in:
@@ -494,7 +494,7 @@ public class LocalVariablesUtil {
|
||||
}
|
||||
|
||||
private static int getTypeSlotSize(PsiType varType) {
|
||||
if (varType == PsiType.DOUBLE || varType == PsiType.LONG) {
|
||||
if (PsiType.DOUBLE.equals(varType) || PsiType.LONG.equals(varType)) {
|
||||
return 2;
|
||||
}
|
||||
return 1;
|
||||
|
||||
@@ -109,7 +109,7 @@ public class SimplifyBooleanExpressionFix extends LocalQuickFixOnPsiElement {
|
||||
public static void simplifyIfStatement(final PsiExpression expression) throws IncorrectOperationException {
|
||||
PsiElement parent = expression.getParent();
|
||||
if (!(parent instanceof PsiIfStatement) || ((PsiIfStatement)parent).getCondition() != expression) return;
|
||||
if (!(expression instanceof PsiLiteralExpression) || expression.getType() != PsiType.BOOLEAN) return;
|
||||
if (!(expression instanceof PsiLiteralExpression) || !PsiType.BOOLEAN.equals(expression.getType())) return;
|
||||
boolean condition = Boolean.parseBoolean(expression.getText());
|
||||
PsiIfStatement ifStatement = (PsiIfStatement)parent;
|
||||
if (condition) {
|
||||
@@ -210,7 +210,7 @@ public class SimplifyBooleanExpressionFix extends LocalQuickFixOnPsiElement {
|
||||
}
|
||||
|
||||
public static boolean canBeSimplified(@NotNull PsiExpression expression) {
|
||||
if (!(expression instanceof PsiConditionalExpression) && expression.getType() != PsiType.BOOLEAN) return false;
|
||||
if (!(expression instanceof PsiConditionalExpression) && !PsiType.BOOLEAN.equals(expression.getType())) return false;
|
||||
|
||||
final ExpressionVisitor expressionVisitor = new ExpressionVisitor(expression.getManager(), false);
|
||||
final Ref<Boolean> canBeSimplified = new Ref<Boolean>(Boolean.FALSE);
|
||||
|
||||
@@ -1218,7 +1218,7 @@ public class ControlFlowAnalyzer extends JavaElementVisitor {
|
||||
}
|
||||
|
||||
private void generateBoxingUnboxingInstructionFor(@NotNull PsiExpression expression, PsiType expectedType) {
|
||||
if (expectedType == PsiType.VOID) return;
|
||||
if (PsiType.VOID.equals(expectedType)) return;
|
||||
|
||||
PsiType exprType = expression.getType();
|
||||
|
||||
|
||||
@@ -572,7 +572,7 @@ public class DataFlowInspectionBase extends BaseJavaBatchLocalInspectionTool {
|
||||
|
||||
PsiType returnType = method.getReturnType();
|
||||
// no warnings in void lambdas, where the expression is not returned anyway
|
||||
if (block instanceof PsiExpression && block.getParent() instanceof PsiLambdaExpression && returnType == PsiType.VOID) return;
|
||||
if (block instanceof PsiExpression && block.getParent() instanceof PsiLambdaExpression && PsiType.VOID.equals(returnType)) return;
|
||||
|
||||
// no warnings for Void methods, where only null can be possibly returned
|
||||
if (returnType == null || returnType.equalsToText(CommonClassNames.JAVA_LANG_VOID)) return;
|
||||
|
||||
@@ -36,7 +36,7 @@ public class PurityInference {
|
||||
|
||||
public static boolean inferPurity(@NotNull final PsiMethod method) {
|
||||
if (!InferenceFromSourceUtil.shouldInferFromSource(method) ||
|
||||
method.getReturnType() == PsiType.VOID ||
|
||||
PsiType.VOID.equals(method.getReturnType()) ||
|
||||
method.getBody() == null ||
|
||||
method.isConstructor() ||
|
||||
PropertyUtil.isSimpleGetter(method)) {
|
||||
|
||||
@@ -517,18 +517,16 @@ public class StandardInstructionVisitor extends InstructionVisitor {
|
||||
PsiType varType = var.getVariableType();
|
||||
if (!(varType instanceof PsiPrimitiveType)) return null;
|
||||
|
||||
if (varType == PsiType.FLOAT || varType == PsiType.DOUBLE) return null;
|
||||
if (PsiType.FLOAT.equals(varType) || PsiType.DOUBLE.equals(varType)) return null;
|
||||
|
||||
double minValue = varType == PsiType.BYTE ? Byte.MIN_VALUE :
|
||||
varType == PsiType.SHORT ? Short.MIN_VALUE :
|
||||
varType == PsiType.INT ? Integer.MIN_VALUE :
|
||||
varType == PsiType.CHAR ? Character.MIN_VALUE :
|
||||
Long.MIN_VALUE;
|
||||
double maxValue = varType == PsiType.BYTE ? Byte.MAX_VALUE :
|
||||
varType == PsiType.SHORT ? Short.MAX_VALUE :
|
||||
varType == PsiType.INT ? Integer.MAX_VALUE :
|
||||
varType == PsiType.CHAR ? Character.MAX_VALUE :
|
||||
Long.MAX_VALUE;
|
||||
double minValue = PsiType.BYTE.equals(varType) ? Byte.MIN_VALUE : PsiType.SHORT.equals(varType)
|
||||
? Short.MIN_VALUE : PsiType.INT.equals(varType)
|
||||
? Integer.MIN_VALUE : PsiType.CHAR.equals(varType) ? Character.MIN_VALUE :
|
||||
Long.MIN_VALUE;
|
||||
double maxValue = PsiType.BYTE.equals(varType) ? Byte.MAX_VALUE : PsiType.SHORT.equals(varType)
|
||||
? Short.MAX_VALUE : PsiType.INT.equals(varType)
|
||||
? Integer.MAX_VALUE : PsiType.CHAR.equals(varType) ? Character.MAX_VALUE :
|
||||
Long.MAX_VALUE;
|
||||
|
||||
return checkComparisonWithKnownRange(instruction, runner, memState, opSign, comparedWith, minValue, maxValue);
|
||||
}
|
||||
|
||||
@@ -251,7 +251,7 @@ public class RefJavaUtilImpl extends RefJavaUtil{
|
||||
|
||||
if (refExpression instanceof PsiMethodReferenceExpression) {
|
||||
PsiType returnType = psiMethod.getReturnType();
|
||||
if (!psiMethod.isConstructor() && returnType != PsiType.VOID) {
|
||||
if (!psiMethod.isConstructor() && !PsiType.VOID.equals(returnType)) {
|
||||
refMethod.setReturnValueUsed(true);
|
||||
addTypeReference(psiFrom, returnType, refFrom.getRefManager());
|
||||
}
|
||||
@@ -263,7 +263,7 @@ public class RefJavaUtilImpl extends RefJavaUtil{
|
||||
);
|
||||
if (call != null) {
|
||||
PsiType returnType = psiMethod.getReturnType();
|
||||
if (!psiMethod.isConstructor() && returnType != PsiType.VOID) {
|
||||
if (!psiMethod.isConstructor() && !PsiType.VOID.equals(returnType)) {
|
||||
if (!(call.getParent() instanceof PsiExpressionStatement)) {
|
||||
refMethod.setReturnValueUsed(true);
|
||||
}
|
||||
|
||||
@@ -27,11 +27,9 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.util.Pass;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.*;
|
||||
import com.intellij.xml.util.XmlUtil;
|
||||
import org.intellij.lang.annotations.Pattern;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -407,7 +405,7 @@ public class UncheckedWarningLocalInspectionBase extends BaseJavaBatchLocalInspe
|
||||
if (psiElement instanceof PsiMethod) {
|
||||
final PsiMethod method = (PsiMethod)psiElement;
|
||||
final PsiType returnType = method.getReturnType();
|
||||
if (returnType != null && returnType != PsiType.VOID) {
|
||||
if (returnType != null && !PsiType.VOID.equals(returnType)) {
|
||||
final PsiExpression returnValue = statement.getReturnValue();
|
||||
if (returnValue != null) {
|
||||
final PsiType valueType = returnValue.getType();
|
||||
|
||||
@@ -221,7 +221,7 @@ public class ParametersFolder {
|
||||
if (expression == null) break;
|
||||
|
||||
final PsiType expressionType = ((PsiExpression)expression).getType();
|
||||
if (expressionType != null && expressionType != PsiType.VOID && !(expression.getParent() instanceof PsiExpressionStatement)) {
|
||||
if (expressionType != null && !PsiType.VOID.equals(expressionType) && !(expression.getParent() instanceof PsiExpressionStatement)) {
|
||||
if (dependsOnLocals(expression, inputVariables)) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ public class FunctionalInterfaceSuggester {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (returnType == PsiType.VOID && interfaceMethodReturnType != PsiType.VOID) {
|
||||
if (PsiType.VOID.equals(returnType) && !PsiType.VOID.equals(interfaceMethodReturnType)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ public class JavaRegExpModifierProvider implements RegExpModifierProvider {
|
||||
@Override
|
||||
public int getFlags(PsiElement elementInHost, PsiFile regexp) {
|
||||
final PsiExpressionList list = PsiTreeUtil.getParentOfType(elementInHost, PsiExpressionList.class);
|
||||
if (list != null && list.getExpressions().length == 2 && list.getExpressionTypes()[1] == PsiType.INT) {
|
||||
if (list != null && list.getExpressions().length == 2 && PsiType.INT.equals(list.getExpressionTypes()[1])) {
|
||||
final Object result = JavaConstantExpressionEvaluator.computeConstantExpression(list.getExpressions()[1], false);
|
||||
if (result instanceof Integer) {
|
||||
//noinspection MagicConstant
|
||||
|
||||
@@ -757,7 +757,7 @@ public class JavaCompletionUtil {
|
||||
TailType toInsert = tailType;
|
||||
LookupItem<?> lookupItem = item.as(LookupItem.CLASS_CONDITION_KEY);
|
||||
if (lookupItem == null || lookupItem.getAttribute(LookupItem.TAIL_TYPE_ATTR) != TailType.UNKNOWN) {
|
||||
if (!hasTail && item.getObject() instanceof PsiMethod && ((PsiMethod)item.getObject()).getReturnType() == PsiType.VOID) {
|
||||
if (!hasTail && item.getObject() instanceof PsiMethod && PsiType.VOID.equals(((PsiMethod)item.getObject()).getReturnType())) {
|
||||
PsiDocumentManager.getInstance(context.getProject()).commitAllDocuments();
|
||||
if (psiElement().beforeLeaf(psiElement().withText(".")).accepts(context.getFile().findElementAt(context.getTailOffset() - 1))) {
|
||||
return false;
|
||||
|
||||
@@ -491,7 +491,7 @@ public class JavaKeywordCompletion {
|
||||
private static boolean mayExpectBoolean(CompletionParameters parameters) {
|
||||
for (ExpectedTypeInfo info : JavaSmartCompletionContributor.getExpectedTypes(parameters)) {
|
||||
PsiType type = info.getType();
|
||||
if (type instanceof PsiClassType || type == PsiType.BOOLEAN) return true;
|
||||
if (type instanceof PsiClassType || PsiType.BOOLEAN.equals(type)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -325,7 +325,7 @@ public class JavaMemberNameCompletionContributor extends CompletionContributor {
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasStartMatches(matcher, result) && PsiType.VOID != varType && includeOverlapped) {
|
||||
if (!hasStartMatches(matcher, result) && !PsiType.VOID.equals(varType) && includeOverlapped) {
|
||||
// use suggested names as suffixes
|
||||
final String requiredSuffix = codeStyleManager.getSuffixByVariableKind(varKind);
|
||||
final String prefix = matcher.getPrefix();
|
||||
|
||||
@@ -81,7 +81,7 @@ public class JavaMethodMergingContributor extends CompletionContributor {
|
||||
|
||||
private static int getPriority(LookupElement element) {
|
||||
PsiMethod method = assertNotNull(getItemMethod(element));
|
||||
return (method.getReturnType() == PsiType.VOID ? 0 : 1) +
|
||||
return (PsiType.VOID.equals(method.getReturnType()) ? 0 : 1) +
|
||||
(method.getParameterList().getParametersCount() > 0 ? 2 : 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ class SmartCastProvider extends CompletionProvider<CompletionParameters> {
|
||||
type = ((PsiWildcardType)type).getBound();
|
||||
}
|
||||
|
||||
if (type == null || type == PsiType.VOID) {
|
||||
if (type == null || PsiType.VOID.equals(type)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ public class DelegateWithDefaultParamValueIntentionAction extends PsiElementBase
|
||||
final String methodCall;
|
||||
if (method.getReturnType() == null) {
|
||||
methodCall = "this";
|
||||
} else if (method.getReturnType() != PsiType.VOID) {
|
||||
} else if (!PsiType.VOID.equals(method.getReturnType())) {
|
||||
methodCall = "return " + method.getName();
|
||||
} else {
|
||||
methodCall = method.getName();
|
||||
|
||||
@@ -55,7 +55,7 @@ public class MissingReturnExpressionFixer implements Fixer {
|
||||
PsiElement parent = PsiTreeUtil.getParentOfType(psiElement, PsiClassInitializer.class, PsiMethod.class);
|
||||
if (parent instanceof PsiMethod) {
|
||||
final PsiType returnType = ((PsiMethod)parent).getReturnType();
|
||||
if (returnType != null && returnType != PsiType.VOID) {
|
||||
if (returnType != null && !PsiType.VOID.equals(returnType)) {
|
||||
final int startOffset = retStatement.getTextRange().getStartOffset();
|
||||
if (returnValue != null) {
|
||||
editor.getDocument().insertString(startOffset + "return".length(), ";");
|
||||
@@ -84,7 +84,7 @@ public class MissingReturnExpressionFixer implements Fixer {
|
||||
if (!(prev instanceof PsiJavaToken)) {
|
||||
int offset = returnStatement.getTextRange().getEndOffset();
|
||||
final PsiMethod method = PsiTreeUtil.getParentOfType(returnStatement, PsiMethod.class, true, PsiLambdaExpression.class);
|
||||
if (method != null && method.getReturnType() == PsiType.VOID) {
|
||||
if (method != null && PsiType.VOID.equals(method.getReturnType())) {
|
||||
offset = returnStatement.getTextRange().getStartOffset() + "return".length();
|
||||
}
|
||||
editor.getDocument().insertString(offset, ";");
|
||||
@@ -101,7 +101,7 @@ public class MissingReturnExpressionFixer implements Fixer {
|
||||
editor.getDocument().insertString(offset, ";");
|
||||
if (prevToken.getTokenType() == JavaTokenType.RETURN_KEYWORD) {
|
||||
final PsiMethod method = PsiTreeUtil.getParentOfType(returnStatement, PsiMethod.class);
|
||||
if (method != null && method.getReturnType() != PsiType.VOID) {
|
||||
if (method != null && !PsiType.VOID.equals(method.getReturnType())) {
|
||||
editor.getCaretModel().moveToOffset(offset);
|
||||
processor.setSkipEnter(true);
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ public class GenerateDelegateHandler implements LanguageCodeInsightActionHandler
|
||||
|
||||
PsiModifierList modifierList = null;
|
||||
|
||||
if (method.getReturnType() != PsiType.VOID) {
|
||||
if (!PsiType.VOID.equals(method.getReturnType())) {
|
||||
call.append("return ");
|
||||
}
|
||||
|
||||
|
||||
@@ -337,7 +337,7 @@ public class OverrideImplementUtil extends OverrideImplementExploreUtil {
|
||||
@NotNull
|
||||
public static String callSuper(PsiMethod superMethod, PsiMethod overriding) {
|
||||
@NonNls StringBuilder buffer = new StringBuilder();
|
||||
if (!superMethod.isConstructor() && superMethod.getReturnType() != PsiType.VOID) {
|
||||
if (!superMethod.isConstructor() && !PsiType.VOID.equals(superMethod.getReturnType())) {
|
||||
buffer.append("return ");
|
||||
}
|
||||
buffer.append("super");
|
||||
|
||||
@@ -54,7 +54,7 @@ public class IntroduceVariableIntentionAction extends BaseRefactoringIntentionAc
|
||||
|
||||
final PsiExpression expression = statement.getExpression();
|
||||
|
||||
return expression.getType() != PsiType.VOID && !(expression instanceof PsiAssignmentExpression);
|
||||
return !PsiType.VOID.equals(expression.getType()) && !(expression instanceof PsiAssignmentExpression);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -406,7 +406,7 @@ public class JavaDocumentationProvider extends DocumentationProviderEx implement
|
||||
if (typeParameterList != null) {
|
||||
createTypeParamsListComment(builder, project, commenter, typeParameterList);
|
||||
}
|
||||
if (psiMethod.getReturnType() != null && psiMethod.getReturnType() != PsiType.VOID) {
|
||||
if (psiMethod.getReturnType() != null && !PsiType.VOID.equals(psiMethod.getReturnType())) {
|
||||
builder.append(CodeDocumentationUtil.createDocCommentLine(RETURN_TAG, project, commenter));
|
||||
builder.append(LINE_SEPARATOR);
|
||||
}
|
||||
|
||||
@@ -267,10 +267,10 @@ public class ExtractMethodProcessor implements MatchProvider {
|
||||
if (expressionType == null) {
|
||||
expressionType = PsiType.VOID;
|
||||
}
|
||||
myHasExpressionOutput = expressionType != PsiType.VOID;
|
||||
myHasExpressionOutput = !PsiType.VOID.equals(expressionType);
|
||||
|
||||
final PsiType returnStatementType = getExpectedReturnType();
|
||||
myHasReturnStatementOutput = myHasReturnStatement && returnStatementType != null && returnStatementType != PsiType.VOID;
|
||||
myHasReturnStatementOutput = myHasReturnStatement && returnStatementType != null && !PsiType.VOID.equals(returnStatementType);
|
||||
|
||||
if (myGenerateConditionalExit && myOutputVariables.length == 1) {
|
||||
if (!(myOutputVariables[0].getType() instanceof PsiPrimitiveType)) {
|
||||
@@ -381,7 +381,7 @@ public class ExtractMethodProcessor implements MatchProvider {
|
||||
|
||||
private boolean areAllExitPointsAreNotNull(PsiType returnStatementType) {
|
||||
if (insertNotNullCheckIfPossible() && myControlFlowWrapper.getOutputVariables(false).length == 0) {
|
||||
boolean isNotNull = returnStatementType != null && returnStatementType != PsiType.VOID;
|
||||
boolean isNotNull = returnStatementType != null && !PsiType.VOID.equals(returnStatementType);
|
||||
for (PsiStatement statement : myExitStatements) {
|
||||
if (statement instanceof PsiReturnStatement) {
|
||||
final PsiExpression returnValue = ((PsiReturnStatement)statement).getReturnValue();
|
||||
@@ -432,7 +432,7 @@ public class ExtractMethodProcessor implements MatchProvider {
|
||||
return;
|
||||
}
|
||||
final PsiMethod method = (PsiMethod)myCodeFragmentMember;
|
||||
if (!method.isConstructor() || myReturnType != PsiType.VOID) {
|
||||
if (!method.isConstructor() || !PsiType.VOID.equals(myReturnType)) {
|
||||
return;
|
||||
}
|
||||
final PsiCodeBlock body = method.getBody();
|
||||
|
||||
@@ -277,7 +277,7 @@ public class ExtractLightMethodObjectHandler {
|
||||
private static boolean isValidVariableType(PsiType type) {
|
||||
if (type instanceof PsiClassType ||
|
||||
type instanceof PsiArrayType ||
|
||||
type instanceof PsiPrimitiveType && type != PsiType.VOID) {
|
||||
type instanceof PsiPrimitiveType && !PsiType.VOID.equals(type)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -549,7 +549,7 @@ public class InheritanceToDelegationProcessor extends BaseRefactoringProcessor {
|
||||
@NonNls final StringBuffer buffer = new StringBuffer();
|
||||
buffer.append("{\n");
|
||||
|
||||
if (methodToAdd.getReturnType() != PsiType.VOID) {
|
||||
if (!PsiType.VOID.equals(methodToAdd.getReturnType())) {
|
||||
buffer.append("return ");
|
||||
}
|
||||
|
||||
|
||||
@@ -747,7 +747,7 @@ public class InlineMethodProcessor extends BaseRefactoringProcessor {
|
||||
PsiType returnType = callSubstitutor.substitute(myMethod.getReturnType());
|
||||
String resultName = null;
|
||||
final int applicabilityLevel = PsiUtil.getApplicabilityLevel(myMethod, callSubstitutor, argumentList);
|
||||
if (returnType != null && returnType != PsiType.VOID && tailCallType == InlineUtil.TailCallType.None) {
|
||||
if (returnType != null && !PsiType.VOID.equals(returnType) && tailCallType == InlineUtil.TailCallType.None) {
|
||||
resultName = myJavaCodeStyle.propertyNameToVariableName("result", VariableKind.LOCAL_VARIABLE);
|
||||
resultName = myJavaCodeStyle.suggestUniqueVariableName(resultName, block.getFirstChild(), true);
|
||||
PsiDeclarationStatement declaration = myFactory.createVariableDeclarationStatement(resultName, returnType, null);
|
||||
|
||||
@@ -236,7 +236,7 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
|
||||
PsiExpression expression = PsiTreeUtil.getParentOfType(elementAtCaret, PsiExpression.class);
|
||||
while (expression != null) {
|
||||
if (!expressions.contains(expression) && !(expression instanceof PsiParenthesizedExpression) && !(expression instanceof PsiSuperExpression) &&
|
||||
(acceptVoid || expression.getType() != PsiType.VOID)) {
|
||||
(acceptVoid || !PsiType.VOID.equals(expression.getType()))) {
|
||||
if (expression instanceof PsiMethodReferenceExpression) {
|
||||
expressions.add(expression);
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class WrapReturnValueAction extends BaseRefactoringAction{
|
||||
final PsiMethod psiMethod = PsiTreeUtil.getParentOfType(element, PsiMethod.class, false);
|
||||
if (psiMethod != null && !(psiMethod instanceof PsiCompiledElement)) {
|
||||
final PsiType returnType = psiMethod.getReturnType();
|
||||
return returnType != null && returnType != PsiType.VOID;
|
||||
return returnType != null && !PsiType.VOID.equals(returnType);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ public class LambdaUtil {
|
||||
|
||||
public static boolean isLambdaFullyInferred(PsiLambdaExpression expression, PsiType functionalInterfaceType) {
|
||||
final boolean hasParams = expression.getParameterList().getParametersCount() > 0;
|
||||
if (hasParams || getFunctionalInterfaceReturnType(functionalInterfaceType) != PsiType.VOID) { //todo check that void lambdas without params check
|
||||
if (hasParams || !PsiType.VOID.equals(getFunctionalInterfaceReturnType(functionalInterfaceType))) { //todo check that void lambdas without params check
|
||||
|
||||
return !dependsOnTypeParams(functionalInterfaceType, functionalInterfaceType, expression);
|
||||
}
|
||||
@@ -570,7 +570,7 @@ public class LambdaUtil {
|
||||
}
|
||||
|
||||
public static String checkReturnTypeCompatible(PsiLambdaExpression lambdaExpression, PsiType functionalInterfaceReturnType) {
|
||||
if (functionalInterfaceReturnType == PsiType.VOID) {
|
||||
if (PsiType.VOID.equals(functionalInterfaceReturnType)) {
|
||||
final PsiElement body = lambdaExpression.getBody();
|
||||
if (body instanceof PsiCodeBlock) {
|
||||
if (!getReturnExpressions(lambdaExpression).isEmpty()) return "Unexpected return value";
|
||||
|
||||
@@ -321,7 +321,7 @@ public class PsiMethodReferenceUtil {
|
||||
returnType = ((PsiMethod)resolve).getReturnType();
|
||||
}
|
||||
PsiType methodReturnType = subst.substitute(returnType);
|
||||
if (interfaceReturnType != null && interfaceReturnType != PsiType.VOID) {
|
||||
if (interfaceReturnType != null && !PsiType.VOID.equals(interfaceReturnType)) {
|
||||
if (methodReturnType == null) {
|
||||
methodReturnType = JavaPsiFacade.getElementFactory(expression.getProject()).createType(containingClass, subst);
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public class PsiConcatenationUtil {
|
||||
addFormatParameter(subExpression, formatString, formatParameters, printfFormat);
|
||||
}
|
||||
if (stringStarted) {
|
||||
if (optype != null && (optype.equalsToText(JAVA_LANG_STRING) || optype == PsiType.CHAR)) {
|
||||
if (optype != null && (optype.equalsToText(JAVA_LANG_STRING) || PsiType.CHAR.equals(optype))) {
|
||||
buildFormatString(op, formatString, formatParameters, printfFormat);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
*/
|
||||
package com.intellij.psi.util;
|
||||
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.codeInsight.runner.JavaMainMethodProvider;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.psi.*;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
@@ -59,7 +59,7 @@ public class PsiMethodUtil {
|
||||
|
||||
public static boolean isMainMethod(final PsiMethod method) {
|
||||
if (method == null || method.getContainingClass() == null) return false;
|
||||
if (PsiType.VOID != method.getReturnType()) return false;
|
||||
if (!PsiType.VOID.equals(method.getReturnType())) return false;
|
||||
if (!method.hasModifierProperty(PsiModifier.STATIC)) return false;
|
||||
if (!method.hasModifierProperty(PsiModifier.PUBLIC)) return false;
|
||||
final PsiParameter[] parameters = method.getParameterList().getParameters();
|
||||
|
||||
@@ -80,7 +80,7 @@ public class InferredTypeTest extends LightCodeInsightFixtureTestCase {
|
||||
final PsiJavaFile file = (PsiJavaFile)myFixture.addFileToProject("R.java", "public interface R {@D void run();}");
|
||||
final PsiClass psiClass = file.getClasses()[0];
|
||||
final PsiMethod method = psiClass.getMethods()[0];
|
||||
assertFalse(PsiType.VOID == method.getReturnType());
|
||||
assertFalse(PsiType.VOID.equals(method.getReturnType()));
|
||||
myFixture.configureByText("a.java", "class A {{R r = () -> {};}} ");
|
||||
myFixture.checkHighlighting(false, false, false);
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public class ConvertFieldToThreadLocalIntention extends PsiElementBaseIntentionA
|
||||
if (psiField.getTypeElement() == null) return false;
|
||||
final PsiType fieldType = psiField.getType();
|
||||
final PsiClass fieldTypeClass = PsiUtil.resolveClassInType(fieldType);
|
||||
if (fieldType instanceof PsiPrimitiveType && fieldType != PsiType.VOID || fieldType instanceof PsiArrayType) return true;
|
||||
if (fieldType instanceof PsiPrimitiveType && !PsiType.VOID.equals(fieldType) || fieldType instanceof PsiArrayType) return true;
|
||||
return fieldTypeClass != null && !Comparing.strEqual(fieldTypeClass.getQualifiedName(), ThreadLocal.class.getName())
|
||||
&& AllowedApiFilterExtension.isClassAllowed(ThreadLocal.class.getName(), element);
|
||||
}
|
||||
@@ -121,7 +121,7 @@ public class ConvertFieldToThreadLocalIntention extends PsiElementBaseIntentionA
|
||||
if (initializer == null) {
|
||||
final PsiType type = psiField.getType();
|
||||
String initializerText = null;
|
||||
if (type == PsiType.BOOLEAN) {
|
||||
if (PsiType.BOOLEAN.equals(type)) {
|
||||
initializerText = "false";
|
||||
}
|
||||
else if (type instanceof PsiPrimitiveType) {
|
||||
|
||||
@@ -39,19 +39,19 @@ public class AtomicConversionRule extends TypeConversionRule {
|
||||
}
|
||||
|
||||
private static boolean isAtomicTypeMigration(PsiType from, PsiClassType to, PsiExpression context) {
|
||||
if (from == PsiType.INT && to.getCanonicalText().equals(AtomicInteger.class.getName())) {
|
||||
if (PsiType.INT.equals(from) && to.getCanonicalText().equals(AtomicInteger.class.getName())) {
|
||||
return true;
|
||||
}
|
||||
if (from.equals(PsiType.INT.createArrayType()) && to.getCanonicalText().equals(AtomicIntegerArray.class.getName())) {
|
||||
return true;
|
||||
}
|
||||
if (from == PsiType.LONG && to.getCanonicalText().equals(AtomicLong.class.getName())) {
|
||||
if (PsiType.LONG.equals(from) && to.getCanonicalText().equals(AtomicLong.class.getName())) {
|
||||
return true;
|
||||
}
|
||||
if (from.equals(PsiType.LONG.createArrayType()) && to.getCanonicalText().equals(AtomicLongArray.class.getName())) {
|
||||
return true;
|
||||
}
|
||||
if (from == PsiType.BOOLEAN && to.getCanonicalText().equals(AtomicBoolean.class.getName())) {
|
||||
if (PsiType.BOOLEAN.equals(from) && to.getCanonicalText().equals(AtomicBoolean.class.getName())) {
|
||||
return true;
|
||||
}
|
||||
final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(to);
|
||||
|
||||
@@ -193,7 +193,7 @@ class BooleanMethodIsAlwaysInvertedInspectionBase extends GlobalJavaBatchInspect
|
||||
if (refElement instanceof RefMethod) {
|
||||
final PsiElement element = refElement.getElement();
|
||||
if (!(element instanceof PsiMethod)) return;
|
||||
if (((PsiMethod)element).getReturnType() != PsiType.BOOLEAN) return;
|
||||
if (!PsiType.BOOLEAN.equals(((PsiMethod)element).getReturnType())) return;
|
||||
refElement.putUserData(ALWAYS_INVERTED, Boolean.TRUE); //initial mark boolean methods
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ public class UnpredictableBigDecimalConstructorCallInspection
|
||||
final PsiParameter[] parameters = parameterList.getParameters();
|
||||
final PsiParameter firstParameter = parameters[0];
|
||||
final PsiType type = firstParameter.getType();
|
||||
if (type != PsiType.DOUBLE) {
|
||||
if (!PsiType.DOUBLE.equals(type)) {
|
||||
return;
|
||||
}
|
||||
final PsiExpressionList argumentList = expression.getArgumentList();
|
||||
|
||||
@@ -137,9 +137,9 @@ public class ParenthesesUtils {
|
||||
return false;
|
||||
}
|
||||
if (JavaTokenType.PLUS == tokenType || JavaTokenType.ASTERISK == tokenType) {
|
||||
return primitiveType != PsiType.FLOAT && primitiveType != PsiType.DOUBLE;
|
||||
return !PsiType.FLOAT.equals(primitiveType) && !PsiType.DOUBLE.equals(primitiveType);
|
||||
} else if (JavaTokenType.EQEQ == tokenType || JavaTokenType.NE == tokenType) {
|
||||
return primitiveType == PsiType.BOOLEAN;
|
||||
return PsiType.BOOLEAN.equals(primitiveType);
|
||||
} else if (JavaTokenType.AND == tokenType || JavaTokenType.OR == tokenType || JavaTokenType.XOR == tokenType) {
|
||||
return true;
|
||||
} else if (JavaTokenType.OROR == tokenType || JavaTokenType.ANDAND == tokenType) {
|
||||
|
||||
@@ -445,7 +445,7 @@ public class StringBufferReplaceableByStringInspection extends BaseInspection {
|
||||
final PsiExpression[] arguments = argumentList.getExpressions();
|
||||
if (arguments.length == 3) {
|
||||
return arguments[0].getType() instanceof PsiArrayType &&
|
||||
arguments[1].getType() == PsiType.INT && arguments[2].getType() == PsiType.INT;
|
||||
PsiType.INT.equals(arguments[1].getType()) && PsiType.INT.equals(arguments[2].getType());
|
||||
}
|
||||
return arguments.length == 1;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public class BeforeClassOrAfterClassIsPublicStaticVoidNoArgInspection
|
||||
modifierList.setModifierProperty(PsiModifier.STATIC, true);
|
||||
}
|
||||
|
||||
if (method.getReturnType() != PsiType.VOID) {
|
||||
if (!PsiType.VOID.equals(method.getReturnType())) {
|
||||
ChangeSignatureProcessor csp =
|
||||
new ChangeSignatureProcessor(project, method, false, PsiModifier.PUBLIC, method.getName(), PsiType.VOID,
|
||||
new ParameterInfoImpl[0]);
|
||||
|
||||
@@ -60,7 +60,7 @@ public class SubstitutedExpressionEvaluationHelper {
|
||||
final PsiMethodCallExpression c = (PsiMethodCallExpression)o;
|
||||
final PsiMethod m = (PsiMethod)c.getMethodExpression().resolve();
|
||||
final PsiType returnType = m != null? m.getReturnType() : null;
|
||||
if (returnType != null && returnType != PsiType.VOID) {
|
||||
if (returnType != null && !PsiType.VOID.equals(returnType)) {
|
||||
// find substitution
|
||||
final Object substituted = calcSubstituted(m);
|
||||
if (substituted != null) return substituted;
|
||||
|
||||
@@ -158,7 +158,7 @@ public class ExtensionDomExtender extends DomExtender<Extensions> {
|
||||
Class clazz = String.class;
|
||||
if (withElement != null || isClassField(fieldName)) {
|
||||
clazz = PsiClass.class;
|
||||
} else if (field.getType() == PsiType.BOOLEAN) {
|
||||
} else if (PsiType.BOOLEAN.equals(field.getType())) {
|
||||
clazz = Boolean.class;
|
||||
}
|
||||
final DomExtension extension =
|
||||
|
||||
@@ -102,7 +102,7 @@ public class DevKitImplicitUsageProvider implements ImplicitUsageProvider {
|
||||
|
||||
private static boolean isDomElementVisitorMethod(PsiMethod method,
|
||||
PsiClass containingClass) {
|
||||
if (method.getReturnType() != PsiType.VOID ||
|
||||
if (!PsiType.VOID.equals(method.getReturnType()) ||
|
||||
!method.getName().startsWith("visit") ||
|
||||
method.getParameterList().getParametersCount() != 1 ||
|
||||
!InheritanceUtil.isInheritor(containingClass, "com.intellij.util.xml.DomElementVisitor")) {
|
||||
|
||||
@@ -1067,7 +1067,7 @@ public class GroovyAnnotator extends GroovyElementVisitor {
|
||||
PsiMethod superMethod = superMethodSignature.getMethod();
|
||||
PsiType declaredReturnType = superMethod.getReturnType();
|
||||
PsiType superReturnType = superMethodSignature.getSubstitutor().substitute(declaredReturnType);
|
||||
if (superReturnType == PsiType.VOID && method instanceof GrMethod && ((GrMethod)method).getReturnTypeElementGroovy() == null) return;
|
||||
if (PsiType.VOID.equals(superReturnType) && method instanceof GrMethod && ((GrMethod)method).getReturnTypeElementGroovy() == null) return;
|
||||
if (superMethodSignature.isRaw()) superReturnType = TypeConversionUtil.erasure(declaredReturnType);
|
||||
if (returnType == null || superReturnType == null || method == superMethod) continue;
|
||||
PsiClass superClass = superMethod.getContainingClass();
|
||||
|
||||
@@ -84,10 +84,10 @@ public class MissingReturnInspection extends GroovySuppressableInspectionTool {
|
||||
PsiClass resolved = ((PsiClassType)inferredReturnType).resolve();
|
||||
if (resolved != null && !(resolved instanceof PsiTypeParameter)) return mustReturnValue;
|
||||
}
|
||||
return inferredReturnType != null && inferredReturnType != PsiType.VOID ? shouldReturnValue : shouldNotReturnValue;
|
||||
return inferredReturnType != null && !PsiType.VOID.equals(inferredReturnType) ? shouldReturnValue : shouldNotReturnValue;
|
||||
}
|
||||
else if (subject instanceof GrMethod) {
|
||||
return ((GrMethod)subject).getReturnTypeElementGroovy() != null && ((GrMethod)subject).getReturnType() != PsiType.VOID
|
||||
return ((GrMethod)subject).getReturnTypeElementGroovy() != null && !PsiType.VOID.equals(((GrMethod)subject).getReturnType())
|
||||
? mustReturnValue
|
||||
: shouldNotReturnValue;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiSubstitutorImpl;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -696,7 +695,7 @@ public class GroovyTypeCheckVisitor extends BaseInspectionVisitor {
|
||||
@NotNull PsiElement elementToHighlight) {
|
||||
if (getTupleInitializer(expression) != null) return;
|
||||
final PsiType returnType = PsiImplUtil.inferReturnType(expression);
|
||||
if (returnType == null || returnType == PsiType.VOID) return;
|
||||
if (returnType == null || PsiType.VOID.equals(returnType)) return;
|
||||
processAssignment(returnType, expression, elementToHighlight, "cannot.return.type", context, ApplicableTo.RETURN_VALUE);
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ public class LiteralConstructorReference extends PsiReferenceBase.Poly<GrListOrM
|
||||
if (conversionType == null) return null;
|
||||
if (listOrMap.isEmpty()) {
|
||||
PsiType unboxed = TypesUtil.unboxPrimitiveTypeWrapper(conversionType);
|
||||
if (PsiType.BOOLEAN == unboxed || PsiType.CHAR == unboxed) {
|
||||
if (PsiType.BOOLEAN.equals(unboxed) || PsiType.CHAR.equals(unboxed)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -956,8 +956,8 @@ public class ControlFlowBuilder extends GroovyRecursiveElementVisitor {
|
||||
if (type == null) return false;
|
||||
|
||||
if (type instanceof PsiPrimitiveType) {
|
||||
if (type == PsiType.BOOLEAN) return sections.length == 2;
|
||||
if (type == PsiType.BYTE || type == PsiType.CHAR) return sections.length == 128;
|
||||
if (PsiType.BOOLEAN.equals(type)) return sections.length == 2;
|
||||
if (PsiType.BYTE.equals(type) || PsiType.CHAR.equals(type)) return sections.length == 128;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ public class MaybeReturnInstruction extends InstructionImpl {
|
||||
GrExpression expression = (GrExpression) getElement();
|
||||
assert expression != null;
|
||||
final PsiType type = expression.getType();
|
||||
return type != PsiType.VOID && !PsiUtil.isVoidMethodCall(expression);
|
||||
return !PsiType.VOID.equals(type) && !PsiUtil.isVoidMethodCall(expression);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class GrRangeType extends GrLiteralClassType {
|
||||
myRight = right;
|
||||
myIterationType = TypesUtil
|
||||
.boxPrimitiveType(TypesUtil.getLeastUpperBoundNullable(myLeft, myRight, getPsiManager()), getPsiManager(), scope);
|
||||
if (TypesUtil.unboxPrimitiveTypeWrapper(myIterationType) == PsiType.INT) {
|
||||
if (PsiType.INT.equals(TypesUtil.unboxPrimitiveTypeWrapper(myIterationType))) {
|
||||
myQualifiedName = GroovyCommonClassNames.GROOVY_LANG_INT_RANGE;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -119,7 +119,7 @@ public class GrReferenceResolveRunner {
|
||||
private boolean processQualifier(@NotNull GrExpression qualifier) {
|
||||
PsiType qualifierType = qualifier.getType();
|
||||
ResolveState state = ResolveState.initial().put(ClassHint.RESOLVE_CONTEXT, qualifier);
|
||||
if (qualifierType == null || qualifierType == PsiType.VOID) {
|
||||
if (qualifierType == null || PsiType.VOID.equals(qualifierType)) {
|
||||
if (qualifier instanceof GrReferenceExpression) {
|
||||
PsiElement resolved = ((GrReferenceExpression)qualifier).resolve();
|
||||
if (resolved != null && !resolved.processDeclarations(processor, state, null, place)) return false;
|
||||
|
||||
@@ -441,7 +441,7 @@ public class TypesUtil {
|
||||
@NotNull PsiManager manager,
|
||||
@NotNull GlobalSearchScope resolveScope,
|
||||
boolean boxVoid) {
|
||||
if (result instanceof PsiPrimitiveType && (boxVoid || result != PsiType.VOID)) {
|
||||
if (result instanceof PsiPrimitiveType && (boxVoid || !PsiType.VOID.equals(result))) {
|
||||
PsiPrimitiveType primitive = (PsiPrimitiveType)result;
|
||||
String boxedTypeName = primitive.getBoxedTypeName();
|
||||
if (boxedTypeName != null) {
|
||||
|
||||
@@ -38,7 +38,7 @@ public class GrBooleanTypeConverter extends GrTypeConverter {
|
||||
@NotNull PsiType actualType,
|
||||
@NotNull GroovyPsiElement context,
|
||||
@NotNull ApplicableTo currentPosition) {
|
||||
if (PsiType.BOOLEAN != TypesUtil.unboxPrimitiveTypeWrapper(targetType)) return null;
|
||||
if (!PsiType.BOOLEAN.equals(TypesUtil.unboxPrimitiveTypeWrapper(targetType))) return null;
|
||||
if (PsiType.NULL == actualType) {
|
||||
switch (currentPosition) {
|
||||
case METHOD_PARAMETER:
|
||||
|
||||
@@ -42,14 +42,14 @@ public class GrCharConverter extends GrTypeConverter {
|
||||
@NotNull PsiType rType,
|
||||
@NotNull GroovyPsiElement context,
|
||||
@NotNull ApplicableTo currentPosition) {
|
||||
if (PsiType.CHAR != TypesUtil.unboxPrimitiveTypeWrapper(lType)) return null;
|
||||
if (PsiType.CHAR == TypesUtil.unboxPrimitiveTypeWrapper(rType)) return ConversionResult.OK;
|
||||
if (!PsiType.CHAR.equals(TypesUtil.unboxPrimitiveTypeWrapper(lType))) return null;
|
||||
if (PsiType.CHAR.equals(TypesUtil.unboxPrimitiveTypeWrapper(rType))) return ConversionResult.OK;
|
||||
|
||||
// can cast and assign numeric types to char
|
||||
if (TypesUtil.isNumericType(rType)) {
|
||||
if (rType instanceof PsiPrimitiveType ||
|
||||
currentPosition != ApplicableTo.EXPLICIT_CAST && TypesUtil.unboxPrimitiveTypeWrapper(rType) instanceof PsiPrimitiveType) {
|
||||
return PsiType.CHAR == lType ? ConversionResult.OK : ConversionResult.ERROR;
|
||||
return PsiType.CHAR.equals(lType) ? ConversionResult.OK : ConversionResult.ERROR;
|
||||
}
|
||||
else {
|
||||
// BigDecimal && BigInteger
|
||||
@@ -76,7 +76,7 @@ public class GrCharConverter extends GrTypeConverter {
|
||||
}
|
||||
}
|
||||
|
||||
if (PsiType.BOOLEAN == TypesUtil.unboxPrimitiveTypeWrapper(rType)) {
|
||||
if (PsiType.BOOLEAN.equals(TypesUtil.unboxPrimitiveTypeWrapper(rType))) {
|
||||
switch (currentPosition) {
|
||||
case EXPLICIT_CAST:
|
||||
return ConversionResult.ERROR;
|
||||
|
||||
@@ -51,27 +51,27 @@ public class GrNullVoidConverter extends GrTypeConverter {
|
||||
final PsiClassType objectType = TypesUtil.getJavaLangObject(context);
|
||||
|
||||
if (currentPosition == ApplicableTo.EXPLICIT_CAST) {
|
||||
if (TypesUtil.unboxPrimitiveTypeWrapper(targetType) == PsiType.VOID) { // cast to V(v)oid
|
||||
if (PsiType.VOID.equals(TypesUtil.unboxPrimitiveTypeWrapper(targetType))) { // cast to V(v)oid
|
||||
if (actualType.equals(objectType)) return ConversionResult.WARNING; // cast Object to V(v)oid compiles but fails at runtime
|
||||
if (targetType == PsiType.VOID) { // cast to void
|
||||
if (PsiType.VOID.equals(targetType)) { // cast to void
|
||||
// can cast void to void only
|
||||
return actualType == PsiType.VOID ? ConversionResult.OK : ConversionResult.ERROR;
|
||||
return PsiType.VOID.equals(actualType) ? ConversionResult.OK : ConversionResult.ERROR;
|
||||
}
|
||||
else { // cast to Void
|
||||
// can cast Void, void and null to Void
|
||||
return actualType == PsiType.NULL || TypesUtil.unboxPrimitiveTypeWrapper(actualType) == PsiType.VOID
|
||||
return actualType == PsiType.NULL || PsiType.VOID.equals(TypesUtil.unboxPrimitiveTypeWrapper(actualType))
|
||||
? ConversionResult.OK
|
||||
: ConversionResult.ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (currentPosition == ApplicableTo.RETURN_VALUE) {
|
||||
if (targetType.equals(objectType) && actualType == PsiType.VOID) {
|
||||
if (targetType.equals(objectType) && PsiType.VOID.equals(actualType)) {
|
||||
return ConversionResult.OK; // can return void from Object
|
||||
}
|
||||
}
|
||||
|
||||
if (actualType == PsiType.VOID) {
|
||||
if (PsiType.VOID.equals(actualType)) {
|
||||
switch (currentPosition) {
|
||||
case EXPLICIT_CAST:
|
||||
return ConversionResult.ERROR;
|
||||
|
||||
@@ -217,7 +217,7 @@ public class GroovyPropertyUtils {
|
||||
if (method.getName().startsWith(IS_PREFIX) && !PsiType.BOOLEAN.equals(method.getReturnType())) {
|
||||
return false;
|
||||
}
|
||||
if (method.getReturnType() == PsiType.VOID) return false;
|
||||
if (PsiType.VOID.equals(method.getReturnType())) return false;
|
||||
if (propertyName == null) return true;
|
||||
|
||||
final String byGetter = getPropertyNameByGetter(method);
|
||||
|
||||
@@ -1182,7 +1182,7 @@ public class PsiUtil {
|
||||
if (controlFlowOwnerParent instanceof GrMethod && ((GrMethod)controlFlowOwnerParent).isConstructor()) {
|
||||
return false;
|
||||
}
|
||||
else if (controlFlowOwnerParent instanceof PsiMethod && ((PsiMethod)controlFlowOwnerParent).getReturnType() == PsiType.VOID) {
|
||||
else if (controlFlowOwnerParent instanceof PsiMethod && PsiType.VOID.equals(((PsiMethod)controlFlowOwnerParent).getReturnType())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ public class AccessorResolverProcessor extends MethodResolverProcessor {
|
||||
}
|
||||
|
||||
private static boolean isBoolean(PsiMethod method) {
|
||||
return method.getReturnType() == PsiType.BOOLEAN;
|
||||
return PsiType.BOOLEAN.equals(method.getReturnType());
|
||||
}
|
||||
|
||||
private boolean addAccessor(PsiMethod method, ResolveState state) {
|
||||
|
||||
@@ -58,7 +58,7 @@ public class GroovyStdTypeCalculators {
|
||||
@Override
|
||||
public PsiType compute() {
|
||||
PsiType returnType = finalClosure.getReturnType();
|
||||
if (returnType == PsiType.VOID) return null;
|
||||
if (PsiType.VOID.equals(returnType)) return null;
|
||||
return returnType;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -96,7 +96,7 @@ public class ConvertSimpleGetterToPropertyIntention extends Intention {
|
||||
|
||||
GrStatement statement = statements[0];
|
||||
if (!(statement instanceof GrReturnStatement && ((GrReturnStatement)statement).getReturnValue() != null ||
|
||||
statement instanceof GrExpression && ((GrExpression)statement).getType() != PsiType.VOID)) {
|
||||
statement instanceof GrExpression && !PsiType.VOID.equals(((GrExpression)statement).getType()))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -48,7 +48,7 @@ public class GrIntroduceLocalVariableIntention extends Intention {
|
||||
|
||||
private static boolean isTargetVisible(PsiElement element) {
|
||||
if (PsiUtil.isExpressionStatement(element) && element instanceof GrExpression) {
|
||||
if (((GrExpression)element).getType() != PsiType.VOID) {
|
||||
if (!PsiType.VOID.equals(((GrExpression)element).getType())) {
|
||||
if (PsiTreeUtil.getParentOfType(element, GrAssignmentExpression.class) == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -290,7 +290,7 @@ public class CompleteReferenceExpression {
|
||||
Project project = qualifier.getProject();
|
||||
final PsiType qualifierType = TypesUtil.boxPrimitiveType(qualifier.getType(), qualifier.getManager(), qualifier.getResolveScope());
|
||||
final ResolveState state = ResolveState.initial();
|
||||
if (qualifierType == null || qualifierType == PsiType.VOID) {
|
||||
if (qualifierType == null || PsiType.VOID.equals(qualifierType)) {
|
||||
if (qualifier instanceof GrReferenceExpression) {
|
||||
PsiElement resolved = ((GrReferenceExpression)qualifier).resolve();
|
||||
if (resolved instanceof PsiPackage || resolved instanceof PsiVariable) {
|
||||
|
||||
@@ -323,7 +323,7 @@ public class GroovyCompletionData {
|
||||
|
||||
PsiElement parent = flowOwner.getParent();
|
||||
if (parent instanceof GrMethod) {
|
||||
return ((GrMethod)parent).getReturnType() != PsiType.VOID;
|
||||
return !PsiType.VOID.equals(((GrMethod)parent).getReturnType());
|
||||
}
|
||||
else if (parent instanceof GrClassInitializer) {
|
||||
return false;
|
||||
|
||||
@@ -325,7 +325,7 @@ public class GroovyCompletionUtil {
|
||||
private static boolean getterMatches(PrefixMatcher matcher, PsiMethod element, String importedName) {
|
||||
return GroovyPropertyUtils.isSimplePropertyGetter(element) &&
|
||||
(matcher.prefixMatches(GroovyPropertyUtils.getGetterNameNonBoolean(importedName)) ||
|
||||
element.getReturnType() == PsiType.BOOLEAN && matcher.prefixMatches(GroovyPropertyUtils.getGetterNameBoolean(importedName)));
|
||||
PsiType.BOOLEAN.equals(element.getReturnType()) && matcher.prefixMatches(GroovyPropertyUtils.getGetterNameBoolean(importedName)));
|
||||
}
|
||||
|
||||
public static LookupElement createClassLookupItem(PsiClass psiClass) {
|
||||
|
||||
@@ -496,8 +496,7 @@ public class GroovyDocumentationProvider implements CodeDocumentationProvider, E
|
||||
JavaDocumentationProvider.generateParametersTakingDocFromSuperMethods(project, builder, commenter, method);
|
||||
|
||||
final PsiType returnType = method.getInferredReturnType();
|
||||
if ((returnType != null || method.getModifierList().hasModifierProperty(GrModifier.DEF)) &&
|
||||
returnType != PsiType.VOID) {
|
||||
if ((returnType != null || method.getModifierList().hasModifierProperty(GrModifier.DEF)) && !PsiType.VOID.equals(returnType)) {
|
||||
builder.append(CodeDocumentationUtil.createDocCommentLine(RETURN_TAG, project, commenter));
|
||||
builder.append(LINE_SEPARATOR);
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ public class GroovyOverrideImplementUtil {
|
||||
@NotNull
|
||||
private static String callSuper(PsiMethod superMethod, PsiMethod overriding) {
|
||||
@NonNls StringBuilder buffer = new StringBuilder();
|
||||
if (!superMethod.isConstructor() && superMethod.getReturnType() != PsiType.VOID) {
|
||||
if (!superMethod.isConstructor() && !PsiType.VOID.equals(superMethod.getReturnType())) {
|
||||
buffer.append("return ");
|
||||
}
|
||||
buffer.append("super");
|
||||
|
||||
@@ -190,7 +190,7 @@ public class ClassItemGeneratorImpl implements ClassItemGenerator {
|
||||
builder.append("this");
|
||||
}
|
||||
else {
|
||||
if (context.typeProvider.getReturnType(method) != PsiType.VOID) {
|
||||
if (!PsiType.VOID.equals(context.typeProvider.getReturnType(method))) {
|
||||
builder.append("return ");
|
||||
}
|
||||
builder.append(method.getName());
|
||||
|
||||
@@ -90,7 +90,7 @@ public class ClosureGenerator {
|
||||
final GrParameter[] parameters = block.getAllParameters();
|
||||
GenerationUtil.writeParameterList(builder, parameters, new GeneratorClassNameProvider(), context);
|
||||
|
||||
Collection<GrStatement> myExitPoints = returnType != PsiType.VOID ? ControlFlowUtils.collectReturns(block) : Collections.<GrStatement>emptySet();
|
||||
Collection<GrStatement> myExitPoints = !PsiType.VOID.equals(returnType) ? ControlFlowUtils.collectReturns(block) : Collections.<GrStatement>emptySet();
|
||||
boolean shouldInsertReturnNull = !(returnType instanceof PsiPrimitiveType) &&
|
||||
MissingReturnInspection.methodMissesSomeReturns(block, MissingReturnInspection.ReturnStatus.shouldNotReturnValue);
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ public class CodeBlockGenerator extends Generator {
|
||||
boolean shouldInsertReturnNull;
|
||||
myExitPoints.clear();
|
||||
PsiType returnType = context.typeProvider.getReturnType(method);
|
||||
if (!method.isConstructor() && returnType != PsiType.VOID) {
|
||||
if (!method.isConstructor() && !PsiType.VOID.equals(returnType)) {
|
||||
myExitPoints.addAll(ControlFlowUtils.collectReturns(block));
|
||||
shouldInsertReturnNull = block != null &&
|
||||
!(returnType instanceof PsiPrimitiveType) &&
|
||||
@@ -338,7 +338,7 @@ public class CodeBlockGenerator extends Generator {
|
||||
private boolean isRealExpression(GrExpression expression) {
|
||||
final PsiType type = expression.getType();
|
||||
|
||||
if (type == PsiType.VOID) return false; //statement
|
||||
if (PsiType.VOID.equals(type)) return false; //statement
|
||||
|
||||
if (type == PsiType.NULL) return !org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil.isVoidMethodCall(expression);
|
||||
|
||||
@@ -351,7 +351,8 @@ public class CodeBlockGenerator extends Generator {
|
||||
builder.append("return ");
|
||||
|
||||
final PsiType expectedReturnType = PsiImplUtil.inferReturnType(expression);
|
||||
final PsiType nnReturnType = expectedReturnType == null || expectedReturnType == PsiType.VOID ? TypesUtil.getJavaLangObject(expression) : expectedReturnType;
|
||||
final PsiType nnReturnType = expectedReturnType == null || PsiType.VOID.equals(expectedReturnType)
|
||||
? TypesUtil.getJavaLangObject(expression) : expectedReturnType;
|
||||
GenerationUtil.wrapInCastIfNeeded(builder, nnReturnType, expression.getNominalType(), expression, context, new StatementWriter() {
|
||||
@Override
|
||||
public void writeStatement(StringBuilder builder, ExpressionContext context) {
|
||||
@@ -382,7 +383,7 @@ public class CodeBlockGenerator extends Generator {
|
||||
builder.append("if (");
|
||||
if (condition != null) {
|
||||
final PsiType type = condition.getType();
|
||||
if (TypesUtil.unboxPrimitiveTypeWrapper(type) == PsiType.BOOLEAN) {
|
||||
if (PsiType.BOOLEAN.equals(TypesUtil.unboxPrimitiveTypeWrapper(type))) {
|
||||
writeExpression(condition, builder, context);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -374,7 +374,7 @@ public class ExpressionGenerator extends Generator {
|
||||
var = null;
|
||||
}
|
||||
final PsiType type = condition.getType();
|
||||
if (type == null || TypesUtil.unboxPrimitiveTypeWrapper(type) == PsiType.BOOLEAN) {
|
||||
if (type == null || PsiType.BOOLEAN.equals(TypesUtil.unboxPrimitiveTypeWrapper(type))) {
|
||||
if (elvis) {
|
||||
builder.append(var);
|
||||
}
|
||||
@@ -721,7 +721,7 @@ public class ExpressionGenerator extends Generator {
|
||||
}
|
||||
|
||||
private static boolean isBooleanType(PsiType type) {
|
||||
return type == PsiType.BOOLEAN || type != null && type.equalsToText(CommonClassNames.JAVA_LANG_BOOLEAN);
|
||||
return PsiType.BOOLEAN.equals(type) || type != null && type.equalsToText(CommonClassNames.JAVA_LANG_BOOLEAN);
|
||||
}
|
||||
|
||||
private void writeSimpleBinaryExpression(PsiElement opToken, GrExpression left, GrExpression right) {
|
||||
@@ -901,7 +901,7 @@ public class ExpressionGenerator extends Generator {
|
||||
|
||||
boolean isChar = false;
|
||||
for (TypeConstraint constraint : constraints) {
|
||||
if (constraint instanceof SubtypeConstraint && TypesUtil.unboxPrimitiveTypeWrapper(constraint.getDefaultType()) == PsiType.CHAR) {
|
||||
if (constraint instanceof SubtypeConstraint && PsiType.CHAR.equals(TypesUtil.unboxPrimitiveTypeWrapper(constraint.getDefaultType()))) {
|
||||
isChar = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,12 +46,12 @@ import org.jetbrains.plugins.groovy.lang.psi.api.util.GrStatementOwner;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.util.GrVariableDeclarationOwner;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.dataFlow.reachingDefs.VariableInfo;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.ApplicationStatementUtil;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyNamesUtil;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.util.GrStringUtil;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
|
||||
import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyNamesUtil;
|
||||
import org.jetbrains.plugins.groovy.refactoring.extract.method.ExtractMethodInfoHelper;
|
||||
import org.jetbrains.plugins.groovy.refactoring.introduce.StringPartInfo;
|
||||
|
||||
@@ -323,7 +323,7 @@ public class ExtractUtil {
|
||||
buffer.append(") { \n");
|
||||
|
||||
GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(helper.getProject());
|
||||
generateBody(helper, type == PsiType.VOID, buffer, helper.isForceReturn());
|
||||
generateBody(helper, PsiType.VOID.equals(type), buffer, helper.isForceReturn());
|
||||
|
||||
buffer.append("\n}");
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ public class GroovyExtractMethodDialog extends DialogWrapper {
|
||||
myNameLabel.setLabelFor(myNameField);
|
||||
|
||||
final PsiType type = myHelper.getOutputType();
|
||||
if (type != PsiType.VOID) {
|
||||
if (!PsiType.VOID.equals(type)) {
|
||||
myForceReturnCheckBox.setSelected(GroovyApplicationSettings.getInstance().FORCE_RETURN);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -257,7 +257,7 @@ public class GroovyMethodInliner implements InlineHandler.Inliner {
|
||||
}
|
||||
|
||||
// Process method return statements
|
||||
if (returnCount > 1 && PsiType.VOID != methodType && !isTailMethodCall) {
|
||||
if (returnCount > 1 && !PsiType.VOID.equals(methodType) && !isTailMethodCall) {
|
||||
PsiType type = methodType != null && methodType.equalsToText(CommonClassNames.JAVA_LANG_OBJECT) ? null : methodType;
|
||||
GrVariableDeclaration resultDecl = factory.createVariableDeclaration(ArrayUtil.EMPTY_STRING_ARRAY, "", type, resultName);
|
||||
GrStatement statement = ((GrStatementOwner) owner).addStatementBefore(resultDecl, anchor);
|
||||
@@ -421,7 +421,7 @@ public class GroovyMethodInliner implements InlineHandler.Inliner {
|
||||
if (statements[0] instanceof GrExpression) return (GrExpression) statements[0];
|
||||
if (statements[0] instanceof GrReturnStatement) {
|
||||
GrExpression value = ((GrReturnStatement) statements[0]).getReturnValue();
|
||||
if (value == null && PsiUtil.getSmartReturnType(method) != PsiType.VOID) {
|
||||
if (value == null && !PsiType.VOID.equals(PsiUtil.getSmartReturnType(method))) {
|
||||
return GroovyPsiElementFactory.getInstance(method.getProject()).createExpressionFromText("null");
|
||||
}
|
||||
return value;
|
||||
|
||||
@@ -237,7 +237,7 @@ public abstract class GrIntroduceHandlerBase<Settings extends GrIntroduceSetting
|
||||
}
|
||||
|
||||
if (expression instanceof GrClosableBlock && expression.getParent() instanceof GrStringInjection) return true;
|
||||
if (!acceptVoidCalls && expression instanceof GrMethodCall && PsiType.VOID == expression.getType()) return true;
|
||||
if (!acceptVoidCalls && expression instanceof GrMethodCall && PsiType.VOID.equals(expression.getType())) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ public class GrIntroduceParameterDialog extends DialogWrapper {
|
||||
}
|
||||
|
||||
final PsiType closureReturnType = inferClosureReturnType();
|
||||
if (closureReturnType == PsiType.VOID) {
|
||||
if (PsiType.VOID.equals(closureReturnType)) {
|
||||
myForceReturnCheckBox.setEnabled(false);
|
||||
myForceReturnCheckBox.setSelected(false);
|
||||
}
|
||||
|
||||
@@ -22,10 +22,10 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.impl.ExpressionConverter;
|
||||
import com.intellij.psi.javadoc.PsiDocTag;
|
||||
import com.intellij.psi.util.InheritanceUtil;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.impl.ExpressionConverter;
|
||||
import com.intellij.refactoring.introduceParameter.IntroduceParameterData;
|
||||
import com.intellij.refactoring.introduceParameter.IntroduceParameterMethodUsagesProcessor;
|
||||
import com.intellij.refactoring.introduceParameter.IntroduceParameterUtil;
|
||||
@@ -278,7 +278,7 @@ public class GroovyIntroduceParameterMethodUsagesProcessor implements IntroduceP
|
||||
GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(project);
|
||||
|
||||
final String typeText =
|
||||
forcedType.equalsToText(CommonClassNames.JAVA_LANG_OBJECT) || forcedType == PsiType.NULL || forcedType == PsiType.VOID
|
||||
forcedType.equalsToText(CommonClassNames.JAVA_LANG_OBJECT) || forcedType == PsiType.NULL || PsiType.VOID.equals(forcedType)
|
||||
? null
|
||||
: forcedType.getCanonicalText();
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ import com.intellij.openapi.module.ModuleUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
@@ -587,7 +586,7 @@ public final class Generator {
|
||||
outer: for (int i = 0; i < allGetDataMethods.length; i++) {
|
||||
final PsiMethod _getMethod = allGetDataMethods[i];
|
||||
|
||||
if (_getMethod.getReturnType() != PsiType.VOID) {
|
||||
if (!PsiType.VOID.equals(_getMethod.getReturnType())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -602,7 +601,7 @@ public final class Generator {
|
||||
}
|
||||
|
||||
for (final PsiMethod _setMethod : allSetDataMethods) {
|
||||
if (_setMethod.getReturnType() != PsiType.VOID) {
|
||||
if (!PsiType.VOID.equals(_setMethod.getReturnType())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user