Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
7bd205a3
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,发现更多精彩内容 >>
提交
7bd205a3
编写于
3月 01, 2016
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
More plugin -> extension renames and reorg
上级
9f5d72c1
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
131 addition
and
99 deletion
+131
-99
src/vs/workbench/node/extensionHostMain.ts
src/vs/workbench/node/extensionHostMain.ts
+4
-4
src/vs/workbench/node/extensionPoints.ts
src/vs/workbench/node/extensionPoints.ts
+126
-94
src/vs/workbench/node/pluginHostProcess.ts
src/vs/workbench/node/pluginHostProcess.ts
+1
-1
未找到文件。
src/vs/workbench/node/
plugi
nHostMain.ts
→
src/vs/workbench/node/
extensio
nHostMain.ts
浏览文件 @
7bd205a3
...
...
@@ -26,7 +26,7 @@ import {ExtHostTelemetryService} from 'vs/workbench/api/node/extHostTelemetry';
import
{
BaseRequestService
}
from
'
vs/platform/request/common/baseRequestService
'
;
import
{
BaseWorkspaceContextService
}
from
'
vs/platform/workspace/common/baseWorkspaceContextService
'
;
import
{
ModeServiceImpl
}
from
'
vs/editor/common/services/modeServiceImpl
'
;
import
{
Plugi
nScanner
,
MessagesCollector
}
from
'
vs/workbench/node/extensionPoints
'
;
import
{
Extensio
nScanner
,
MessagesCollector
}
from
'
vs/workbench/node/extensionPoints
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
Client
}
from
'
vs/base/node/service.net
'
;
import
{
IExtensionsService
}
from
'
vs/workbench/parts/extensions/common/extensions
'
;
...
...
@@ -153,9 +153,9 @@ export class PluginHostMain {
}
private
static
scanPlugins
(
collector
:
MessagesCollector
,
builtinPluginsPath
:
string
,
userInstallPath
:
string
,
pluginDevelopmentPath
:
string
,
version
:
string
):
TPromise
<
IExtensionDescription
[]
>
{
const
builtinPlugins
=
PluginScanner
.
scanPlugi
ns
(
version
,
collector
,
builtinPluginsPath
,
true
);
const
userPlugins
=
!
userInstallPath
?
TPromise
.
as
([])
:
PluginScanner
.
scanPlugi
ns
(
version
,
collector
,
userInstallPath
,
false
);
const
developedPlugins
=
!
pluginDevelopmentPath
?
TPromise
.
as
([])
:
PluginScanner
.
scanOneOrMultiplePlugi
ns
(
version
,
collector
,
pluginDevelopmentPath
,
false
);
const
builtinPlugins
=
ExtensionScanner
.
scanExtensio
ns
(
version
,
collector
,
builtinPluginsPath
,
true
);
const
userPlugins
=
!
userInstallPath
?
TPromise
.
as
([])
:
ExtensionScanner
.
scanExtensio
ns
(
version
,
collector
,
userInstallPath
,
false
);
const
developedPlugins
=
!
pluginDevelopmentPath
?
TPromise
.
as
([])
:
ExtensionScanner
.
scanOneOrMultipleExtensio
ns
(
version
,
collector
,
pluginDevelopmentPath
,
false
);
return
TPromise
.
join
([
builtinPlugins
,
userPlugins
,
developedPlugins
]).
then
((
_
:
IExtensionDescription
[][])
=>
{
let
builtinPlugins
=
_
[
0
];
...
...
src/vs/workbench/node/extensionPoints.ts
浏览文件 @
7bd205a3
...
...
@@ -69,7 +69,74 @@ export class MessagesCollector {
}
}
export
class
PluginScanner
{
abstract
class
ExtensionManifestHandler
{
protected
_ourVersion
:
string
;
protected
_collector
:
MessagesCollector
;
protected
_absoluteFolderPath
:
string
;
protected
_isBuiltin
:
boolean
;
protected
_absoluteManifestPath
:
string
;
constructor
(
ourVersion
:
string
,
collector
:
MessagesCollector
,
absoluteFolderPath
:
string
,
isBuiltin
:
boolean
)
{
this
.
_ourVersion
=
ourVersion
;
this
.
_collector
=
collector
;
this
.
_absoluteFolderPath
=
absoluteFolderPath
;
this
.
_isBuiltin
=
isBuiltin
;
this
.
_absoluteManifestPath
=
paths
.
join
(
absoluteFolderPath
,
MANIFEST_FILE
);
}
}
class
ExtensionManifestParser
extends
ExtensionManifestHandler
{
public
parse
():
TPromise
<
IExtensionDescription
>
{
return
pfs
.
readFile
(
this
.
_absoluteManifestPath
).
then
((
manifestContents
)
=>
{
let
errors
:
string
[]
=
[];
let
extensionDescription
:
IExtensionDescription
=
json
.
parse
(
manifestContents
.
toString
(),
errors
);
if
(
errors
.
length
>
0
)
{
errors
.
forEach
((
error
)
=>
{
this
.
_collector
.
error
(
this
.
_absoluteFolderPath
,
'
Failed to parse
'
+
this
.
_absoluteManifestPath
+
'
:
'
+
error
);
});
return
null
;
}
return
extensionDescription
;
},
(
err
)
=>
{
this
.
_collector
.
error
(
this
.
_absoluteFolderPath
,
'
Cannot read file
'
+
this
.
_absoluteManifestPath
+
'
:
'
+
err
.
message
);
return
null
;
});
}
}
class
ExtensionManifestNLSReplacer
extends
ExtensionManifestHandler
{
public
replaceNLS
(
extensionDescription
:
IExtensionDescription
):
TPromise
<
IExtensionDescription
>
{
let
extension
=
paths
.
extname
(
this
.
_absoluteManifestPath
);
let
basename
=
this
.
_absoluteManifestPath
.
substr
(
0
,
this
.
_absoluteManifestPath
.
length
-
extension
.
length
);
return
pfs
.
fileExists
(
basename
+
'
.nls
'
+
extension
).
then
(
exists
=>
{
if
(
!
exists
)
{
return
extensionDescription
;
}
return
ExtensionManifestNLSReplacer
.
findMessageBundle
(
basename
).
then
(
messageBundle
=>
{
if
(
!
messageBundle
)
{
return
extensionDescription
;
}
return
pfs
.
readFile
(
messageBundle
).
then
(
messageBundleContent
=>
{
let
errors
:
string
[]
=
[];
let
messages
:
{
[
key
:
string
]:
string
;
}
=
json
.
parse
(
messageBundleContent
.
toString
(),
errors
);
if
(
errors
.
length
>
0
)
{
errors
.
forEach
((
error
)
=>
{
this
.
_collector
.
error
(
this
.
_absoluteFolderPath
,
'
Failed to parse
'
+
messageBundle
+
'
:
'
+
error
);
});
return
extensionDescription
;
}
ExtensionManifestNLSReplacer
.
_replaceNLStrings
(
extensionDescription
,
messages
,
this
.
_collector
,
this
.
_absoluteFolderPath
);
return
extensionDescription
;
},
(
err
)
=>
{
this
.
_collector
.
error
(
this
.
_absoluteFolderPath
,
'
Cannot read file
'
+
messageBundle
+
'
:
'
+
err
.
message
);
return
null
;
});
});
});
}
private
static
findMessageBundle
(
basename
:
string
):
TPromise
<
string
>
{
return
new
TPromise
<
string
>
((
c
,
e
,
p
)
=>
{
...
...
@@ -123,23 +190,56 @@ export class PluginScanner {
}
}
}
else
if
(
Types
.
isObject
(
value
))
{
PluginScann
er
.
_replaceNLStrings
(
value
,
messages
,
collector
,
messageScope
);
ExtensionManifestNLSReplac
er
.
_replaceNLStrings
(
value
,
messages
,
collector
,
messageScope
);
}
else
if
(
Types
.
isArray
(
value
))
{
(
<
any
[]
>
value
).
forEach
(
element
=>
{
if
(
Types
.
isObject
(
element
))
{
PluginScann
er
.
_replaceNLStrings
(
element
,
messages
,
collector
,
messageScope
);
ExtensionManifestNLSReplac
er
.
_replaceNLStrings
(
element
,
messages
,
collector
,
messageScope
);
}
});
}
}
});
}
}
class
ExtensionManifestValidator
extends
ExtensionManifestHandler
{
validate
(
extensionDescription
:
IExtensionDescription
):
IExtensionDescription
{
extensionDescription
.
isBuiltin
=
this
.
_isBuiltin
;
let
notices
:
string
[]
=
[];
if
(
!
isValidExtensionDescription
(
this
.
_ourVersion
,
this
.
_absoluteFolderPath
,
extensionDescription
,
notices
))
{
notices
.
forEach
((
error
)
=>
{
this
.
_collector
.
error
(
this
.
_absoluteFolderPath
,
error
);
});
return
null
;
}
// in this case the notices are warnings
notices
.
forEach
((
error
)
=>
{
this
.
_collector
.
warn
(
this
.
_absoluteFolderPath
,
error
);
});
// id := `publisher.name`
extensionDescription
.
id
=
`
${
extensionDescription
.
publisher
}
.
${
extensionDescription
.
name
}
`
;
// main := absolutePath(`main`)
if
(
extensionDescription
.
main
)
{
extensionDescription
.
main
=
paths
.
normalize
(
paths
.
join
(
this
.
_absoluteFolderPath
,
extensionDescription
.
main
));
}
extensionDescription
.
extensionFolderPath
=
this
.
_absoluteFolderPath
;
return
extensionDescription
;
}
}
export
class
ExtensionScanner
{
/**
*
Scan the plugi
n defined in `absoluteFolderPath`
*
Read the extensio
n defined in `absoluteFolderPath`
*/
public
static
scan
Plugi
n
(
public
static
scan
Extensio
n
(
version
:
string
,
collector
:
MessagesCollector
,
absoluteFolderPath
:
string
,
...
...
@@ -147,97 +247,29 @@ export class PluginScanner {
)
:
TPromise
<
IExtensionDescription
>
{
absoluteFolderPath
=
paths
.
normalize
(
absoluteFolderPath
);
let
absoluteManifestPath
=
paths
.
join
(
absoluteFolderPath
,
MANIFEST_FILE
);
let
parseJSONManifest
=
(
manifestContents
:
string
):
IExtensionDescription
=>
{
let
errors
:
string
[]
=
[];
let
pluginDescFromFile
:
IExtensionDescription
=
json
.
parse
(
manifestContents
,
errors
);
if
(
errors
.
length
>
0
)
{
errors
.
forEach
((
error
)
=>
{
collector
.
error
(
absoluteFolderPath
,
'
Failed to parse
'
+
absoluteManifestPath
+
'
:
'
+
error
);
});
let
parser
=
new
ExtensionManifestParser
(
version
,
collector
,
absoluteFolderPath
,
isBuiltin
);
return
parser
.
parse
().
then
((
extensionDescription
)
=>
{
if
(
extensionDescription
===
null
)
{
return
null
;
}
return
pluginDescFromFile
;
};
let
replaceNLStrings
=
(
pluginDescFromFile
:
IExtensionDescription
):
TPromise
<
IExtensionDescription
>
=>
{
let
extension
=
paths
.
extname
(
absoluteManifestPath
);
let
basename
=
absoluteManifestPath
.
substr
(
0
,
absoluteManifestPath
.
length
-
extension
.
length
);
return
pfs
.
fileExists
(
basename
+
'
.nls
'
+
extension
).
then
(
exists
=>
{
if
(
!
exists
)
{
return
pluginDescFromFile
;
}
return
PluginScanner
.
findMessageBundle
(
basename
).
then
(
messageBundle
=>
{
if
(
!
messageBundle
)
{
return
pluginDescFromFile
;
}
return
pfs
.
readFile
(
messageBundle
).
then
(
messageBundleContent
=>
{
let
errors
:
string
[]
=
[];
let
messages
:
{
[
key
:
string
]:
string
;
}
=
json
.
parse
(
messageBundleContent
.
toString
(),
errors
);
if
(
errors
.
length
>
0
)
{
errors
.
forEach
((
error
)
=>
{
collector
.
error
(
absoluteFolderPath
,
'
Failed to parse
'
+
messageBundle
+
'
:
'
+
error
);
});
return
pluginDescFromFile
;
}
PluginScanner
.
_replaceNLStrings
(
pluginDescFromFile
,
messages
,
collector
,
absoluteFolderPath
);
return
pluginDescFromFile
;
});
});
});
};
return
pfs
.
readFile
(
absoluteManifestPath
).
then
((
manifestContents
)
=>
{
let
pluginDescFromFile
=
parseJSONManifest
(
manifestContents
.
toString
());
if
(
pluginDescFromFile
===
null
)
{
let
nlsReplacer
=
new
ExtensionManifestNLSReplacer
(
version
,
collector
,
absoluteFolderPath
,
isBuiltin
);
return
nlsReplacer
.
replaceNLS
(
extensionDescription
);
}).
then
((
extensionDescription
)
=>
{
if
(
extensionDescription
===
null
)
{
return
null
;
}
return
replaceNLStrings
(
pluginDescFromFile
);
}).
then
((
pluginDescFromFile
)
=>
{
if
(
pluginDescFromFile
===
null
)
{
return
null
;
}
pluginDescFromFile
.
isBuiltin
=
isBuiltin
;
let
notices
:
string
[]
=
[];
if
(
!
isValidExtensionDescription
(
version
,
absoluteFolderPath
,
pluginDescFromFile
,
notices
))
{
notices
.
forEach
((
error
)
=>
{
collector
.
error
(
absoluteFolderPath
,
error
);
});
return
null
;
}
// in this case the notices are warnings
notices
.
forEach
((
error
)
=>
{
collector
.
warn
(
absoluteFolderPath
,
error
);
});
// id := `publisher.name`
pluginDescFromFile
.
id
=
`
${
pluginDescFromFile
.
publisher
}
.
${
pluginDescFromFile
.
name
}
`
;
// main := absolutePath(`main`)
if
(
pluginDescFromFile
.
main
)
{
pluginDescFromFile
.
main
=
paths
.
normalize
(
paths
.
join
(
absoluteFolderPath
,
pluginDescFromFile
.
main
));
}
pluginDescFromFile
.
extensionFolderPath
=
absoluteFolderPath
;
return
pluginDescFromFile
;
},
(
err
)
=>
{
collector
.
error
(
absoluteFolderPath
,
'
Cannot read file
'
+
absoluteManifestPath
+
'
:
'
+
err
.
message
);
return
null
;
let
validator
=
new
ExtensionManifestValidator
(
version
,
collector
,
absoluteFolderPath
,
isBuiltin
);
return
validator
.
validate
(
extensionDescription
);
});
}
/**
* Scan a list of extensions defined in `absoluteFolderPath`
*/
public
static
scan
Plugi
ns
(
public
static
scan
Extensio
ns
(
version
:
string
,
collector
:
MessagesCollector
,
absoluteFolderPath
:
string
,
...
...
@@ -254,13 +286,13 @@ export class PluginScanner {
return
obsolete
.
then
(
obsolete
=>
{
return
pfs
.
readDirsInDir
(
absoluteFolderPath
)
.
then
(
folders
=>
TPromise
.
join
(
folders
.
map
(
f
=>
this
.
scan
Plugi
n
(
version
,
collector
,
paths
.
join
(
absoluteFolderPath
,
f
),
isBuiltin
))))
.
then
(
plugins
=>
plugi
ns
.
filter
(
item
=>
item
!==
null
))
.
then
(
folders
=>
TPromise
.
join
(
folders
.
map
(
f
=>
this
.
scan
Extensio
n
(
version
,
collector
,
paths
.
join
(
absoluteFolderPath
,
f
),
isBuiltin
))))
.
then
(
extensionDescriptions
=>
extensionDescriptio
ns
.
filter
(
item
=>
item
!==
null
))
// TODO: align with extensionsService
.
then
(
plugins
=>
plugi
ns
.
filter
(
p
=>
!
obsolete
[
`
${
p
.
publisher
}
.
${
p
.
name
}
-
${
p
.
version
}
`
]))
.
then
(
plugi
ns
=>
{
const
pluginsById
=
values
(
groupBy
(
plugi
ns
,
p
=>
p
.
id
));
return
plugi
nsById
.
map
(
p
=>
p
.
sort
((
a
,
b
)
=>
semver
.
rcompare
(
a
.
version
,
b
.
version
))[
0
]);
.
then
(
extensionDescriptions
=>
extensionDescriptio
ns
.
filter
(
p
=>
!
obsolete
[
`
${
p
.
publisher
}
.
${
p
.
name
}
-
${
p
.
version
}
`
]))
.
then
(
extensionDescriptio
ns
=>
{
const
extensionDescriptionsById
=
values
(
groupBy
(
extensionDescriptio
ns
,
p
=>
p
.
id
));
return
extensionDescriptio
nsById
.
map
(
p
=>
p
.
sort
((
a
,
b
)
=>
semver
.
rcompare
(
a
.
version
,
b
.
version
))[
0
]);
})
.
then
(
null
,
err
=>
{
collector
.
error
(
absoluteFolderPath
,
err
);
...
...
@@ -270,10 +302,10 @@ export class PluginScanner {
}
/**
* Combination of scan
Plugin and scanPlugins: If a plugin manifest is found at root, we load just this plugin, otherwise we assume
* the folder contains multiple extensions.
* Combination of scan
Extension and scanExtensions: If an extension manifest is found at root, we load just this extension,
*
otherwise we assume
the folder contains multiple extensions.
*/
public
static
scanOneOrMultiple
Plugi
ns
(
public
static
scanOneOrMultiple
Extensio
ns
(
version
:
string
,
collector
:
MessagesCollector
,
absoluteFolderPath
:
string
,
...
...
@@ -282,14 +314,14 @@ export class PluginScanner {
{
return
pfs
.
fileExists
(
paths
.
join
(
absoluteFolderPath
,
MANIFEST_FILE
)).
then
((
exists
)
=>
{
if
(
exists
)
{
return
this
.
scan
Plugi
n
(
version
,
collector
,
absoluteFolderPath
,
isBuiltin
).
then
((
extensionDescription
)
=>
{
return
this
.
scan
Extensio
n
(
version
,
collector
,
absoluteFolderPath
,
isBuiltin
).
then
((
extensionDescription
)
=>
{
if
(
extensionDescription
===
null
)
{
return
[];
}
return
[
extensionDescription
];
});
}
return
this
.
scan
Plugi
ns
(
version
,
collector
,
absoluteFolderPath
,
isBuiltin
);
return
this
.
scan
Extensio
ns
(
version
,
collector
,
absoluteFolderPath
,
isBuiltin
);
},
(
err
)
=>
{
collector
.
error
(
absoluteFolderPath
,
err
);
return
[];
...
...
src/vs/workbench/node/pluginHostProcess.ts
浏览文件 @
7bd205a3
...
...
@@ -7,7 +7,7 @@
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
PluginHostMain
,
createServices
,
IInitData
,
exit
}
from
'
vs/workbench/node/
plugi
nHostMain
'
;
import
{
PluginHostMain
,
createServices
,
IInitData
,
exit
}
from
'
vs/workbench/node/
extensio
nHostMain
'
;
import
{
Client
,
connect
}
from
'
vs/base/node/service.net
'
;
import
{
create
as
createIPC
,
IPluginsIPC
}
from
'
vs/platform/extensions/common/ipcRemoteCom
'
;
import
marshalling
=
require
(
'
vs/base/common/marshalling
'
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录