inline same param value: ensure literals are escaped

This commit is contained in:
Anna.Kozlova
2018-03-19 17:48:41 +01:00
parent 3cbdf3636b
commit b91bb73dd2
2 changed files with 2 additions and 3 deletions
@@ -143,7 +143,7 @@ public class RefParameterImpl extends RefJavaElementImpl implements RefParameter
return null;
}
Object constValue = JavaConstantExpressionEvaluator.computeConstantExpression(expression, false);
return constValue == null ? VALUE_IS_NOT_CONST : constValue;
return constValue == null ? VALUE_IS_NOT_CONST : constValue instanceof String ? "\"" + constValue + "\"" : constValue;
}
@Nullable
@@ -247,8 +247,7 @@ public class SameParameterValueInspectionBase extends GlobalJavaBatchInspectionT
boolean usedForWriting) {
final String name = parameter.getName();
String stringPresentation = value instanceof PsiType ? ((PsiType)value).getPresentableText() + ".class"
: value instanceof String ? "\"" + value + "\""
: String.valueOf(value);
: String.valueOf(value);
return manager.createProblemDescriptor(ObjectUtils.notNull(parameter.getNameIdentifier(), parameter),
InspectionsBundle.message("inspection.same.parameter.problem.descriptor",
name,