Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
徽霖
Vscode
提交
855bcc50
V
Vscode
项目概览
徽霖
/
Vscode
通知
9
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,发现更多精彩内容 >>
提交
855bcc50
编写于
10月 06, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
get rid of IEnvService (fixes #10656)
上级
91db8b52
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
45 addition
and
78 deletion
+45
-78
src/vs/code/electron-main/main.ts
src/vs/code/electron-main/main.ts
+10
-12
src/vs/code/electron-main/menus.ts
src/vs/code/electron-main/menus.ts
+3
-3
src/vs/code/electron-main/paths.ts
src/vs/code/electron-main/paths.ts
+20
-53
src/vs/code/electron-main/windows.ts
src/vs/code/electron-main/windows.ts
+7
-8
src/vs/platform/environment/node/environmentService.ts
src/vs/platform/environment/node/environmentService.ts
+5
-2
未找到文件。
src/vs/code/electron-main/main.ts
浏览文件 @
855bcc50
...
...
@@ -11,7 +11,7 @@ import { assign } from 'vs/base/common/objects';
import
*
as
platform
from
'
vs/base/common/platform
'
;
import
{
parseMainProcessArgv
,
ParsedArgs
}
from
'
vs/platform/environment/node/argv
'
;
import
{
mkdirp
}
from
'
vs/base/node/pfs
'
;
import
{
IEnvService
,
EnvService
}
from
'
vs/code/electron-main/env
'
;
import
{
validatePaths
}
from
'
vs/code/electron-main/paths
'
;
import
{
IWindowsService
,
WindowsManager
,
WindowEventService
}
from
'
vs/code/electron-main/windows
'
;
import
{
IWindowEventService
}
from
'
vs/code/common/windows
'
;
import
{
WindowEventChannel
}
from
'
vs/code/common/windowsIpc
'
;
...
...
@@ -72,7 +72,6 @@ function quit(accessor: ServicesAccessor, arg?: any) {
function
main
(
accessor
:
ServicesAccessor
,
mainIpcServer
:
Server
,
userEnv
:
platform
.
IProcessEnvironment
):
void
{
const
instantiationService
=
accessor
.
get
(
IInstantiationService
);
const
logService
=
accessor
.
get
(
ILogService
);
const
envService
=
accessor
.
get
(
IEnvService
);
const
environmentService
=
accessor
.
get
(
IEnvironmentService
);
const
windowsService
=
accessor
.
get
(
IWindowsService
);
const
windowEventService
=
accessor
.
get
(
IWindowEventService
);
...
...
@@ -103,7 +102,7 @@ function main(accessor: ServicesAccessor, mainIpcServer: Server, userEnv: platfo
logService
.
log
(
'
Starting VS Code in verbose mode
'
);
logService
.
log
(
`from:
${
environmentService
.
appRoot
}
`
);
logService
.
log
(
'
args:
'
,
env
Service
.
cliA
rgs
);
logService
.
log
(
'
args:
'
,
env
ironmentService
.
a
rgs
);
// Setup Windows mutex
let
windowsMutex
:
Mutex
=
null
;
...
...
@@ -253,19 +252,18 @@ function main(accessor: ServicesAccessor, mainIpcServer: Server, userEnv: platfo
updateService
.
initialize
();
// Open our first window
if
(
env
Service
.
cliArgs
[
'
new-window
'
]
&&
envService
.
cliA
rgs
.
_
.
length
===
0
)
{
windowsService
.
open
({
cli
:
env
Service
.
cliA
rgs
,
forceNewWindow
:
true
,
forceEmpty
:
true
});
// new window if "-n" was used without paths
}
else
if
(
global
.
macOpenFiles
&&
global
.
macOpenFiles
.
length
&&
(
!
env
Service
.
cliArgs
.
_
||
!
envService
.
cliA
rgs
.
_
.
length
))
{
windowsService
.
open
({
cli
:
env
Service
.
cliA
rgs
,
pathsToOpen
:
global
.
macOpenFiles
});
// mac: open-file event received on startup
if
(
env
ironmentService
.
args
[
'
new-window
'
]
&&
environmentService
.
a
rgs
.
_
.
length
===
0
)
{
windowsService
.
open
({
cli
:
env
ironmentService
.
a
rgs
,
forceNewWindow
:
true
,
forceEmpty
:
true
});
// new window if "-n" was used without paths
}
else
if
(
global
.
macOpenFiles
&&
global
.
macOpenFiles
.
length
&&
(
!
env
ironmentService
.
args
.
_
||
!
environmentService
.
a
rgs
.
_
.
length
))
{
windowsService
.
open
({
cli
:
env
ironmentService
.
a
rgs
,
pathsToOpen
:
global
.
macOpenFiles
});
// mac: open-file event received on startup
}
else
{
windowsService
.
open
({
cli
:
env
Service
.
cliArgs
,
forceNewWindow
:
envService
.
cliArgs
[
'
new-window
'
],
diffMode
:
envService
.
cliA
rgs
.
diff
});
// default: read paths from cli
windowsService
.
open
({
cli
:
env
ironmentService
.
args
,
forceNewWindow
:
environmentService
.
args
[
'
new-window
'
],
diffMode
:
environmentService
.
a
rgs
.
diff
});
// default: read paths from cli
}
}
function
setupIPC
(
accessor
:
ServicesAccessor
):
TPromise
<
Server
>
{
const
logService
=
accessor
.
get
(
ILogService
);
const
environmentService
=
accessor
.
get
(
IEnvironmentService
);
const
envService
=
accessor
.
get
(
IEnvService
);
function
setup
(
retry
:
boolean
):
TPromise
<
Server
>
{
return
serve
(
environmentService
.
mainIPCHandle
).
then
(
server
=>
{
...
...
@@ -301,7 +299,7 @@ function setupIPC(accessor: ServicesAccessor): TPromise<Server> {
const
channel
=
client
.
getChannel
<
ILaunchChannel
>
(
'
launch
'
);
const
service
=
new
LaunchChannelClient
(
channel
);
return
service
.
start
(
env
Service
.
cliA
rgs
,
process
.
env
)
return
service
.
start
(
env
ironmentService
.
a
rgs
,
process
.
env
)
.
then
(()
=>
client
.
dispose
())
.
then
(()
=>
TPromise
.
wrapError
(
'
Sent env to running instance. Terminating...
'
));
},
...
...
@@ -426,7 +424,7 @@ function getEnvironment(accessor: ServicesAccessor): TPromise<platform.IProcessE
function
createPaths
(
environmentService
:
IEnvironmentService
):
TPromise
<
any
>
{
const
paths
=
[
environmentService
.
appSettingsHome
,
environmentService
.
userHome
,
environmentService
.
extensionsPath
];
return
TPromise
.
join
(
paths
.
map
(
p
=>
mkdirp
(
p
)))
as
TPromise
<
any
>
;
}
...
...
@@ -435,6 +433,7 @@ function start(): void {
try
{
args
=
parseMainProcessArgv
(
process
.
argv
);
args
=
validatePaths
(
args
);
}
catch
(
err
)
{
console
.
error
(
err
.
message
);
process
.
exit
(
1
);
...
...
@@ -445,7 +444,6 @@ function start(): void {
const
services
=
new
ServiceCollection
();
services
.
set
(
IEnvironmentService
,
new
SyncDescriptor
(
EnvironmentService
,
args
,
process
.
execPath
));
services
.
set
(
IEnvService
,
new
SyncDescriptor
(
EnvService
));
services
.
set
(
ILogService
,
new
SyncDescriptor
(
MainLogService
));
services
.
set
(
IWindowsService
,
new
SyncDescriptor
(
WindowsManager
));
services
.
set
(
IWindowEventService
,
new
SyncDescriptor
(
WindowEventService
));
...
...
src/vs/code/electron-main/menus.ts
浏览文件 @
855bcc50
...
...
@@ -8,7 +8,7 @@
import
*
as
nls
from
'
vs/nls
'
;
import
*
as
platform
from
'
vs/base/common/platform
'
;
import
*
as
arrays
from
'
vs/base/common/arrays
'
;
import
{
IEnv
Service
}
from
'
vs/code/electron-main/env
'
;
import
{
IEnv
ironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
ipcMain
as
ipc
,
app
,
shell
,
dialog
,
Menu
,
MenuItem
}
from
'
electron
'
;
import
{
IWindowsService
}
from
'
vs/code/electron-main/windows
'
;
import
{
IPath
,
VSCodeWindow
}
from
'
vs/code/electron-main/window
'
;
...
...
@@ -45,7 +45,7 @@ export class VSCodeMenu {
@
IUpdateService
private
updateService
:
IUpdateService
,
@
IConfigurationService
private
configurationService
:
IConfigurationService
,
@
IWindowsService
private
windowsService
:
IWindowsService
,
@
IEnv
Service
private
envService
:
IEnv
Service
@
IEnv
ironmentService
private
environmentService
:
IEnvironment
Service
)
{
this
.
actionIdKeybindingRequests
=
[];
...
...
@@ -405,7 +405,7 @@ export class VSCodeMenu {
return
new
MenuItem
({
label
:
unMnemonicLabel
(
path
),
click
:
(
menuItem
,
win
,
event
)
=>
{
const
openInNewWindow
=
event
&&
((
!
platform
.
isMacintosh
&&
event
.
ctrlKey
)
||
(
platform
.
isMacintosh
&&
event
.
metaKey
));
const
success
=
!!
this
.
windowsService
.
open
({
cli
:
this
.
env
Service
.
cliA
rgs
,
pathsToOpen
:
[
path
],
forceNewWindow
:
openInNewWindow
});
const
success
=
!!
this
.
windowsService
.
open
({
cli
:
this
.
env
ironmentService
.
a
rgs
,
pathsToOpen
:
[
path
],
forceNewWindow
:
openInNewWindow
});
if
(
!
success
)
{
this
.
windowsService
.
removeFromRecentPathsList
(
path
);
this
.
updateMenu
();
...
...
src/vs/code/electron-main/
env
.ts
→
src/vs/code/electron-main/
paths
.ts
浏览文件 @
855bcc50
...
...
@@ -12,55 +12,26 @@ import * as strings from 'vs/base/common/strings';
import
*
as
paths
from
'
vs/base/common/paths
'
;
import
*
as
platform
from
'
vs/base/common/platform
'
;
import
*
as
types
from
'
vs/base/common/types
'
;
import
{
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
parseMainProcessArgv
,
ParsedArgs
}
from
'
vs/platform/environment/node/argv
'
;
import
{
ParsedArgs
}
from
'
vs/platform/environment/node/argv
'
;
export
const
IEnvService
=
createDecorator
<
IEnvService
>
(
'
mainEnvironmentService
'
);
export
function
validatePaths
(
args
:
ParsedArgs
):
ParsedArgs
{
export
interface
IEnvService
{
_serviceBrand
:
any
;
cliArgs
:
ParsedArgs
;
}
// Realpath/normalize paths and watch out for goto line mode
const
paths
=
doValidatePaths
(
args
.
_
,
args
.
goto
);
export
class
EnvService
implements
IEnvService
{
_serviceBrand
:
any
;
private
_cliArgs
:
ParsedArgs
;
get
cliArgs
():
ParsedArgs
{
return
this
.
_cliArgs
;
}
constructor
()
{
const
argv
=
parseMainProcessArgv
(
process
.
argv
);
const
paths
=
parsePathArguments
(
argv
.
_
,
argv
.
goto
);
this
.
_cliArgs
=
Object
.
freeze
({
_
:
paths
,
performance
:
argv
.
performance
,
verbose
:
argv
.
verbose
,
debugPluginHost
:
argv
.
debugPluginHost
,
debugBrkPluginHost
:
argv
.
debugBrkPluginHost
,
logExtensionHostCommunication
:
argv
.
logExtensionHostCommunication
,
'
new-window
'
:
argv
[
'
new-window
'
],
'
reuse-window
'
:
argv
[
'
reuse-window
'
],
goto
:
argv
.
goto
,
diff
:
argv
.
diff
&&
paths
.
length
===
2
,
extensionHomePath
:
normalizePath
(
argv
.
extensionHomePath
),
extensionDevelopmentPath
:
normalizePath
(
argv
.
extensionDevelopmentPath
),
extensionTestsPath
:
normalizePath
(
argv
.
extensionTestsPath
),
'
disable-extensions
'
:
argv
[
'
disable-extensions
'
],
'
open-url
'
:
argv
[
'
open-url
'
],
locale
:
argv
.
locale
,
wait
:
argv
.
wait
});
}
// Update environment
args
.
_
=
paths
;
args
.
diff
=
args
.
diff
&&
paths
.
length
===
2
;
return
args
;
}
function
parsePathArgument
s
(
args
:
string
[],
gotoLineMode
?:
boolean
):
string
[]
{
function
doValidatePath
s
(
args
:
string
[],
gotoLineMode
?:
boolean
):
string
[]
{
const
cwd
=
process
.
env
[
'
VSCODE_CWD
'
]
||
process
.
cwd
();
const
result
=
args
.
map
(
arg
=>
{
let
pathCandidate
=
String
(
arg
);
let
parsedPath
:
IPa
rsedPath
;
let
parsedPath
:
IPa
thWithLineAndColumn
;
if
(
gotoLineMode
)
{
parsedPath
=
parseLineAndColumnAware
(
pathCandidate
);
pathCandidate
=
parsedPath
.
path
;
...
...
@@ -86,7 +57,7 @@ function parsePathArguments(args: string[], gotoLineMode?: boolean): string[] {
if
(
gotoLineMode
)
{
parsedPath
.
path
=
realPath
;
return
to
LineAndColumn
Path
(
parsedPath
);
return
toPath
(
parsedPath
);
}
return
realPath
;
...
...
@@ -120,17 +91,13 @@ function preparePath(cwd: string, p: string): string {
return
p
;
}
function
normalizePath
(
p
?:
string
):
string
{
return
p
?
path
.
normalize
(
p
)
:
p
;
}
export
interface
IParsedPath
{
export
interface
IPathWithLineAndColumn
{
path
:
string
;
line
?:
number
;
column
?:
number
;
}
export
function
parseLineAndColumnAware
(
rawPath
:
string
):
IPa
rsedPath
{
export
function
parseLineAndColumnAware
(
rawPath
:
string
):
IPa
thWithLineAndColumn
{
const
segments
=
rawPath
.
split
(
'
:
'
);
// C:\file.txt:<line>:<column>
let
path
:
string
;
...
...
@@ -159,15 +126,15 @@ export function parseLineAndColumnAware(rawPath: string): IParsedPath {
};
}
function
to
LineAndColumnPath
(
parsedPath
:
IParsedPath
):
string
{
const
segments
=
[
p
arsedPath
.
path
];
function
to
Path
(
p
:
IPathWithLineAndColumn
):
string
{
const
segments
=
[
p
.
path
];
if
(
types
.
isNumber
(
p
arsedPath
.
line
))
{
segments
.
push
(
String
(
p
arsedPath
.
line
));
if
(
types
.
isNumber
(
p
.
line
))
{
segments
.
push
(
String
(
p
.
line
));
}
if
(
types
.
isNumber
(
p
arsedPath
.
column
))
{
segments
.
push
(
String
(
p
arsedPath
.
column
));
if
(
types
.
isNumber
(
p
.
column
))
{
segments
.
push
(
String
(
p
.
column
));
}
return
segments
.
join
(
'
:
'
);
...
...
src/vs/code/electron-main/windows.ts
浏览文件 @
855bcc50
...
...
@@ -18,7 +18,7 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment'
import
{
IStorageService
}
from
'
vs/code/electron-main/storage
'
;
import
{
IPath
,
VSCodeWindow
,
ReadyState
,
IWindowConfiguration
,
IWindowState
as
ISingleWindowState
,
defaultWindowState
,
IWindowSettings
}
from
'
vs/code/electron-main/window
'
;
import
{
ipcMain
as
ipc
,
app
,
screen
,
crashReporter
,
BrowserWindow
,
dialog
}
from
'
electron
'
;
import
{
I
EnvService
,
IParsedPath
,
parseLineAndColumnAware
}
from
'
vs/code/electron-main/env
'
;
import
{
I
PathWithLineAndColumn
,
parseLineAndColumnAware
}
from
'
vs/code/electron-main/paths
'
;
import
{
ILifecycleService
}
from
'
vs/code/electron-main/lifecycle
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IUpdateService
,
IUpdate
}
from
'
vs/code/electron-main/update-manager
'
;
...
...
@@ -163,7 +163,6 @@ export class WindowsManager implements IWindowsService {
@
IInstantiationService
private
instantiationService
:
IInstantiationService
,
@
ILogService
private
logService
:
ILogService
,
@
IStorageService
private
storageService
:
IStorageService
,
@
IEnvService
private
envService
:
IEnvService
,
@
IEnvironmentService
private
environmentService
:
IEnvironmentService
,
@
ILifecycleService
private
lifecycleService
:
ILifecycleService
,
@
IUpdateService
private
updateService
:
IUpdateService
,
...
...
@@ -222,7 +221,7 @@ export class WindowsManager implements IWindowsService {
// Handle paths delayed in case more are coming!
runningTimeout
=
setTimeout
(()
=>
{
this
.
open
({
cli
:
this
.
env
Service
.
cliA
rgs
,
pathsToOpen
:
macOpenFiles
,
preferNewWindow
:
true
/* dropping on the dock prefers to open in a new window */
});
this
.
open
({
cli
:
this
.
env
ironmentService
.
a
rgs
,
pathsToOpen
:
macOpenFiles
,
preferNewWindow
:
true
/* dropping on the dock prefers to open in a new window */
});
macOpenFiles
=
[];
runningTimeout
=
null
;
},
100
);
...
...
@@ -238,7 +237,7 @@ export class WindowsManager implements IWindowsService {
this
.
logService
.
log
(
'
IPC#vscode-windowOpen:
'
,
paths
);
if
(
paths
&&
paths
.
length
)
{
this
.
open
({
cli
:
this
.
env
Service
.
cliA
rgs
,
pathsToOpen
:
paths
,
forceNewWindow
:
forceNewWindow
});
this
.
open
({
cli
:
this
.
env
ironmentService
.
a
rgs
,
pathsToOpen
:
paths
,
forceNewWindow
:
forceNewWindow
});
}
});
...
...
@@ -277,7 +276,7 @@ export class WindowsManager implements IWindowsService {
const
win
=
this
.
getWindowById
(
windowId
);
if
(
win
)
{
this
.
open
({
cli
:
this
.
env
Service
.
cliA
rgs
,
forceEmpty
:
true
,
windowToUse
:
win
});
this
.
open
({
cli
:
this
.
env
ironmentService
.
a
rgs
,
forceEmpty
:
true
,
windowToUse
:
win
});
}
});
...
...
@@ -862,7 +861,7 @@ export class WindowsManager implements IWindowsService {
return
null
;
}
let
parsedPath
:
IPa
rsedPath
;
let
parsedPath
:
IPa
thWithLineAndColumn
;
if
(
gotoLineMode
)
{
parsedPath
=
parseLineAndColumnAware
(
anyPath
);
anyPath
=
parsedPath
.
path
;
...
...
@@ -1107,7 +1106,7 @@ export class WindowsManager implements IWindowsService {
private
doPickAndOpen
(
options
:
INativeOpenDialogOptions
):
void
{
this
.
getFileOrFolderPaths
(
options
,
(
paths
:
string
[])
=>
{
if
(
paths
&&
paths
.
length
)
{
this
.
open
({
cli
:
this
.
env
Service
.
cliA
rgs
,
pathsToOpen
:
paths
,
forceNewWindow
:
options
.
forceNewWindow
});
this
.
open
({
cli
:
this
.
env
ironmentService
.
a
rgs
,
pathsToOpen
:
paths
,
forceNewWindow
:
options
.
forceNewWindow
});
}
});
}
...
...
@@ -1213,7 +1212,7 @@ export class WindowsManager implements IWindowsService {
}
public
openNewWindow
():
void
{
this
.
open
({
cli
:
this
.
env
Service
.
cliA
rgs
,
forceNewWindow
:
true
,
forceEmpty
:
true
});
this
.
open
({
cli
:
this
.
env
ironmentService
.
a
rgs
,
forceNewWindow
:
true
,
forceEmpty
:
true
});
}
public
sendToFocused
(
channel
:
string
,
...
args
:
any
[]):
void
{
...
...
src/vs/platform/environment/node/environmentService.ts
浏览文件 @
855bcc50
...
...
@@ -79,9 +79,12 @@ export class EnvironmentService implements IEnvironmentService {
@
memoize
get
extensionsPath
():
string
{
return
path
.
normalize
(
this
.
_args
.
extensionHomePath
||
path
.
join
(
this
.
userHome
,
'
extensions
'
));
}
get
extensionDevelopmentPath
():
string
{
return
this
.
_args
.
extensionDevelopmentPath
;
}
@
memoize
get
extensionDevelopmentPath
():
string
{
return
this
.
_args
.
extensionDevelopmentPath
?
path
.
normalize
(
this
.
_args
.
extensionDevelopmentPath
)
:
this
.
_args
.
extensionDevelopmentPath
;
}
@
memoize
get
extensionTestsPath
():
string
{
return
this
.
_args
.
extensionTestsPath
?
path
.
normalize
(
this
.
_args
.
extensionTestsPath
)
:
this
.
_args
.
extensionTestsPath
;
}
get
extensionTestsPath
():
string
{
return
this
.
_args
.
extensionTestsPath
;
}
get
disableExtensions
():
boolean
{
return
this
.
_args
[
'
disable-extensions
'
];
}
@
memoize
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录