Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
1637345e
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1637345e
编写于
5月 03, 2018
作者:
I
isidor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debugUtils
上级
77a8731d
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
78 addition
and
72 deletion
+78
-72
src/vs/workbench/parts/debug/common/debug.ts
src/vs/workbench/parts/debug/common/debug.ts
+0
-16
src/vs/workbench/parts/debug/common/debugUtils.ts
src/vs/workbench/parts/debug/common/debugUtils.ts
+63
-0
src/vs/workbench/parts/debug/electron-browser/debugHover.ts
src/vs/workbench/parts/debug/electron-browser/debugHover.ts
+2
-44
src/vs/workbench/parts/debug/electron-browser/rawDebugSession.ts
...workbench/parts/debug/electron-browser/rawDebugSession.ts
+3
-2
src/vs/workbench/parts/debug/test/common/debugUtils.test.ts
src/vs/workbench/parts/debug/test/common/debugUtils.test.ts
+10
-10
未找到文件。
src/vs/workbench/parts/debug/common/debug.ts
浏览文件 @
1637345e
...
...
@@ -730,19 +730,3 @@ export interface IDebugEditorContribution extends IEditorContribution {
closeBreakpointWidget
():
void
;
addLaunchConfiguration
():
TPromise
<
any
>
;
}
// utils
const
_formatPIIRegexp
=
/{
([^
}
]
+
)
}/g
;
export
function
formatPII
(
value
:
string
,
excludePII
:
boolean
,
args
:
{
[
key
:
string
]:
string
}):
string
{
return
value
.
replace
(
_formatPIIRegexp
,
function
(
match
,
group
)
{
if
(
excludePII
&&
group
.
length
>
0
&&
group
[
0
]
!==
'
_
'
)
{
return
match
;
}
return
args
&&
args
.
hasOwnProperty
(
group
)
?
args
[
group
]
:
match
;
});
}
src/vs/workbench/parts/debug/common/debugUtils.ts
0 → 100644
浏览文件 @
1637345e
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
const
_formatPIIRegexp
=
/{
([^
}
]
+
)
}/g
;
export
function
formatPII
(
value
:
string
,
excludePII
:
boolean
,
args
:
{
[
key
:
string
]:
string
}):
string
{
return
value
.
replace
(
_formatPIIRegexp
,
function
(
match
,
group
)
{
if
(
excludePII
&&
group
.
length
>
0
&&
group
[
0
]
!==
'
_
'
)
{
return
match
;
}
return
args
&&
args
.
hasOwnProperty
(
group
)
?
args
[
group
]
:
match
;
});
}
export
function
getExactExpressionRange
(
lineContent
:
string
,
range
:
Range
):
Range
{
let
matchingExpression
:
string
=
undefined
;
let
startOffset
=
0
;
// Some example supported expressions: myVar.prop, a.b.c.d, myVar?.prop, myVar->prop, MyClass::StaticProp, *myVar
// Match any character except a set of characters which often break interesting sub-expressions
let
expression
:
RegExp
=
/
([^
()
\[\]
{}<>
\s
+
\-/
%~#^;=|,`!
]
|
\-
>
)
+/g
;
let
result
:
RegExpExecArray
=
undefined
;
// First find the full expression under the cursor
while
(
result
=
expression
.
exec
(
lineContent
))
{
let
start
=
result
.
index
+
1
;
let
end
=
start
+
result
[
0
].
length
;
if
(
start
<=
range
.
startColumn
&&
end
>=
range
.
endColumn
)
{
matchingExpression
=
result
[
0
];
startOffset
=
start
;
break
;
}
}
// If there are non-word characters after the cursor, we want to truncate the expression then.
// For example in expression 'a.b.c.d', if the focus was under 'b', 'a.b' would be evaluated.
if
(
matchingExpression
)
{
let
subExpression
:
RegExp
=
/
\w
+/g
;
let
subExpressionResult
:
RegExpExecArray
=
undefined
;
while
(
subExpressionResult
=
subExpression
.
exec
(
matchingExpression
))
{
let
subEnd
=
subExpressionResult
.
index
+
1
+
startOffset
+
subExpressionResult
[
0
].
length
;
if
(
subEnd
>=
range
.
endColumn
)
{
break
;
}
}
if
(
subExpressionResult
)
{
matchingExpression
=
matchingExpression
.
substring
(
0
,
subExpression
.
lastIndex
);
}
}
return
matchingExpression
?
new
Range
(
range
.
startLineNumber
,
startOffset
,
range
.
endLineNumber
,
startOffset
+
matchingExpression
.
length
-
1
)
:
new
Range
(
range
.
startLineNumber
,
0
,
range
.
endLineNumber
,
0
);
}
src/vs/workbench/parts/debug/electron-browser/debugHover.ts
浏览文件 @
1637345e
...
...
@@ -28,6 +28,7 @@ import { editorHoverBackground, editorHoverBorder } from 'vs/platform/theme/comm
import
{
WorkbenchTree
,
WorkbenchTreeController
}
from
'
vs/platform/list/browser/listService
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
ModelDecorationOptions
}
from
'
vs/editor/common/model/textModel
'
;
import
{
getExactExpressionRange
}
from
'
vs/workbench/parts/debug/common/debugUtils
'
;
const
$
=
dom
.
$
;
const
MAX_ELEMENTS_SHOWN
=
18
;
...
...
@@ -138,55 +139,12 @@ export class DebugHoverWidget implements IContentWidget {
return
this
.
domNode
;
}
private
getExactExpressionRange
(
lineContent
:
string
,
range
:
Range
):
Range
{
let
matchingExpression
:
string
=
undefined
;
let
startOffset
=
0
;
// Some example supported expressions: myVar.prop, a.b.c.d, myVar?.prop, myVar->prop, MyClass::StaticProp, *myVar
// Match any character except a set of characters which often break interesting sub-expressions
let
expression
:
RegExp
=
/
([^
()
\[\]
{}<>
\s
+
\-/
%~#^;=|,`!
]
|
\-
>
)
+/g
;
let
result
:
RegExpExecArray
=
undefined
;
// First find the full expression under the cursor
while
(
result
=
expression
.
exec
(
lineContent
))
{
let
start
=
result
.
index
+
1
;
let
end
=
start
+
result
[
0
].
length
;
if
(
start
<=
range
.
startColumn
&&
end
>=
range
.
endColumn
)
{
matchingExpression
=
result
[
0
];
startOffset
=
start
;
break
;
}
}
// If there are non-word characters after the cursor, we want to truncate the expression then.
// For example in expression 'a.b.c.d', if the focus was under 'b', 'a.b' would be evaluated.
if
(
matchingExpression
)
{
let
subExpression
:
RegExp
=
/
\w
+/g
;
let
subExpressionResult
:
RegExpExecArray
=
undefined
;
while
(
subExpressionResult
=
subExpression
.
exec
(
matchingExpression
))
{
let
subEnd
=
subExpressionResult
.
index
+
1
+
startOffset
+
subExpressionResult
[
0
].
length
;
if
(
subEnd
>=
range
.
endColumn
)
{
break
;
}
}
if
(
subExpressionResult
)
{
matchingExpression
=
matchingExpression
.
substring
(
0
,
subExpression
.
lastIndex
);
}
}
return
matchingExpression
?
new
Range
(
range
.
startLineNumber
,
startOffset
,
range
.
endLineNumber
,
startOffset
+
matchingExpression
.
length
-
1
)
:
new
Range
(
range
.
startLineNumber
,
0
,
range
.
endLineNumber
,
0
);
}
public
showAt
(
range
:
Range
,
focus
:
boolean
):
TPromise
<
void
>
{
const
pos
=
range
.
getStartPosition
();
const
process
=
this
.
debugService
.
getViewModel
().
focusedProcess
;
const
lineContent
=
this
.
editor
.
getModel
().
getLineContent
(
pos
.
lineNumber
);
const
expressionRange
=
this
.
getExactExpressionRange
(
lineContent
,
range
);
const
expressionRange
=
getExactExpressionRange
(
lineContent
,
range
);
// use regex to extract the sub-expression #9821
const
matchingExpression
=
lineContent
.
substring
(
expressionRange
.
startColumn
-
1
,
expressionRange
.
endColumn
);
if
(
!
matchingExpression
)
{
...
...
src/vs/workbench/parts/debug/electron-browser/rawDebugSession.ts
浏览文件 @
1637345e
...
...
@@ -17,6 +17,7 @@ import { IOutputService } from 'vs/workbench/parts/output/common/output';
import
{
IWorkspaceFolder
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
INotificationService
}
from
'
vs/platform/notification/common/notification
'
;
import
{
StreamDebugAdapter
}
from
'
vs/workbench/parts/debug/node/debugAdapter
'
;
import
{
formatPII
}
from
'
vs/workbench/parts/debug/common/debugUtils
'
;
export
interface
SessionExitedEvent
extends
debug
.
DebugEvent
{
...
...
@@ -211,7 +212,7 @@ export class RawDebugSession implements debug.ISession {
const
promise
=
this
.
internalSend
<
R
>
(
command
,
args
).
then
(
response
=>
response
,
(
errorResponse
:
DebugProtocol
.
ErrorResponse
)
=>
{
const
error
=
errorResponse
&&
errorResponse
.
body
?
errorResponse
.
body
.
error
:
null
;
const
errorMessage
=
errorResponse
?
errorResponse
.
message
:
''
;
const
telemetryMessage
=
error
?
debug
.
formatPII
(
error
.
format
,
true
,
error
.
variables
)
:
errorMessage
;
const
telemetryMessage
=
error
?
formatPII
(
error
.
format
,
true
,
error
.
variables
)
:
errorMessage
;
if
(
error
&&
error
.
sendTelemetry
)
{
/* __GDPR__
"debugProtocolErrorResponse" : {
...
...
@@ -228,7 +229,7 @@ export class RawDebugSession implements debug.ISession {
}
}
const
userMessage
=
error
?
debug
.
formatPII
(
error
.
format
,
false
,
error
.
variables
)
:
errorMessage
;
const
userMessage
=
error
?
formatPII
(
error
.
format
,
false
,
error
.
variables
)
:
errorMessage
;
if
(
error
&&
error
.
url
)
{
const
label
=
error
.
urlLabel
?
error
.
urlLabel
:
nls
.
localize
(
'
moreInfo
'
,
"
More Info
"
);
return
TPromise
.
wrapError
<
R
>
(
errors
.
create
(
userMessage
,
{
...
...
src/vs/workbench/parts/debug/test/common/debugUtils.test.ts
浏览文件 @
1637345e
...
...
@@ -3,18 +3,18 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
*
as
debug
from
'
vs/workbench/parts/debug/common/debug
'
;
import
*
as
assert
from
'
assert
'
;
import
{
formatPII
}
from
'
vs/workbench/parts/debug/common/debugUtils
'
;
suite
(
'
Debug - Utils
'
,
()
=>
{
test
(
'
formatPII
'
,
()
=>
{
assert
.
strictEqual
(
debug
.
formatPII
(
'
Foo Bar
'
,
false
,
{}),
'
Foo Bar
'
);
assert
.
strictEqual
(
debug
.
formatPII
(
'
Foo {key} Bar
'
,
false
,
{}),
'
Foo {key} Bar
'
);
assert
.
strictEqual
(
debug
.
formatPII
(
'
Foo {key} Bar
'
,
false
,
{
'
key
'
:
'
yes
'
}),
'
Foo yes Bar
'
);
assert
.
strictEqual
(
debug
.
formatPII
(
'
Foo {_0} Bar {_0}
'
,
true
,
{
'
_0
'
:
'
yes
'
}),
'
Foo yes Bar yes
'
);
assert
.
strictEqual
(
debug
.
formatPII
(
'
Foo {0} Bar {1}{2}
'
,
false
,
{
'
0
'
:
'
yes
'
}),
'
Foo yes Bar {1}{2}
'
);
assert
.
strictEqual
(
debug
.
formatPII
(
'
Foo {0} Bar {1}{2}
'
,
false
,
{
'
0
'
:
'
yes
'
,
'
1
'
:
'
undefined
'
}),
'
Foo yes Bar undefined{2}
'
);
assert
.
strictEqual
(
debug
.
formatPII
(
'
Foo {_key0} Bar {key1}{key2}
'
,
true
,
{
'
_key0
'
:
'
yes
'
,
'
key1
'
:
'
5
'
,
'
key2
'
:
'
false
'
}),
'
Foo yes Bar {key1}{key2}
'
);
assert
.
strictEqual
(
debug
.
formatPII
(
'
Foo {_key0} Bar {key1}{key2}
'
,
false
,
{
'
_key0
'
:
'
yes
'
,
'
key1
'
:
'
5
'
,
'
key2
'
:
'
false
'
}),
'
Foo yes Bar 5false
'
);
assert
.
strictEqual
(
formatPII
(
'
Foo Bar
'
,
false
,
{}),
'
Foo Bar
'
);
assert
.
strictEqual
(
formatPII
(
'
Foo {key} Bar
'
,
false
,
{}),
'
Foo {key} Bar
'
);
assert
.
strictEqual
(
formatPII
(
'
Foo {key} Bar
'
,
false
,
{
'
key
'
:
'
yes
'
}),
'
Foo yes Bar
'
);
assert
.
strictEqual
(
formatPII
(
'
Foo {_0} Bar {_0}
'
,
true
,
{
'
_0
'
:
'
yes
'
}),
'
Foo yes Bar yes
'
);
assert
.
strictEqual
(
formatPII
(
'
Foo {0} Bar {1}{2}
'
,
false
,
{
'
0
'
:
'
yes
'
}),
'
Foo yes Bar {1}{2}
'
);
assert
.
strictEqual
(
formatPII
(
'
Foo {0} Bar {1}{2}
'
,
false
,
{
'
0
'
:
'
yes
'
,
'
1
'
:
'
undefined
'
}),
'
Foo yes Bar undefined{2}
'
);
assert
.
strictEqual
(
formatPII
(
'
Foo {_key0} Bar {key1}{key2}
'
,
true
,
{
'
_key0
'
:
'
yes
'
,
'
key1
'
:
'
5
'
,
'
key2
'
:
'
false
'
}),
'
Foo yes Bar {key1}{key2}
'
);
assert
.
strictEqual
(
formatPII
(
'
Foo {_key0} Bar {key1}{key2}
'
,
false
,
{
'
_key0
'
:
'
yes
'
,
'
key1
'
:
'
5
'
,
'
key2
'
:
'
false
'
}),
'
Foo yes Bar 5false
'
);
});
});
\ No newline at end of file
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录