Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
2119aefc
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,发现更多精彩内容 >>
提交
2119aefc
编写于
11月 30, 2017
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ps - better output
上级
df6a4213
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
93 addition
and
27 deletion
+93
-27
src/vs/code/electron-main/diagnostics.ts
src/vs/code/electron-main/diagnostics.ts
+60
-20
src/vs/code/electron-main/launch.ts
src/vs/code/electron-main/launch.ts
+33
-7
未找到文件。
src/vs/code/electron-main/diagnostics.ts
浏览文件 @
2119aefc
...
...
@@ -18,24 +18,48 @@ import { app } from 'electron';
export
function
printDiagnostics
(
info
:
IMainProcessInfo
):
Promise
<
any
>
{
return
listProcesses
(
info
.
mainPID
).
then
(
rootProcess
=>
{
console
.
log
(
formatProcessList
(
info
,
rootProcess
));
console
.
log
(
'
\n
'
);
console
.
log
(
'
\n
'
);
// Environment Info
console
.
log
(
''
);
console
.
log
(
formatEnvironment
(
info
));
// Process List
console
.
log
(
''
);
console
.
log
(
formatProcessList
(
info
,
rootProcess
));
let
stats
=
collectWorkspaceStats
(
'
.
'
,
[
'
node_modules
'
,
'
.git
'
]);
// TODO call for each root folder
console
.
log
(
formatWorkspaceStats
(
stats
));
// Workspace Stats
if
(
info
.
windows
.
some
(
window
=>
window
.
folders
.
length
>
0
))
{
console
.
log
(
''
);
console
.
log
(
'
Workspace Stats:
'
);
info
.
windows
.
forEach
(
window
=>
{
if
(
window
.
folders
.
length
===
0
)
{
return
;
}
console
.
log
(
`| Renderer (
${
window
.
title
}
)`
);
window
.
folders
.
forEach
(
folder
=>
{
console
.
log
(
`| Folder (
${
folder
}
)`
);
const
stats
=
collectWorkspaceStats
(
folder
,
[
'
node_modules
'
,
'
.git
'
]);
console
.
log
(
formatWorkspaceStats
(
stats
));
});
});
}
console
.
log
(
''
);
console
.
log
(
''
);
});
}
function
formatWorkspaceStats
(
workspaceStats
:
WorkspaceStats
):
string
{
let
output
:
string
[]
=
[];
const
output
:
string
[]
=
[];
const
lineLength
=
60
;
let
col
=
0
;
le
t
appendAndWrap
=
(
index
:
string
,
value
:
number
)
=>
{
le
t
item
=
`
${
index
}
(
${
value
}
)`
;
cons
t
appendAndWrap
=
(
index
:
string
,
value
:
number
)
=>
{
cons
t
item
=
`
${
index
}
(
${
value
}
)`
;
if
(
col
+
item
.
length
>
lineLength
)
{
output
.
push
(
line
);
line
=
'
'
;
line
=
'
|
'
;
col
=
line
.
length
;
}
else
{
...
...
@@ -44,31 +68,38 @@ function formatWorkspaceStats(workspaceStats: WorkspaceStats): string {
line
+=
item
;
};
output
.
push
(
'
Workspace:
'
);
const
lineLength
=
60
;
let
line
=
'
File types:
'
;
let
col
=
0
;
// File Types
let
line
=
'
| File types:
'
;
let
hasFileTypes
=
false
;
workspaceStats
.
fileTypes
.
forEach
((
item
)
=>
{
if
(
item
.
value
>
20
)
{
hasFileTypes
=
true
;
appendAndWrap
(
item
.
name
,
item
.
value
);
}
});
if
(
!
hasFileTypes
)
{
line
=
`
${
line
}
<not enough data>`
;
}
output
.
push
(
line
);
output
.
push
(
''
);
line
=
'
Configuration files:
'
;
// Conf Files
line
=
'
| Conf files:
'
;
col
=
0
;
let
hasConfFiles
=
false
;
workspaceStats
.
configFiles
.
forEach
((
item
)
=>
{
hasConfFiles
=
true
;
appendAndWrap
(
item
.
name
,
item
.
value
);
});
if
(
!
hasConfFiles
)
{
line
=
`
${
line
}
<not enough data>`
;
}
output
.
push
(
line
);
return
output
.
join
(
'
\n
'
);
}
function
formatProcessList
(
info
:
IMainProcessInfo
,
rootProcess
:
ProcessItem
):
string
{
const
mapPidToWindowTitle
=
new
Map
<
number
,
string
>
();
info
.
windows
.
forEach
(
window
=>
mapPidToWindowTitle
.
set
(
window
.
pid
,
window
.
title
));
function
formatEnvironment
(
info
:
IMainProcessInfo
):
string
{
const
MB
=
1024
*
1024
;
const
GB
=
1024
*
MB
;
...
...
@@ -85,7 +116,16 @@ function formatProcessList(info: IMainProcessInfo, rootProcess: ProcessItem): st
}
output
.
push
(
`VM:
${
Math
.
round
((
virtualMachineHint
.
value
()
*
100
))}
%`
);
output
.
push
(
`Screen Reader:
${
app
.
isAccessibilitySupportEnabled
()
?
'
yes
'
:
'
no
'
}
`
);
output
.
push
(
''
);
return
output
.
join
(
'
\n
'
);
}
function
formatProcessList
(
info
:
IMainProcessInfo
,
rootProcess
:
ProcessItem
):
string
{
const
mapPidToWindowTitle
=
new
Map
<
number
,
string
>
();
info
.
windows
.
forEach
(
window
=>
mapPidToWindowTitle
.
set
(
window
.
pid
,
window
.
title
));
const
output
:
string
[]
=
[];
output
.
push
(
'
CPU %
\t
Mem MB
\t
Process
'
);
formatProcessItem
(
mapPidToWindowTitle
,
output
,
rootProcess
,
0
);
...
...
src/vs/code/electron-main/launch.ts
浏览文件 @
2119aefc
...
...
@@ -15,6 +15,7 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation'
import
{
OpenContext
}
from
'
vs/platform/windows/common/windows
'
;
import
{
IWindowsMainService
,
ICodeWindow
}
from
'
vs/platform/windows/electron-main/windows
'
;
import
{
whenDeleted
}
from
'
vs/base/node/pfs
'
;
import
{
IWorkspacesMainService
}
from
'
vs/platform/workspaces/common/workspaces
'
;
export
const
ID
=
'
launchService
'
;
export
const
ILaunchService
=
createDecorator
<
ILaunchService
>
(
ID
);
...
...
@@ -24,9 +25,15 @@ export interface IStartArguments {
userEnv
:
IProcessEnvironment
;
}
export
interface
IWindowInfo
{
pid
:
number
;
title
:
string
;
folders
:
string
[];
}
export
interface
IMainProcessInfo
{
mainPID
:
number
;
windows
:
{
pid
:
number
;
title
:
string
;
}
[];
windows
:
IWindowInfo
[];
}
export
interface
ILaunchService
{
...
...
@@ -90,7 +97,8 @@ export class LaunchService implements ILaunchService {
constructor
(
@
ILogService
private
logService
:
ILogService
,
@
IWindowsMainService
private
windowsMainService
:
IWindowsMainService
,
@
IURLService
private
urlService
:
IURLService
@
IURLService
private
urlService
:
IURLService
,
@
IWorkspacesMainService
private
workspacesMainService
:
IWorkspacesMainService
)
{
}
public
start
(
args
:
ParsedArgs
,
userEnv
:
IProcessEnvironment
):
TPromise
<
void
>
{
...
...
@@ -149,14 +157,32 @@ export class LaunchService implements ILaunchService {
public
getMainProcessInfo
():
TPromise
<
IMainProcessInfo
>
{
this
.
logService
.
info
(
'
Received request for main process info from other instance.
'
);
return
TPromise
.
as
({
return
TPromise
.
wrap
({
mainPID
:
process
.
pid
,
windows
:
this
.
windowsMainService
.
getWindows
().
map
(
window
=>
{
return
{
pid
:
window
.
win
.
webContents
.
getOSProcessId
(),
title
:
window
.
win
.
getTitle
()
};
return
this
.
getWindowInfo
(
window
);
})
}
as
IMainProcessInfo
);
}
private
getWindowInfo
(
window
:
ICodeWindow
):
IWindowInfo
{
const
folders
:
string
[]
=
[];
if
(
window
.
openedFolderPath
)
{
folders
.
push
(
window
.
openedFolderPath
);
}
else
if
(
window
.
openedWorkspace
)
{
const
rootFolders
=
this
.
workspacesMainService
.
resolveWorkspaceSync
(
window
.
openedWorkspace
.
configPath
).
folders
;
rootFolders
.
forEach
(
root
=>
{
if
(
root
.
uri
.
scheme
===
'
file
'
)
{
folders
.
push
(
root
.
uri
.
fsPath
);
}
});
}
return
{
pid
:
window
.
win
.
webContents
.
getOSProcessId
(),
title
:
window
.
win
.
getTitle
(),
folders
}
as
IWindowInfo
;
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录