Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
24fbd1f5
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,发现更多精彩内容 >>
提交
24fbd1f5
编写于
6月 12, 2017
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add $acceptWorkspaceData to push new info about open folders, #28526
上级
0ace0d0f
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
49 addition
and
30 deletion
+49
-30
src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts
src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts
+25
-21
src/vs/workbench/api/node/extHost.api.impl.ts
src/vs/workbench/api/node/extHost.api.impl.ts
+1
-2
src/vs/workbench/api/node/extHost.protocol.ts
src/vs/workbench/api/node/extHost.protocol.ts
+6
-1
src/vs/workbench/api/node/extHostWorkspace.ts
src/vs/workbench/api/node/extHostWorkspace.ts
+14
-4
src/vs/workbench/test/electron-browser/api/extHostWorkspace.test.ts
...kbench/test/electron-browser/api/extHostWorkspace.test.ts
+3
-2
未找到文件。
src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts
浏览文件 @
24fbd1f5
...
...
@@ -13,39 +13,41 @@ import { ITextFileService } from 'vs/workbench/services/textfile/common/textfile
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
{
Uri
}
from
'
vscode
'
;
import
{
MainThreadWorkspaceShape
}
from
'
../node/extHost.protocol
'
;
import
{
MainThreadWorkspaceShape
,
ExtHostWorkspaceShape
,
ExtHostContext
}
from
'
../node/extHost.protocol
'
;
import
{
ITextModelResolverService
}
from
'
vs/editor/common/services/resolverService
'
;
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
{
IThreadService
}
from
'
vs/workbench/services/thread/common/threadService
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
export
class
MainThreadWorkspace
extends
MainThreadWorkspaceShape
{
private
_activeSearches
:
{
[
id
:
number
]:
TPromise
<
Uri
[]
>
}
=
Object
.
create
(
null
);
private
_searchService
:
ISearchService
;
private
_contextService
:
IWorkspaceContextService
;
private
_textFileService
:
ITextFileService
;
private
_editorService
:
IWorkbenchEditorService
;
private
_textModelResolverService
:
ITextModelResolverService
;
private
_fileService
:
IFileService
;
private
readonly
_toDispose
:
IDisposable
[]
=
[];
private
readonly
_activeSearches
:
{
[
id
:
number
]:
TPromise
<
URI
[]
>
}
=
Object
.
create
(
null
);
private
readonly
_proxy
:
ExtHostWorkspaceShape
;
constructor
(
@
ISearchService
searchService
:
ISearchService
,
@
IWorkspaceContextService
contextService
:
IWorkspaceContextService
,
@
ITextFileService
textFileService
:
ITextFileService
,
@
IWorkbenchEditorService
editorService
:
IWorkbenchEditorService
,
@
ITextModelResolverService
textModelResolverService
:
ITextModelResolverService
,
@
IFileService
fileService
:
IFileService
@
ISearchService
private
readonly
_searchService
:
ISearchService
,
@
IWorkspaceContextService
private
readonly
_contextService
:
IWorkspaceContextService
,
@
ITextFileService
private
readonly
_textFileService
:
ITextFileService
,
@
IWorkbenchEditorService
private
readonly
_editorService
:
IWorkbenchEditorService
,
@
ITextModelResolverService
private
readonly
_textModelResolverService
:
ITextModelResolverService
,
@
IFileService
private
readonly
_fileService
:
IFileService
,
@
IThreadService
threadService
:
IThreadService
)
{
super
();
this
.
_proxy
=
threadService
.
get
(
ExtHostContext
.
ExtHostWorkspace
);
this
.
_contextService
.
onDidChangeFolders
(
this
.
_onDidChangeWorkspace
,
this
,
this
.
_toDispose
);
}
// --- workspace ---
this
.
_searchService
=
searchService
;
this
.
_contextService
=
contextService
;
this
.
_textFileService
=
textFileService
;
this
.
_editorService
=
editorService
;
this
.
_fileService
=
fileService
;
this
.
_textModelResolverService
=
textModelResolverService
;
private
_onDidChangeWorkspace
(
folders
:
URI
[]):
void
{
this
.
_proxy
.
$acceptWorkspaceData
(
folders
);
}
// --- search ---
$startSearch
(
include
:
string
,
exclude
:
string
,
maxResults
:
number
,
requestId
:
number
):
Thenable
<
URI
[]
>
{
const
workspace
=
this
.
_contextService
.
getWorkspace
();
if
(
!
workspace
)
{
...
...
@@ -84,6 +86,8 @@ export class MainThreadWorkspace extends MainThreadWorkspaceShape {
return
undefined
;
}
// --- save & edit resources ---
$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.api.impl.ts
浏览文件 @
24fbd1f5
...
...
@@ -91,6 +91,7 @@ export function createApiFactory(
const
extHostTerminalService
=
col
.
define
(
ExtHostContext
.
ExtHostTerminalService
).
set
<
ExtHostTerminalService
>
(
new
ExtHostTerminalService
(
threadService
));
const
extHostSCM
=
col
.
define
(
ExtHostContext
.
ExtHostSCM
).
set
<
ExtHostSCM
>
(
new
ExtHostSCM
(
threadService
,
extHostCommands
));
const
extHostTask
=
col
.
define
(
ExtHostContext
.
ExtHostTask
).
set
<
ExtHostTask
>
(
new
ExtHostTask
(
threadService
));
const
extHostWorkspace
=
col
.
define
(
ExtHostContext
.
ExtHostWorkspace
).
set
<
ExtHostWorkspace
>
(
new
ExtHostWorkspace
(
threadService
,
initData
.
workspace
&&
[
initData
.
workspace
.
resource
]));
col
.
define
(
ExtHostContext
.
ExtHostExtensionService
).
set
(
extensionService
);
col
.
finish
(
false
,
threadService
);
...
...
@@ -99,8 +100,6 @@ export function createApiFactory(
const
extHostStatusBar
=
new
ExtHostStatusBar
(
threadService
);
const
extHostProgress
=
new
ExtHostProgress
(
threadService
.
get
(
MainContext
.
MainThreadProgress
));
const
extHostOutputService
=
new
ExtHostOutputService
(
threadService
);
const
workspacePath
=
initData
.
workspace
?
initData
.
workspace
.
resource
.
fsPath
:
undefined
;
const
extHostWorkspace
=
new
ExtHostWorkspace
(
threadService
,
workspacePath
);
const
extHostLanguages
=
new
ExtHostLanguages
(
threadService
);
// Register API-ish commands
...
...
src/vs/workbench/api/node/extHost.protocol.ts
浏览文件 @
24fbd1f5
...
...
@@ -404,6 +404,10 @@ export abstract class ExtHostTreeViewsShape {
$getChildren
(
treeViewId
:
string
,
treeItemHandle
:
number
):
TPromise
<
ITreeItem
[]
>
{
throw
ni
();
}
}
export
abstract
class
ExtHostWorkspaceShape
{
$acceptWorkspaceData
(
folders
:
URI
[]):
void
{
throw
ni
();
}
}
export
abstract
class
ExtHostExtensionServiceShape
{
$activateExtension
(
extensionDescription
:
IExtensionDescription
):
TPromise
<
void
>
{
throw
ni
();
}
}
...
...
@@ -524,5 +528,6 @@ export const ExtHostContext = {
ExtHostExtensionService
:
createExtId
<
ExtHostExtensionServiceShape
>
(
'
ExtHostExtensionService
'
,
ExtHostExtensionServiceShape
),
ExtHostTerminalService
:
createExtId
<
ExtHostTerminalServiceShape
>
(
'
ExtHostTerminalService
'
,
ExtHostTerminalServiceShape
),
ExtHostSCM
:
createExtId
<
ExtHostSCMShape
>
(
'
ExtHostSCM
'
,
ExtHostSCMShape
),
ExtHostTask
:
createExtId
<
ExtHostTaskShape
>
(
'
ExtHostTask
'
,
ExtHostTaskShape
)
ExtHostTask
:
createExtId
<
ExtHostTaskShape
>
(
'
ExtHostTask
'
,
ExtHostTaskShape
),
ExtHostWorkspace
:
createExtId
<
ExtHostWorkspaceShape
>
(
'
ExtHostWorkspace
'
,
ExtHostWorkspaceShape
),
};
src/vs/workbench/api/node/extHostWorkspace.ts
浏览文件 @
24fbd1f5
...
...
@@ -6,26 +6,30 @@
import
URI
from
'
vs/base/common/uri
'
;
import
{
normalize
}
from
'
vs/base/common/paths
'
;
import
{
isFalsyOrEmpty
}
from
'
vs/base/common/arrays
'
;
import
{
relative
}
from
'
path
'
;
import
{
IThreadService
}
from
'
vs/workbench/services/thread/common/threadService
'
;
import
{
IResourceEdit
}
from
'
vs/editor/common/services/bulkEdit
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
fromRange
,
EndOfLine
}
from
'
vs/workbench/api/node/extHostTypeConverters
'
;
import
{
MainContext
,
MainThreadWorkspaceShape
}
from
'
./extHost.protocol
'
;
import
{
ExtHostWorkspaceShape
,
MainContext
,
MainThreadWorkspaceShape
}
from
'
./extHost.protocol
'
;
import
*
as
vscode
from
'
vscode
'
;
export
class
ExtHostWorkspace
{
export
class
ExtHostWorkspace
extends
ExtHostWorkspaceShape
{
private
static
_requestIdPool
=
0
;
private
_proxy
:
MainThreadWorkspaceShape
;
private
_workspacePath
:
string
;
constructor
(
threadService
:
IThreadService
,
workspacePath
:
string
)
{
constructor
(
threadService
:
IThreadService
,
folders
:
URI
[])
{
super
();
this
.
_proxy
=
threadService
.
get
(
MainContext
.
MainThreadWorkspace
);
this
.
_workspacePath
=
workspace
Path
;
this
.
_workspacePath
=
isFalsyOrEmpty
(
folders
)
?
undefined
:
folders
[
0
].
fs
Path
;
}
// --- workspace ---
getPath
():
string
{
return
this
.
_workspacePath
;
}
...
...
@@ -55,6 +59,12 @@ export class ExtHostWorkspace {
return
normalize
(
result
);
}
$acceptWorkspaceData
(
folders
:
URI
[]):
void
{
// todo@joh do something, align with ctor URI[] vs IWorkspace
}
// --- search ---
findFiles
(
include
:
string
,
exclude
:
string
,
maxResults
?:
number
,
token
?:
vscode
.
CancellationToken
):
Thenable
<
vscode
.
Uri
[]
>
{
const
requestId
=
ExtHostWorkspace
.
_requestIdPool
++
;
const
result
=
this
.
_proxy
.
$startSearch
(
include
,
exclude
,
maxResults
,
requestId
);
...
...
src/vs/workbench/test/electron-browser/api/extHostWorkspace.test.ts
浏览文件 @
24fbd1f5
...
...
@@ -6,6 +6,7 @@
'
use strict
'
;
import
*
as
assert
from
'
assert
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
ExtHostWorkspace
}
from
'
vs/workbench/api/node/extHostWorkspace
'
;
import
{
TestThreadService
}
from
'
./testThreadService
'
;
...
...
@@ -13,7 +14,7 @@ suite('ExtHostWorkspace', function () {
test
(
'
asRelativePath
'
,
function
()
{
const
ws
=
new
ExtHostWorkspace
(
new
TestThreadService
(),
'
/Coding/Applications/NewsWoWBot
'
);
const
ws
=
new
ExtHostWorkspace
(
new
TestThreadService
(),
[
URI
.
file
(
'
/Coding/Applications/NewsWoWBot
'
)]
);
assert
.
equal
(
ws
.
getRelativePath
(
'
/Coding/Applications/NewsWoWBot/bernd/das/brot
'
),
'
bernd/das/brot
'
);
assert
.
equal
(
ws
.
getRelativePath
(
'
/Apps/DartPubCache/hosted/pub.dartlang.org/convert-2.0.1/lib/src/hex.dart
'
),
...
...
@@ -26,7 +27,7 @@ suite('ExtHostWorkspace', function () {
test
(
'
asRelativePath, same paths, #11402
'
,
function
()
{
const
root
=
'
/home/aeschli/workspaces/samples/docker
'
;
const
input
=
'
/home/aeschli/workspaces/samples/docker
'
;
const
ws
=
new
ExtHostWorkspace
(
new
TestThreadService
(),
root
);
const
ws
=
new
ExtHostWorkspace
(
new
TestThreadService
(),
[
URI
.
file
(
root
)]
);
assert
.
equal
(
ws
.
getRelativePath
(
input
),
input
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录