convert IndexedVariablesConsumer, FunctionValue, ValueType, PrimitiveValue to kotlin

This commit is contained in:
Vladimir Krivosheev
2016-11-09 14:56:57 +01:00
parent fb337eaa6a
commit 240c0b2d33
4 changed files with 53 additions and 81 deletions
@@ -1,35 +1,30 @@
package org.jetbrains.debugger.values;
package org.jetbrains.debugger.values
import com.intellij.util.ThreeState;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.concurrency.Promise;
import org.jetbrains.debugger.Scope;
import com.intellij.util.ThreeState
import org.jetbrains.concurrency.Promise
import org.jetbrains.debugger.Scope
public interface FunctionValue extends ObjectValue {
interface FunctionValue : ObjectValue {
/**
* You must invoke {@link #resolve} to use any function value methods
* You must invoke [.resolve] to use any function value methods
*/
@NotNull
Promise<FunctionValue> resolve();
fun resolve(): Promise<FunctionValue>
/**
* Returns position of opening parenthesis of function arguments. Position is absolute
* within resource (not relative to script start position).
*
* @return position or null if position is not available
*/
int getOpenParenLine();
val openParenLine: Int
int getOpenParenColumn();
val openParenColumn: Int
@Nullable
Scope[] getScopes();
val scopes: Array<Scope>?
/**
* Method could be called (it is normal and expected) for unresolved function.
* It must return quickly. Return {@link com.intellij.util.ThreeState#UNSURE} otherwise.
* It must return quickly. Return [com.intellij.util.ThreeState.UNSURE] otherwise.
*/
@NotNull
ThreeState hasScopes();
fun hasScopes() = ThreeState.UNSURE
}
@@ -1,18 +1,13 @@
package org.jetbrains.debugger.values;
package org.jetbrains.debugger.values
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.debugger.Variable;
import org.jetbrains.debugger.Variable
import java.util.List;
public abstract class IndexedVariablesConsumer {
abstract class IndexedVariablesConsumer {
// null if array is not sparse
public abstract void consumeRanges(@Nullable int[] ranges);
abstract fun consumeRanges(ranges: IntArray?)
public abstract void consumeVariables(@NotNull List<Variable> variables);
abstract fun consumeVariables(variables: List<Variable>)
public boolean isObsolete() {
return false;
}
open val isObsolete: Boolean
get() = false
}
@@ -1,45 +1,30 @@
package org.jetbrains.debugger.values;
package org.jetbrains.debugger.values
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
open class PrimitiveValue(type: ValueType, override val valueString: String) : ValueBase(type) {
public class PrimitiveValue extends ValueBase {
public static final String NA_N_VALUE = "NaN";
public static final String INFINITY_VALUE = "Infinity";
public static final PrimitiveValue NULL = new PrimitiveValue(ValueType.NULL, "null");
public static final PrimitiveValue UNDEFINED = new PrimitiveValue(ValueType.UNDEFINED, "undefined");
public static final PrimitiveValue NAN = new PrimitiveValue(ValueType.NUMBER, NA_N_VALUE);
public static final PrimitiveValue INFINITY = new PrimitiveValue(ValueType.NUMBER, INFINITY_VALUE);
private static final PrimitiveValue TRUE = new PrimitiveValue(ValueType.BOOLEAN, "true");
private static final PrimitiveValue FALSE = new PrimitiveValue(ValueType.BOOLEAN, "false");
private final String valueString;
public PrimitiveValue(@NotNull ValueType type, @NotNull String valueString) {
super(type);
this.valueString = valueString;
constructor(type: ValueType, value: Int) : this(type, Integer.toString(value)) {
}
@NotNull
public static PrimitiveValue bool(@NotNull String value) {
return value.equals("true") ? TRUE : FALSE;
constructor(type: ValueType, value: Long) : this(type, java.lang.Long.toString(value)) {
}
public PrimitiveValue(ValueType type, int value) {
this(type, Integer.toString(value));
}
companion object {
val NA_N_VALUE = "NaN"
val INFINITY_VALUE = "Infinity"
public PrimitiveValue(ValueType type, long value) {
this(type, Long.toString(value));
}
@JvmField
val NULL = PrimitiveValue(ValueType.NULL, "null")
@JvmField
val UNDEFINED = PrimitiveValue(ValueType.UNDEFINED, "undefined")
@Nullable
@Override
public final String getValueString() {
return valueString;
val NAN = PrimitiveValue(ValueType.NUMBER, NA_N_VALUE)
val INFINITY = PrimitiveValue(ValueType.NUMBER, INFINITY_VALUE)
private val TRUE = PrimitiveValue(ValueType.BOOLEAN, "true")
private val FALSE = PrimitiveValue(ValueType.BOOLEAN, "false")
fun bool(value: String): PrimitiveValue {
return if (value == "true") TRUE else FALSE
}
}
}
@@ -1,11 +1,11 @@
package org.jetbrains.debugger.values;
package org.jetbrains.debugger.values
import org.jetbrains.annotations.NotNull;
private val VALUE_TYPES = ValueType.values()
/**
* Don't forget to update NashornDebuggerSupport.ValueType and DebuggerSupport.ts respectively also
*/
public enum ValueType {
enum class ValueType {
OBJECT,
NUMBER,
STRING,
@@ -16,21 +16,18 @@ public enum ValueType {
NODE,
UNDEFINED,
NULL;
private static final ValueType[] VALUE_TYPES = ValueType.values();
@NotNull
public static ValueType fromIndex(int index) {
return VALUE_TYPES[index];
}
NULL,
SYMBOL;
/**
* Returns whether {@code type} corresponds to a JsObject. Note that while 'null' is an object
* in JavaScript world, here for API consistency it has bogus type {@link #NULL} and is
* not a {@link ObjectValue}
* Returns whether `type` corresponds to a JsObject. Note that while 'null' is an object
* in JavaScript world, here for API consistency it has bogus type [.NULL] and is
* not a [ObjectValue]
*/
public boolean isObjectType() {
return this == OBJECT || this == ARRAY || this == FUNCTION || this == NODE;
val isObjectType: Boolean
get() = this == OBJECT || this == ARRAY || this == FUNCTION || this == NODE
companion object {
fun fromIndex(index: Int) = VALUE_TYPES.get(index)
}
}