From 841d1d00a2644f960a06a0710c4f6fbef40b3494 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Thu, 15 Oct 2015 15:11:41 +0200 Subject: [PATCH] [js-debugger] cleanup after convert to kotlin --- .../jetbrains/io/fastCgi/FastCgiService.kt | 7 +- .../org/jetbrains/concurrency/Promise.java | 2 +- .../src/org/jetbrains/concurrency/promise.kt | 35 ++++++ .../org/jetbrains/util/concurrency/Promise.kt | 8 +- .../util/concurrency/RejectedPromise.kt | 2 +- .../jetbrains/debugger/StandaloneVmHelper.kt | 13 +-- .../src/org/jetbrains/rpc/CommandSender.java | 10 -- .../src/org/jetbrains/rpc/ErrorConsumer.java | 8 -- .../javascript/debugger/NameMapper.kt | 2 +- .../jetbrains/debugger/DebugProcessImpl.kt | 8 +- .../jetbrains/debugger/DebuggerViewSupport.kt | 2 +- .../debugger/FunctionScopesValueGroup.kt | 13 +-- .../debugger/ProcessHandlerWrapper.kt | 4 +- .../debugger/RejectErrorReporter.java | 4 +- .../jetbrains/debugger/ScopeVariablesGroup.kt | 25 ++--- .../org/jetbrains/debugger/VariableView.kt | 104 +++++++----------- .../src/org/jetbrains/debugger/Variables.kt | 67 ++++++----- .../debugger/connection/RemoteVmConnection.kt | 4 +- .../script-debugger/debugger-ui/src/util.kt | 4 +- 19 files changed, 151 insertions(+), 171 deletions(-) create mode 100644 platform/platform-impl/src/org/jetbrains/concurrency/promise.kt delete mode 100644 platform/script-debugger/backend/src/org/jetbrains/rpc/CommandSender.java delete mode 100644 platform/script-debugger/backend/src/org/jetbrains/rpc/ErrorConsumer.java diff --git a/platform/built-in-server/src/org/jetbrains/io/fastCgi/FastCgiService.kt b/platform/built-in-server/src/org/jetbrains/io/fastCgi/FastCgiService.kt index e7d54e0210f7..63989e44549f 100644 --- a/platform/built-in-server/src/org/jetbrains/io/fastCgi/FastCgiService.kt +++ b/platform/built-in-server/src/org/jetbrains/io/fastCgi/FastCgiService.kt @@ -15,7 +15,6 @@ */ package org.jetbrains.io.fastCgi -import com.intellij.execution.process.OSProcessHandler import com.intellij.openapi.diagnostic.Logger import com.intellij.openapi.project.Project import com.intellij.util.Consumer @@ -144,11 +143,7 @@ public abstract class FastCgiService(project: Project) : SingleConnectionNetServ } else { processHandler.get() - .done(object : Consumer { - override fun consume(osProcessHandler: OSProcessHandler) { - fastCgiRequest.writeToServerChannel(notEmptyContent, processChannel!!) - } - }) + .done { fastCgiRequest.writeToServerChannel(notEmptyContent, processChannel!!) } .rejected { Promise.logError(LOG, it) handleError(fastCgiRequest, notEmptyContent) diff --git a/platform/core-api/src/org/jetbrains/concurrency/Promise.java b/platform/core-api/src/org/jetbrains/concurrency/Promise.java index 2ce7c001d1d1..2d578c354523 100644 --- a/platform/core-api/src/org/jetbrains/concurrency/Promise.java +++ b/platform/core-api/src/org/jetbrains/concurrency/Promise.java @@ -67,7 +67,7 @@ public abstract class Promise { } @NotNull - public static Promise all(@NotNull Collection> promises) { + public static Promise all(@NotNull Collection> promises) { return all(promises, null); } diff --git a/platform/platform-impl/src/org/jetbrains/concurrency/promise.kt b/platform/platform-impl/src/org/jetbrains/concurrency/promise.kt new file mode 100644 index 000000000000..4264de0597b7 --- /dev/null +++ b/platform/platform-impl/src/org/jetbrains/concurrency/promise.kt @@ -0,0 +1,35 @@ +/* + * Copyright 2000-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.concurrency + +import com.intellij.util.Function + +inline fun Promise.then(crossinline handler: (T) -> SUB_RESULT) = then(object : Function { + override fun `fun`(param: T) = handler(param) +}) + +inline fun Promise.thenAsync(crossinline handler: (T) -> Promise) = then(object : AsyncFunction { + override fun `fun`(param: T) = handler(param) +}) + +inline fun Promise.thenAsyncVoid(crossinline handler: (T) -> Promise<*>) = then(object : AsyncFunction { + override fun `fun`(param: T): Promise { + @Suppress("UNCHECKED_CAST") + return handler(param) as Promise + } +}) + +fun ResolvedPromise(): Promise<*> = Promise.DONE \ No newline at end of file diff --git a/platform/platform-impl/src/org/jetbrains/util/concurrency/Promise.kt b/platform/platform-impl/src/org/jetbrains/util/concurrency/Promise.kt index d5371c3e0e35..448fd53a347c 100644 --- a/platform/platform-impl/src/org/jetbrains/util/concurrency/Promise.kt +++ b/platform/platform-impl/src/org/jetbrains/util/concurrency/Promise.kt @@ -17,8 +17,8 @@ package org.jetbrains.util.concurrency import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.diagnostic.Logger -import org.jetbrains.concurrency.Promise as OJCPromise import org.jetbrains.concurrency.AsyncPromise as OJCAsyncPromise +import org.jetbrains.concurrency.Promise as OJCPromise interface Promise { enum class State { @@ -33,7 +33,7 @@ interface Promise { fun rejected(rejected: (Throwable) -> Unit): Promise - fun processed(processed: (T?) -> Unit): Promise + fun processed(@Suppress("BASE_WITH_NULLABLE_UPPER_BOUND") processed: (T?) -> Unit): Promise fun then(done: (T) -> SUB_RESULT): Promise @@ -93,8 +93,8 @@ fun ResolvedPromise(result: T): Promise = DonePromise(result) fun OJCPromise.toPromise(): AsyncPromise { val promise = AsyncPromise() val oldPromise = this - done({ promise.setResult(it) }) - .rejected({ promise.setError(it) }) + done { promise.setResult(it) } + .rejected { promise.setError(it) } if (oldPromise is OJCAsyncPromise) { promise diff --git a/platform/platform-impl/src/org/jetbrains/util/concurrency/RejectedPromise.kt b/platform/platform-impl/src/org/jetbrains/util/concurrency/RejectedPromise.kt index 08b523a31adf..6c2c6a85eb2c 100644 --- a/platform/platform-impl/src/org/jetbrains/util/concurrency/RejectedPromise.kt +++ b/platform/platform-impl/src/org/jetbrains/util/concurrency/RejectedPromise.kt @@ -15,7 +15,7 @@ */ package org.jetbrains.util.concurrency -class RejectedPromise(private val error: Throwable) : Promise { +internal class RejectedPromise(private val error: Throwable) : Promise { override public val state: Promise.State get() = Promise.State.REJECTED diff --git a/platform/script-debugger/backend/src/org/jetbrains/debugger/StandaloneVmHelper.kt b/platform/script-debugger/backend/src/org/jetbrains/debugger/StandaloneVmHelper.kt index 67c3045af634..8ca522934fa3 100644 --- a/platform/script-debugger/backend/src/org/jetbrains/debugger/StandaloneVmHelper.kt +++ b/platform/script-debugger/backend/src/org/jetbrains/debugger/StandaloneVmHelper.kt @@ -30,7 +30,7 @@ import org.jetbrains.util.concurrency.catchError import java.util.concurrent.TimeUnit import org.jetbrains.concurrency.Promise as OJCPromise -public open class StandaloneVmHelper(private val vm: Vm, private val messageProcessor: MessageProcessor) : MessageWriter(), AttachStateManager { +open class StandaloneVmHelper(private val vm: Vm, private val messageProcessor: MessageProcessor) : MessageWriter(), AttachStateManager { private @Volatile var channel: Channel? = null override fun write(content: ByteBuf) = write((content as Any)) @@ -40,16 +40,16 @@ public open class StandaloneVmHelper(private val vm: Vm, private val messageProc return if (currentChannel == null || !currentChannel.isActive) null else currentChannel } - public fun write(content: Any): Boolean { + fun write(content: Any): Boolean { val channel = getChannelIfActive() return channel != null && !channel.writeAndFlush(content).isCancelled } - public interface VmEx : Vm { - public fun createDisconnectRequest(): Request? + interface VmEx : Vm { + fun createDisconnectRequest(): Request? } - public fun setChannel(channel: Channel) { + fun setChannel(channel: Channel) { this.channel = channel channel.closeFuture().addListener(MyChannelFutureListener()) } @@ -82,8 +82,7 @@ public open class StandaloneVmHelper(private val vm: Vm, private val messageProc messageProcessor.closed() channel = null - @Suppress("USELESS_CAST") - val p = messageProcessor.send(disconnectRequest) as OJCPromise<*> + val p = messageProcessor.send(disconnectRequest) p.processed { promise.catchError { messageProcessor.cancelWaitingRequests() diff --git a/platform/script-debugger/backend/src/org/jetbrains/rpc/CommandSender.java b/platform/script-debugger/backend/src/org/jetbrains/rpc/CommandSender.java deleted file mode 100644 index 87618be3bb93..000000000000 --- a/platform/script-debugger/backend/src/org/jetbrains/rpc/CommandSender.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.jetbrains.rpc; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.concurrency.Promise; -import org.jetbrains.jsonProtocol.Request; - -public interface CommandSender { - @NotNull - Promise send(@NotNull Request message); -} \ No newline at end of file diff --git a/platform/script-debugger/backend/src/org/jetbrains/rpc/ErrorConsumer.java b/platform/script-debugger/backend/src/org/jetbrains/rpc/ErrorConsumer.java deleted file mode 100644 index d081df871648..000000000000 --- a/platform/script-debugger/backend/src/org/jetbrains/rpc/ErrorConsumer.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.jetbrains.rpc; - -import com.intellij.openapi.util.ActionCallback; -import org.jetbrains.annotations.Nullable; - -public interface ErrorConsumer { - void consume(String errorMessage, @Nullable ERROR_DETAILS errorDetails, C callback); -} \ No newline at end of file diff --git a/platform/script-debugger/debugger-ui/src/com/jetbrains/javascript/debugger/NameMapper.kt b/platform/script-debugger/debugger-ui/src/com/jetbrains/javascript/debugger/NameMapper.kt index 6e8a7bbe9b9e..b809849996d1 100644 --- a/platform/script-debugger/debugger-ui/src/com/jetbrains/javascript/debugger/NameMapper.kt +++ b/platform/script-debugger/debugger-ui/src/com/jetbrains/javascript/debugger/NameMapper.kt @@ -24,8 +24,8 @@ import gnu.trove.THashMap import org.jetbrains.debugger.sourcemap.MappingEntry import org.jetbrains.debugger.sourcemap.MappingList import org.jetbrains.debugger.sourcemap.SourceMap +import org.jetbrains.rpc.LOG -import org.jetbrains.rpc.CommandProcessor.LOG private val S1 = ",()[]{}=" // don't trim trailing .&: - could be part of expression diff --git a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/DebugProcessImpl.kt b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/DebugProcessImpl.kt index ad3c7b908927..2f46bc4dd59c 100644 --- a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/DebugProcessImpl.kt +++ b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/DebugProcessImpl.kt @@ -38,10 +38,10 @@ import java.util.concurrent.ConcurrentMap import java.util.concurrent.atomic.AtomicBoolean public abstract class DebugProcessImpl>(session: XDebugSession, - public val connection: C, - private val editorsProvider: XDebuggerEditorsProvider, - private val smartStepIntoHandler: XSmartStepIntoHandler<*>?, - protected val executionResult: ExecutionResult?) : XDebugProcess(session) { + public val connection: C, + private val editorsProvider: XDebuggerEditorsProvider, + private val smartStepIntoHandler: XSmartStepIntoHandler<*>?, + protected val executionResult: ExecutionResult?) : XDebugProcess(session) { protected val repeatStepInto: AtomicBoolean = AtomicBoolean() @Volatile protected var lastStep: StepAction? = null @Volatile protected var lastCallFrame: CallFrame? = null diff --git a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/DebuggerViewSupport.kt b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/DebuggerViewSupport.kt index cbaaf1d1d65c..26c9b2084874 100644 --- a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/DebuggerViewSupport.kt +++ b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/DebuggerViewSupport.kt @@ -56,7 +56,7 @@ interface DebuggerViewSupport { fun computeInlineDebuggerData(name: String, variable: Variable, context: VariableContext, callback: XInlineDebuggerDataCallback) = ThreeState.UNSURE // return null if you don't need to add additional properties - fun computeAdditionalObjectProperties(value: ObjectValue, variable: Variable, context: VariableContext, node: XCompositeNode): Promise? = null + fun computeAdditionalObjectProperties(value: ObjectValue, variable: Variable, context: VariableContext, node: XCompositeNode): Promise<*>? = null fun getMemberFilter(context: VariableContext): Promise diff --git a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/FunctionScopesValueGroup.kt b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/FunctionScopesValueGroup.kt index 6f8ad5dc5bb3..35524b875c28 100644 --- a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/FunctionScopesValueGroup.kt +++ b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/FunctionScopesValueGroup.kt @@ -15,13 +15,12 @@ */ package org.jetbrains.debugger -import com.intellij.util.Consumer import com.intellij.xdebugger.frame.XCompositeNode import com.intellij.xdebugger.frame.XValueChildrenList import com.intellij.xdebugger.frame.XValueGroup import org.jetbrains.concurrency.Promise import org.jetbrains.debugger.values.FunctionValue -import org.jetbrains.rpc.CommandProcessor +import org.jetbrains.rpc.LOG import java.util.* internal class FunctionScopesValueGroup(private val value: FunctionValue, private val variableContext: VariableContext) : XValueGroup("Function scopes") { @@ -40,11 +39,9 @@ internal class FunctionScopesValueGroup(private val value: FunctionValue, privat } } }) - .rejected(object : Consumer { - override fun consume(error: Throwable) { - Promise.logError(CommandProcessor.LOG, error) - node.setErrorMessage(error.getMessage()!!) - } - }) + .rejected { + Promise.logError(LOG, it) + node.setErrorMessage(it.getMessage()!!) + } } } \ No newline at end of file diff --git a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/ProcessHandlerWrapper.kt b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/ProcessHandlerWrapper.kt index 6050748bbd38..b58bab56102a 100644 --- a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/ProcessHandlerWrapper.kt +++ b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/ProcessHandlerWrapper.kt @@ -19,10 +19,8 @@ import com.intellij.execution.KillableProcess import com.intellij.execution.process.ProcessAdapter import com.intellij.execution.process.ProcessEvent import com.intellij.execution.process.ProcessHandler -import com.intellij.openapi.diagnostic.Logger import com.intellij.xdebugger.XDebugProcess - -private val LOG: Logger = Logger.getInstance(ProcessHandlerWrapper::class.java) +import org.jetbrains.rpc.LOG class ProcessHandlerWrapper(private val debugProcess: XDebugProcess, private val handler: ProcessHandler) : ProcessHandler(), KillableProcess { init { diff --git a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/RejectErrorReporter.java b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/RejectErrorReporter.java index 85da0944f378..337ec586106e 100644 --- a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/RejectErrorReporter.java +++ b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/RejectErrorReporter.java @@ -21,7 +21,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.concurrency.AsyncPromise; import org.jetbrains.concurrency.Promise; -import org.jetbrains.rpc.CommandProcessor; +import org.jetbrains.rpc.CommandProcessorKt; public final class RejectErrorReporter implements Consumer { private final XDebugSession session; @@ -38,7 +38,7 @@ public final class RejectErrorReporter implements Consumer { @Override public void consume(Throwable error) { - Promise.logError(CommandProcessor.LOG, error); + Promise.logError(CommandProcessorKt.getLOG(), error); if (error != AsyncPromise.OBSOLETE_ERROR) { session.reportError((description == null ? "" : description + ": ") + error.getMessage()); } diff --git a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/ScopeVariablesGroup.kt b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/ScopeVariablesGroup.kt index 38be77f26bea..0e711016c1c4 100644 --- a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/ScopeVariablesGroup.kt +++ b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/ScopeVariablesGroup.kt @@ -38,19 +38,18 @@ class ScopeVariablesGroup(val scope: Scope, parentContext: VariableContext, call return } - promise.done(object : ObsolescentConsumer(node) { - override fun consume(ignored: Void) { - callFrame.receiverVariable.done(object : ObsolescentConsumer(node) { - override fun consume(variable: Variable?) { - node.addChildren(if (variable == null) XValueChildrenList.EMPTY else XValueChildrenList.singleton(VariableView(variable, context)), true) - } - }).rejected(object : ObsolescentConsumer(node) { - override fun consume(error: Throwable?) { - node.addChildren(XValueChildrenList.EMPTY, true) - } - }) - } - }) + promise + .done(object : ObsolescentConsumer(node) { + override fun consume(ignored: Any?) { + callFrame.receiverVariable + .done(object : ObsolescentConsumer(node) { + override fun consume(variable: Variable?) = node.addChildren(if (variable == null) XValueChildrenList.EMPTY else XValueChildrenList.singleton(VariableView(variable, context)), true) + }) + .rejected(object : ObsolescentConsumer(node) { + override fun consume(error: Throwable?) = node.addChildren(XValueChildrenList.EMPTY, true) + }) + } + }) } } diff --git a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/VariableView.kt b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/VariableView.kt index 8e2e8d0b38a2..e0501853e2a9 100644 --- a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/VariableView.kt +++ b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/VariableView.kt @@ -31,7 +31,6 @@ import com.intellij.xdebugger.frame.presentation.XKeywordValuePresentation import com.intellij.xdebugger.frame.presentation.XNumericValuePresentation import com.intellij.xdebugger.frame.presentation.XStringValuePresentation import com.intellij.xdebugger.frame.presentation.XValuePresentation -import org.jetbrains.concurrency.ObsolescentAsyncFunction import org.jetbrains.concurrency.Promise import org.jetbrains.debugger.values.* import java.util.* @@ -116,7 +115,6 @@ class VariableView(name: String, private val variable: Variable, private val con } private fun computePresentation(value: Value, node: XValueNode) { - val valueString = value.valueString when (value.type) { ValueType.OBJECT, ValueType.NODE -> context.viewSupport.computeObjectPresentation((value as ObjectValue), variable, context, node, icon) @@ -124,20 +122,20 @@ class VariableView(name: String, private val variable: Variable, private val con ValueType.ARRAY -> context.viewSupport.computeArrayPresentation(value, variable, context, node, icon) - ValueType.BOOLEAN, ValueType.NULL, ValueType.UNDEFINED -> node.setPresentation(icon, XKeywordValuePresentation(valueString), false) + ValueType.BOOLEAN, ValueType.NULL, ValueType.UNDEFINED -> node.setPresentation(icon, XKeywordValuePresentation(value.valueString!!), false) - ValueType.NUMBER -> node.setPresentation(icon, createNumberPresentation(valueString), false) + ValueType.NUMBER -> node.setPresentation(icon, createNumberPresentation(value.valueString!!), false) ValueType.STRING -> { - node.setPresentation(icon, XStringValuePresentation(valueString), false) + node.setPresentation(icon, XStringValuePresentation(value.valueString!!), false) // isTruncated in terms of debugger backend, not in our terms (i.e. sometimes we cannot control truncation), // so, even in case of StringValue, we check value string length - if ((value is StringValue && value.isTruncated) || valueString.length() > XValueNode.MAX_VALUE_LENGTH) { + if ((value is StringValue && value.isTruncated) || value.valueString!!.length() > XValueNode.MAX_VALUE_LENGTH) { node.setFullValueEvaluator(MyFullValueEvaluator(value)) } } - else -> node.setPresentation(icon, null, valueString, true) + else -> node.setPresentation(icon, null, value.valueString!!, true) } } @@ -181,32 +179,19 @@ class VariableView(name: String, private val variable: Variable, private val con promises.add(computeNamedProperties(objectValue, node, !hasIndexedProperties && additionalProperties == null)) } else { - promises.add(additionalProperties.then(object : ObsolescentAsyncFunction { - override fun isObsolete(): Boolean { - return node.isObsolete - } - - override fun `fun`(o: Void): Promise { - return computeNamedProperties(objectValue, node, true) - } - })) + promises.add(additionalProperties.thenAsync(node) { computeNamedProperties(objectValue, node, true) }) } } if (hasIndexedProperties == hasNamedProperties || additionalProperties != null) { - Promise.all(promises).processed(object : ObsolescentConsumer(node) { - override fun consume(aVoid: Void) { - node.addChildren(XValueChildrenList.EMPTY, true) - } + Promise.all(promises).processed(object : ObsolescentConsumer(node) { + override fun consume(aVoid: Any?) = node.addChildren(XValueChildrenList.EMPTY, true) }) } } - abstract class ObsolescentIndexedVariablesConsumer protected constructor(protected val node: XCompositeNode) : IndexedVariablesConsumer() { - - override fun isObsolete(): Boolean { - return node.isObsolete - } + abstract class ObsolescentIndexedVariablesConsumer(protected val node: XCompositeNode) : IndexedVariablesConsumer() { + override fun isObsolete() = node.isObsolete } private fun computeIndexedProperties(value: ArrayValue, node: XCompositeNode, isLastChildren: Boolean): Promise<*> { @@ -228,29 +213,27 @@ class VariableView(name: String, private val variable: Variable, private val con }, null) } - private fun computeNamedProperties(value: ObjectValue, node: XCompositeNode, isLastChildren: Boolean): Promise { - return processVariables(this, value.properties, node) { memberFilter, variables -> - this@VariableView.memberFilter = memberFilter + private fun computeNamedProperties(value: ObjectValue, node: XCompositeNode, isLastChildren: Boolean) = processVariables(this, value.properties, node) { memberFilter, variables -> + this@VariableView.memberFilter = memberFilter - if (value.type == ValueType.ARRAY && value !is ArrayValue) { - computeArrayRanges(variables, node) - return@processVariables - } + if (value.type == ValueType.ARRAY && value !is ArrayValue) { + computeArrayRanges(variables, node) + return@processVariables + } - var functionValue = value as? FunctionValue - if (functionValue != null && functionValue.hasScopes() == ThreeState.NO) { - functionValue = null - } + var functionValue = value as? FunctionValue + if (functionValue != null && functionValue.hasScopes() == ThreeState.NO) { + functionValue = null + } - remainingChildren = processNamedObjectProperties(variables, node, this@VariableView, memberFilter, XCompositeNode.MAX_CHILDREN_TO_SHOW, isLastChildren && functionValue == null) - if (remainingChildren != null) { - remainingChildrenOffset = XCompositeNode.MAX_CHILDREN_TO_SHOW - } + remainingChildren = processNamedObjectProperties(variables, node, this@VariableView, memberFilter, XCompositeNode.MAX_CHILDREN_TO_SHOW, isLastChildren && functionValue == null) + if (remainingChildren != null) { + remainingChildrenOffset = XCompositeNode.MAX_CHILDREN_TO_SHOW + } - if (functionValue != null) { - // we pass context as variable context instead of this variable value - we cannot watch function scopes variables, so, this variable name doesn't matter - node.addChildren(XValueChildrenList.bottomGroup(FunctionScopesValueGroup(functionValue, context)), isLastChildren) - } + if (functionValue != null) { + // we pass context as variable context instead of this variable value - we cannot watch function scopes variables, so, this variable name doesn't matter + node.addChildren(XValueChildrenList.bottomGroup(FunctionScopesValueGroup(functionValue, context)), isLastChildren) } } @@ -312,7 +295,7 @@ class VariableView(name: String, private val variable: Variable, private val con return object : XValueModifier() { override fun getInitialValueEditorText(): String? { if (value!!.type == ValueType.STRING) { - val string = value!!.valueString + val string = value!!.valueString!! val builder = StringBuilder(string.length()) builder.append('"') StringUtil.escapeStringCharacters(string.length(), string, builder) @@ -325,10 +308,7 @@ class VariableView(name: String, private val variable: Variable, private val con } override fun setValue(expression: String, callback: XValueModifier.XModificationCallback) { - val valueModifier = variable.valueModifier - assert(valueModifier != null) - //noinspection unchecked - valueModifier!!.setValue(variable, expression, evaluateContext) + variable.valueModifier!!.setValue(variable, expression, evaluateContext) .done(Consumer { value = null callback.valueModified() @@ -346,11 +326,11 @@ class VariableView(name: String, private val variable: Variable, private val con override fun computeSourcePosition(navigatable: XNavigatable) { if (value is FunctionValue) { - (value as FunctionValue).resolve().done(object : Consumer { - override fun consume(function: FunctionValue) { - viewSupport.vm!!.scriptManager.getScript(function).done(object : Consumer