mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[js-debugger] cleanup after convert to kotlin
This commit is contained in:
@@ -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<OSProcessHandler> {
|
||||
override fun consume(osProcessHandler: OSProcessHandler) {
|
||||
fastCgiRequest.writeToServerChannel(notEmptyContent, processChannel!!)
|
||||
}
|
||||
})
|
||||
.done { fastCgiRequest.writeToServerChannel(notEmptyContent, processChannel!!) }
|
||||
.rejected {
|
||||
Promise.logError(LOG, it)
|
||||
handleError(fastCgiRequest, notEmptyContent)
|
||||
|
||||
@@ -67,7 +67,7 @@ public abstract class Promise<T> {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Promise<Void> all(@NotNull Collection<Promise<?>> promises) {
|
||||
public static Promise<?> all(@NotNull Collection<Promise<?>> promises) {
|
||||
return all(promises, null);
|
||||
}
|
||||
|
||||
|
||||
@@ -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 <T, SUB_RESULT> Promise<T>.then(crossinline handler: (T) -> SUB_RESULT) = then(object : Function<T, SUB_RESULT> {
|
||||
override fun `fun`(param: T) = handler(param)
|
||||
})
|
||||
|
||||
inline fun <T, SUB_RESULT> Promise<T>.thenAsync(crossinline handler: (T) -> Promise<SUB_RESULT>) = then(object : AsyncFunction<T, SUB_RESULT> {
|
||||
override fun `fun`(param: T) = handler(param)
|
||||
})
|
||||
|
||||
inline fun <T> Promise<T>.thenAsyncVoid(crossinline handler: (T) -> Promise<*>) = then(object : AsyncFunction<T, Any?> {
|
||||
override fun `fun`(param: T): Promise<Any?> {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return handler(param) as Promise<Any?>
|
||||
}
|
||||
})
|
||||
|
||||
fun ResolvedPromise(): Promise<*> = Promise.DONE
|
||||
@@ -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<T> {
|
||||
enum class State {
|
||||
@@ -33,7 +33,7 @@ interface Promise<T> {
|
||||
|
||||
fun rejected(rejected: (Throwable) -> Unit): Promise<T>
|
||||
|
||||
fun processed(processed: (T?) -> Unit): Promise<T>
|
||||
fun processed(@Suppress("BASE_WITH_NULLABLE_UPPER_BOUND") processed: (T?) -> Unit): Promise<T>
|
||||
|
||||
fun <SUB_RESULT> then(done: (T) -> SUB_RESULT): Promise<SUB_RESULT>
|
||||
|
||||
@@ -93,8 +93,8 @@ fun <T> ResolvedPromise(result: T): Promise<T> = DonePromise(result)
|
||||
fun <T> OJCPromise<T>.toPromise(): AsyncPromise<T> {
|
||||
val promise = AsyncPromise<T>()
|
||||
val oldPromise = this
|
||||
done({ promise.setResult(it) })
|
||||
.rejected({ promise.setError(it) })
|
||||
done { promise.setResult(it) }
|
||||
.rejected { promise.setError(it) }
|
||||
|
||||
if (oldPromise is OJCAsyncPromise) {
|
||||
promise
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.jetbrains.util.concurrency
|
||||
|
||||
class RejectedPromise<T>(private val error: Throwable) : Promise<T> {
|
||||
internal class RejectedPromise<T>(private val error: Throwable) : Promise<T> {
|
||||
override public val state: Promise.State
|
||||
get() = Promise.State.REJECTED
|
||||
|
||||
|
||||
@@ -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<out Any?>?
|
||||
interface VmEx : Vm {
|
||||
fun createDisconnectRequest(): Request<out Any>?
|
||||
}
|
||||
|
||||
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()
|
||||
|
||||
@@ -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
|
||||
<RESULT> Promise<RESULT> send(@NotNull Request<RESULT> message);
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package org.jetbrains.rpc;
|
||||
|
||||
import com.intellij.openapi.util.ActionCallback;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface ErrorConsumer<C extends ActionCallback, ERROR_DETAILS> {
|
||||
void consume(String errorMessage, @Nullable ERROR_DETAILS errorDetails, C callback);
|
||||
}
|
||||
+1
-1
@@ -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
|
||||
|
||||
@@ -38,10 +38,10 @@ import java.util.concurrent.ConcurrentMap
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
|
||||
public abstract class DebugProcessImpl<C : VmConnection<*>>(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
|
||||
|
||||
+1
-1
@@ -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<Void>? = null
|
||||
fun computeAdditionalObjectProperties(value: ObjectValue, variable: Variable, context: VariableContext, node: XCompositeNode): Promise<*>? = null
|
||||
|
||||
fun getMemberFilter(context: VariableContext): Promise<MemberFilter>
|
||||
|
||||
|
||||
+5
-8
@@ -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<Throwable> {
|
||||
override fun consume(error: Throwable) {
|
||||
Promise.logError(CommandProcessor.LOG, error)
|
||||
node.setErrorMessage(error.getMessage()!!)
|
||||
}
|
||||
})
|
||||
.rejected {
|
||||
Promise.logError(LOG, it)
|
||||
node.setErrorMessage(it.getMessage()!!)
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-3
@@ -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 {
|
||||
|
||||
+2
-2
@@ -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<Throwable> {
|
||||
private final XDebugSession session;
|
||||
@@ -38,7 +38,7 @@ public final class RejectErrorReporter implements Consumer<Throwable> {
|
||||
|
||||
@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());
|
||||
}
|
||||
|
||||
+12
-13
@@ -38,19 +38,18 @@ class ScopeVariablesGroup(val scope: Scope, parentContext: VariableContext, call
|
||||
return
|
||||
}
|
||||
|
||||
promise.done(object : ObsolescentConsumer<Void>(node) {
|
||||
override fun consume(ignored: Void) {
|
||||
callFrame.receiverVariable.done(object : ObsolescentConsumer<Variable>(node) {
|
||||
override fun consume(variable: Variable?) {
|
||||
node.addChildren(if (variable == null) XValueChildrenList.EMPTY else XValueChildrenList.singleton(VariableView(variable, context)), true)
|
||||
}
|
||||
}).rejected(object : ObsolescentConsumer<Throwable>(node) {
|
||||
override fun consume(error: Throwable?) {
|
||||
node.addChildren(XValueChildrenList.EMPTY, true)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
promise
|
||||
.done(object : ObsolescentConsumer<Any?>(node) {
|
||||
override fun consume(ignored: Any?) {
|
||||
callFrame.receiverVariable
|
||||
.done(object : ObsolescentConsumer<Variable>(node) {
|
||||
override fun consume(variable: Variable?) = node.addChildren(if (variable == null) XValueChildrenList.EMPTY else XValueChildrenList.singleton(VariableView(variable, context)), true)
|
||||
})
|
||||
.rejected(object : ObsolescentConsumer<Throwable>(node) {
|
||||
override fun consume(error: Throwable?) = node.addChildren(XValueChildrenList.EMPTY, true)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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<Void, Void> {
|
||||
override fun isObsolete(): Boolean {
|
||||
return node.isObsolete
|
||||
}
|
||||
|
||||
override fun `fun`(o: Void): Promise<Void> {
|
||||
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<Void>(node) {
|
||||
override fun consume(aVoid: Void) {
|
||||
node.addChildren(XValueChildrenList.EMPTY, true)
|
||||
}
|
||||
Promise.all(promises).processed(object : ObsolescentConsumer<Any?>(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<Void> {
|
||||
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<Any?> {
|
||||
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<FunctionValue> {
|
||||
override fun consume(function: FunctionValue) {
|
||||
viewSupport.vm!!.scriptManager.getScript(function).done(object : Consumer<Script> {
|
||||
override fun consume(script: Script?) {
|
||||
val position = if (script == null) null else viewSupport.getSourceInfo(null, script, function.openParenLine, function.openParenColumn)
|
||||
(value as FunctionValue).resolve()
|
||||
.done { function ->
|
||||
viewSupport.vm!!.scriptManager.getScript(function)
|
||||
.done {
|
||||
val position = if (it == null) null else viewSupport.getSourceInfo(null, it, function.openParenLine, function.openParenColumn)
|
||||
navigatable.setSourcePosition(if (position == null)
|
||||
null
|
||||
else
|
||||
@@ -388,9 +368,7 @@ class VariableView(name: String, private val variable: Variable, private val con
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
else {
|
||||
viewSupport.computeSourcePosition(name, variable, context, navigatable)
|
||||
@@ -413,21 +391,21 @@ class VariableView(name: String, private val variable: Variable, private val con
|
||||
return context.viewSupport.propertyNamesToString(list, false)
|
||||
}
|
||||
|
||||
private class MyFullValueEvaluator(private val value: Value) : XFullValueEvaluator(if (value is StringValue) value.length else value.valueString.length()) {
|
||||
private class MyFullValueEvaluator(private val value: Value) : XFullValueEvaluator(if (value is StringValue) value.length else value.valueString!!.length()) {
|
||||
override fun startEvaluation(callback: XFullValueEvaluator.XFullValueEvaluationCallback) {
|
||||
if (value !is StringValue || !value.isTruncated) {
|
||||
callback.evaluated(value.valueString)
|
||||
callback.evaluated(value.valueString!!)
|
||||
return
|
||||
}
|
||||
|
||||
val evaluated = AtomicBoolean()
|
||||
value.fullString.done(object : Consumer<String> {
|
||||
override fun consume(s: String) {
|
||||
value.fullString
|
||||
.done {
|
||||
if (!callback.isObsolete && evaluated.compareAndSet(false, true)) {
|
||||
callback.evaluated(value.valueString)
|
||||
callback.evaluated(value.valueString!!)
|
||||
}
|
||||
}
|
||||
}).rejected(createErrorMessageConsumer(callback))
|
||||
.rejected(createErrorMessageConsumer(callback))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -483,7 +461,7 @@ fun getClassName(value: ObjectValue): String {
|
||||
|
||||
fun getObjectValueDescription(value: ObjectValue): String {
|
||||
val description = value.valueString
|
||||
return if (description.isNullOrEmpty()) getClassName(value) else description
|
||||
return if (description.isNullOrEmpty()) getClassName(value) else description!!
|
||||
}
|
||||
|
||||
internal fun trimFunctionDescription(value: Value): String {
|
||||
|
||||
@@ -32,14 +32,14 @@ private val NATURAL_NAME_COMPARATOR = object : Comparator<Variable> {
|
||||
override fun compare(o1: Variable, o2: Variable) = naturalCompare(o1.name, o2.name)
|
||||
}
|
||||
|
||||
// start properties loading to achieve, possibly, parallel execution (properties loading & member filter computation)
|
||||
fun processVariables(context: VariableContext,
|
||||
variables: Promise<List<Variable>>,
|
||||
obsolescent: Obsolescent,
|
||||
consumer: (memberFilter: MemberFilter, variables: List<Variable>) -> Unit): Promise<Void> {
|
||||
// start properties loading to achieve, possibly, parallel execution (properties loading & member filter computation)
|
||||
return context.memberFilter.then(object : ValueNodeAsyncFunction<MemberFilter, Void>(obsolescent) {
|
||||
override fun `fun`(memberFilter: MemberFilter): Promise<Void> {
|
||||
return variables.then(object : ObsolescentFunction<List<Variable>, Void> {
|
||||
consumer: (memberFilter: MemberFilter, variables: List<Variable>) -> Unit) = context.memberFilter
|
||||
.then(object : ValueNodeAsyncFunction<MemberFilter, Any?>(obsolescent) {
|
||||
override fun `fun`(memberFilter: MemberFilter): Promise<Any?> {
|
||||
return variables.then(object : ObsolescentFunction<List<Variable>, Any?> {
|
||||
override fun isObsolete() = obsolescent.isObsolete
|
||||
|
||||
override fun `fun`(variables: List<Variable>): Void? {
|
||||
@@ -49,46 +49,43 @@ fun processVariables(context: VariableContext,
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun processScopeVariables(scope: Scope,
|
||||
node: XCompositeNode,
|
||||
context: VariableContext,
|
||||
isLast: Boolean): Promise<Void> {
|
||||
return processVariables(context, scope.variablesHost.get(), node, { memberFilter, variables ->
|
||||
val additionalVariables = memberFilter.additionalVariables
|
||||
val properties = ArrayList<Variable>(variables.size() + additionalVariables.size())
|
||||
val functions = SmartList<Variable>()
|
||||
for (variable in variables) {
|
||||
if (memberFilter.isMemberVisible(variable)) {
|
||||
val value = variable.value
|
||||
if (value != null && value.type == ValueType.FUNCTION && value.valueString != null && !UNNAMED_FUNCTION_PATTERN.matcher(value.valueString).lookingAt()) {
|
||||
functions.add(variable)
|
||||
}
|
||||
else {
|
||||
properties.add(variable)
|
||||
}
|
||||
isLast: Boolean) = processVariables(context, scope.variablesHost.get(), node, { memberFilter, variables ->
|
||||
val additionalVariables = memberFilter.additionalVariables
|
||||
val properties = ArrayList<Variable>(variables.size() + additionalVariables.size())
|
||||
val functions = SmartList<Variable>()
|
||||
for (variable in variables) {
|
||||
if (memberFilter.isMemberVisible(variable)) {
|
||||
val value = variable.value
|
||||
if (value != null && value.type == ValueType.FUNCTION && value.valueString != null && !UNNAMED_FUNCTION_PATTERN.matcher(value.valueString).lookingAt()) {
|
||||
functions.add(variable)
|
||||
}
|
||||
else {
|
||||
properties.add(variable)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val comparator = if (memberFilter.hasNameMappings()) comparator { o1, o2 -> naturalCompare(memberFilter.rawNameToSource(o1), memberFilter.rawNameToSource(o2)) } else NATURAL_NAME_COMPARATOR
|
||||
Collections.sort(properties, comparator)
|
||||
Collections.sort(functions, comparator)
|
||||
val comparator = if (memberFilter.hasNameMappings()) comparator { o1, o2 -> naturalCompare(memberFilter.rawNameToSource(o1), memberFilter.rawNameToSource(o2)) } else NATURAL_NAME_COMPARATOR
|
||||
Collections.sort(properties, comparator)
|
||||
Collections.sort(functions, comparator)
|
||||
|
||||
addAditionalVariables(variables, additionalVariables, properties, memberFilter)
|
||||
addAditionalVariables(variables, additionalVariables, properties, memberFilter)
|
||||
|
||||
if (!properties.isEmpty()) {
|
||||
node.addChildren(createVariablesList(properties, context, memberFilter), functions.isEmpty() && isLast)
|
||||
}
|
||||
if (!properties.isEmpty()) {
|
||||
node.addChildren(createVariablesList(properties, context, memberFilter), functions.isEmpty() && isLast)
|
||||
}
|
||||
|
||||
if (!functions.isEmpty()) {
|
||||
node.addChildren(XValueChildrenList.bottomGroup(VariablesGroup("Functions", functions, context)), isLast)
|
||||
}
|
||||
else if (isLast && properties.isEmpty()) {
|
||||
node.addChildren(XValueChildrenList.EMPTY, true)
|
||||
}
|
||||
})
|
||||
}
|
||||
if (!functions.isEmpty()) {
|
||||
node.addChildren(XValueChildrenList.bottomGroup(VariablesGroup("Functions", functions, context)), isLast)
|
||||
}
|
||||
else if (isLast && properties.isEmpty()) {
|
||||
node.addChildren(XValueChildrenList.EMPTY, true)
|
||||
}
|
||||
})
|
||||
|
||||
fun processNamedObjectProperties(variables: List<Variable>,
|
||||
node: XCompositeNode,
|
||||
|
||||
+2
-2
@@ -25,7 +25,7 @@ import com.intellij.util.io.socketConnection.ConnectionStatus
|
||||
import io.netty.bootstrap.Bootstrap
|
||||
import org.jetbrains.debugger.Vm
|
||||
import org.jetbrains.io.NettyUtil
|
||||
import org.jetbrains.rpc.CommandProcessor
|
||||
import org.jetbrains.rpc.LOG
|
||||
import org.jetbrains.util.concurrency.AsyncPromise
|
||||
import org.jetbrains.util.concurrency.Promise
|
||||
import org.jetbrains.util.concurrency.RejectedPromise
|
||||
@@ -63,7 +63,7 @@ abstract class RemoteVmConnection : VmConnection<Vm>() {
|
||||
}
|
||||
.rejected {
|
||||
if (it !is ConnectException) {
|
||||
Promise.logError(CommandProcessor.LOG, it)
|
||||
Promise.logError(LOG, it)
|
||||
}
|
||||
setState(ConnectionStatus.CONNECTION_FAILED, it.getMessage())
|
||||
}
|
||||
|
||||
@@ -19,12 +19,12 @@ import com.intellij.xdebugger.XDebugSession
|
||||
import org.jetbrains.concurrency.Promise
|
||||
import org.jetbrains.debugger.SuspendContext
|
||||
import org.jetbrains.debugger.Vm
|
||||
import org.jetbrains.rpc.CommandProcessor
|
||||
import org.jetbrains.rpc.LOG
|
||||
import org.jetbrains.util.concurrency.AsyncPromise
|
||||
|
||||
// have to use package "com.intellij.xdebugger.util" to avoid package clash
|
||||
fun XDebugSession.rejectedErrorReporter(description: String? = null): (Throwable) -> Unit = {
|
||||
Promise.logError(CommandProcessor.LOG, it)
|
||||
Promise.logError(LOG, it)
|
||||
if (it != AsyncPromise.OBSOLETE_ERROR) {
|
||||
reportError("${if (description == null) "" else description + ": "}${it.getMessage()}")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user