mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 22:51:17 +07:00
PY-48235 Add quoting policy for PyXCopyValueAction
IJ-CR-110671 GitOrigin-RevId: 768a88b91943de9dcab5c5023073c82c5f8c93d7
This commit is contained in:
committed by
intellij-monorepo-bot
parent
34d15a1d21
commit
c368c2f4f1
@@ -6,10 +6,12 @@ import com.intellij.xdebugger.impl.ui.tree.actions.XFetchValueActionBase
|
||||
import com.intellij.xdebugger.impl.ui.tree.nodes.HeadlessValueEvaluationCallback
|
||||
import com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl
|
||||
|
||||
class PyCopyValueEvaluationCallback(node: XValueNodeImpl, private val valueCollector: XFetchValueActionBase.ValueCollector) : HeadlessValueEvaluationCallback(node) {
|
||||
class PyCopyValueEvaluationCallback(node: XValueNodeImpl,
|
||||
private val valueCollector: XFetchValueActionBase.ValueCollector,
|
||||
private val currentPolicy: QuotingPolicy) : HeadlessValueEvaluationCallback(node) {
|
||||
private val valueIndex = valueCollector.acquire()
|
||||
|
||||
override fun evaluationComplete(value: String, project: Project) {
|
||||
valueCollector.evaluationComplete(valueIndex, value)
|
||||
valueCollector.evaluationComplete(valueIndex, getQuotingString(currentPolicy, value))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.jetbrains.python.debugger
|
||||
|
||||
interface AbstractPolicy
|
||||
|
||||
|
||||
fun interface PolicyListener {
|
||||
fun valuesPolicyUpdated()
|
||||
}
|
||||
|
||||
|
||||
enum class ValuesPolicy : AbstractPolicy {
|
||||
SYNC,
|
||||
ASYNC,
|
||||
ON_DEMAND
|
||||
}
|
||||
|
||||
enum class QuotingPolicy : AbstractPolicy {
|
||||
SINGLE,
|
||||
DOUBLE,
|
||||
NONE
|
||||
}
|
||||
|
||||
fun getQuotingString(policy: QuotingPolicy, value: String): String =
|
||||
when (policy) {
|
||||
QuotingPolicy.SINGLE -> value
|
||||
QuotingPolicy.DOUBLE -> value.replace("'", "\"")
|
||||
QuotingPolicy.NONE -> value.replace("'", "")
|
||||
}
|
||||
@@ -65,10 +65,6 @@ public class PyDebugValue extends XNamedValue {
|
||||
|
||||
private @NotNull PyDebugValueDescriptor myDescriptor = new PyDebugValueDescriptor();
|
||||
|
||||
public enum ValuesPolicy {
|
||||
SYNC, ASYNC, ON_DEMAND
|
||||
}
|
||||
|
||||
private static final Map<String, ValuesPolicy> POLICY_DEFAULT_VALUES = ImmutableMap.of("__pydevd_value_async", ValuesPolicy.ASYNC,
|
||||
"__pydevd_value_on_demand",
|
||||
ValuesPolicy.ON_DEMAND);
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.intellij.xdebugger.frame.XValueNode;
|
||||
import com.jetbrains.python.debugger.PyDebugValue;
|
||||
import com.jetbrains.python.debugger.PyDebuggerException;
|
||||
import com.jetbrains.python.debugger.PyFrameAccessor;
|
||||
import com.jetbrains.python.debugger.ValuesPolicy;
|
||||
import com.jetbrains.python.debugger.pydev.PyDebugCallback;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
Reference in New Issue
Block a user