Warnings fixed

GitOrigin-RevId: 43e324ef2f032fa735b53809409f975d6590918e
This commit is contained in:
Tagir Valeev
2020-05-05 15:01:28 +07:00
committed by intellij-monorepo-bot
parent f050885adb
commit e1b282d364
10 changed files with 46 additions and 45 deletions

View File

@@ -42,7 +42,7 @@ public class ColorUtil {
final Object o = helper.computeConstantExpression(each);
if (o instanceof Integer) {
values[i] = ((Integer) o).intValue();
values[i] = values[i] > 255 && expressions.length > 1 ? 255 : values[i] < 0 ? 0 : values[i];
values[i] = values[i] > 255 && expressions.length > 1 ? 255 : Math.max(values[i], 0);
i++;
} else if (o instanceof Float) {
values2[j] = ((Float) o).floatValue();

View File

@@ -90,7 +90,7 @@ public class JavaPreviewHintProvider implements PreviewHintProvider {
if (o instanceof Integer) {
values[i] = ((Integer)o).intValue();
if (expressions.length != 1) {
values[i] = values[i] > 255 ? 255 : values[i] < 0 ? 0 : values[i];
values[i] = values[i] > 255 ? 255 : Math.max(values[i], 0);
}
i++;

View File

@@ -165,15 +165,15 @@ public class TypeMigrationProcessor extends BaseRefactoringProcessor {
String toType = myRootTypes.fun(myRoots[0]).getPresentableText();
String text;
text = getPresentation(myRoots[0]);
name = "Migrate Type of " + text + " from \'" + fromType + "\' to \'" + toType + "\'";
name = "Migrate Type of " + text + " from '" + fromType + "' to '" + toType + "'";
} else {
final int rootsInPresentationCount = myRoots.length > MAX_ROOT_IN_PREVIEW_PRESENTATION ? MAX_ROOT_IN_PREVIEW_PRESENTATION : myRoots.length;
final int rootsInPresentationCount = Math.min(myRoots.length, MAX_ROOT_IN_PREVIEW_PRESENTATION);
String[] rootsPresentation = new String[rootsInPresentationCount];
for (int i = 0; i < rootsInPresentationCount; i++) {
final PsiElement root = myRoots[i];
rootsPresentation[i] = root instanceof PsiNamedElement ? ((PsiNamedElement)root).getName() : root.getText();
}
rootsPresentation = StringUtil.surround(rootsPresentation, "\'", "\'");
rootsPresentation = StringUtil.surround(rootsPresentation, "'", "'");
name = "Migrate Type of " + StringUtil.join(rootsPresentation, ", ");
if (myRoots.length > MAX_ROOT_IN_PREVIEW_PRESENTATION) {
name += "...";
@@ -187,16 +187,16 @@ public class TypeMigrationProcessor extends BaseRefactoringProcessor {
public static String getPresentation(PsiElement element) {
String text;
if (element instanceof PsiField) {
text = "field \'" + ((PsiField)element).getName() + "\'";
text = "field '" + ((PsiField)element).getName() + "'";
}
else if (element instanceof PsiParameter) {
text = "parameter \'" + ((PsiParameter)element).getName() + "\'";
text = "parameter '" + ((PsiParameter)element).getName() + "'";
}
else if (element instanceof PsiLocalVariable) {
text = "variable \'" + ((PsiLocalVariable)element).getName() + "\'";
text = "variable '" + ((PsiLocalVariable)element).getName() + "'";
}
else if (element instanceof PsiMethod) {
text = "method \'" + ((PsiMethod)element).getName() + "\' return";
text = "method '" + ((PsiMethod)element).getName() + "' return";
}
else {
text = element.getText();

View File

@@ -42,7 +42,7 @@ public class StringLiteralEscaper<T extends PsiLanguageInjectionHost> extends Li
public int getOffsetInHost(int offsetInDecoded, @NotNull final TextRange rangeInsideHost) {
int result = offsetInDecoded < outSourceOffsets.length ? outSourceOffsets[offsetInDecoded] : -1;
if (result == -1) return -1;
return (result <= rangeInsideHost.getLength() ? result : rangeInsideHost.getLength()) + rangeInsideHost.getStartOffset();
return Math.min(result, rangeInsideHost.getLength()) + rangeInsideHost.getStartOffset();
}
@Override

View File

@@ -30,7 +30,7 @@ public abstract class JSStringLiteralEscaper<T extends PsiLanguageInjectionHost>
public int getOffsetInHost(int offsetInDecoded, @NotNull final TextRange rangeInsideHost) {
int result = offsetInDecoded < outSourceOffsets.length ? outSourceOffsets[offsetInDecoded] : -1;
if (result == -1) return -1;
return (result <= rangeInsideHost.getLength() ? result : rangeInsideHost.getLength()) + rangeInsideHost.getStartOffset();
return Math.min(result, rangeInsideHost.getLength()) + rangeInsideHost.getStartOffset();
}
@Override

View File

@@ -60,7 +60,7 @@ public class ActionCallback implements Disposable {
myName = name;
assert countToDone >= 0 : "count=" + countToDone;
myDone = new ExecutionCallback(countToDone >= 1 ? countToDone : 1);
myDone = new ExecutionCallback(Math.max(countToDone, 1));
myRejected = new ExecutionCallback();
if (countToDone < 1) {

View File

@@ -11,6 +11,6 @@ class ColorConverter {
}
private static int fix(int value) {
return value < 0 ? 0 : value > 255 ? 255 : value;
return Math.max(0, Math.min(value, 255));
}
}

View File

@@ -35,11 +35,11 @@ public class EditorFontsConstants {
}
private static int round(int min, int max, int val) {
return val < min ? min : val > max ? max : val;
return Math.max(min, Math.min(max, val));
}
private static float round(float min, float max, float val) {
return val < min ? min : val > max ? max : val;
return Math.max(min, Math.min(max, val));
}
private EditorFontsConstants() {

View File

@@ -16,7 +16,6 @@
package com.intellij.junit5;
import com.intellij.junit4.ExpectedPatterns;
import com.intellij.junit4.JUnit4TestListener;
import com.intellij.rt.execution.junit.ComparisonFailureData;
import com.intellij.rt.execution.junit.MapSerializerUtil;
import org.junit.platform.engine.TestExecutionResult;
@@ -118,10 +117,10 @@ public class JUnit5TestExecutionListener implements TestExecutionListener {
comment = myRootName.substring(0, lastPointIdx);
}
myPrintStream.println("##teamcity[rootName name = \'" + escapeName(name) +
(comment != null ? ("\' comment = \'" + escapeName(comment)) : "") + "\'" +
" location = \'java:suite://" + escapeName(myRootName) +
"\']");
myPrintStream.println("##teamcity[rootName name = '" + escapeName(name) +
(comment != null ? ("' comment = '" + escapeName(comment)) : "") + "'" +
" location = 'java:suite://" + escapeName(myRootName) +
"']");
}
}
@@ -135,7 +134,7 @@ public class JUnit5TestExecutionListener implements TestExecutionListener {
sendTreeUnderRoot(childIdentifier, visited);
}
else {
System.err.println("Identifier \'" + getId(childIdentifier) + "\' is reused");
System.err.println("Identifier '" + getId(childIdentifier) + "' is reused");
}
}
myPrintStream.println("##teamcity[suiteTreeEnded" + idAndName + "]");
@@ -202,9 +201,9 @@ public class JUnit5TestExecutionListener implements TestExecutionListener {
if (messageName != null) {
if (status == TestExecutionResult.Status.FAILED) {
String parentId = getParentId(testIdentifier);
String nameAndId = " name=\'" + CLASS_CONFIGURATION +
"\' nodeId=\'" + escapeName(getId(testIdentifier)) +
"\' parentNodeId=\'" + escapeName(parentId) + "\' ";
String nameAndId = " name='" + CLASS_CONFIGURATION +
"' nodeId='" + escapeName(getId(testIdentifier)) +
"' parentNodeId='" + escapeName(parentId) + "' ";
testFailure(CLASS_CONFIGURATION, getId(testIdentifier), parentId, messageName, throwableOptional, 0, reason, true);
myPrintStream.println("\n##teamcity[testFinished" + nameAndId + "]");
}
@@ -236,7 +235,7 @@ public class JUnit5TestExecutionListener implements TestExecutionListener {
}
private void testFinished(TestIdentifier testIdentifier, long duration) {
myPrintStream.println("\n##teamcity[testFinished" + idAndName(testIdentifier) + (duration > 0 ? " duration=\'" + duration + "\'" : "") + "]");
myPrintStream.println("\n##teamcity[testFinished" + idAndName(testIdentifier) + (duration > 0 ? " duration='" + duration + "'" : "") + "]");
}
private void testFailure(TestIdentifier testIdentifier,
@@ -325,10 +324,10 @@ public class JUnit5TestExecutionListener implements TestExecutionListener {
}
private String idAndName(TestIdentifier testIdentifier, String displayName) {
return " id=\'" + escapeName(getId(testIdentifier)) +
"\' name=\'" + escapeName(displayName) +
"\' nodeId=\'" + escapeName(getId(testIdentifier)) +
"\' parentNodeId=\'" + escapeName(getParentId(testIdentifier)) + "\'";
return " id='" + escapeName(getId(testIdentifier)) +
"' name='" + escapeName(displayName) +
"' nodeId='" + escapeName(getId(testIdentifier)) +
"' parentNodeId='" + escapeName(getParentId(testIdentifier)) + "'";
}
private String getParentId(TestIdentifier testIdentifier) {
@@ -351,14 +350,14 @@ public class JUnit5TestExecutionListener implements TestExecutionListener {
return root.getSource()
.map(testSource -> getLocationHintValue(testSource, rootParent != null ? rootParent.getSource().orElse(null) : null))
.filter(maybeLocationHintValue -> !NO_LOCATION_HINT_VALUE.equals(maybeLocationHintValue))
.map(locationHintValue -> "locationHint=\'" + locationHintValue + "\'" + getMetainfo(root))
.map(locationHintValue -> "locationHint='" + locationHintValue + "'" + getMetainfo(root))
.orElse(NO_LOCATION_HINT);
}
private static String getMetainfo(TestIdentifier root) {
return root.getSource()
.filter(testSource -> testSource instanceof MethodSource)
.map(testSource -> " metainfo=\'" + ((MethodSource)testSource).getMethodParameterTypes() + "\'")
.map(testSource -> " metainfo='" + ((MethodSource)testSource).getMethodParameterTypes() + "'")
.orElse(NO_LOCATION_HINT);
}

View File

@@ -44,7 +44,7 @@ public class IDEATestNGRemoteListener {
for (ITestNGMethod method : allMethods) {
if (method.isTest()) count += method.getInvocationCount();
}
myPrintStream.println("##teamcity[testCount count = \'" + count + "\']");
myPrintStream.println("##teamcity[testCount count = '" + count + "']");
}
}
catch (NoSuchMethodError ignore) {}
@@ -66,9 +66,9 @@ public class IDEATestNGRemoteListener {
}
if (!found) {
final String fullEscapedMethodName = escapeName(getShortName(method.getTestClass().getName()) + "/" + method.getMethodName());
myPrintStream.println("##teamcity[testStarted name=\'" + fullEscapedMethodName + "\']");
myPrintStream.println("##teamcity[testIgnored name=\'" + fullEscapedMethodName + "\']");
myPrintStream.println("##teamcity[testFinished name=\'" + fullEscapedMethodName + "\']");
myPrintStream.println("##teamcity[testStarted name='" + fullEscapedMethodName + "']");
myPrintStream.println("##teamcity[testIgnored name='" + fullEscapedMethodName + "']");
myPrintStream.println("##teamcity[testFinished name='" + fullEscapedMethodName + "']");
break;
}
}
@@ -182,7 +182,7 @@ public class IDEATestNGRemoteListener {
for (int i = myCurrentSuites.size() - 1; i >= idx; i--) {
currentClass = myCurrentSuites.remove(i);
myPrintStream.println("##teamcity[testSuiteFinished name=\'" + escapeName(currentClass) + "\']");
myPrintStream.println("##teamcity[testSuiteFinished name='" + escapeName(currentClass) + "']");
}
for (int i = idx; i < parentsHierarchy.size(); i++) {
@@ -198,15 +198,15 @@ public class IDEATestNGRemoteListener {
}
}
}
myPrintStream.println("\n##teamcity[testSuiteStarted name =\'" + escapeName(currentClassName) +
(provideLocation ? "\' locationHint = \'" + location : "") + "\']");
myPrintStream.println("\n##teamcity[testSuiteStarted name ='" + escapeName(currentClassName) +
(provideLocation ? "' locationHint = '" + location : "") + "']");
myCurrentSuites.add(currentClassName);
}
return false;
}
public void onSuiteFinish(String suiteName) {
myPrintStream.println("##teamcity[testSuiteFinished name=\'" + escapeName(suiteName) + "\']");
myPrintStream.println("##teamcity[testSuiteFinished name='" + escapeName(suiteName) + "']");
}
private void onTestStart(ExposedTestResult result, String paramString, Integer invocationCount, boolean config) {
@@ -215,8 +215,10 @@ public class IDEATestNGRemoteListener {
final String className = result.getClassName();
final String methodName = result.getDisplayMethodName();
final String location = className + "/" + result.getMethodName() + (invocationCount >= 0 ? "[" + invocationCount + "]" : "");
myPrintStream.println("\n##teamcity[testStarted name=\'" + escapeName(getShortName(className) + "." + methodName + (paramString != null ? paramString : "")) +
"\' locationHint=\'java:test://" + escapeName(location) + (config ? "\' config=\'true" : "") + "\']");
myPrintStream.println(
"\n##teamcity[testStarted name='" + escapeName(getShortName(className) + "." + methodName + (paramString != null ? paramString : "")) +
"' locationHint='java:test://" + escapeName(location) + (config ? "' config='true" : "") +
"']");
}
public void onTestFailure(ExposedTestResult result) {
@@ -260,16 +262,16 @@ public class IDEATestNGRemoteListener {
onTestStart(result);
mySkipped++;
}
myPrintStream.println("\n##teamcity[testIgnored name=\'" + escapeName(getTestMethodNameWithParams(result)) + "\']");
myPrintStream.println("\n##teamcity[testIgnored name='" + escapeName(getTestMethodNameWithParams(result)) + "']");
onTestFinished(result);
}
public void onTestFinished(ExposedTestResult result) {
final long duration = result.getDuration();
myPrintStream.println("\n##teamcity[testFinished name=\'" +
myPrintStream.println("\n##teamcity[testFinished name='" +
escapeName(getTestMethodNameWithParams(result)) +
(duration > 0 ? "\' duration=\'" + duration : "") +
"\']");
(duration > 0 ? "' duration='" + duration : "") +
"']");
}
private synchronized String getTestMethodNameWithParams(ExposedTestResult result) {