Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
07ee9253
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,发现更多精彩内容 >>
提交
07ee9253
编写于
10月 21, 2019
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Web: implement browser extension debug service properly (fixes #81493)
上级
715cdf7c
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
196 addition
and
57 deletion
+196
-57
src/vs/code/browser/workbench/workbench.ts
src/vs/code/browser/workbench/workbench.ts
+69
-23
src/vs/workbench/contrib/debug/browser/extensionHostDebugService.ts
...kbench/contrib/debug/browser/extensionHostDebugService.ts
+74
-10
src/vs/workbench/services/environment/browser/environmentService.ts
...kbench/services/environment/browser/environmentService.ts
+42
-21
src/vs/workbench/services/host/browser/browserHostService.ts
src/vs/workbench/services/host/browser/browserHostService.ts
+11
-2
src/vs/workbench/workbench.web.api.ts
src/vs/workbench/workbench.web.api.ts
+0
-1
未找到文件。
src/vs/code/browser/workbench/workbench.ts
浏览文件 @
07ee9253
...
...
@@ -202,27 +202,41 @@ class PollingURLCallbackProvider extends Disposable implements IURLCallbackProvi
class
WorkspaceProvider
implements
IWorkspaceProvider
{
constructor
(
public
readonly
workspace
:
IWorkspace
)
{
}
async
open
(
workspace
:
IWorkspace
,
options
?:
{
reuse
?:
boolean
}):
Promise
<
void
>
{
if
(
options
&&
options
.
reuse
&&
this
.
isSame
(
this
.
workspace
,
workspace
))
{
return
;
// return early if workspace is not changing and we are reusing window
static
QUERY_PARAM_EMPTY_WINDOW
=
'
ew
'
;
static
QUERY_PARAM_FOLDER
=
'
folder
'
;
static
QUERY_PARAM_WORKSPACE
=
'
workspace
'
;
constructor
(
public
readonly
workspace
:
IWorkspace
,
public
readonly
environment
:
ReadonlyMap
<
string
,
string
>
)
{
}
async
open
(
workspace
:
IWorkspace
,
options
?:
{
reuse
?:
boolean
,
environment
?:
Map
<
string
,
string
>
}):
Promise
<
void
>
{
if
(
options
&&
options
.
reuse
&&
!
options
.
environment
&&
this
.
isSame
(
this
.
workspace
,
workspace
))
{
return
;
// return early if workspace and environment is not changing and we are reusing window
}
// Empty
let
targetHref
:
string
|
undefined
=
undefined
;
if
(
!
workspace
)
{
targetHref
=
`
${
document
.
location
.
origin
}${
document
.
location
.
pathname
}
?
ew
=true`
;
targetHref
=
`
${
document
.
location
.
origin
}${
document
.
location
.
pathname
}
?
${
WorkspaceProvider
.
QUERY_PARAM_EMPTY_WINDOW
}
=true`
;
}
// Folder
else
if
(
isFolderToOpen
(
workspace
))
{
targetHref
=
`
${
document
.
location
.
origin
}${
document
.
location
.
pathname
}
?
folder
=
${
workspace
.
folderUri
.
path
}
`
;
targetHref
=
`
${
document
.
location
.
origin
}${
document
.
location
.
pathname
}
?
${
WorkspaceProvider
.
QUERY_PARAM_FOLDER
}
=
${
workspace
.
folderUri
.
path
}
`
;
}
// Workspace
else
if
(
isWorkspaceToOpen
(
workspace
))
{
targetHref
=
`
${
document
.
location
.
origin
}${
document
.
location
.
pathname
}
?workspace=
${
workspace
.
workspaceUri
.
path
}
`
;
targetHref
=
`
${
document
.
location
.
origin
}${
document
.
location
.
pathname
}
?
${
WorkspaceProvider
.
QUERY_PARAM_WORKSPACE
}
=
${
workspace
.
workspaceUri
.
path
}
`
;
}
// Environment
if
(
options
&&
options
.
environment
)
{
for
(
const
[
key
,
value
]
of
options
.
environment
)
{
targetHref
+=
`&
${
key
}
=
${
encodeURIComponent
(
value
)}
`
;
}
}
if
(
targetHref
)
{
...
...
@@ -255,21 +269,53 @@ class WorkspaceProvider implements IWorkspaceProvider {
}
}
const
configElement
=
document
.
getElementById
(
'
vscode-workbench-web-configuration
'
);
const
configElementAttribute
=
configElement
?
configElement
.
getAttribute
(
'
data-settings
'
)
:
undefined
;
if
(
!
configElement
||
!
configElementAttribute
)
{
throw
new
Error
(
'
Missing web configuration element
'
);
}
(
function
()
{
const
options
:
IWorkbenchConstructionOptions
&
{
folderUri
?:
UriComponents
,
workspaceUri
?:
UriComponents
}
=
JSON
.
parse
(
configElementAttribute
);
options
.
workspaceProvider
=
new
WorkspaceProvider
(
options
.
folderUri
?
{
folderUri
:
URI
.
revive
(
options
.
folderUri
)
}
:
options
.
workspaceUri
?
{
workspaceUri
:
URI
.
revive
(
options
.
workspaceUri
)
}
:
undefined
);
options
.
urlCallbackProvider
=
new
PollingURLCallbackProvider
();
options
.
credentialsProvider
=
new
LocalStorageCredentialsProvider
();
// Find config element in DOM
const
configElement
=
document
.
getElementById
(
'
vscode-workbench-web-configuration
'
);
const
configElementAttribute
=
configElement
?
configElement
.
getAttribute
(
'
data-settings
'
)
:
undefined
;
if
(
!
configElement
||
!
configElementAttribute
)
{
throw
new
Error
(
'
Missing web configuration element
'
);
}
if
(
Array
.
isArray
(
options
.
staticExtensions
))
{
options
.
staticExtensions
.
forEach
(
extension
=>
{
extension
.
extensionLocation
=
URI
.
revive
(
extension
.
extensionLocation
);
});
}
const
options
:
IWorkbenchConstructionOptions
&
{
folderUri
?:
UriComponents
,
workspaceUri
?:
UriComponents
}
=
JSON
.
parse
(
configElementAttribute
);
// Determine workspace to open
let
workspace
:
IWorkspace
;
if
(
options
.
folderUri
)
{
workspace
=
{
folderUri
:
URI
.
revive
(
options
.
folderUri
)
};
}
else
if
(
options
.
workspaceUri
)
{
workspace
=
{
workspaceUri
:
URI
.
revive
(
options
.
workspaceUri
)
};
}
else
{
workspace
=
undefined
;
}
// Find environmental properties
const
environment
=
new
Map
<
string
,
string
>
();
if
(
document
&&
document
.
location
&&
document
.
location
.
search
)
{
const
query
=
document
.
location
.
search
.
substring
(
1
);
const
vars
=
query
.
split
(
'
&
'
);
for
(
let
p
of
vars
)
{
const
pair
=
p
.
split
(
'
=
'
);
if
(
pair
.
length
===
2
)
{
const
[
key
,
value
]
=
pair
;
if
(
key
!==
WorkspaceProvider
.
QUERY_PARAM_EMPTY_WINDOW
&&
key
!==
WorkspaceProvider
.
QUERY_PARAM_FOLDER
&&
key
!==
WorkspaceProvider
.
QUERY_PARAM_WORKSPACE
)
{
environment
.
set
(
key
,
decodeURIComponent
(
value
));
}
}
}
}
options
.
workspaceProvider
=
new
WorkspaceProvider
(
workspace
,
environment
);
options
.
urlCallbackProvider
=
new
PollingURLCallbackProvider
();
options
.
credentialsProvider
=
new
LocalStorageCredentialsProvider
();
if
(
Array
.
isArray
(
options
.
staticExtensions
))
{
options
.
staticExtensions
.
forEach
(
extension
=>
{
extension
.
extensionLocation
=
URI
.
revive
(
extension
.
extensionLocation
);
});
}
create
(
document
.
body
,
options
);
// Finally create workbench
create
(
document
.
body
,
options
);
})();
src/vs/workbench/contrib/debug/browser/extensionHostDebugService.ts
浏览文件 @
07ee9253
...
...
@@ -5,7 +5,6 @@
import
{
ExtensionHostDebugChannelClient
,
ExtensionHostDebugBroadcastChannel
}
from
'
vs/platform/debug/common/extensionHostDebugIpc
'
;
import
{
IRemoteAgentService
}
from
'
vs/workbench/services/remote/common/remoteAgentService
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
registerSingleton
}
from
'
vs/platform/instantiation/common/extensions
'
;
import
{
IExtensionHostDebugService
}
from
'
vs/platform/debug/common/extensionHostDebug
'
;
import
{
IDebugHelperService
}
from
'
vs/workbench/contrib/debug/common/debug
'
;
...
...
@@ -13,17 +12,19 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
import
{
TelemetryService
}
from
'
vs/platform/telemetry/common/telemetryService
'
;
import
{
IChannel
}
from
'
vs/base/parts/ipc/common/ipc
'
;
import
{
Event
}
from
'
vs/base/common/event
'
;
import
{
IProcessEnvironment
}
from
'
vs/base/common/platform
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
IWorkbenchEnvironmentService
}
from
'
vs/workbench/services/environment/common/environmentService
'
;
import
{
IWorkspaceProvider
,
IWorkspace
}
from
'
vs/workbench/services/host/browser/browserHostService
'
;
class
BrowserExtensionHostDebugService
extends
ExtensionHostDebugChannelClient
implements
IExtensionHostDebugService
{
private
workspaceProvider
:
IWorkspaceProvider
;
constructor
(
@
IRemoteAgentService
remoteAgentService
:
IRemoteAgentService
,
@
I
EnvironmentService
environmentService
:
I
EnvironmentService
@
I
WorkbenchEnvironmentService
environmentService
:
IWorkbench
EnvironmentService
)
{
const
connection
=
remoteAgentService
.
getConnection
();
let
channel
:
IChannel
;
if
(
connection
)
{
channel
=
connection
.
getChannel
(
ExtensionHostDebugBroadcastChannel
.
ChannelName
);
...
...
@@ -35,11 +36,26 @@ class BrowserExtensionHostDebugService extends ExtensionHostDebugChannelClient i
super
(
channel
);
if
(
environmentService
.
options
&&
environmentService
.
options
.
workspaceProvider
)
{
this
.
workspaceProvider
=
environmentService
.
options
.
workspaceProvider
;
}
else
{
this
.
workspaceProvider
=
{
open
:
async
()
=>
undefined
,
workspace
:
undefined
};
console
.
warn
(
'
Extension Host Debugging not available due to missing workspace provider.
'
);
}
this
.
registerListeners
(
environmentService
);
}
private
registerListeners
(
environmentService
:
IWorkbenchEnvironmentService
):
void
{
// Reload window on reload request
this
.
_register
(
this
.
onReload
(
event
=>
{
if
(
environmentService
.
isExtensionDevelopment
&&
environmentService
.
debugExtensionHost
.
debugId
===
event
.
sessionId
)
{
window
.
location
.
reload
();
}
}));
// Close window on close request
this
.
_register
(
this
.
onClose
(
event
=>
{
if
(
environmentService
.
isExtensionDevelopment
&&
environmentService
.
debugExtensionHost
.
debugId
===
event
.
sessionId
)
{
window
.
close
();
...
...
@@ -47,7 +63,45 @@ class BrowserExtensionHostDebugService extends ExtensionHostDebugChannelClient i
}));
}
openExtensionDevelopmentHostWindow
(
args
:
string
[],
env
:
IProcessEnvironment
):
Promise
<
void
>
{
async
openExtensionDevelopmentHostWindow
(
args
:
string
[]):
Promise
<
void
>
{
if
(
!
this
.
workspaceProvider
.
environment
)
{
// TODO@Ben remove me once environment is adopted
return
this
.
openExtensionDevelopmentHostWindowLegacy
(
args
);
}
// Find out which workspace to open debug window on
let
debugWorkspace
:
IWorkspace
=
undefined
;
const
folderUriArg
=
this
.
findArgument
(
'
folder-uri
'
,
args
);
if
(
folderUriArg
)
{
debugWorkspace
=
{
folderUri
:
URI
.
parse
(
folderUriArg
)
};
}
// Add environment parameters required for debug to work
const
environment
=
new
Map
<
string
,
string
>
();
const
extensionDevelopmentPath
=
this
.
findArgument
(
'
extensionDevelopmentPath
'
,
args
);
if
(
extensionDevelopmentPath
)
{
environment
.
set
(
'
extensionDevelopmentPath
'
,
extensionDevelopmentPath
);
}
const
debugId
=
this
.
findArgument
(
'
debugId
'
,
args
);
if
(
debugId
)
{
environment
.
set
(
'
debugId
'
,
debugId
);
}
const
inspectBrkExtensions
=
this
.
findArgument
(
'
inspect-brk-extensions
'
,
args
);
if
(
inspectBrkExtensions
)
{
environment
.
set
(
'
inspect-brk-extensions
'
,
inspectBrkExtensions
);
}
// Open debug window as new window. Pass ParsedArgs over.
this
.
workspaceProvider
.
open
(
debugWorkspace
,
{
reuse
:
false
,
// debugging always requires a new window
environment
// mandatory properties to enable debugging
});
}
private
async
openExtensionDevelopmentHostWindowLegacy
(
args
:
string
[]):
Promise
<
void
>
{
// we pass the "args" as query parameters of the URL
let
newAddress
=
`
${
document
.
location
.
origin
}${
document
.
location
.
pathname
}
?`
;
...
...
@@ -73,7 +127,7 @@ class BrowserExtensionHostDebugService extends ExtensionHostDebugChannelClient i
const
f
=
findArgument
(
'
folder-uri
'
);
if
(
f
)
{
const
u
=
URI
.
parse
(
f
[
0
]
);
const
u
=
URI
.
parse
(
f
);
gotFolder
=
true
;
addQueryParameter
(
'
folder
'
,
u
.
path
);
}
...
...
@@ -84,24 +138,34 @@ class BrowserExtensionHostDebugService extends ExtensionHostDebugChannelClient i
const
ep
=
findArgument
(
'
extensionDevelopmentPath
'
);
if
(
ep
)
{
let
u
=
ep
[
0
];
addQueryParameter
(
'
edp
'
,
u
);
addQueryParameter
(
'
extensionDevelopmentPath
'
,
ep
);
}
const
di
=
findArgument
(
'
debugId
'
);
if
(
di
)
{
addQueryParameter
(
'
d
i
'
,
di
);
addQueryParameter
(
'
d
ebugId
'
,
di
);
}
const
ibe
=
findArgument
(
'
inspect-brk-extensions
'
);
if
(
ibe
)
{
addQueryParameter
(
'
i
be
'
,
ibe
);
addQueryParameter
(
'
i
nspect-brk-extensions
'
,
ibe
);
}
window
.
open
(
newAddress
);
return
Promise
.
resolve
();
}
private
findArgument
(
key
:
string
,
args
:
string
[]):
string
|
undefined
{
for
(
const
a
of
args
)
{
const
k
=
`--
${
key
}
=`
;
if
(
a
.
indexOf
(
k
)
===
0
)
{
return
a
.
substr
(
k
.
length
);
}
}
return
undefined
;
}
}
registerSingleton
(
IExtensionHostDebugService
,
BrowserExtensionHostDebugService
);
...
...
src/vs/workbench/services/environment/browser/environmentService.ts
浏览文件 @
07ee9253
...
...
@@ -100,32 +100,53 @@ export class BrowserWorkbenchEnvironmentService implements IWorkbenchEnvironment
this
.
untitledWorkspacesHome
=
URI
.
from
({
scheme
:
Schemas
.
untitled
,
path
:
'
Workspaces
'
});
if
(
document
&&
document
.
location
&&
document
.
location
.
search
)
{
const
map
=
new
Map
<
string
,
string
>
();
const
query
=
document
.
location
.
search
.
substring
(
1
);
const
vars
=
query
.
split
(
'
&
'
);
for
(
let
p
of
vars
)
{
const
pair
=
p
.
split
(
'
=
'
);
if
(
pair
.
length
>=
2
)
{
map
.
set
(
pair
[
0
],
decodeURIComponent
(
pair
[
1
]));
// Fill in selected extra environmental properties
if
(
options
.
workspaceProvider
&&
options
.
workspaceProvider
.
environment
)
{
const
environment
=
options
.
workspaceProvider
.
environment
;
for
(
const
[
key
,
value
]
of
environment
)
{
switch
(
key
)
{
case
'
extensionDevelopmentPath
'
:
this
.
extensionDevelopmentLocationURI
=
[
URI
.
parse
(
value
)];
this
.
isExtensionDevelopment
=
true
;
break
;
case
'
debugId
'
:
this
.
debugExtensionHost
.
debugId
=
value
;
break
;
case
'
inspect-brk-extensions
'
:
this
.
debugExtensionHost
.
port
=
parseInt
(
value
);
this
.
debugExtensionHost
.
break
=
false
;
break
;
}
}
}
else
{
// TODO@Ben remove me once environment is adopted
if
(
document
&&
document
.
location
&&
document
.
location
.
search
)
{
const
map
=
new
Map
<
string
,
string
>
();
const
query
=
document
.
location
.
search
.
substring
(
1
);
const
vars
=
query
.
split
(
'
&
'
);
for
(
let
p
of
vars
)
{
const
pair
=
p
.
split
(
'
=
'
);
if
(
pair
.
length
>=
2
)
{
map
.
set
(
pair
[
0
],
decodeURIComponent
(
pair
[
1
]));
}
}
const
edp
=
map
.
get
(
'
edp
'
);
if
(
edp
)
{
this
.
extensionDevelopmentLocationURI
=
[
URI
.
parse
(
edp
)];
this
.
isExtensionDevelopment
=
true
;
}
const
edp
=
map
.
get
(
'
extensionDevelopmentPath
'
);
if
(
edp
)
{
this
.
extensionDevelopmentLocationURI
=
[
URI
.
parse
(
edp
)];
this
.
isExtensionDevelopment
=
true
;
}
const
di
=
map
.
get
(
'
di
'
);
if
(
di
)
{
this
.
debugExtensionHost
.
debugId
=
di
;
}
const
di
=
map
.
get
(
'
debugId
'
);
if
(
di
)
{
this
.
debugExtensionHost
.
debugId
=
di
;
}
const
ibe
=
map
.
get
(
'
ibe
'
);
if
(
ibe
)
{
this
.
debugExtensionHost
.
port
=
parseInt
(
ibe
);
this
.
debugExtensionHost
.
break
=
false
;
const
ibe
=
map
.
get
(
'
inspect-brk-extensions
'
);
if
(
ibe
)
{
this
.
debugExtensionHost
.
port
=
parseInt
(
ibe
);
this
.
debugExtensionHost
.
break
=
false
;
}
}
}
}
...
...
src/vs/workbench/services/host/browser/browserHostService.ts
浏览文件 @
07ee9253
...
...
@@ -33,13 +33,22 @@ export interface IWorkspaceProvider {
*/
readonly
workspace
:
IWorkspace
;
/**
* Optionally a set of environmental properties to be used
* as environment for the workspace to open.
*/
readonly
environment
?:
ReadonlyMap
<
string
,
string
>
;
/**
* Asks to open a workspace in the current or a new window.
*
* @param workspace the workspace to open.
* @param options wether to open inside the current window or a new window.
* @param options optional options for the workspace to open.
* - `reuse`: wether to open inside the current window or a new window
* - `environment`: a map of environmental properties that should be
* filled into the environment of the workspace to open.
*/
open
(
workspace
:
IWorkspace
,
options
?:
{
reuse
?:
boolean
}):
Promise
<
void
>
;
open
(
workspace
:
IWorkspace
,
options
?:
{
reuse
?:
boolean
,
environment
?:
Map
<
string
,
string
>
}):
Promise
<
void
>
;
}
export
class
BrowserHostService
extends
Disposable
implements
IHostService
{
...
...
src/vs/workbench/workbench.web.api.ts
浏览文件 @
07ee9253
...
...
@@ -82,7 +82,6 @@ interface IWorkbenchConstructionOptions {
*/
logLevel
?:
LogLevel
;
/**
* Experimental: Support for update reporting.
*/
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录