Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
0f800b76
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,发现更多精彩内容 >>
提交
0f800b76
编写于
12月 16, 2015
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
load latest extension version
fixes #1111
上级
c27759dd
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
83 addition
and
30 deletion
+83
-30
src/vs/base/common/arrays.ts
src/vs/base/common/arrays.ts
+4
-0
src/vs/platform/plugins/common/plugins.ts
src/vs/platform/plugins/common/plugins.ts
+1
-0
src/vs/workbench/electron-main/sharedProcessMain.ts
src/vs/workbench/electron-main/sharedProcessMain.ts
+5
-1
src/vs/workbench/node/extensionPoints.ts
src/vs/workbench/node/extensionPoints.ts
+35
-18
src/vs/workbench/node/pluginHostMain.ts
src/vs/workbench/node/pluginHostMain.ts
+3
-4
src/vs/workbench/parts/extensions/common/extensions.ts
src/vs/workbench/parts/extensions/common/extensions.ts
+1
-1
src/vs/workbench/parts/extensions/electron-browser/extensionsQuickOpen.ts
.../parts/extensions/electron-browser/extensionsQuickOpen.ts
+2
-2
src/vs/workbench/parts/extensions/node/extensionsService.ts
src/vs/workbench/parts/extensions/node/extensionsService.ts
+32
-4
未找到文件。
src/vs/base/common/arrays.ts
浏览文件 @
0f800b76
...
...
@@ -220,3 +220,7 @@ export function commonPrefixLength<T>(one: T[], other: T[], equals: (a: T, b: T)
return
result
;
}
export
function
flatten
<
T
>
(
arr
:
T
[][]):
T
[]
{
return
arr
.
reduce
((
r
,
v
)
=>
r
.
concat
(
v
),
[]);
}
\ No newline at end of file
src/vs/platform/plugins/common/plugins.ts
浏览文件 @
0f800b76
...
...
@@ -11,6 +11,7 @@ import Severity from 'vs/base/common/severity';
export
interface
IPluginDescription
{
id
:
string
;
name
:
string
;
version
:
string
;
publisher
:
string
;
isBuiltin
:
boolean
;
extensionFolderPath
:
string
;
...
...
src/vs/workbench/electron-main/sharedProcessMain.ts
浏览文件 @
0f800b76
...
...
@@ -61,7 +61,11 @@ function main(server: Server, initData: IInitData): void {
instantiationService
.
addSingleton
(
IRequestService
,
requestService
);
instantiationService
.
addSingleton
(
IExtensionsService
,
new
SyncDescriptor
(
ExtensionsService
));
server
.
registerService
(
'
ExtensionService
'
,
instantiationService
.
getInstance
(
IExtensionsService
));
const
extensionService
=
<
ExtensionsService
>
instantiationService
.
getInstance
(
IExtensionsService
);
server
.
registerService
(
'
ExtensionService
'
,
extensionService
);
// eventually clean up old extensions
setTimeout
(()
=>
extensionService
.
removeDeprecatedExtensions
(),
5000
);
}
function
setupIPC
(
hook
:
string
):
TPromise
<
Server
>
{
...
...
src/vs/workbench/node/extensionPoints.ts
浏览文件 @
0f800b76
...
...
@@ -5,19 +5,15 @@
'
use strict
'
;
import
nls
=
require
(
'
vs/nls
'
);
import
fs
=
require
(
'
fs
'
);
import
pfs
=
require
(
'
vs/base/node/pfs
'
);
import
{
IPluginDescription
}
from
'
vs/platform/plugins/common/plugins
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
groupBy
,
values
}
from
'
vs/base/common/collections
'
;
import
paths
=
require
(
'
vs/base/common/paths
'
);
import
json
=
require
(
'
vs/base/common/json
'
);
import
strings
=
require
(
'
vs/base/common/strings
'
);
import
{
ILanguageExtensionPoint
}
from
'
vs/editor/common/modes/languageExtensionPoint
'
;
import
{
PluginsRegistry
,
IPluginsMessageCollector
}
from
'
vs/platform/plugins/common/pluginsRegistry
'
;
import
{
IPluginsMessageCollector
}
from
'
vs/platform/plugins/common/pluginsRegistry
'
;
import
{
isValidPluginDescription
}
from
'
vs/platform/plugins/node/pluginVersionValidator
'
;
import
*
as
semver
from
'
semver
'
;
const
MANIFEST_FILE
=
'
package.json
'
;
...
...
@@ -26,7 +22,13 @@ export class PluginScanner {
/**
* Scan the plugin defined in `absoluteFolderPath`
*/
public
static
scanPlugin
(
version
:
string
,
collector
:
IPluginsMessageCollector
,
absoluteFolderPath
:
string
,
isBuiltin
:
boolean
):
TPromise
<
IPluginDescription
>
{
public
static
scanPlugin
(
version
:
string
,
collector
:
IPluginsMessageCollector
,
absoluteFolderPath
:
string
,
isBuiltin
:
boolean
)
:
TPromise
<
IPluginDescription
>
{
absoluteFolderPath
=
paths
.
normalize
(
absoluteFolderPath
);
let
builder
=
collector
.
scopeTo
(
absoluteFolderPath
);
let
absoluteManifestPath
=
paths
.
join
(
absoluteFolderPath
,
MANIFEST_FILE
);
...
...
@@ -81,22 +83,37 @@ export class PluginScanner {
/**
* Scan a list of extensions defined in `absoluteFolderPath`
*/
public
static
scanPlugins
(
version
:
string
,
collector
:
IPluginsMessageCollector
,
absoluteFolderPath
:
string
,
isBuiltin
:
boolean
):
TPromise
<
IPluginDescription
[]
>
{
return
pfs
.
readDirsInDir
(
absoluteFolderPath
).
then
((
folders
)
=>
{
return
TPromise
.
join
(
folders
.
map
((
folder
)
=>
this
.
scanPlugin
(
version
,
collector
,
paths
.
join
(
absoluteFolderPath
,
folder
),
isBuiltin
))
);
},
(
err
)
=>
{
collector
.
error
(
absoluteFolderPath
,
err
);
return
[];
}).
then
((
results
)
=>
results
.
filter
(
item
=>
(
item
!==
null
)));
public
static
scanPlugins
(
version
:
string
,
collector
:
IPluginsMessageCollector
,
absoluteFolderPath
:
string
,
isBuiltin
:
boolean
)
:
TPromise
<
IPluginDescription
[]
>
{
return
pfs
.
readDirsInDir
(
absoluteFolderPath
)
.
then
(
folders
=>
TPromise
.
join
(
folders
.
map
(
f
=>
this
.
scanPlugin
(
version
,
collector
,
paths
.
join
(
absoluteFolderPath
,
f
),
isBuiltin
))))
.
then
(
plugins
=>
plugins
.
filter
(
item
=>
item
!==
null
))
.
then
(
plugins
=>
{
const
pluginsById
=
values
(
groupBy
(
plugins
,
p
=>
p
.
id
));
return
pluginsById
.
map
(
p
=>
p
.
sort
((
a
,
b
)
=>
semver
.
rcompare
(
a
.
version
,
b
.
version
))[
0
]);
})
.
then
(
null
,
err
=>
{
collector
.
error
(
absoluteFolderPath
,
err
);
return
[];
});
}
/**
* Combination of scanPlugin and scanPlugins: If a plugin manifest is found at root, we load just this plugin, otherwise we assume
* the folder contains multiple extensions.
*/
public
static
scanOneOrMultiplePlugins
(
version
:
string
,
collector
:
IPluginsMessageCollector
,
absoluteFolderPath
:
string
,
isBuiltin
:
boolean
):
TPromise
<
IPluginDescription
[]
>
{
public
static
scanOneOrMultiplePlugins
(
version
:
string
,
collector
:
IPluginsMessageCollector
,
absoluteFolderPath
:
string
,
isBuiltin
:
boolean
)
:
TPromise
<
IPluginDescription
[]
>
{
return
pfs
.
fileExists
(
paths
.
join
(
absoluteFolderPath
,
MANIFEST_FILE
)).
then
((
exists
)
=>
{
if
(
exists
)
{
return
this
.
scanPlugin
(
version
,
collector
,
absoluteFolderPath
,
isBuiltin
).
then
((
pluginDescription
)
=>
{
...
...
src/vs/workbench/node/pluginHostMain.ts
浏览文件 @
0f800b76
...
...
@@ -162,10 +162,9 @@ export class PluginHostMain {
}
private
static
scanPlugins
(
collector
:
IPluginsMessageCollector
,
builtinPluginsPath
:
string
,
userInstallPath
:
string
,
pluginDevelopmentPath
:
string
,
version
:
string
):
TPromise
<
IPluginDescription
[]
>
{
let
builtinPlugins
:
TPromise
<
IPluginDescription
[]
>
=
PluginScanner
.
scanPlugins
(
version
,
collector
,
builtinPluginsPath
,
true
);
let
userPlugins
:
TPromise
<
IPluginDescription
[]
>
=
(
userInstallPath
?
PluginScanner
.
scanPlugins
(
version
,
collector
,
userInstallPath
,
false
)
:
TPromise
.
as
([]));
let
developedPlugins
:
TPromise
<
IPluginDescription
[]
>
=
(
pluginDevelopmentPath
?
PluginScanner
.
scanOneOrMultiplePlugins
(
version
,
collector
,
pluginDevelopmentPath
,
false
)
:
TPromise
.
as
([]));
const
builtinPlugins
=
PluginScanner
.
scanPlugins
(
version
,
collector
,
builtinPluginsPath
,
true
);
const
userPlugins
=
!
userInstallPath
?
TPromise
.
as
([])
:
PluginScanner
.
scanPlugins
(
version
,
collector
,
userInstallPath
,
false
);
const
developedPlugins
=
!
pluginDevelopmentPath
?
TPromise
.
as
([])
:
PluginScanner
.
scanOneOrMultiplePlugins
(
version
,
collector
,
pluginDevelopmentPath
,
false
);
return
TPromise
.
join
([
builtinPlugins
,
userPlugins
,
developedPlugins
]).
then
((
_
:
IPluginDescription
[][])
=>
{
let
builtinPlugins
=
_
[
0
];
...
...
src/vs/workbench/parts/extensions/common/extensions.ts
浏览文件 @
0f800b76
...
...
@@ -50,5 +50,5 @@ export interface IExtensionsService {
install
(
extension
:
IExtension
):
TPromise
<
IExtension
>
;
install
(
zipPath
:
string
):
TPromise
<
IExtension
>
;
uninstall
(
extension
:
IExtension
):
TPromise
<
void
>
;
getInstalled
():
TPromise
<
IExtension
[]
>
;
getInstalled
(
includeDuplicateVersions
?:
boolean
):
TPromise
<
IExtension
[]
>
;
}
src/vs/workbench/parts/extensions/electron-browser/extensionsQuickOpen.ts
浏览文件 @
0f800b76
...
...
@@ -244,10 +244,10 @@ class DataSource implements IDataSource<IExtensionEntry> {
const
extension
=
entry
.
extension
;
if
(
extension
.
galleryInformation
)
{
return
extension
.
galleryInformation
.
id
;
return
`
${
extension
.
galleryInformation
.
id
}
-
${
extension
.
version
}
`
;
}
return
`local@
${
extension
.
publisher
}
.
${
extension
.
name
}
@
${
extension
.
path
||
''
}
`
;
return
`local@
${
extension
.
publisher
}
.
${
extension
.
name
}
-
${
extension
.
version
}
@
${
extension
.
path
||
''
}
`
;
}
getLabel
(
entry
:
IExtensionEntry
):
string
{
...
...
src/vs/workbench/parts/extensions/node/extensionsService.ts
浏览文件 @
0f800b76
...
...
@@ -13,6 +13,7 @@ import { ServiceEvent } from 'vs/base/common/service';
import
errors
=
require
(
'
vs/base/common/errors
'
);
import
*
as
pfs
from
'
vs/base/node/pfs
'
;
import
{
assign
}
from
'
vs/base/common/objects
'
;
import
{
flatten
}
from
'
vs/base/common/arrays
'
;
import
{
extract
,
buffer
}
from
'
vs/base/node/zip
'
;
import
{
Promise
,
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IExtensionsService
,
IExtension
,
IExtensionManifest
,
IGalleryInformation
}
from
'
vs/workbench/parts/extensions/common/extensions
'
;
...
...
@@ -22,6 +23,8 @@ import { IWorkspaceContextService } from 'vs/workbench/services/workspace/common
import
{
Limiter
}
from
'
vs/base/common/async
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
UserSettings
}
from
'
vs/workbench/node/userSettings
'
;
import
*
as
semver
from
'
semver
'
;
import
{
groupBy
,
values
}
from
'
vs/base/common/collections
'
;
function
parseManifest
(
raw
:
string
):
TPromise
<
IExtensionManifest
>
{
return
new
Promise
((
c
,
e
)
=>
{
...
...
@@ -119,7 +122,7 @@ export class ExtensionsService implements IExtensionsService {
const
url
=
galleryInformation
.
downloadUrl
;
const
zipPath
=
path
.
join
(
tmpdir
(),
galleryInformation
.
id
);
const
extensionPath
=
path
.
join
(
this
.
extensionsPath
,
`
${
extension
.
publisher
}
.
${
extension
.
name
}
`
);
const
extensionPath
=
path
.
join
(
this
.
extensionsPath
,
`
${
extension
.
publisher
}
.
${
extension
.
name
}
-
${
extension
.
version
}
`
);
const
manifestPath
=
path
.
join
(
extensionPath
,
'
package.json
'
);
const
settings
=
TPromise
.
join
([
...
...
@@ -162,11 +165,31 @@ export class ExtensionsService implements IExtensionsService {
.
then
(()
=>
this
.
_onDidUninstallExtension
.
fire
(
extension
));
}
public
getInstalled
():
TPromise
<
IExtension
[]
>
{
public
getInstalled
(
includeDuplicateVersions
:
boolean
=
false
):
TPromise
<
IExtension
[]
>
{
const
all
=
this
.
getAllInstalled
();
if
(
includeDuplicateVersions
)
{
return
all
;
}
return
all
.
then
(
plugins
=>
{
const
byId
=
values
(
groupBy
(
plugins
,
p
=>
`
${
p
.
publisher
}
.
${
p
.
name
}
`
));
return
byId
.
map
(
p
=>
p
.
sort
((
a
,
b
)
=>
semver
.
rcompare
(
a
.
version
,
b
.
version
))[
0
]);
});
}
private
getDeprecated
():
TPromise
<
IExtension
[]
>
{
return
this
.
getAllInstalled
().
then
(
plugins
=>
{
const
byId
=
values
(
groupBy
(
plugins
,
p
=>
`
${
p
.
publisher
}
.
${
p
.
name
}
`
));
return
flatten
(
byId
.
map
(
p
=>
p
.
sort
((
a
,
b
)
=>
semver
.
rcompare
(
a
.
version
,
b
.
version
)).
slice
(
1
)));
});
}
private
getAllInstalled
():
TPromise
<
IExtension
[]
>
{
const
limiter
=
new
Limiter
(
10
);
return
pfs
.
readdir
(
this
.
extensionsPath
)
.
then
<
IExtension
Manifest
[]
>
(
extensions
=>
Promise
.
join
(
extensions
.
map
(
e
=>
{
.
then
<
IExtension
[]
>
(
extensions
=>
Promise
.
join
(
extensions
.
map
(
e
=>
{
const
extensionPath
=
path
.
join
(
this
.
extensionsPath
,
e
);
return
limiter
.
queue
(
...
...
@@ -180,6 +203,11 @@ export class ExtensionsService implements IExtensionsService {
}
private
getInstallationPath
(
extension
:
IExtension
):
string
{
return
extension
.
path
||
path
.
join
(
this
.
extensionsPath
,
`
${
extension
.
publisher
}
.
${
extension
.
name
}
`
);
return
extension
.
path
||
path
.
join
(
this
.
extensionsPath
,
`
${
extension
.
publisher
}
.
${
extension
.
name
}
`
);
}
public
removeDeprecatedExtensions
():
TPromise
<
void
>
{
return
this
.
getDeprecated
()
.
then
<
void
>
(
extensions
=>
TPromise
.
join
(
extensions
.
filter
(
e
=>
!!
e
.
path
).
map
(
e
=>
pfs
.
rimraf
(
e
.
path
))));
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录