Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
04b6de76
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,体验更适合开发者的 AI 搜索 >>
提交
04b6de76
编写于
8月 15, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Cleanup in ExtHostExtensionService
上级
f330bea3
变更
6
展开全部
隐藏空白更改
内联
并排
Showing
6 changed file
with
354 addition
and
394 deletion
+354
-394
src/vs/workbench/api/node/extHost.api.impl.ts
src/vs/workbench/api/node/extHost.api.impl.ts
+1
-1
src/vs/workbench/api/node/extHostExtensionActivator.ts
src/vs/workbench/api/node/extHostExtensionActivator.ts
+241
-0
src/vs/workbench/api/node/extHostExtensionService.ts
src/vs/workbench/api/node/extHostExtensionService.ts
+108
-386
src/vs/workbench/node/extensionHostMain.ts
src/vs/workbench/node/extensionHostMain.ts
+1
-1
src/vs/workbench/services/extensions/electron-browser/extensionService.ts
.../services/extensions/electron-browser/extensionService.ts
+2
-3
src/vs/workbench/services/extensions/node/extensionDescriptionRegistry.ts
.../services/extensions/node/extensionDescriptionRegistry.ts
+1
-3
未找到文件。
src/vs/workbench/api/node/extHost.api.impl.ts
浏览文件 @
04b6de76
...
...
@@ -604,7 +604,7 @@ class Extension<T> implements vscode.Extension<T> {
}
get
exports
():
T
{
return
<
T
>
this
.
_extensionService
.
get
(
this
.
id
);
return
<
T
>
this
.
_extensionService
.
get
ExtensionExports
(
this
.
id
);
}
activate
():
Thenable
<
T
>
{
...
...
src/vs/workbench/api/node/extHostExtensionActivator.ts
0 → 100644
浏览文件 @
04b6de76
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
*
as
nls
from
'
vs/nls
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
Severity
from
'
vs/base/common/severity
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
ExtensionDescriptionRegistry
}
from
"
vs/workbench/services/extensions/node/extensionDescriptionRegistry
"
;
import
{
IExtensionDescription
}
from
'
vs/platform/extensions/common/extensions
'
;
const
hasOwnProperty
=
Object
.
hasOwnProperty
;
const
NO_OP_VOID_PROMISE
=
TPromise
.
as
<
void
>
(
void
0
);
export
interface
IExtensionMemento
{
get
<
T
>
(
key
:
string
,
defaultValue
:
T
):
T
;
update
(
key
:
string
,
value
:
any
):
Thenable
<
boolean
>
;
}
export
interface
IExtensionContext
{
subscriptions
:
IDisposable
[];
workspaceState
:
IExtensionMemento
;
globalState
:
IExtensionMemento
;
extensionPath
:
string
;
storagePath
:
string
;
asAbsolutePath
(
relativePath
:
string
):
string
;
}
/**
* Represents the source code (module) of an extension.
*/
export
interface
IExtensionModule
{
activate
(
ctx
:
IExtensionContext
):
TPromise
<
IExtensionAPI
>
;
deactivate
():
void
;
}
/**
* Represents the API of an extension (return value of `activate`).
*/
export
interface
IExtensionAPI
{
// _extensionAPIBrand: any;
}
export
class
ActivatedExtension
{
activationFailed
:
boolean
;
module
:
IExtensionModule
;
exports
:
IExtensionAPI
;
subscriptions
:
IDisposable
[];
constructor
(
activationFailed
:
boolean
,
module
:
IExtensionModule
,
exports
:
IExtensionAPI
,
subscriptions
:
IDisposable
[])
{
this
.
activationFailed
=
activationFailed
;
this
.
module
=
module
;
this
.
exports
=
exports
;
this
.
subscriptions
=
subscriptions
;
}
}
export
class
EmptyExtension
extends
ActivatedExtension
{
constructor
()
{
super
(
false
,
{
activate
:
undefined
,
deactivate
:
undefined
},
undefined
,
[]);
}
}
export
class
FailedExtension
extends
ActivatedExtension
{
constructor
()
{
super
(
true
,
{
activate
:
undefined
,
deactivate
:
undefined
},
undefined
,
[]);
}
}
export
interface
IExtensionsActivatorHost
{
showMessage
(
severity
:
Severity
,
message
:
string
):
void
;
actualActivateExtension
(
extensionDescription
:
IExtensionDescription
):
TPromise
<
ActivatedExtension
>
;
}
export
class
ExtensionsActivator
{
private
readonly
_registry
:
ExtensionDescriptionRegistry
;
private
readonly
_host
:
IExtensionsActivatorHost
;
private
readonly
_activatingExtensions
:
{
[
extensionId
:
string
]:
TPromise
<
void
>
;
};
private
readonly
_activatedExtensions
:
{
[
extensionId
:
string
]:
ActivatedExtension
;
};
/**
* A map of already activated events to speed things up if the same activation event is triggered multiple times.
*/
private
readonly
_alreadyActivatedEvents
:
{
[
activationEvent
:
string
]:
boolean
;
};
constructor
(
registry
:
ExtensionDescriptionRegistry
,
host
:
IExtensionsActivatorHost
)
{
this
.
_registry
=
registry
;
this
.
_host
=
host
;
this
.
_activatingExtensions
=
{};
this
.
_activatedExtensions
=
{};
this
.
_alreadyActivatedEvents
=
Object
.
create
(
null
);
}
public
isActivated
(
extensionId
:
string
):
boolean
{
return
hasOwnProperty
.
call
(
this
.
_activatedExtensions
,
extensionId
);
}
public
getActivatedExtension
(
extensionId
:
string
):
ActivatedExtension
{
if
(
!
hasOwnProperty
.
call
(
this
.
_activatedExtensions
,
extensionId
))
{
throw
new
Error
(
'
Extension `
'
+
extensionId
+
'
` is not known or not activated
'
);
}
return
this
.
_activatedExtensions
[
extensionId
];
}
public
activateByEvent
(
activationEvent
:
string
):
TPromise
<
void
>
{
if
(
this
.
_alreadyActivatedEvents
[
activationEvent
])
{
return
NO_OP_VOID_PROMISE
;
}
let
activateExtensions
=
this
.
_registry
.
getExtensionDescriptionsForActivationEvent
(
activationEvent
);
return
this
.
_activateExtensions
(
activateExtensions
,
0
).
then
(()
=>
{
this
.
_alreadyActivatedEvents
[
activationEvent
]
=
true
;
});
}
public
activateById
(
extensionId
:
string
):
TPromise
<
void
>
{
let
desc
=
this
.
_registry
.
getExtensionDescription
(
extensionId
);
if
(
!
desc
)
{
throw
new
Error
(
'
Extension `
'
+
extensionId
+
'
` is not known
'
);
}
return
this
.
_activateExtensions
([
desc
],
0
);
}
/**
* Handle semantics related to dependencies for `currentExtension`.
* semantics: `redExtensions` must wait for `greenExtensions`.
*/
private
_handleActivateRequest
(
currentExtension
:
IExtensionDescription
,
greenExtensions
:
{
[
id
:
string
]:
IExtensionDescription
;
},
redExtensions
:
IExtensionDescription
[]):
void
{
let
depIds
=
(
typeof
currentExtension
.
extensionDependencies
===
'
undefined
'
?
[]
:
currentExtension
.
extensionDependencies
);
let
currentExtensionGetsGreenLight
=
true
;
for
(
let
j
=
0
,
lenJ
=
depIds
.
length
;
j
<
lenJ
;
j
++
)
{
let
depId
=
depIds
[
j
];
let
depDesc
=
this
.
_registry
.
getExtensionDescription
(
depId
);
if
(
!
depDesc
)
{
// Error condition 1: unknown dependency
this
.
_host
.
showMessage
(
Severity
.
Error
,
nls
.
localize
(
'
unknownDep
'
,
"
Extension `{1}` failed to activate. Reason: unknown dependency `{0}`.
"
,
depId
,
currentExtension
.
id
));
this
.
_activatedExtensions
[
currentExtension
.
id
]
=
new
FailedExtension
();
return
;
}
if
(
hasOwnProperty
.
call
(
this
.
_activatedExtensions
,
depId
))
{
let
dep
=
this
.
_activatedExtensions
[
depId
];
if
(
dep
.
activationFailed
)
{
// Error condition 2: a dependency has already failed activation
this
.
_host
.
showMessage
(
Severity
.
Error
,
nls
.
localize
(
'
failedDep1
'
,
"
Extension `{1}` failed to activate. Reason: dependency `{0}` failed to activate.
"
,
depId
,
currentExtension
.
id
));
this
.
_activatedExtensions
[
currentExtension
.
id
]
=
new
FailedExtension
();
return
;
}
}
else
{
// must first wait for the dependency to activate
currentExtensionGetsGreenLight
=
false
;
greenExtensions
[
depId
]
=
depDesc
;
}
}
if
(
currentExtensionGetsGreenLight
)
{
greenExtensions
[
currentExtension
.
id
]
=
currentExtension
;
}
else
{
redExtensions
.
push
(
currentExtension
);
}
}
private
_activateExtensions
(
extensionDescriptions
:
IExtensionDescription
[],
recursionLevel
:
number
):
TPromise
<
void
>
{
// console.log(recursionLevel, '_activateExtensions: ', extensionDescriptions.map(p => p.id));
if
(
extensionDescriptions
.
length
===
0
)
{
return
TPromise
.
as
(
void
0
);
}
extensionDescriptions
=
extensionDescriptions
.
filter
((
p
)
=>
!
hasOwnProperty
.
call
(
this
.
_activatedExtensions
,
p
.
id
));
if
(
extensionDescriptions
.
length
===
0
)
{
return
TPromise
.
as
(
void
0
);
}
if
(
recursionLevel
>
10
)
{
// More than 10 dependencies deep => most likely a dependency loop
for
(
let
i
=
0
,
len
=
extensionDescriptions
.
length
;
i
<
len
;
i
++
)
{
// Error condition 3: dependency loop
this
.
_host
.
showMessage
(
Severity
.
Error
,
nls
.
localize
(
'
failedDep2
'
,
"
Extension `{0}` failed to activate. Reason: more than 10 levels of dependencies (most likely a dependency loop).
"
,
extensionDescriptions
[
i
].
id
));
this
.
_activatedExtensions
[
extensionDescriptions
[
i
].
id
]
=
new
FailedExtension
();
}
return
TPromise
.
as
(
void
0
);
}
let
greenMap
:
{
[
id
:
string
]:
IExtensionDescription
;
}
=
Object
.
create
(
null
),
red
:
IExtensionDescription
[]
=
[];
for
(
let
i
=
0
,
len
=
extensionDescriptions
.
length
;
i
<
len
;
i
++
)
{
this
.
_handleActivateRequest
(
extensionDescriptions
[
i
],
greenMap
,
red
);
}
// Make sure no red is also green
for
(
let
i
=
0
,
len
=
red
.
length
;
i
<
len
;
i
++
)
{
if
(
greenMap
[
red
[
i
].
id
])
{
delete
greenMap
[
red
[
i
].
id
];
}
}
let
green
=
Object
.
keys
(
greenMap
).
map
(
id
=>
greenMap
[
id
]);
// console.log('greenExtensions: ', green.map(p => p.id));
// console.log('redExtensions: ', red.map(p => p.id));
if
(
red
.
length
===
0
)
{
// Finally reached only leafs!
return
TPromise
.
join
(
green
.
map
((
p
)
=>
this
.
_activateExtension
(
p
))).
then
(
_
=>
void
0
);
}
return
this
.
_activateExtensions
(
green
,
recursionLevel
+
1
).
then
(
_
=>
{
return
this
.
_activateExtensions
(
red
,
recursionLevel
+
1
);
});
}
private
_activateExtension
(
extensionDescription
:
IExtensionDescription
):
TPromise
<
void
>
{
if
(
hasOwnProperty
.
call
(
this
.
_activatedExtensions
,
extensionDescription
.
id
))
{
return
TPromise
.
as
(
void
0
);
}
if
(
hasOwnProperty
.
call
(
this
.
_activatingExtensions
,
extensionDescription
.
id
))
{
return
this
.
_activatingExtensions
[
extensionDescription
.
id
];
}
this
.
_activatingExtensions
[
extensionDescription
.
id
]
=
this
.
_host
.
actualActivateExtension
(
extensionDescription
).
then
(
null
,
(
err
)
=>
{
this
.
_host
.
showMessage
(
Severity
.
Error
,
nls
.
localize
(
'
activationError
'
,
"
Activating extension `{0}` failed: {1}.
"
,
extensionDescription
.
id
,
err
.
message
));
console
.
error
(
'
Activating extension `
'
+
extensionDescription
.
id
+
'
` failed:
'
,
err
.
message
);
console
.
log
(
'
Here is the error stack:
'
,
err
.
stack
);
// Treat the extension as being empty
return
new
FailedExtension
();
}).
then
((
x
:
ActivatedExtension
)
=>
{
this
.
_activatedExtensions
[
extensionDescription
.
id
]
=
x
;
delete
this
.
_activatingExtensions
[
extensionDescription
.
id
];
});
return
this
.
_activatingExtensions
[
extensionDescription
.
id
];
}
}
src/vs/workbench/api/node/extHostExtensionService.ts
浏览文件 @
04b6de76
此差异已折叠。
点击以展开。
src/vs/workbench/node/extensionHostMain.ts
浏览文件 @
04b6de76
...
...
@@ -60,7 +60,7 @@ export class ExtensionHostMain {
}
public
start
():
TPromise
<
void
>
{
return
this
.
_extensionService
.
onReady
()
return
this
.
_extensionService
.
on
ExtensionAPI
Ready
()
.
then
(()
=>
this
.
handleEagerExtensions
())
.
then
(()
=>
this
.
handleExtensionTests
());
}
...
...
src/vs/workbench/services/extensions/electron-browser/extensionService.ts
浏览文件 @
04b6de76
...
...
@@ -10,7 +10,7 @@ import pkg from 'vs/platform/node/package';
import
{
localize
}
from
'
vs/nls
'
;
import
*
as
path
from
'
path
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
ExtensionDescriptionRegistry
}
from
'
vs/platform/extensions/common/abstractExtensionService
'
;
import
{
ExtensionDescriptionRegistry
}
from
"
vs/workbench/services/extensions/node/extensionDescriptionRegistry
"
;
import
{
IMessage
,
IExtensionDescription
,
IExtensionsStatus
,
IExtensionService
,
ExtensionPointContribution
}
from
'
vs/platform/extensions/common/extensions
'
;
import
{
IExtensionEnablementService
}
from
'
vs/platform/extensionManagement/common/extensionManagement
'
;
import
{
areSameExtensions
,
getGloballyDisabledExtensions
}
from
'
vs/platform/extensionManagement/common/extensionManagementUtil
'
;
...
...
@@ -168,8 +168,7 @@ export class ExtensionService implements IThreadService, IExtensionService {
return
installedExtensions
.
filter
(
e
=>
disabledExtensions
.
every
(
id
=>
!
areSameExtensions
({
id
},
e
)));
}).
then
((
extensionDescriptions
)
=>
{
this
.
_registry
=
new
ExtensionDescriptionRegistry
();
this
.
_registry
.
registerExtensions
(
extensionDescriptions
);
this
.
_registry
=
new
ExtensionDescriptionRegistry
(
extensionDescriptions
);
let
availableExtensions
=
this
.
_registry
.
getAllExtensionDescriptions
();
let
extensionPoints
=
ExtensionsRegistry
.
getExtensionPoints
();
...
...
src/vs/
platform/extensions/common/abstractExtensionService
.ts
→
src/vs/
workbench/services/extensions/node/extensionDescriptionRegistry
.ts
浏览文件 @
04b6de76
...
...
@@ -13,13 +13,11 @@ export class ExtensionDescriptionRegistry {
private
_extensionsArr
:
IExtensionDescription
[];
private
_activationMap
:
{
[
activationEvent
:
string
]:
IExtensionDescription
[];
};
constructor
()
{
constructor
(
extensionDescriptions
:
IExtensionDescription
[]
)
{
this
.
_extensionsMap
=
{};
this
.
_extensionsArr
=
[];
this
.
_activationMap
=
{};
}
public
registerExtensions
(
extensionDescriptions
:
IExtensionDescription
[]):
void
{
for
(
let
i
=
0
,
len
=
extensionDescriptions
.
length
;
i
<
len
;
i
++
)
{
let
extensionDescription
=
extensionDescriptions
[
i
];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录