Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
e170425f
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,发现更多精彩内容 >>
提交
e170425f
编写于
6月 28, 2016
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixes #8167: Do not use IWorkspaceContextService in compat web worker anymore
上级
5d5b3b44
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
48 addition
and
35 deletion
+48
-35
src/vs/workbench/parts/output/common/outputMode.ts
src/vs/workbench/parts/output/common/outputMode.ts
+15
-1
src/vs/workbench/parts/output/common/outputWorker.ts
src/vs/workbench/parts/output/common/outputWorker.ts
+26
-19
src/vs/workbench/parts/output/test/outputWorker.test.ts
src/vs/workbench/parts/output/test/outputWorker.test.ts
+7
-15
未找到文件。
src/vs/workbench/parts/output/common/outputMode.ts
浏览文件 @
e170425f
...
@@ -13,6 +13,7 @@ import * as modes from 'vs/editor/common/modes';
...
@@ -13,6 +13,7 @@ import * as modes from 'vs/editor/common/modes';
import
{
CompatMode
,
ModeWorkerManager
}
from
'
vs/editor/common/modes/abstractMode
'
;
import
{
CompatMode
,
ModeWorkerManager
}
from
'
vs/editor/common/modes/abstractMode
'
;
import
{
wireCancellationToken
}
from
'
vs/base/common/async
'
;
import
{
wireCancellationToken
}
from
'
vs/base/common/async
'
;
import
{
ICompatWorkerService
,
CompatWorkerAttr
}
from
'
vs/editor/common/services/compatWorkerService
'
;
import
{
ICompatWorkerService
,
CompatWorkerAttr
}
from
'
vs/editor/common/services/compatWorkerService
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
export
class
OutputMode
extends
CompatMode
{
export
class
OutputMode
extends
CompatMode
{
...
@@ -21,7 +22,8 @@ export class OutputMode extends CompatMode {
...
@@ -21,7 +22,8 @@ export class OutputMode extends CompatMode {
constructor
(
constructor
(
descriptor
:
IModeDescriptor
,
descriptor
:
IModeDescriptor
,
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
ICompatWorkerService
compatWorkerService
:
ICompatWorkerService
@
ICompatWorkerService
compatWorkerService
:
ICompatWorkerService
,
@
IWorkspaceContextService
contextService
:
IWorkspaceContextService
)
{
)
{
super
(
descriptor
.
id
,
compatWorkerService
);
super
(
descriptor
.
id
,
compatWorkerService
);
this
.
_modeWorkerManager
=
new
ModeWorkerManager
<
OutputWorker
>
(
descriptor
,
'
vs/workbench/parts/output/common/outputWorker
'
,
'
OutputWorker
'
,
null
,
instantiationService
);
this
.
_modeWorkerManager
=
new
ModeWorkerManager
<
OutputWorker
>
(
descriptor
,
'
vs/workbench/parts/output/common/outputWorker
'
,
'
OutputWorker
'
,
null
,
instantiationService
);
...
@@ -31,12 +33,24 @@ export class OutputMode extends CompatMode {
...
@@ -31,12 +33,24 @@ export class OutputMode extends CompatMode {
return
wireCancellationToken
(
token
,
this
.
_provideLinks
(
model
.
uri
));
return
wireCancellationToken
(
token
,
this
.
_provideLinks
(
model
.
uri
));
}
}
});
});
if
(
compatWorkerService
.
isInMainThread
)
{
let
workspace
=
contextService
.
getWorkspace
();
if
(
workspace
)
{
this
.
_configure
(
workspace
.
resource
);
}
}
}
}
private
_worker
<
T
>
(
runner
:
(
worker
:
OutputWorker
)
=>
TPromise
<
T
>
):
TPromise
<
T
>
{
private
_worker
<
T
>
(
runner
:
(
worker
:
OutputWorker
)
=>
TPromise
<
T
>
):
TPromise
<
T
>
{
return
this
.
_modeWorkerManager
.
worker
(
runner
);
return
this
.
_modeWorkerManager
.
worker
(
runner
);
}
}
static
$_configure
=
CompatWorkerAttr
(
OutputMode
,
OutputMode
.
prototype
.
_configure
);
private
_configure
(
workspaceResource
:
URI
):
TPromise
<
void
>
{
return
this
.
_worker
((
w
)
=>
w
.
configure
(
workspaceResource
));
}
static
$_provideLinks
=
CompatWorkerAttr
(
OutputMode
,
OutputMode
.
prototype
.
_provideLinks
);
static
$_provideLinks
=
CompatWorkerAttr
(
OutputMode
,
OutputMode
.
prototype
.
_provideLinks
);
private
_provideLinks
(
resource
:
URI
):
TPromise
<
modes
.
ILink
[]
>
{
private
_provideLinks
(
resource
:
URI
):
TPromise
<
modes
.
ILink
[]
>
{
return
this
.
_worker
((
w
)
=>
w
.
provideLinks
(
resource
));
return
this
.
_worker
((
w
)
=>
w
.
provideLinks
(
resource
));
...
...
src/vs/workbench/parts/output/common/outputWorker.ts
浏览文件 @
e170425f
...
@@ -5,7 +5,6 @@
...
@@ -5,7 +5,6 @@
'
use strict
'
;
'
use strict
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IMarkerService
}
from
'
vs/platform/markers/common/markers
'
;
import
{
IResourceService
}
from
'
vs/editor/common/services/resourceService
'
;
import
{
IResourceService
}
from
'
vs/editor/common/services/resourceService
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
strings
=
require
(
'
vs/base/common/strings
'
);
import
strings
=
require
(
'
vs/base/common/strings
'
);
...
@@ -13,35 +12,34 @@ import arrays = require('vs/base/common/arrays');
...
@@ -13,35 +12,34 @@ import arrays = require('vs/base/common/arrays');
import
paths
=
require
(
'
vs/base/common/paths
'
);
import
paths
=
require
(
'
vs/base/common/paths
'
);
import
{
ILink
}
from
'
vs/editor/common/modes
'
;
import
{
ILink
}
from
'
vs/editor/common/modes
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
IWorkspaceContextService
,
IWorkspace
}
from
'
vs/platform/workspace/common/workspace
'
;
export
interface
IResourceCreator
{
toResource
:
(
workspaceRelativePath
:
string
)
=>
URI
;
}
/**
/**
* A base class of text editor worker that helps with detecting links in the text that point to files in the workspace.
* A base class of text editor worker that helps with detecting links in the text that point to files in the workspace.
*/
*/
export
class
OutputWorker
{
export
class
OutputWorker
{
private
_
contextService
:
IWorkspaceContextService
;
private
_
workspaceResource
:
URI
;
private
patterns
:
RegExp
[];
private
patterns
:
RegExp
[];
private
resourceService
:
IResourceService
;
private
resourceService
:
IResourceService
;
private
markerService
:
IMarkerService
;
private
_modeId
:
string
;
private
_modeId
:
string
;
constructor
(
constructor
(
modeId
:
string
,
modeId
:
string
,
@
IResourceService
resourceService
:
IResourceService
,
@
IResourceService
resourceService
:
IResourceService
@
IMarkerService
markerService
:
IMarkerService
,
@
IWorkspaceContextService
contextService
:
IWorkspaceContextService
)
{
)
{
this
.
_modeId
=
modeId
;
this
.
_modeId
=
modeId
;
this
.
resourceService
=
resourceService
;
this
.
resourceService
=
resourceService
;
this
.
markerService
=
markerService
;
this
.
_workspaceResource
=
null
;
this
.
_contextService
=
contextService
;
this
.
patterns
=
[];
let
workspace
=
this
.
_contextService
.
getWorkspace
();
this
.
patterns
=
workspace
?
OutputWorker
.
createPatterns
(
workspace
)
:
[];
}
}
public
get
contextService
():
IWorkspaceContextService
{
public
configure
(
workspaceResource
:
URI
):
TPromise
<
void
>
{
return
this
.
_contextService
;
this
.
_workspaceResource
=
workspaceResource
;
this
.
patterns
=
OutputWorker
.
createPatterns
(
this
.
_workspaceResource
);
return
TPromise
.
as
(
void
0
);
}
}
public
provideLinks
(
resource
:
URI
):
TPromise
<
ILink
[]
>
{
public
provideLinks
(
resource
:
URI
):
TPromise
<
ILink
[]
>
{
...
@@ -52,19 +50,28 @@ export class OutputWorker {
...
@@ -52,19 +50,28 @@ export class OutputWorker {
let
model
=
this
.
resourceService
.
get
(
resource
);
let
model
=
this
.
resourceService
.
get
(
resource
);
let
resourceCreator
:
IResourceCreator
=
{
toResource
:
(
workspaceRelativePath
:
string
):
URI
=>
{
if
(
typeof
workspaceRelativePath
===
'
string
'
&&
this
.
_workspaceResource
)
{
return
URI
.
file
(
paths
.
join
(
this
.
_workspaceResource
.
fsPath
,
workspaceRelativePath
));
}
return
null
;
}
};
for
(
let
i
=
1
,
lineCount
=
model
.
getLineCount
();
i
<=
lineCount
;
i
++
)
{
for
(
let
i
=
1
,
lineCount
=
model
.
getLineCount
();
i
<=
lineCount
;
i
++
)
{
links
.
push
(...
OutputWorker
.
detectLinks
(
model
.
getLineContent
(
i
),
i
,
this
.
patterns
,
this
.
_contextService
));
links
.
push
(...
OutputWorker
.
detectLinks
(
model
.
getLineContent
(
i
),
i
,
this
.
patterns
,
resourceCreator
));
}
}
return
TPromise
.
as
(
links
);
return
TPromise
.
as
(
links
);
}
}
public
static
createPatterns
(
workspace
:
IWorkspace
):
RegExp
[]
{
public
static
createPatterns
(
workspace
Resource
:
URI
):
RegExp
[]
{
let
patterns
:
RegExp
[]
=
[];
let
patterns
:
RegExp
[]
=
[];
let
workspaceRootVariants
=
arrays
.
distinct
([
let
workspaceRootVariants
=
arrays
.
distinct
([
paths
.
normalize
(
workspace
.
r
esource
.
fsPath
,
true
),
paths
.
normalize
(
workspace
R
esource
.
fsPath
,
true
),
paths
.
normalize
(
workspace
.
r
esource
.
fsPath
,
false
)
paths
.
normalize
(
workspace
R
esource
.
fsPath
,
false
)
]);
]);
workspaceRootVariants
.
forEach
((
workspaceRoot
)
=>
{
workspaceRootVariants
.
forEach
((
workspaceRoot
)
=>
{
...
@@ -93,7 +100,7 @@ export class OutputWorker {
...
@@ -93,7 +100,7 @@ export class OutputWorker {
/**
/**
* Detect links. Made public static to allow for tests.
* Detect links. Made public static to allow for tests.
*/
*/
public
static
detectLinks
(
line
:
string
,
lineIndex
:
number
,
patterns
:
RegExp
[],
contextService
:
I
WorkspaceContextService
):
ILink
[]
{
public
static
detectLinks
(
line
:
string
,
lineIndex
:
number
,
patterns
:
RegExp
[],
contextService
:
I
ResourceCreator
):
ILink
[]
{
let
links
:
ILink
[]
=
[];
let
links
:
ILink
[]
=
[];
patterns
.
forEach
((
pattern
)
=>
{
patterns
.
forEach
((
pattern
)
=>
{
...
...
src/vs/workbench/parts/output/test/outputWorker.test.ts
浏览文件 @
e170425f
...
@@ -22,21 +22,13 @@ function toOSPath(p: string): string {
...
@@ -22,21 +22,13 @@ function toOSPath(p: string): string {
suite
(
'
Workbench - OutputWorker
'
,
()
=>
{
suite
(
'
Workbench - OutputWorker
'
,
()
=>
{
test
(
'
OutputWorker - Link detection
'
,
function
()
{
test
(
'
OutputWorker - Link detection
'
,
function
()
{
let
patternsSlash
=
OutputWorker
.
createPatterns
({
let
patternsSlash
=
OutputWorker
.
createPatterns
(
id
:
'
foo
'
,
URI
.
file
(
'
C:/Users/someone/AppData/Local/Temp/_monacodata_9888/workspaces/mankala
'
)
name
:
'
foo
'
,
);
resource
:
URI
.
file
(
'
C:/Users/someone/AppData/Local/Temp/_monacodata_9888/workspaces/mankala
'
),
uid
:
0
,
let
patternsBackSlash
=
OutputWorker
.
createPatterns
(
mtime
:
0
URI
.
file
(
'
C:
\\
Users
\\
someone
\\
AppData
\\
Local
\\
Temp
\\
_monacodata_9888
\\
workspaces
\\
mankala
'
)
});
);
let
patternsBackSlash
=
OutputWorker
.
createPatterns
({
id
:
'
foo
'
,
name
:
'
foo
'
,
resource
:
URI
.
file
(
'
C:
\\
Users
\\
someone
\\
AppData
\\
Local
\\
Temp
\\
_monacodata_9888
\\
workspaces
\\
mankala
'
),
uid
:
0
,
mtime
:
0
});
let
contextService
=
new
TestContextService
();
let
contextService
=
new
TestContextService
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录