Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
af195c96
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,发现更多精彩内容 >>
提交
af195c96
编写于
8月 17, 2017
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
api-ify search provider, needs query logic...
上级
fe207183
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
101 addition
and
11 deletion
+101
-11
src/vs/platform/progress/common/progress.ts
src/vs/platform/progress/common/progress.ts
+3
-3
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+4
-0
src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts
src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts
+48
-1
src/vs/workbench/api/node/extHost.protocol.ts
src/vs/workbench/api/node/extHost.protocol.ts
+8
-0
src/vs/workbench/api/node/extHostWorkspace.ts
src/vs/workbench/api/node/extHostWorkspace.ts
+38
-7
未找到文件。
src/vs/platform/progress/common/progress.ts
浏览文件 @
af195c96
...
...
@@ -39,10 +39,10 @@ export const emptyProgress: IProgress<any> = Object.freeze({ report() { } });
export
class
Progress
<
T
>
implements
IProgress
<
T
>
{
private
_callback
:
()
=>
void
;
private
_callback
:
(
data
:
T
)
=>
void
;
private
_value
:
T
;
constructor
(
callback
:
()
=>
void
)
{
constructor
(
callback
:
(
data
:
T
)
=>
void
)
{
this
.
_callback
=
callback
;
}
...
...
@@ -52,7 +52,7 @@ export class Progress<T> implements IProgress<T> {
report
(
item
:
T
)
{
this
.
_value
=
item
;
this
.
_callback
();
this
.
_callback
(
this
.
_value
);
}
}
...
...
src/vs/vscode.proposed.d.ts
浏览文件 @
af195c96
...
...
@@ -16,6 +16,10 @@ declare module 'vscode' {
writeContents
(
resource
:
Uri
,
contents
:
string
):
void
|
Thenable
<
void
>
;
}
export
interface
SearchProvider
{
provideSearchResults
(
query
:
any
,
progress
:
Progress
<
Uri
>
,
token
?:
CancellationToken
):
Thenable
<
void
>
;
}
export
namespace
workspace
{
export
function
registerFileSystemProvider
(
authority
:
string
,
provider
:
FileSystemProvider
):
Disposable
;
...
...
src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts
浏览文件 @
af195c96
...
...
@@ -12,7 +12,7 @@ import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/edi
import
{
ITextFileService
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
ICommonCodeEditor
,
isCommonCodeEditor
}
from
'
vs/editor/common/editorCommon
'
;
import
{
bulkEdit
,
IResourceEdit
}
from
'
vs/editor/common/services/bulkEdit
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
TPromise
,
PPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
MainThreadWorkspaceShape
,
ExtHostWorkspaceShape
,
ExtHostContext
,
MainContext
,
IExtHostContext
}
from
'
../node/extHost.protocol
'
;
import
{
ITextModelService
}
from
'
vs/editor/common/services/resolverService
'
;
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
...
...
@@ -101,6 +101,53 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape {
// --- save & edit resources ---
private
readonly
_searchProvider
=
new
Map
<
number
,
IDisposable
>
();
private
readonly
_searchSession
=
new
Map
<
number
,
{
resolve
:
Function
,
reject
:
Function
,
progress
:
Function
}
>
();
private
_searchSessionIdPool
:
number
=
0
;
$registerSearchProvider
(
handle
:
number
,
type
:
number
):
void
{
this
.
_searchProvider
.
set
(
handle
,
this
.
_searchService
.
registerSearchResultProvider
({
search
:
(
query
)
=>
{
if
(
query
.
type
!==
type
)
{
return
null
;
}
const
session
=
++
this
.
_searchSessionIdPool
;
return
new
PPromise
<
any
,
any
>
((
resolve
,
reject
,
progress
)
=>
{
this
.
_searchSession
.
set
(
session
,
{
resolve
,
reject
,
progress
});
this
.
_proxy
.
$startSearch
(
handle
,
session
,
query
);
},
()
=>
{
this
.
_proxy
.
$cancelSearch
(
handle
,
session
);
});
}
}));
}
$unregisterSearchProvider
(
handle
:
number
):
void
{
const
registration
=
this
.
_searchProvider
.
get
(
handle
);
if
(
registration
)
{
registration
.
dispose
();
this
.
_searchProvider
.
delete
(
handle
);
}
}
$updateSearchSession
(
session
:
number
,
data
):
void
{
if
(
this
.
_searchSession
.
has
(
session
))
{
this
.
_searchSession
.
get
(
session
).
progress
(
data
);
}
}
$finishSearchSession
(
session
:
number
,
err
?:
any
):
void
{
if
(
this
.
_searchSession
.
has
(
session
))
{
const
{
resolve
,
reject
}
=
this
.
_searchSession
.
get
(
session
);
this
.
_searchSession
.
delete
(
session
);
if
(
err
)
{
reject
(
err
);
}
else
{
resolve
();
}
}
}
$saveAll
(
includeUntitled
?:
boolean
):
Thenable
<
boolean
>
{
return
this
.
_textFileService
.
saveAll
(
includeUntitled
).
then
(
result
=>
{
return
result
.
results
.
every
(
each
=>
each
.
success
===
true
);
...
...
src/vs/workbench/api/node/extHost.protocol.ts
浏览文件 @
af195c96
...
...
@@ -280,6 +280,11 @@ export interface MainThreadWorkspaceShape extends IDisposable {
$applyWorkspaceEdit
(
edits
:
IResourceEdit
[]):
TPromise
<
boolean
>
;
$registerFileSystemProvider
(
handle
:
number
,
authority
:
string
):
void
;
$onFileSystemChange
(
handle
:
number
,
resource
:
URI
):
void
;
$registerSearchProvider
(
handle
:
number
,
type
:
number
):
void
;
$unregisterSearchProvider
(
handle
:
number
):
void
;
$updateSearchSession
(
session
:
number
,
data
):
void
;
$finishSearchSession
(
session
:
number
,
err
?:
any
):
void
;
}
export
interface
MainThreadTaskShape
extends
IDisposable
{
...
...
@@ -418,8 +423,11 @@ export interface ExtHostTreeViewsShape {
export
interface
ExtHostWorkspaceShape
{
$acceptWorkspaceData
(
workspace
:
IWorkspaceData
):
void
;
$resolveFile
(
handle
:
number
,
resource
:
URI
):
TPromise
<
string
>
;
$storeFile
(
handle
:
number
,
resource
:
URI
,
content
:
string
):
TPromise
<
any
>
;
$startSearch
(
handle
:
number
,
session
:
number
,
query
):
void
;
$cancelSearch
(
handle
:
number
,
session
:
number
):
void
;
}
export
interface
ExtHostExtensionServiceShape
{
...
...
src/vs/workbench/api/node/extHostWorkspace.ts
浏览文件 @
af195c96
...
...
@@ -19,6 +19,8 @@ import { compare } from "vs/base/common/strings";
import
{
asWinJsPromise
}
from
'
vs/base/common/async
'
;
import
{
Disposable
}
from
'
vs/workbench/api/node/extHostTypes
'
;
import
{
TrieMap
}
from
'
vs/base/common/map
'
;
import
{
CancellationTokenSource
}
from
'
vs/base/common/cancellation
'
;
import
{
Progress
}
from
'
vs/platform/progress/common/progress
'
;
class
Workspace2
extends
Workspace
{
...
...
@@ -207,27 +209,56 @@ export class ExtHostWorkspace implements ExtHostWorkspaceShape {
// --- EXPERIMENT: workspace resolver
private
readonly
_provider
=
new
Map
<
number
,
vscode
.
FileSystemProvider
>
();
public
registerFileSystemProvider
(
authority
:
string
,
provider
:
vscode
.
FileSystemProvider
):
vscode
.
Disposable
{
private
_handlePool
=
0
;
private
readonly
_fsProvider
=
new
Map
<
number
,
vscode
.
FileSystemProvider
>
();
private
readonly
_searchProvider
=
new
Map
<
number
,
vscode
.
SearchProvider
>
();
private
readonly
_searchSession
=
new
Map
<
number
,
CancellationTokenSource
>
();
const
handle
=
this
.
_provider
.
size
;
this
.
_provider
.
set
(
handle
,
provider
);
registerFileSystemProvider
(
authority
:
string
,
provider
:
vscode
.
FileSystemProvider
):
vscode
.
Disposable
{
const
handle
=
++
this
.
_handlePool
;
this
.
_fsProvider
.
set
(
handle
,
provider
);
const
reg
=
provider
.
onDidChange
(
e
=>
this
.
_proxy
.
$onFileSystemChange
(
handle
,
<
URI
>
e
));
this
.
_proxy
.
$registerFileSystemProvider
(
handle
,
authority
);
return
new
Disposable
(()
=>
{
this
.
_
p
rovider
.
delete
(
handle
);
this
.
_
fsP
rovider
.
delete
(
handle
);
reg
.
dispose
();
});
}
$resolveFile
(
handle
:
number
,
resource
:
URI
):
TPromise
<
string
>
{
const
provider
=
this
.
_
p
rovider
.
get
(
handle
);
const
provider
=
this
.
_
fsP
rovider
.
get
(
handle
);
return
asWinJsPromise
(
token
=>
provider
.
resolveContents
(
resource
));
}
$storeFile
(
handle
:
number
,
resource
:
URI
,
content
:
string
):
TPromise
<
any
>
{
const
provider
=
this
.
_
p
rovider
.
get
(
handle
);
const
provider
=
this
.
_
fsP
rovider
.
get
(
handle
);
return
asWinJsPromise
(
token
=>
provider
.
writeContents
(
resource
,
content
));
}
registerSearchProvider
(
provider
:
vscode
.
SearchProvider
):
vscode
.
Disposable
{
const
handle
=
++
this
.
_handlePool
;
this
.
_searchProvider
.
set
(
handle
,
provider
);
return
new
Disposable
(()
=>
this
.
_fsProvider
.
delete
(
handle
));
}
$startSearch
(
handle
:
number
,
session
:
number
,
query
):
void
{
const
provider
=
this
.
_searchProvider
.
get
(
handle
);
const
source
=
new
CancellationTokenSource
();
const
progress
=
new
Progress
<
any
>
(
chunk
=>
this
.
_proxy
.
$updateSearchSession
(
session
,
chunk
));
this
.
_searchSession
.
set
(
session
,
source
);
TPromise
.
wrap
(
provider
.
provideSearchResults
(
query
,
progress
,
source
.
token
)).
then
(()
=>
{
this
.
_proxy
.
$finishSearchSession
(
session
);
},
err
=>
{
this
.
_proxy
.
$finishSearchSession
(
session
,
err
);
});
}
$cancelSearch
(
handle
:
number
,
session
:
number
):
void
{
if
(
this
.
_searchSession
.
has
(
session
))
{
this
.
_searchSession
.
get
(
session
).
cancel
();
this
.
_searchSession
.
delete
(
session
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录