Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
78f6a691
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
78f6a691
编写于
8月 17, 2018
作者:
I
isidor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
move debug session to a seperate file in electron-browser
上级
c0f818e5
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
257 addition
and
206 deletion
+257
-206
src/vs/workbench/parts/debug/browser/debugActions.ts
src/vs/workbench/parts/debug/browser/debugActions.ts
+3
-3
src/vs/workbench/parts/debug/common/debug.ts
src/vs/workbench/parts/debug/common/debug.ts
+5
-1
src/vs/workbench/parts/debug/common/debugModel.ts
src/vs/workbench/parts/debug/common/debugModel.ts
+5
-180
src/vs/workbench/parts/debug/electron-browser/callStackView.ts
...s/workbench/parts/debug/electron-browser/callStackView.ts
+2
-1
src/vs/workbench/parts/debug/electron-browser/debugService.ts
...vs/workbench/parts/debug/electron-browser/debugService.ts
+4
-2
src/vs/workbench/parts/debug/electron-browser/debugSession.ts
...vs/workbench/parts/debug/electron-browser/debugSession.ts
+176
-0
src/vs/workbench/parts/debug/test/browser/baseDebugView.test.ts
.../workbench/parts/debug/test/browser/baseDebugView.test.ts
+2
-3
src/vs/workbench/parts/debug/test/common/debugViewModel.test.ts
.../workbench/parts/debug/test/common/debugViewModel.test.ts
+2
-3
src/vs/workbench/parts/debug/test/common/mockDebug.ts
src/vs/workbench/parts/debug/test/common/mockDebug.ts
+47
-2
src/vs/workbench/parts/debug/test/electron-browser/debugModel.test.ts
...ench/parts/debug/test/electron-browser/debugModel.test.ts
+11
-11
未找到文件。
src/vs/workbench/parts/debug/browser/debugActions.ts
浏览文件 @
78f6a691
...
...
@@ -14,7 +14,7 @@ import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
{
IDebugService
,
State
,
ISession
,
IThread
,
IEnablement
,
IBreakpoint
,
IStackFrame
,
REPL_ID
,
SessionState
}
from
'
vs/workbench/parts/debug/common/debug
'
;
import
{
Variable
,
Expression
,
Thread
,
Breakpoint
,
Session
}
from
'
vs/workbench/parts/debug/common/debugModel
'
;
import
{
Variable
,
Expression
,
Thread
,
Breakpoint
}
from
'
vs/workbench/parts/debug/common/debugModel
'
;
import
{
IPartService
}
from
'
vs/workbench/services/part/common/partService
'
;
import
{
IPanelService
}
from
'
vs/workbench/services/panel/common/panelService
'
;
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
...
...
@@ -230,7 +230,7 @@ export class RestartAction extends AbstractDebugAction {
}
public
run
(
session
:
ISession
):
TPromise
<
any
>
{
if
(
!
(
session
instanceof
Session
)
)
{
if
(
!
session
||
!
session
.
getId
)
{
session
=
this
.
debugService
.
getViewModel
().
focusedSession
;
}
...
...
@@ -325,7 +325,7 @@ export class StopAction extends AbstractDebugAction {
}
public
run
(
session
:
ISession
):
TPromise
<
any
>
{
if
(
!
(
session
instanceof
Session
)
)
{
if
(
!
session
||
!
session
.
getId
)
{
session
=
this
.
debugService
.
getViewModel
().
focusedSession
;
}
...
...
src/vs/workbench/parts/debug/common/debug.ts
浏览文件 @
78f6a691
...
...
@@ -146,16 +146,20 @@ export enum SessionState {
}
export
interface
ISession
extends
ITreeElement
{
getName
(
includeRoot
:
boolean
):
string
;
readonly
configuration
:
IConfig
;
readonly
raw
:
IRawSession
;
readonly
state
:
SessionState
;
getName
(
includeRoot
:
boolean
):
string
;
getSourceForUri
(
modelUri
:
uri
):
Source
;
getThread
(
threadId
:
number
):
IThread
;
getAllThreads
():
ReadonlyArray
<
IThread
>
;
getSource
(
raw
:
DebugProtocol
.
Source
):
Source
;
getLoadedSources
():
TPromise
<
Source
[]
>
;
completions
(
frameId
:
number
,
text
:
string
,
position
:
Position
,
overwriteBefore
:
number
):
TPromise
<
ISuggestion
[]
>
;
clearThreads
(
removeThreads
:
boolean
,
reference
?:
number
):
void
;
rawUpdate
(
data
:
IRawModelUpdate
):
void
;
}
export
interface
IThread
extends
ITreeElement
{
...
...
src/vs/workbench/parts/debug/common/debugModel.ts
浏览文件 @
78f6a691
...
...
@@ -16,14 +16,11 @@ import severity from 'vs/base/common/severity';
import
{
isObject
,
isString
,
isUndefinedOrNull
}
from
'
vs/base/common/types
'
;
import
{
distinct
}
from
'
vs/base/common/arrays
'
;
import
{
Range
,
IRange
}
from
'
vs/editor/common/core/range
'
;
import
{
ISuggestion
}
from
'
vs/editor/common/modes
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
ITreeElement
,
IExpression
,
IExpressionContainer
,
ISession
,
IStackFrame
,
IExceptionBreakpoint
,
IBreakpoint
,
IFunctionBreakpoint
,
IModel
,
IReplElementSource
,
I
Config
,
IRawSession
,
IThread
,
IRawModelUpdate
,
IScope
,
IRawStoppedDetails
,
IEnablement
,
IBreakpointData
,
IExceptionInfo
,
IReplElement
,
SessionState
,
IBreakpointsChangeEvent
,
IBreakpointUpdateData
,
IBaseBreakpoint
I
Thread
,
IRawModelUpdate
,
IScope
,
IRawStoppedDetails
,
IEnablement
,
IBreakpointData
,
IExceptionInfo
,
IReplElement
,
IBreakpointsChangeEvent
,
IBreakpointUpdateData
,
IBaseBreakpoint
}
from
'
vs/workbench/parts/debug/common/debug
'
;
import
{
Source
}
from
'
vs/workbench/parts/debug/common/debugSource
'
;
import
{
mixin
}
from
'
vs/base/common/objects
'
;
import
{
commonSuffixLength
}
from
'
vs/base/common/strings
'
;
import
{
sep
}
from
'
vs/base/common/paths
'
;
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
...
...
@@ -552,175 +549,6 @@ export class Thread implements IThread {
}
}
export
class
Session
implements
ISession
{
private
sources
:
Map
<
string
,
Source
>
;
private
threads
:
Map
<
number
,
Thread
>
;
constructor
(
private
_configuration
:
{
resolved
:
IConfig
,
unresolved
:
IConfig
},
private
session
:
IRawSession
&
ITreeElement
)
{
this
.
threads
=
new
Map
<
number
,
Thread
>
();
this
.
sources
=
new
Map
<
string
,
Source
>
();
}
public
get
configuration
():
IConfig
{
return
this
.
_configuration
.
resolved
;
}
public
get
unresolvedConfiguration
():
IConfig
{
return
this
.
_configuration
.
unresolved
;
}
public
get
raw
():
IRawSession
&
ITreeElement
{
return
this
.
session
;
}
public
set
raw
(
value
:
IRawSession
&
ITreeElement
)
{
this
.
session
=
value
;
}
public
getName
(
includeRoot
:
boolean
):
string
{
return
includeRoot
&&
this
.
raw
.
root
?
`
${
this
.
configuration
.
name
}
(
${
resources
.
basenameOrAuthority
(
this
.
raw
.
root
.
uri
)}
)`
:
this
.
configuration
.
name
;
}
public
get
state
():
SessionState
{
return
this
.
configuration
.
type
===
'
attach
'
?
SessionState
.
ATTACH
:
SessionState
.
LAUNCH
;
}
public
getSourceForUri
(
modelUri
:
uri
):
Source
{
return
this
.
sources
.
get
(
modelUri
.
toString
());
}
public
getSource
(
raw
:
DebugProtocol
.
Source
):
Source
{
let
source
=
new
Source
(
raw
,
this
.
getId
());
if
(
this
.
sources
.
has
(
source
.
uri
.
toString
()))
{
source
=
this
.
sources
.
get
(
source
.
uri
.
toString
());
source
.
raw
=
mixin
(
source
.
raw
,
raw
);
if
(
source
.
raw
&&
raw
)
{
// Always take the latest presentation hint from adapter #42139
source
.
raw
.
presentationHint
=
raw
.
presentationHint
;
}
}
else
{
this
.
sources
.
set
(
source
.
uri
.
toString
(),
source
);
}
return
source
;
}
public
getThread
(
threadId
:
number
):
Thread
{
return
this
.
threads
.
get
(
threadId
);
}
public
getAllThreads
():
IThread
[]
{
const
result
:
IThread
[]
=
[];
this
.
threads
.
forEach
(
t
=>
result
.
push
(
t
));
return
result
;
}
public
getLoadedSources
():
TPromise
<
Source
[]
>
{
return
this
.
raw
.
loadedSources
({}).
then
(
response
=>
{
return
response
.
body
.
sources
.
map
(
src
=>
this
.
getSource
(
src
));
},
error
=>
{
return
[];
});
}
public
getId
():
string
{
return
this
.
session
.
getId
();
}
public
rawUpdate
(
data
:
IRawModelUpdate
):
void
{
if
(
data
.
thread
&&
!
this
.
threads
.
has
(
data
.
threadId
))
{
// A new thread came in, initialize it.
this
.
threads
.
set
(
data
.
threadId
,
new
Thread
(
this
,
data
.
thread
.
name
,
data
.
thread
.
id
));
}
else
if
(
data
.
thread
&&
data
.
thread
.
name
)
{
// Just the thread name got updated #18244
this
.
threads
.
get
(
data
.
threadId
).
name
=
data
.
thread
.
name
;
}
if
(
data
.
stoppedDetails
)
{
// Set the availability of the threads' callstacks depending on
// whether the thread is stopped or not
if
(
data
.
stoppedDetails
.
allThreadsStopped
)
{
this
.
threads
.
forEach
(
thread
=>
{
thread
.
stoppedDetails
=
thread
.
threadId
===
data
.
threadId
?
data
.
stoppedDetails
:
{
reason
:
undefined
};
thread
.
stopped
=
true
;
thread
.
clearCallStack
();
});
}
else
if
(
this
.
threads
.
has
(
data
.
threadId
))
{
// One thread is stopped, only update that thread.
const
thread
=
this
.
threads
.
get
(
data
.
threadId
);
thread
.
stoppedDetails
=
data
.
stoppedDetails
;
thread
.
clearCallStack
();
thread
.
stopped
=
true
;
}
}
}
public
clearThreads
(
removeThreads
:
boolean
,
reference
:
number
=
undefined
):
void
{
if
(
reference
!==
undefined
&&
reference
!==
null
)
{
if
(
this
.
threads
.
has
(
reference
))
{
const
thread
=
this
.
threads
.
get
(
reference
);
thread
.
clearCallStack
();
thread
.
stoppedDetails
=
undefined
;
thread
.
stopped
=
false
;
if
(
removeThreads
)
{
this
.
threads
.
delete
(
reference
);
}
}
}
else
{
this
.
threads
.
forEach
(
thread
=>
{
thread
.
clearCallStack
();
thread
.
stoppedDetails
=
undefined
;
thread
.
stopped
=
false
;
});
if
(
removeThreads
)
{
this
.
threads
.
clear
();
ExpressionContainer
.
allValues
.
clear
();
}
}
}
public
completions
(
frameId
:
number
,
text
:
string
,
position
:
Position
,
overwriteBefore
:
number
):
TPromise
<
ISuggestion
[]
>
{
if
(
!
this
.
raw
.
capabilities
.
supportsCompletionsRequest
)
{
return
TPromise
.
as
([]);
}
return
this
.
raw
.
completions
({
frameId
,
text
,
column
:
position
.
column
,
line
:
position
.
lineNumber
}).
then
(
response
=>
{
const
result
:
ISuggestion
[]
=
[];
if
(
response
&&
response
.
body
&&
response
.
body
.
targets
)
{
response
.
body
.
targets
.
forEach
(
item
=>
{
if
(
item
&&
item
.
label
)
{
result
.
push
({
label
:
item
.
label
,
insertText
:
item
.
text
||
item
.
label
,
type
:
item
.
type
,
filterText
:
item
.
start
&&
item
.
length
&&
text
.
substr
(
item
.
start
,
item
.
length
).
concat
(
item
.
label
),
overwriteBefore
:
item
.
length
||
overwriteBefore
});
}
});
}
return
result
;
},
()
=>
[]);
}
setNotAvailable
(
modelUri
:
uri
)
{
const
source
=
this
.
sources
.
get
(
modelUri
.
toString
());
if
(
source
)
{
source
.
available
=
false
;
}
}
}
export
class
Enablement
implements
IEnablement
{
constructor
(
public
enabled
:
boolean
,
...
...
@@ -905,7 +733,7 @@ export class ThreadAndSessionIds implements ITreeElement {
export
class
Model
implements
IModel
{
private
sessions
:
Session
[];
private
sessions
:
I
Session
[];
private
toDispose
:
lifecycle
.
IDisposable
[];
private
replElements
:
IReplElement
[];
private
schedulers
=
new
Map
<
string
,
RunOnceScheduler
>
();
...
...
@@ -935,15 +763,12 @@ export class Model implements IModel {
return
'
root
'
;
}
public
getSessions
():
Session
[]
{
public
getSessions
():
I
Session
[]
{
return
this
.
sessions
;
}
public
addSession
(
configuration
:
{
resolved
:
IConfig
,
unresolved
:
IConfig
},
raw
:
IRawSession
&
ITreeElement
):
Session
{
const
session
=
new
Session
(
configuration
,
raw
);
public
addSession
(
session
:
ISession
):
void
{
this
.
sessions
.
push
(
session
);
return
session
;
}
public
removeSession
(
id
:
string
):
void
{
...
...
@@ -1277,7 +1102,7 @@ export class Model implements IModel {
}
public
sourceIsNotAvailable
(
uri
:
uri
):
void
{
this
.
sessions
.
forEach
(
p
=>
p
.
setNotAvailable
(
uri
)
);
this
.
sessions
.
forEach
(
p
=>
p
.
getSourceForUri
(
uri
).
available
=
false
);
this
.
_onDidChangeCallStack
.
fire
();
}
...
...
src/vs/workbench/parts/debug/electron-browser/callStackView.ts
浏览文件 @
78f6a691
...
...
@@ -10,7 +10,7 @@ import { TPromise } from 'vs/base/common/winjs.base';
import
*
as
errors
from
'
vs/base/common/errors
'
;
import
{
TreeViewsViewletPanel
,
IViewletViewOptions
}
from
'
vs/workbench/browser/parts/views/viewsViewlet
'
;
import
{
IDebugService
,
State
,
IStackFrame
,
ISession
,
IThread
,
CONTEXT_CALLSTACK_ITEM_TYPE
}
from
'
vs/workbench/parts/debug/common/debug
'
;
import
{
Thread
,
StackFrame
,
ThreadAndSessionIds
,
Session
,
Model
}
from
'
vs/workbench/parts/debug/common/debugModel
'
;
import
{
Thread
,
StackFrame
,
ThreadAndSessionIds
,
Model
}
from
'
vs/workbench/parts/debug/common/debugModel
'
;
import
{
IContextMenuService
}
from
'
vs/platform/contextview/browser/contextView
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
MenuId
}
from
'
vs/platform/actions/common/actions
'
;
...
...
@@ -28,6 +28,7 @@ import { Separator } from 'vs/base/browser/ui/actionbar/actionbar';
import
{
IContextKey
,
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IViewletPanelOptions
}
from
'
vs/workbench/browser/parts/views/panelViewlet
'
;
import
{
IUriLabelService
}
from
'
vs/platform/uriLabel/common/uriLabel
'
;
import
{
Session
}
from
'
vs/workbench/parts/debug/electron-browser/debugSession
'
;
const
$
=
dom
.
$
;
...
...
src/vs/workbench/parts/debug/electron-browser/debugService.ts
浏览文件 @
78f6a691
...
...
@@ -28,7 +28,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import
{
IStorageService
,
StorageScope
}
from
'
vs/platform/storage/common/storage
'
;
import
*
as
debug
from
'
vs/workbench/parts/debug/common/debug
'
;
import
{
RawDebugSession
}
from
'
vs/workbench/parts/debug/electron-browser/rawDebugSession
'
;
import
{
Model
,
ExceptionBreakpoint
,
FunctionBreakpoint
,
Breakpoint
,
Expression
,
RawObjectReplElement
,
ExpressionContainer
,
Session
,
Thread
}
from
'
vs/workbench/parts/debug/common/debugModel
'
;
import
{
Model
,
ExceptionBreakpoint
,
FunctionBreakpoint
,
Breakpoint
,
Expression
,
RawObjectReplElement
,
ExpressionContainer
,
Thread
}
from
'
vs/workbench/parts/debug/common/debugModel
'
;
import
{
ViewModel
}
from
'
vs/workbench/parts/debug/common/debugViewModel
'
;
import
*
as
debugactions
from
'
vs/workbench/parts/debug/browser/debugActions
'
;
import
{
ConfigurationManager
}
from
'
vs/workbench/parts/debug/electron-browser/debugConfigurationManager
'
;
...
...
@@ -55,6 +55,7 @@ import { normalizeDriveLetter } from 'vs/base/common/labels';
import
{
RunOnceScheduler
}
from
'
vs/base/common/async
'
;
import
product
from
'
vs/platform/node/product
'
;
import
{
deepClone
,
equals
}
from
'
vs/base/common/objects
'
;
import
{
Session
}
from
'
vs/workbench/parts/debug/electron-browser/debugSession
'
;
const
DEBUG_BREAKPOINTS_KEY
=
'
debug.breakpoint
'
;
const
DEBUG_BREAKPOINTS_ACTIVATED_KEY
=
'
debug.breakpointactivated
'
;
...
...
@@ -895,7 +896,8 @@ export class DebugService implements debug.IDebugService {
const
raw
=
this
.
instantiationService
.
createInstance
(
RawDebugSession
,
sessionId
,
configuration
.
resolved
.
debugServer
,
dbg
,
customTelemetryService
,
root
);
if
(
!
session
)
{
session
=
this
.
model
.
addSession
(
configuration
,
raw
);
session
=
new
Session
(
configuration
,
raw
);
this
.
model
.
addSession
(
session
);
this
.
allSessions
.
set
(
session
.
getId
(),
session
);
}
else
{
session
.
raw
=
raw
;
...
...
src/vs/workbench/parts/debug/electron-browser/debugSession.ts
0 → 100644
浏览文件 @
78f6a691
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
uri
from
'
vs/base/common/uri
'
;
import
*
as
resources
from
'
vs/base/common/resources
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
ISuggestion
}
from
'
vs/editor/common/modes
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
ITreeElement
,
ISession
,
IConfig
,
IRawSession
,
IThread
,
IRawModelUpdate
,
SessionState
}
from
'
vs/workbench/parts/debug/common/debug
'
;
import
{
Source
}
from
'
vs/workbench/parts/debug/common/debugSource
'
;
import
{
mixin
}
from
'
vs/base/common/objects
'
;
import
{
Thread
,
ExpressionContainer
}
from
'
vs/workbench/parts/debug/common/debugModel
'
;
export
class
Session
implements
ISession
{
private
sources
:
Map
<
string
,
Source
>
;
private
threads
:
Map
<
number
,
Thread
>
;
constructor
(
private
_configuration
:
{
resolved
:
IConfig
,
unresolved
:
IConfig
},
private
session
:
IRawSession
&
ITreeElement
)
{
this
.
threads
=
new
Map
<
number
,
Thread
>
();
this
.
sources
=
new
Map
<
string
,
Source
>
();
}
public
get
configuration
():
IConfig
{
return
this
.
_configuration
.
resolved
;
}
public
get
unresolvedConfiguration
():
IConfig
{
return
this
.
_configuration
.
unresolved
;
}
public
get
raw
():
IRawSession
&
ITreeElement
{
return
this
.
session
;
}
public
set
raw
(
value
:
IRawSession
&
ITreeElement
)
{
this
.
session
=
value
;
}
public
getName
(
includeRoot
:
boolean
):
string
{
return
includeRoot
&&
this
.
raw
.
root
?
`
${
this
.
configuration
.
name
}
(
${
resources
.
basenameOrAuthority
(
this
.
raw
.
root
.
uri
)}
)`
:
this
.
configuration
.
name
;
}
public
get
state
():
SessionState
{
return
this
.
configuration
.
type
===
'
attach
'
?
SessionState
.
ATTACH
:
SessionState
.
LAUNCH
;
}
public
getSourceForUri
(
modelUri
:
uri
):
Source
{
return
this
.
sources
.
get
(
modelUri
.
toString
());
}
public
getSource
(
raw
:
DebugProtocol
.
Source
):
Source
{
let
source
=
new
Source
(
raw
,
this
.
getId
());
if
(
this
.
sources
.
has
(
source
.
uri
.
toString
()))
{
source
=
this
.
sources
.
get
(
source
.
uri
.
toString
());
source
.
raw
=
mixin
(
source
.
raw
,
raw
);
if
(
source
.
raw
&&
raw
)
{
// Always take the latest presentation hint from adapter #42139
source
.
raw
.
presentationHint
=
raw
.
presentationHint
;
}
}
else
{
this
.
sources
.
set
(
source
.
uri
.
toString
(),
source
);
}
return
source
;
}
public
getThread
(
threadId
:
number
):
Thread
{
return
this
.
threads
.
get
(
threadId
);
}
public
getAllThreads
():
IThread
[]
{
const
result
:
IThread
[]
=
[];
this
.
threads
.
forEach
(
t
=>
result
.
push
(
t
));
return
result
;
}
public
getLoadedSources
():
TPromise
<
Source
[]
>
{
return
this
.
raw
.
loadedSources
({}).
then
(
response
=>
{
return
response
.
body
.
sources
.
map
(
src
=>
this
.
getSource
(
src
));
},
error
=>
{
return
[];
});
}
public
getId
():
string
{
return
this
.
session
.
getId
();
}
public
rawUpdate
(
data
:
IRawModelUpdate
):
void
{
if
(
data
.
thread
&&
!
this
.
threads
.
has
(
data
.
threadId
))
{
// A new thread came in, initialize it.
this
.
threads
.
set
(
data
.
threadId
,
new
Thread
(
this
,
data
.
thread
.
name
,
data
.
thread
.
id
));
}
else
if
(
data
.
thread
&&
data
.
thread
.
name
)
{
// Just the thread name got updated #18244
this
.
threads
.
get
(
data
.
threadId
).
name
=
data
.
thread
.
name
;
}
if
(
data
.
stoppedDetails
)
{
// Set the availability of the threads' callstacks depending on
// whether the thread is stopped or not
if
(
data
.
stoppedDetails
.
allThreadsStopped
)
{
this
.
threads
.
forEach
(
thread
=>
{
thread
.
stoppedDetails
=
thread
.
threadId
===
data
.
threadId
?
data
.
stoppedDetails
:
{
reason
:
undefined
};
thread
.
stopped
=
true
;
thread
.
clearCallStack
();
});
}
else
if
(
this
.
threads
.
has
(
data
.
threadId
))
{
// One thread is stopped, only update that thread.
const
thread
=
this
.
threads
.
get
(
data
.
threadId
);
thread
.
stoppedDetails
=
data
.
stoppedDetails
;
thread
.
clearCallStack
();
thread
.
stopped
=
true
;
}
}
}
public
clearThreads
(
removeThreads
:
boolean
,
reference
:
number
=
undefined
):
void
{
if
(
reference
!==
undefined
&&
reference
!==
null
)
{
if
(
this
.
threads
.
has
(
reference
))
{
const
thread
=
this
.
threads
.
get
(
reference
);
thread
.
clearCallStack
();
thread
.
stoppedDetails
=
undefined
;
thread
.
stopped
=
false
;
if
(
removeThreads
)
{
this
.
threads
.
delete
(
reference
);
}
}
}
else
{
this
.
threads
.
forEach
(
thread
=>
{
thread
.
clearCallStack
();
thread
.
stoppedDetails
=
undefined
;
thread
.
stopped
=
false
;
});
if
(
removeThreads
)
{
this
.
threads
.
clear
();
ExpressionContainer
.
allValues
.
clear
();
}
}
}
public
completions
(
frameId
:
number
,
text
:
string
,
position
:
Position
,
overwriteBefore
:
number
):
TPromise
<
ISuggestion
[]
>
{
if
(
!
this
.
raw
.
capabilities
.
supportsCompletionsRequest
)
{
return
TPromise
.
as
([]);
}
return
this
.
raw
.
completions
({
frameId
,
text
,
column
:
position
.
column
,
line
:
position
.
lineNumber
}).
then
(
response
=>
{
const
result
:
ISuggestion
[]
=
[];
if
(
response
&&
response
.
body
&&
response
.
body
.
targets
)
{
response
.
body
.
targets
.
forEach
(
item
=>
{
if
(
item
&&
item
.
label
)
{
result
.
push
({
label
:
item
.
label
,
insertText
:
item
.
text
||
item
.
label
,
type
:
item
.
type
,
filterText
:
item
.
start
&&
item
.
length
&&
text
.
substr
(
item
.
start
,
item
.
length
).
concat
(
item
.
label
),
overwriteBefore
:
item
.
length
||
overwriteBefore
});
}
});
}
return
result
;
},
()
=>
[]);
}
}
src/vs/workbench/parts/debug/test/browser/baseDebugView.test.ts
浏览文件 @
78f6a691
...
...
@@ -6,7 +6,7 @@
import
*
as
assert
from
'
assert
'
;
import
{
replaceWhitespace
,
renderExpressionValue
,
renderVariable
}
from
'
vs/workbench/parts/debug/browser/baseDebugView
'
;
import
*
as
dom
from
'
vs/base/browser/dom
'
;
import
{
Expression
,
Variable
,
S
ession
,
S
cope
,
StackFrame
,
Thread
}
from
'
vs/workbench/parts/debug/common/debugModel
'
;
import
{
Expression
,
Variable
,
Scope
,
StackFrame
,
Thread
}
from
'
vs/workbench/parts/debug/common/debugModel
'
;
import
{
MockSession
}
from
'
vs/workbench/parts/debug/test/common/mockDebug
'
;
const
$
=
dom
.
$
;
...
...
@@ -52,8 +52,7 @@ suite('Debug - Base Debug View', () => {
});
test
(
'
render variable
'
,
()
=>
{
const
rawSession
=
new
MockSession
();
const
session
=
new
Session
({
resolved
:
{
name
:
'
mockSession
'
,
type
:
'
node
'
,
request
:
'
launch
'
},
unresolved
:
undefined
},
rawSession
);
const
session
=
new
MockSession
();
const
thread
=
new
Thread
(
session
,
'
mockthread
'
,
1
);
const
stackFrame
=
new
StackFrame
(
thread
,
1
,
null
,
'
app.js
'
,
'
normal
'
,
{
startLineNumber
:
1
,
startColumn
:
1
,
endLineNumber
:
undefined
,
endColumn
:
undefined
},
0
);
const
scope
=
new
Scope
(
stackFrame
,
1
,
'
local
'
,
1
,
false
,
10
,
10
);
...
...
src/vs/workbench/parts/debug/test/common/debugViewModel.test.ts
浏览文件 @
78f6a691
...
...
@@ -5,7 +5,7 @@
import
*
as
assert
from
'
assert
'
;
import
{
ViewModel
}
from
'
vs/workbench/parts/debug/common/debugViewModel
'
;
import
{
StackFrame
,
Expression
,
Thread
,
Session
}
from
'
vs/workbench/parts/debug/common/debugModel
'
;
import
{
StackFrame
,
Expression
,
Thread
}
from
'
vs/workbench/parts/debug/common/debugModel
'
;
import
{
MockSession
}
from
'
vs/workbench/parts/debug/test/common/mockDebug
'
;
import
{
MockContextKeyService
}
from
'
vs/platform/keybinding/test/common/mockKeybindingService
'
;
...
...
@@ -23,8 +23,7 @@ suite('Debug - View Model', () => {
test
(
'
focused stack frame
'
,
()
=>
{
assert
.
equal
(
model
.
focusedStackFrame
,
null
);
assert
.
equal
(
model
.
focusedThread
,
null
);
const
mockSession
=
new
MockSession
();
const
session
=
new
Session
({
resolved
:
{
name
:
'
mockSession
'
,
type
:
'
node
'
,
request
:
'
launch
'
},
unresolved
:
undefined
},
mockSession
);
const
session
=
new
MockSession
();
const
thread
=
new
Thread
(
session
,
'
myThread
'
,
1
);
const
frame
=
new
StackFrame
(
thread
,
1
,
null
,
'
app.js
'
,
'
normal
'
,
{
startColumn
:
1
,
startLineNumber
:
1
,
endColumn
:
undefined
,
endLineNumber
:
undefined
},
0
);
model
.
setFocus
(
frame
,
thread
,
session
,
false
);
...
...
src/vs/workbench/parts/debug/test/common/mockDebug.ts
浏览文件 @
78f6a691
...
...
@@ -7,7 +7,10 @@ import uri from 'vs/base/common/uri';
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IWorkspaceFolder
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
ILaunch
,
IDebugService
,
State
,
DebugEvent
,
ISession
,
IConfigurationManager
,
IStackFrame
,
IBreakpointData
,
IBreakpointUpdateData
,
IConfig
,
IModel
,
IViewModel
,
IRawSession
,
IBreakpoint
,
LoadedSourceEvent
}
from
'
vs/workbench/parts/debug/common/debug
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
ILaunch
,
IDebugService
,
State
,
DebugEvent
,
ISession
,
IConfigurationManager
,
IStackFrame
,
IBreakpointData
,
IBreakpointUpdateData
,
IConfig
,
IModel
,
IViewModel
,
IRawSession
,
IBreakpoint
,
LoadedSourceEvent
,
SessionState
,
IThread
,
IRawModelUpdate
}
from
'
vs/workbench/parts/debug/common/debug
'
;
import
{
Source
}
from
'
vs/workbench/parts/debug/common/debugSource
'
;
import
{
ISuggestion
}
from
'
vs/editor/common/modes
'
;
export
class
MockDebugService
implements
IDebugService
{
public
_serviceBrand
:
any
;
...
...
@@ -114,7 +117,49 @@ export class MockDebugService implements IDebugService {
public
sourceIsNotAvailable
(
uri
:
uri
):
void
{
}
}
export
class
MockSession
implements
IRawSession
{
export
class
MockSession
implements
ISession
{
configuration
:
IConfig
=
{
type
:
'
mock
'
,
request
:
'
launch
'
};
raw
:
IRawSession
=
new
MockRawSession
();
state
=
SessionState
.
LAUNCH
;
getName
(
includeRoot
:
boolean
):
string
{
return
'
mockname
'
;
}
getSourceForUri
(
modelUri
:
uri
):
Source
{
return
null
;
}
getThread
(
threadId
:
number
):
IThread
{
return
null
;
}
getAllThreads
():
ReadonlyArray
<
IThread
>
{
return
[];
}
getSource
(
raw
:
DebugProtocol
.
Source
):
Source
{
return
undefined
;
}
getLoadedSources
():
TPromise
<
Source
[]
>
{
return
TPromise
.
as
([]);
}
completions
(
frameId
:
number
,
text
:
string
,
position
:
Position
,
overwriteBefore
:
number
):
TPromise
<
ISuggestion
[]
>
{
return
TPromise
.
as
([]);
}
clearThreads
(
removeThreads
:
boolean
,
reference
?:
number
):
void
{
}
rawUpdate
(
data
:
IRawModelUpdate
):
void
{
}
getId
():
string
{
return
'
mock
'
;
}
}
export
class
MockRawSession
implements
IRawSession
{
public
readyForBreakpoints
=
true
;
public
emittedStopped
=
true
;
...
...
src/vs/workbench/parts/debug/test/
node
/debugModel.test.ts
→
src/vs/workbench/parts/debug/test/
electron-browser
/debugModel.test.ts
浏览文件 @
78f6a691
...
...
@@ -6,18 +6,19 @@
import
*
as
assert
from
'
assert
'
;
import
uri
from
'
vs/base/common/uri
'
;
import
severity
from
'
vs/base/common/severity
'
;
import
{
SimpleReplElement
,
Model
,
Session
,
Expression
,
RawObjectReplElement
,
StackFrame
,
Thread
}
from
'
vs/workbench/parts/debug/common/debugModel
'
;
import
{
SimpleReplElement
,
Model
,
Expression
,
RawObjectReplElement
,
StackFrame
,
Thread
}
from
'
vs/workbench/parts/debug/common/debugModel
'
;
import
*
as
sinon
from
'
sinon
'
;
import
{
MockSession
}
from
'
vs/workbench/parts/debug/test/common/mockDebug
'
;
import
{
Mock
Raw
Session
}
from
'
vs/workbench/parts/debug/test/common/mockDebug
'
;
import
{
Source
}
from
'
vs/workbench/parts/debug/common/debugSource
'
;
import
{
Session
}
from
'
vs/workbench/parts/debug/electron-browser/debugSession
'
;
suite
(
'
Debug - Model
'
,
()
=>
{
let
model
:
Model
;
let
rawSession
:
MockSession
;
let
rawSession
:
Mock
Raw
Session
;
setup
(()
=>
{
model
=
new
Model
([],
true
,
[],
[],
[]);
rawSession
=
new
MockSession
();
rawSession
=
new
Mock
Raw
Session
();
});
teardown
(()
=>
{
...
...
@@ -108,8 +109,8 @@ suite('Debug - Model', () => {
test
(
'
threads simple
'
,
()
=>
{
const
threadId
=
1
;
const
threadName
=
'
firstThread
'
;
model
.
addSession
(
{
resolved
:
{
name
:
'
mockSession
'
,
type
:
'
node
'
,
request
:
'
launch
'
},
unresolved
:
undefined
},
rawS
ession
);
const
session
=
new
Session
({
resolved
:
{
name
:
'
mockSession
'
,
type
:
'
node
'
,
request
:
'
launch
'
},
unresolved
:
undefined
},
rawSession
);
model
.
addSession
(
s
ession
);
assert
.
equal
(
model
.
getSessions
().
length
,
1
);
model
.
rawUpdate
({
sessionId
:
rawSession
.
getId
(),
...
...
@@ -119,7 +120,6 @@ suite('Debug - Model', () => {
name
:
threadName
}
});
const
session
=
model
.
getSessions
().
filter
(
p
=>
p
.
getId
()
===
rawSession
.
getId
()).
pop
();
assert
.
equal
(
session
.
getThread
(
threadId
).
name
,
threadName
);
...
...
@@ -140,7 +140,8 @@ suite('Debug - Model', () => {
const
stoppedReason
=
'
breakpoint
'
;
// Add the threads
model
.
addSession
({
resolved
:
{
name
:
'
mockSession
'
,
type
:
'
node
'
,
request
:
'
launch
'
},
unresolved
:
undefined
},
rawSession
);
const
session
=
new
Session
({
resolved
:
{
name
:
'
mockSession
'
,
type
:
'
node
'
,
request
:
'
launch
'
},
unresolved
:
undefined
},
rawSession
);
model
.
addSession
(
session
);
model
.
rawUpdate
({
sessionId
:
rawSession
.
getId
(),
threadId
:
threadId1
,
...
...
@@ -169,7 +170,6 @@ suite('Debug - Model', () => {
allThreadsStopped
:
true
},
});
const
session
=
model
.
getSessions
().
filter
(
p
=>
p
.
getId
()
===
rawSession
.
getId
()).
pop
();
const
thread1
=
session
.
getThread
(
threadId1
);
const
thread2
=
session
.
getThread
(
threadId2
);
...
...
@@ -230,7 +230,8 @@ suite('Debug - Model', () => {
const
runningThreadId
=
2
;
const
runningThreadName
=
'
runningThread
'
;
const
stoppedReason
=
'
breakpoint
'
;
model
.
addSession
({
resolved
:
{
name
:
'
mockSession
'
,
type
:
'
node
'
,
request
:
'
launch
'
},
unresolved
:
undefined
},
rawSession
);
const
session
=
new
Session
({
resolved
:
{
name
:
'
mockSession
'
,
type
:
'
node
'
,
request
:
'
launch
'
},
unresolved
:
undefined
},
rawSession
);
model
.
addSession
(
session
);
// Add the threads
model
.
rawUpdate
({
sessionId
:
rawSession
.
getId
(),
...
...
@@ -260,7 +261,6 @@ suite('Debug - Model', () => {
allThreadsStopped
:
false
}
});
const
session
=
model
.
getSessions
().
filter
(
p
=>
p
.
getId
()
===
rawSession
.
getId
()).
pop
();
const
stoppedThread
=
session
.
getThread
(
stoppedThreadId
);
const
runningThread
=
session
.
getThread
(
runningThreadId
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录