Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
fbcdb4c6
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,发现更多精彩内容 >>
提交
fbcdb4c6
编写于
6月 22, 2017
作者:
A
Andre Weinand
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add proposed debug API; fixes #28234
上级
55a46397
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
240 addition
and
0 deletion
+240
-0
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+63
-0
src/vs/workbench/api/electron-browser/extensionHost.contribution.ts
...kbench/api/electron-browser/extensionHost.contribution.ts
+2
-0
src/vs/workbench/api/electron-browser/mainThreadDebugService.ts
.../workbench/api/electron-browser/mainThreadDebugService.ts
+68
-0
src/vs/workbench/api/node/extHost.api.impl.ts
src/vs/workbench/api/node/extHost.api.impl.ts
+14
-0
src/vs/workbench/api/node/extHost.protocol.ts
src/vs/workbench/api/node/extHost.protocol.ts
+13
-0
src/vs/workbench/api/node/extHostDebugService.ts
src/vs/workbench/api/node/extHostDebugService.ts
+80
-0
未找到文件。
src/vs/vscode.proposed.d.ts
浏览文件 @
fbcdb4c6
...
...
@@ -460,4 +460,67 @@ declare module 'vscode' {
*/
onData
(
callback
:
(
data
:
string
)
=>
any
):
void
;
}
/**
* Namespace for dealing with debug sessions.
*/
export
namespace
debug
{
/**
* An [event](#Event) which fires when a debug session has terminated.
*/
export
const
onDidTerminateDebugSession
:
Event
<
DebugSession
>
;
/**
* Create a new debug session based on the given launchConfig.
* @param launchConfig
*/
export
function
createDebugSession
(
launchConfig
:
DebugConfiguration
):
Thenable
<
DebugSession
>
;
}
/**
* Configuration for a debug session.
*/
export
interface
DebugConfiguration
{
/**
* The type for the debug session.
*/
type
:
string
;
/**
* An optional name for the debug session.
*/
name
?:
string
;
/**
* The request type of the debug session.
*/
request
:
string
;
/**
* Additional debug type specific properties.
*/
[
key
:
string
]:
any
;
}
/**
* A debug session.
*/
export
interface
DebugSession
{
/**
* The debug session's type from the debug configuration.
*/
readonly
type
:
string
;
/**
* The debug session's name from the debug configuration.
*/
readonly
name
:
string
;
/**
* Send a custom request to the debug adapter.
*/
customRequest
(
command
:
string
,
args
?:
any
):
Thenable
<
any
>
;
}
}
src/vs/workbench/api/electron-browser/extensionHost.contribution.ts
浏览文件 @
fbcdb4c6
...
...
@@ -15,6 +15,7 @@ import { IExtensionService } from 'vs/platform/extensions/common/extensions';
// --- addressable
import
{
MainThreadCommands
}
from
'
./mainThreadCommands
'
;
import
{
MainThreadConfiguration
}
from
'
./mainThreadConfiguration
'
;
import
{
MainThreadDebugService
}
from
'
./mainThreadDebugService
'
;
import
{
MainThreadDiagnostics
}
from
'
./mainThreadDiagnostics
'
;
import
{
MainThreadDocuments
}
from
'
./mainThreadDocuments
'
;
import
{
MainThreadEditors
}
from
'
./mainThreadEditors
'
;
...
...
@@ -70,6 +71,7 @@ export class ExtHostContribution implements IWorkbenchContribution {
const
col
=
new
InstanceCollection
();
col
.
define
(
MainContext
.
MainThreadCommands
).
set
(
create
(
MainThreadCommands
));
col
.
define
(
MainContext
.
MainThreadConfiguration
).
set
(
create
(
MainThreadConfiguration
));
col
.
define
(
MainContext
.
MainThreadDebugService
).
set
(
create
(
MainThreadDebugService
));
col
.
define
(
MainContext
.
MainThreadDiagnostics
).
set
(
create
(
MainThreadDiagnostics
));
col
.
define
(
MainContext
.
MainThreadDocuments
).
set
(
this
.
instantiationService
.
createInstance
(
MainThreadDocuments
,
documentsAndEditors
));
col
.
define
(
MainContext
.
MainThreadEditors
).
set
(
this
.
instantiationService
.
createInstance
(
MainThreadEditors
,
documentsAndEditors
));
...
...
src/vs/workbench/api/electron-browser/mainThreadDebugService.ts
0 → 100644
浏览文件 @
fbcdb4c6
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDebugService
,
IProcess
,
IConfig
}
from
'
vs/workbench/parts/debug/common/debug
'
;
import
{
IThreadService
}
from
'
vs/workbench/services/thread/common/threadService
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
ExtHostContext
,
ExtHostDebugServiceShape
,
MainThreadDebugServiceShape
,
DebugSessionUUID
}
from
'
../node/extHost.protocol
'
;
export
class
MainThreadDebugService
extends
MainThreadDebugServiceShape
{
private
_proxy
:
ExtHostDebugServiceShape
;
private
_toDispose
:
IDisposable
[];
constructor
(
@
IThreadService
threadService
:
IThreadService
,
@
IDebugService
private
debugService
:
IDebugService
)
{
super
();
this
.
_proxy
=
threadService
.
get
(
ExtHostContext
.
ExtHostDebugService
);
this
.
_toDispose
=
[];
this
.
_toDispose
.
push
(
debugService
.
onDidEndProcess
(
proc
=>
this
.
_proxy
.
$acceptDebugSessionTerminated
(
<
DebugSessionUUID
>
proc
.
getId
(),
proc
.
configuration
.
type
,
proc
.
name
)));
}
public
dispose
():
void
{
this
.
_toDispose
=
dispose
(
this
.
_toDispose
);
}
public
$createDebugSession
(
configuration
:
IConfig
):
TPromise
<
DebugSessionUUID
>
{
if
(
configuration
.
request
!==
'
launch
'
&&
configuration
.
request
!==
'
attach
'
)
{
return
TPromise
.
wrapError
(
`only 'launch' or 'attach' allowed for 'request' attribute`
);
}
return
this
.
debugService
.
createProcess
(
configuration
).
then
(
process
=>
{
if
(
process
)
{
return
<
DebugSessionUUID
>
process
.
getId
();
}
return
TPromise
.
wrapError
(
'
cannot create debug session
'
);
},
err
=>
{
return
TPromise
.
wrapError
(
err
&&
err
.
message
?
err
.
message
:
'
cannot create debug session
'
);
});
}
public
$customDebugAdapterRequest
(
sessionId
:
DebugSessionUUID
,
request
:
string
,
args
:
any
):
TPromise
<
any
>
{
const
process
=
this
.
_findProcessByUUID
(
sessionId
);
if
(
process
)
{
return
process
.
session
.
custom
(
request
,
args
).
then
(
response
=>
{
if
(
response
.
success
)
{
return
response
.
body
;
}
else
{
return
TPromise
.
wrapError
(
response
.
message
);
}
});
}
return
TPromise
.
wrapError
(
'
debug session not found
'
);
}
private
_findProcessByUUID
(
processId
:
DebugSessionUUID
):
IProcess
|
null
{
const
processes
=
this
.
debugService
.
getModel
().
getProcesses
();
const
result
=
processes
.
filter
(
process
=>
process
.
getId
()
===
processId
);
if
(
result
.
length
>
0
)
{
return
processes
[
0
];
// there can only be one
}
return
null
;
}
}
src/vs/workbench/api/node/extHost.api.impl.ts
浏览文件 @
fbcdb4c6
...
...
@@ -34,6 +34,7 @@ import { ExtHostLanguages } from 'vs/workbench/api/node/extHostLanguages';
import
{
ExtHostLanguageFeatures
}
from
'
vs/workbench/api/node/extHostLanguageFeatures
'
;
import
{
ExtHostApiCommands
}
from
'
vs/workbench/api/node/extHostApiCommands
'
;
import
{
ExtHostTask
}
from
'
vs/workbench/api/node/extHostTask
'
;
import
{
ExtHostDebugService
}
from
'
vs/workbench/api/node/extHostDebugService
'
;
import
*
as
extHostTypes
from
'
vs/workbench/api/node/extHostTypes
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
Severity
from
'
vs/base/common/severity
'
;
...
...
@@ -83,6 +84,7 @@ export function createApiFactory(
// Addressable instances
const
col
=
new
InstanceCollection
();
const
extHostHeapService
=
col
.
define
(
ExtHostContext
.
ExtHostHeapService
).
set
<
ExtHostHeapService
>
(
new
ExtHostHeapService
());
const
extHostDebugService
=
col
.
define
(
ExtHostContext
.
ExtHostDebugService
).
set
<
ExtHostDebugService
>
(
new
ExtHostDebugService
(
threadService
));
const
extHostDocumentsAndEditors
=
col
.
define
(
ExtHostContext
.
ExtHostDocumentsAndEditors
).
set
<
ExtHostDocumentsAndEditors
>
(
new
ExtHostDocumentsAndEditors
(
threadService
));
const
extHostDocuments
=
col
.
define
(
ExtHostContext
.
ExtHostDocuments
).
set
<
ExtHostDocuments
>
(
new
ExtHostDocuments
(
threadService
,
extHostDocumentsAndEditors
));
const
extHostDocumentSaveParticipant
=
col
.
define
(
ExtHostContext
.
ExtHostDocumentSaveParticipant
).
set
<
ExtHostDocumentSaveParticipant
>
(
new
ExtHostDocumentSaveParticipant
(
extHostDocuments
,
threadService
.
get
(
MainContext
.
MainThreadWorkspace
)));
...
...
@@ -448,6 +450,17 @@ export function createApiFactory(
}
};
// namespace: debug
const
debug
:
typeof
vscode
.
debug
=
{
createDebugSession
:
proposedApiFunction
(
extension
,
(
config
:
vscode
.
DebugConfiguration
)
=>
{
return
extHostDebugService
.
createDebugSession
(
config
);
}),
onDidTerminateDebugSession
:
proposedApiFunction
(
extension
,
(
listener
,
thisArg
?,
disposables
?)
=>
{
return
extHostDebugService
.
onDidTerminateDebugSession
(
listener
,
thisArg
,
disposables
);
})
};
return
{
version
:
pkg
.
version
,
// namespaces
...
...
@@ -458,6 +471,7 @@ export function createApiFactory(
window
,
workspace
,
scm
,
debug
,
// types
CancellationTokenSource
:
CancellationTokenSource
,
CodeLens
:
extHostTypes
.
CodeLens
,
...
...
src/vs/workbench/api/node/extHost.protocol.ts
浏览文件 @
fbcdb4c6
...
...
@@ -342,6 +342,13 @@ export abstract class MainThreadSCMShape {
$setInputBoxValue
(
value
:
string
):
void
{
throw
ni
();
}
}
export
type
DebugSessionUUID
=
string
;
export
abstract
class
MainThreadDebugServiceShape
{
$createDebugSession
(
config
:
vscode
.
DebugConfiguration
):
TPromise
<
DebugSessionUUID
>
{
throw
ni
();
}
$customDebugAdapterRequest
(
id
:
DebugSessionUUID
,
command
:
string
,
args
:
any
):
TPromise
<
any
>
{
throw
ni
();
}
}
// -- extension host
export
abstract
class
ExtHostCommandsShape
{
...
...
@@ -492,11 +499,16 @@ export abstract class ExtHostTaskShape {
$provideTasks
(
handle
:
number
):
TPromise
<
TaskSet
>
{
throw
ni
();
}
}
export
abstract
class
ExtHostDebugServiceShape
{
$acceptDebugSessionTerminated
(
id
:
DebugSessionUUID
,
type
:
string
,
name
:
string
):
void
{
throw
ni
();
}
}
// --- proxy identifiers
export
const
MainContext
=
{
MainThreadCommands
:
createMainId
<
MainThreadCommandsShape
>
(
'
MainThreadCommands
'
,
MainThreadCommandsShape
),
MainThreadConfiguration
:
createMainId
<
MainThreadConfigurationShape
>
(
'
MainThreadConfiguration
'
,
MainThreadConfigurationShape
),
MainThreadDebugService
:
createMainId
<
MainThreadDebugServiceShape
>
(
'
MainThreadDebugService
'
,
MainThreadDebugServiceShape
),
MainThreadDiagnostics
:
createMainId
<
MainThreadDiagnosticsShape
>
(
'
MainThreadDiagnostics
'
,
MainThreadDiagnosticsShape
),
MainThreadDocuments
:
createMainId
<
MainThreadDocumentsShape
>
(
'
MainThreadDocuments
'
,
MainThreadDocumentsShape
),
MainThreadEditors
:
createMainId
<
MainThreadEditorsShape
>
(
'
MainThreadEditors
'
,
MainThreadEditorsShape
),
...
...
@@ -522,6 +534,7 @@ export const ExtHostContext = {
ExtHostCommands
:
createExtId
<
ExtHostCommandsShape
>
(
'
ExtHostCommands
'
,
ExtHostCommandsShape
),
ExtHostConfiguration
:
createExtId
<
ExtHostConfigurationShape
>
(
'
ExtHostConfiguration
'
,
ExtHostConfigurationShape
),
ExtHostDiagnostics
:
createExtId
<
ExtHostDiagnosticsShape
>
(
'
ExtHostDiagnostics
'
,
ExtHostDiagnosticsShape
),
ExtHostDebugService
:
createExtId
<
ExtHostDebugServiceShape
>
(
'
ExtHostDebugService
'
,
ExtHostDebugServiceShape
),
ExtHostDocumentsAndEditors
:
createExtId
<
ExtHostDocumentsAndEditorsShape
>
(
'
ExtHostDocumentsAndEditors
'
,
ExtHostDocumentsAndEditorsShape
),
ExtHostDocuments
:
createExtId
<
ExtHostDocumentsShape
>
(
'
ExtHostDocuments
'
,
ExtHostDocumentsShape
),
ExtHostDocumentSaveParticipant
:
createExtId
<
ExtHostDocumentSaveParticipantShape
>
(
'
ExtHostDocumentSaveParticipant
'
,
ExtHostDocumentSaveParticipantShape
),
...
...
src/vs/workbench/api/node/extHostDebugService.ts
0 → 100644
浏览文件 @
fbcdb4c6
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
IThreadService
}
from
'
vs/workbench/services/thread/common/threadService
'
;
import
{
MainContext
,
MainThreadDebugServiceShape
,
ExtHostDebugServiceShape
,
DebugSessionUUID
}
from
'
vs/workbench/api/node/extHost.protocol
'
;
import
*
as
vscode
from
'
vscode
'
;
export
class
ExtHostDebugService
extends
ExtHostDebugServiceShape
{
private
_debugServiceProxy
:
MainThreadDebugServiceShape
;
private
_debugSessions
:
Map
<
DebugSessionUUID
,
ExtHostDebugSession
>
=
new
Map
<
DebugSessionUUID
,
ExtHostDebugSession
>
();
private
_onDidTerminateDebugSession
:
Emitter
<
vscode
.
DebugSession
>
;
get
onDidTerminateDebugSession
():
Event
<
vscode
.
DebugSession
>
{
return
this
.
_onDidTerminateDebugSession
.
event
;
}
constructor
(
threadService
:
IThreadService
)
{
super
();
this
.
_onDidTerminateDebugSession
=
new
Emitter
<
vscode
.
DebugSession
>
();
this
.
_debugServiceProxy
=
threadService
.
get
(
MainContext
.
MainThreadDebugService
);
}
public
createDebugSession
(
config
:
vscode
.
DebugConfiguration
):
TPromise
<
vscode
.
DebugSession
>
{
return
this
.
_debugServiceProxy
.
$createDebugSession
(
config
).
then
((
id
:
DebugSessionUUID
)
=>
{
const
debugSession
=
new
ExtHostDebugSession
(
this
.
_debugServiceProxy
,
id
,
config
.
type
,
config
.
name
);
this
.
_debugSessions
.
set
(
id
,
debugSession
);
return
debugSession
;
});
}
public
$acceptDebugSessionTerminated
(
id
:
DebugSessionUUID
,
type
:
string
,
name
:
string
):
void
{
let
debugSession
=
this
.
_debugSessions
.
get
(
id
);
if
(
!
debugSession
)
{
debugSession
=
new
ExtHostDebugSession
(
this
.
_debugServiceProxy
,
id
,
type
,
name
);
}
this
.
_onDidTerminateDebugSession
.
fire
(
debugSession
);
this
.
_debugSessions
.
delete
(
id
);
}
}
export
class
ExtHostDebugSession
implements
vscode
.
DebugSession
{
private
_debugServiceProxy
:
MainThreadDebugServiceShape
;
private
_id
:
DebugSessionUUID
;
private
_type
:
string
;
private
_name
:
string
;
constructor
(
proxy
:
MainThreadDebugServiceShape
,
id
:
DebugSessionUUID
,
type
:
string
,
name
:
string
)
{
this
.
_debugServiceProxy
=
proxy
;
this
.
_id
=
id
;
this
.
_type
=
type
;
this
.
_name
=
name
;
};
public
get
type
():
string
{
return
this
.
_type
;
}
public
get
name
():
string
{
return
this
.
_name
;
}
public
customRequest
(
command
:
string
,
args
:
any
):
Thenable
<
any
>
{
return
this
.
_debugServiceProxy
.
$customDebugAdapterRequest
(
this
.
_id
,
command
,
args
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录