Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
6c45ea53
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
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,发现更多精彩内容 >>
提交
6c45ea53
编写于
9月 07, 2016
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
use a simple worker for output link computation
上级
f708ded7
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
167 addition
and
5 deletion
+167
-5
src/vs/workbench/buildfile.js
src/vs/workbench/buildfile.js
+1
-0
src/vs/workbench/parts/output/browser/output.contribution.ts
src/vs/workbench/parts/output/browser/output.contribution.ts
+11
-4
src/vs/workbench/parts/output/browser/outputServices.ts
src/vs/workbench/parts/output/browser/outputServices.ts
+10
-1
src/vs/workbench/parts/output/common/outputLinkComputer.ts
src/vs/workbench/parts/output/common/outputLinkComputer.ts
+69
-0
src/vs/workbench/parts/output/common/outputLinkProvider.ts
src/vs/workbench/parts/output/common/outputLinkProvider.ts
+76
-0
未找到文件。
src/vs/workbench/buildfile.js
浏览文件 @
6c45ea53
...
...
@@ -29,6 +29,7 @@ exports.collectModules = function(excludes) {
createModuleDescription
(
'
vs/workbench/parts/output/common/outputMode
'
,
languageMainExcludes
),
createModuleDescription
(
'
vs/workbench/parts/output/common/outputWorker
'
,
languageWorkerExcludes
),
createModuleDescription
(
'
vs/workbench/parts/output/common/outputLinkComputer
'
,
[
'
vs/base/common/worker/simpleWorker
'
,
'
vs/editor/common/services/editorSimpleWorker
'
]),
createModuleDescription
(
'
vs/workbench/parts/output/browser/outputPanel
'
,
excludes
),
createModuleDescription
(
'
vs/workbench/parts/debug/browser/debugViewlet
'
,
excludes
),
...
...
src/vs/workbench/parts/output/browser/output.contribution.ts
浏览文件 @
6c45ea53
...
...
@@ -25,15 +25,22 @@ import {ContextKeyExpr} from 'vs/platform/contextkey/common/contextkey';
registerSingleton
(
IOutputService
,
OutputService
);
// Register Output Mode
ModesRegistry
.
register
CompatMod
e
({
ModesRegistry
.
register
Languag
e
({
id
:
OUTPUT_MODE_ID
,
extensions
:
[],
aliases
:
[
null
],
mimetypes
:
[
OUTPUT_MIME
],
moduleId
:
'
vs/workbench/parts/output/common/outputMode
'
,
ctorName
:
'
OutputMode
'
mimetypes
:
[
OUTPUT_MIME
]
});
// ModesRegistry.registerCompatMode({
// id: OUTPUT_MODE_ID,
// extensions: [],
// aliases: [null],
// mimetypes: [OUTPUT_MIME],
// moduleId: 'vs/workbench/parts/output/common/outputMode',
// ctorName: 'OutputMode'
// });
// Register Output Panel
(
<
panel
.
PanelRegistry
>
platform
.
Registry
.
as
(
panel
.
Extensions
.
Panels
)).
registerPanel
(
new
panel
.
PanelDescriptor
(
'
vs/workbench/parts/output/browser/outputPanel
'
,
...
...
src/vs/workbench/parts/output/browser/outputServices.ts
浏览文件 @
6c45ea53
...
...
@@ -17,6 +17,9 @@ import {IOutputEvent, IOutputChannel, IOutputService, Extensions, OUTPUT_PANEL_I
import
{
OutputEditorInput
}
from
'
vs/workbench/parts/output/browser/outputEditorInput
'
;
import
{
OutputPanel
}
from
'
vs/workbench/parts/output/browser/outputPanel
'
;
import
{
IPanelService
}
from
'
vs/workbench/services/panel/common/panelService
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
OutputLinkProvider
}
from
'
vs/workbench/parts/output/common/outputLinkProvider
'
;
const
OUTPUT_ACTIVE_CHANNEL_KEY
=
'
output.activechannel
'
;
...
...
@@ -31,12 +34,16 @@ export class OutputService implements IOutputService {
private
_onOutputChannel
:
Emitter
<
string
>
;
private
_onActiveOutputChannel
:
Emitter
<
string
>
;
private
_outputLinkDetector
:
OutputLinkProvider
;
constructor
(
@
IStorageService
private
storageService
:
IStorageService
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
,
@
IEventService
private
eventService
:
IEventService
,
@
ILifecycleService
private
lifecycleService
:
ILifecycleService
,
@
IPanelService
private
panelService
:
IPanelService
@
IPanelService
private
panelService
:
IPanelService
,
@
IWorkspaceContextService
contextService
:
IWorkspaceContextService
,
@
IModelService
modelService
:
IModelService
)
{
this
.
_onOutput
=
new
Emitter
<
IOutputEvent
>
();
this
.
_onOutputChannel
=
new
Emitter
<
string
>
();
...
...
@@ -46,6 +53,8 @@ export class OutputService implements IOutputService {
const
channels
=
Registry
.
as
<
IOutputChannelRegistry
>
(
Extensions
.
OutputChannels
).
getChannels
();
this
.
activeChannelId
=
this
.
storageService
.
get
(
OUTPUT_ACTIVE_CHANNEL_KEY
,
StorageScope
.
WORKSPACE
,
channels
&&
channels
.
length
>
0
?
channels
[
0
].
id
:
null
);
this
.
_outputLinkDetector
=
new
OutputLinkProvider
(
contextService
,
modelService
);
}
public
get
onOutput
():
Event
<
IOutputEvent
>
{
...
...
src/vs/workbench/parts/output/common/outputLinkComputer.ts
0 → 100644
浏览文件 @
6c45ea53
/*---------------------------------------------------------------------------------------------
* 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
{
IMirrorModel
,
IWorkerContext
}
from
'
vs/editor/common/services/editorSimpleWorker
'
;
import
{
OutputWorker
,
IResourceCreator
}
from
'
vs/workbench/parts/output/common/outputWorker
'
;
import
{
ILink
}
from
'
vs/editor/common/modes
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
paths
=
require
(
'
vs/base/common/paths
'
);
export
interface
ICreateData
{
workspaceResourceUri
:
string
;
}
export
class
OutputLinkComputer
{
private
_ctx
:
IWorkerContext
;
private
_patterns
:
RegExp
[];
private
_workspaceResource
:
URI
;
constructor
(
ctx
:
IWorkerContext
,
createData
:
ICreateData
)
{
this
.
_ctx
=
ctx
;
this
.
_workspaceResource
=
URI
.
parse
(
createData
.
workspaceResourceUri
);
this
.
_patterns
=
OutputWorker
.
createPatterns
(
this
.
_workspaceResource
);
}
private
_getModel
(
uri
:
string
):
IMirrorModel
{
let
models
=
this
.
_ctx
.
getMirrorModels
();
for
(
let
i
=
0
;
i
<
models
.
length
;
i
++
)
{
let
model
=
models
[
i
];
if
(
model
.
uri
.
toString
()
===
uri
)
{
return
model
;
}
}
return
null
;
}
public
computeLinks
(
uri
:
string
):
TPromise
<
ILink
[]
>
{
let
model
=
this
.
_getModel
(
uri
);
if
(
!
model
)
{
return
;
}
let
links
:
ILink
[]
=
[];
let
resourceCreator
:
IResourceCreator
=
{
toResource
:
(
workspaceRelativePath
:
string
):
URI
=>
{
if
(
typeof
workspaceRelativePath
===
'
string
'
)
{
return
URI
.
file
(
paths
.
join
(
this
.
_workspaceResource
.
fsPath
,
workspaceRelativePath
));
}
return
null
;
}
};
let
lines
=
model
.
getValue
().
split
(
/
\r\n
|
\r
|
\n
/
);
for
(
let
i
=
0
,
len
=
lines
.
length
;
i
<
len
;
i
++
)
{
links
.
push
(...
OutputWorker
.
detectLinks
(
lines
[
i
],
i
+
1
,
this
.
_patterns
,
resourceCreator
));
}
return
TPromise
.
as
(
links
);
}
}
export
function
create
(
ctx
:
IWorkerContext
,
createData
:
ICreateData
):
OutputLinkComputer
{
return
new
OutputLinkComputer
(
ctx
,
createData
);
}
src/vs/workbench/parts/output/common/outputLinkProvider.ts
0 → 100644
浏览文件 @
6c45ea53
/*---------------------------------------------------------------------------------------------
* 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
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
RunOnceScheduler
,
wireCancellationToken
}
from
'
vs/base/common/async
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
{
LinkProviderRegistry
,
ILink
}
from
'
vs/editor/common/modes
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
OUTPUT_MODE_ID
}
from
'
vs/workbench/parts/output/common/output
'
;
import
{
MonacoWebWorker
,
createWebWorker
}
from
'
vs/editor/common/services/webWorker
'
;
import
{
ICreateData
,
OutputLinkComputer
}
from
'
vs/workbench/parts/output/common/outputLinkComputer
'
;
export
class
OutputLinkProvider
{
private
static
DISPOSE_WORKER_TIME
=
3
*
60
*
1000
;
// dispose worker after 3 minutes of inactivity
private
_modelService
:
IModelService
;
private
_workspaceResource
:
URI
;
private
_worker
:
MonacoWebWorker
<
OutputLinkComputer
>
;
private
_disposeWorker
:
RunOnceScheduler
;
constructor
(
contextService
:
IWorkspaceContextService
,
modelService
:
IModelService
)
{
let
workspace
=
contextService
.
getWorkspace
();
// Does not do anything unless there is a workspace...
if
(
workspace
)
{
this
.
_modelService
=
modelService
;
this
.
_workspaceResource
=
workspace
.
resource
;
LinkProviderRegistry
.
register
(
OUTPUT_MODE_ID
,
{
provideLinks
:
(
model
,
token
):
Thenable
<
ILink
[]
>
=>
{
return
wireCancellationToken
(
token
,
this
.
_provideLinks
(
model
.
uri
));
}
});
this
.
_worker
=
null
;
this
.
_disposeWorker
=
new
RunOnceScheduler
(()
=>
{
if
(
this
.
_worker
)
{
this
.
_worker
.
dispose
();
this
.
_worker
=
null
;
}
},
OutputLinkProvider
.
DISPOSE_WORKER_TIME
);
}
}
private
_getOrCreateWorker
():
MonacoWebWorker
<
OutputLinkComputer
>
{
this
.
_disposeWorker
.
schedule
();
if
(
!
this
.
_worker
)
{
let
createData
:
ICreateData
=
{
workspaceResourceUri
:
this
.
_workspaceResource
.
toString
()
};
this
.
_worker
=
createWebWorker
<
OutputLinkComputer
>
(
this
.
_modelService
,
{
moduleId
:
'
vs/workbench/parts/output/common/outputLinkComputer
'
,
createData
:
createData
,
label
:
'
outputLinkComputer
'
});
}
return
this
.
_worker
;
}
private
_provideLinks
(
modelUri
:
URI
):
TPromise
<
ILink
[]
>
{
return
this
.
_getOrCreateWorker
().
withSyncedResources
([
modelUri
]).
then
((
linkComputer
)
=>
{
return
linkComputer
.
computeLinks
(
modelUri
.
toString
());
});
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录