From f641cf22962127ab061d21f1815bf411d7501dc0 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Mon, 23 Nov 2015 16:39:00 +0100 Subject: [PATCH] convert CallFrameBase, CallFrame to kotlin --- .../src/org/jetbrains/debugger/CallFrame.java | 37 ++++----- .../org/jetbrains/debugger/CallFrameBase.java | 77 +++++-------------- 2 files changed, 32 insertions(+), 82 deletions(-) diff --git a/platform/script-debugger/backend/src/org/jetbrains/debugger/CallFrame.java b/platform/script-debugger/backend/src/org/jetbrains/debugger/CallFrame.java index 6dcf9fd8d86d..19011ba014f0 100755 --- a/platform/script-debugger/backend/src/org/jetbrains/debugger/CallFrame.java +++ b/platform/script-debugger/backend/src/org/jetbrains/debugger/CallFrame.java @@ -1,46 +1,37 @@ -package org.jetbrains.debugger; +package org.jetbrains.debugger -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.concurrency.Promise; +import org.jetbrains.concurrency.Promise -import java.util.List; - -public interface CallFrame { +interface CallFrame { /** * @return the scopes known in this frame */ - @NotNull - List getVariableScopes(); + val variableScopes: List - boolean hasOnlyGlobalScope(); + val hasOnlyGlobalScope: Boolean /** - * @return the receiver variable known in this frame ("this" variable) - * - * Computed variable must be null if no receiver variable, call {@link com.intellij.openapi.util.AsyncResult#setDone(Object null)} + * receiver variable known in this frame ("this" variable) + * Computed variable must be null if no receiver variable */ - @NotNull - Promise getReceiverVariable(); + val receiverVariable: Promise - int getLine(); + val line: Int - int getColumn(); + val column: Int /** * @return the name of the current function of this frame */ - @Nullable - String getFunctionName(); + val functionName: String? /** * @return context for evaluating expressions in scope of this frame */ - @NotNull - EvaluateContext getEvaluateContext(); + val evaluateContext: EvaluateContext /** - @see com.intellij.xdebugger.frame.XStackFrame#getEqualityObject() + * @see com.intellij.xdebugger.frame.XStackFrame.getEqualityObject */ - Object getEqualityObject(); + val equalityObject: Any } \ No newline at end of file diff --git a/platform/script-debugger/backend/src/org/jetbrains/debugger/CallFrameBase.java b/platform/script-debugger/backend/src/org/jetbrains/debugger/CallFrameBase.java index 7417b83ae5b1..85851c6d5219 100644 --- a/platform/script-debugger/backend/src/org/jetbrains/debugger/CallFrameBase.java +++ b/platform/script-debugger/backend/src/org/jetbrains/debugger/CallFrameBase.java @@ -1,65 +1,24 @@ -package org.jetbrains.debugger; +package org.jetbrains.debugger -import com.intellij.openapi.util.NotNullLazyValue; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import com.intellij.openapi.util.NotNullLazyValue -import java.util.List; +const val RECEIVER_NAME = "this" -public abstract class CallFrameBase implements CallFrame { - public static final String RECEIVER_NAME = "this"; +@Deprecated("") +/** + * Use kotlin - base class is not required in this case (no boilerplate code) + */ +/** + * You must initialize [.scopes] or override [.getVariableScopes] + */ +abstract class CallFrameBase(override val functionName: String?, override val line: Int, override val column: Int, override val evaluateContext: EvaluateContext) : CallFrame { + protected var scopes: NotNullLazyValue>? = null - private final String functionName; - private final int line; - private final int column; + override var hasOnlyGlobalScope: Boolean = false + protected set(value: Boolean) { + field = value + } - protected NotNullLazyValue> scopes; - - protected EvaluateContext evaluateContext; - - protected boolean hasOnlyGlobalScope; - - /** - * You must initialize {@link #scopes} or override {@link #getVariableScopes()} - */ - protected CallFrameBase(@Nullable String functionName, int line, int column, @Nullable("init in your constructor") EvaluateContext evaluateContext) { - this.functionName = functionName; - this.line = line; - this.column = column; - - this.evaluateContext = evaluateContext; - } - - @Override - public final boolean hasOnlyGlobalScope() { - return hasOnlyGlobalScope; - } - - @NotNull - @Override - public List getVariableScopes() { - return scopes.getValue(); - } - - @Nullable - @Override - public String getFunctionName() { - return functionName; - } - - @Override - public int getLine() { - return line; - } - - @Override - public int getColumn() { - return column; - } - - @NotNull - @Override - public final EvaluateContext getEvaluateContext() { - return evaluateContext; - } + override val variableScopes: List + get() = scopes!!.value } \ No newline at end of file