Rename
This commit is contained in:
+4
-4
@@ -75,10 +75,10 @@ public class ConstantExpressionEvaluator private (val trace: BindingTrace) : Jet
|
|||||||
val text = expression.getText()
|
val text = expression.getText()
|
||||||
if (text == null) return null
|
if (text == null) return null
|
||||||
val result: Any? = when (expression.getNode().getElementType()) {
|
val result: Any? = when (expression.getNode().getElementType()) {
|
||||||
JetNodeTypes.INTEGER_CONSTANT -> CompileTimeConstantResolver.parseLongValue(text)
|
JetNodeTypes.INTEGER_CONSTANT -> CompileTimeConstantResolver.parseLong(text)
|
||||||
JetNodeTypes.FLOAT_CONSTANT -> CompileTimeConstantResolver.parseDoubleValue(text)
|
JetNodeTypes.FLOAT_CONSTANT -> CompileTimeConstantResolver.parseDouble(text)
|
||||||
JetNodeTypes.BOOLEAN_CONSTANT -> CompileTimeConstantResolver.parseBooleanValue(text)
|
JetNodeTypes.BOOLEAN_CONSTANT -> CompileTimeConstantResolver.parseBoolean(text)
|
||||||
JetNodeTypes.CHARACTER_CONSTANT -> CompileTimeConstantResolver.parseCharValue(text)
|
JetNodeTypes.CHARACTER_CONSTANT -> CompileTimeConstantResolver.parseChar(text)
|
||||||
JetNodeTypes.NULL -> null
|
JetNodeTypes.NULL -> null
|
||||||
else -> throw IllegalArgumentException("Unsupported constant: " + expression)
|
else -> throw IllegalArgumentException("Unsupported constant: " + expression)
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-6
@@ -157,7 +157,7 @@ public class CompileTimeConstantResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static Long parseLongValue(String text) {
|
public static Long parseLong(String text) {
|
||||||
try {
|
try {
|
||||||
long value;
|
long value;
|
||||||
if (text.startsWith("0x") || text.startsWith("0X")) {
|
if (text.startsWith("0x") || text.startsWith("0X")) {
|
||||||
@@ -179,7 +179,7 @@ public class CompileTimeConstantResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static Double parseDoubleValue(String text) {
|
public static Double parseDouble(String text) {
|
||||||
try {
|
try {
|
||||||
return Double.parseDouble(text);
|
return Double.parseDouble(text);
|
||||||
}
|
}
|
||||||
@@ -189,7 +189,7 @@ public class CompileTimeConstantResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static Object parseBooleanValue(@NotNull String text) {
|
public static Object parseBoolean(@NotNull String text) {
|
||||||
if ("true".equals(text)) {
|
if ("true".equals(text)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -200,7 +200,7 @@ public class CompileTimeConstantResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static Character parseCharValue(@NotNull String text) {
|
public static Character parseChar(@NotNull String text) {
|
||||||
// Strip the quotes
|
// Strip the quotes
|
||||||
if (text.length() < 2 || text.charAt(0) != '\'' || text.charAt(text.length() - 1) != '\'') {
|
if (text.length() < 2 || text.charAt(0) != '\'' || text.charAt(text.length() - 1) != '\'') {
|
||||||
return null;
|
return null;
|
||||||
@@ -217,11 +217,11 @@ public class CompileTimeConstantResolver {
|
|||||||
return text.charAt(0);
|
return text.charAt(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return escapedStringToCharValue(text);
|
return escapedStringToChar(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static Character escapedStringToCharValue(@NotNull String text) {
|
public static Character escapedStringToChar(@NotNull String text) {
|
||||||
if (!(text.length() > 0 && text.charAt(0) == '\\')) return null;
|
if (!(text.length() > 0 && text.charAt(0) == '\\')) return null;
|
||||||
|
|
||||||
// Escape
|
// Escape
|
||||||
|
|||||||
+2
-3
@@ -48,7 +48,6 @@ import org.jetbrains.jet.lang.resolve.calls.tasks.ResolutionCandidate;
|
|||||||
import org.jetbrains.jet.lang.resolve.calls.tasks.TracingStrategy;
|
import org.jetbrains.jet.lang.resolve.calls.tasks.TracingStrategy;
|
||||||
import org.jetbrains.jet.lang.resolve.calls.util.CallMaker;
|
import org.jetbrains.jet.lang.resolve.calls.util.CallMaker;
|
||||||
import org.jetbrains.jet.lang.resolve.constants.*;
|
import org.jetbrains.jet.lang.resolve.constants.*;
|
||||||
import org.jetbrains.jet.lang.resolve.constants.StringValue;
|
|
||||||
import org.jetbrains.jet.lang.resolve.name.LabelName;
|
import org.jetbrains.jet.lang.resolve.name.LabelName;
|
||||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||||
@@ -137,7 +136,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
|
|
||||||
if (noExpectedType(context.expectedType) && context.contextDependency == DEPENDENT) {
|
if (noExpectedType(context.expectedType) && context.contextDependency == DEPENDENT) {
|
||||||
if (elementType == JetNodeTypes.INTEGER_CONSTANT) {
|
if (elementType == JetNodeTypes.INTEGER_CONSTANT) {
|
||||||
Long longValue = CompileTimeConstantResolver.parseLongValue(text);
|
Long longValue = CompileTimeConstantResolver.parseLong(text);
|
||||||
if (longValue != null) {
|
if (longValue != null) {
|
||||||
return createNumberValueTypeInfo(new IntegerValueTypeConstructor((long) longValue), longValue, context.dataFlowInfo);
|
return createNumberValueTypeInfo(new IntegerValueTypeConstructor((long) longValue), longValue, context.dataFlowInfo);
|
||||||
}
|
}
|
||||||
@@ -1179,7 +1178,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitEscapeStringTemplateEntry(@NotNull JetEscapeStringTemplateEntry entry) {
|
public void visitEscapeStringTemplateEntry(@NotNull JetEscapeStringTemplateEntry entry) {
|
||||||
Character character = CompileTimeConstantResolver.escapedStringToCharValue(entry.getText());
|
Character character = CompileTimeConstantResolver.escapedStringToChar(entry.getText());
|
||||||
if (character == null) {
|
if (character == null) {
|
||||||
context.trace.report(Errors.ILLEGAL_ESCAPE.on(entry, entry));
|
context.trace.report(Errors.ILLEGAL_ESCAPE.on(entry, entry));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user