Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
2aa549d5
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,发现更多精彩内容 >>
提交
2aa549d5
编写于
7月 10, 2017
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
starting with remote file service
上级
6da138c8
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
149 addition
and
4 deletion
+149
-4
src/vs/workbench/electron-browser/workbench.ts
src/vs/workbench/electron-browser/workbench.ts
+3
-2
src/vs/workbench/services/files/electron-browser/fileService.ts
.../workbench/services/files/electron-browser/fileService.ts
+2
-2
src/vs/workbench/services/files/electron-browser/remoteFileService.ts
...ench/services/files/electron-browser/remoteFileService.ts
+144
-0
未找到文件。
src/vs/workbench/electron-browser/workbench.ts
浏览文件 @
2aa549d5
...
...
@@ -57,7 +57,8 @@ import { ContextKeyExpr, RawContextKey, IContextKeyService, IContextKey } from '
import
{
IActivityBarService
}
from
'
vs/workbench/services/activity/common/activityBarService
'
;
import
{
IViewletService
}
from
'
vs/workbench/services/viewlet/browser/viewlet
'
;
import
{
ViewletService
}
from
'
vs/workbench/services/viewlet/browser/viewletService
'
;
import
{
FileService
}
from
'
vs/workbench/services/files/electron-browser/fileService
'
;
// import { FileService } from 'vs/workbench/services/files/electron-browser/fileService';
import
{
RemoteFileService
}
from
"
vs/workbench/services/files/electron-browser/remoteFileService
"
;
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
{
IListService
,
ListService
}
from
'
vs/platform/list/browser/listService
'
;
import
{
IConfigurationResolverService
}
from
'
vs/workbench/services/configurationResolver/common/configurationResolver
'
;
...
...
@@ -561,7 +562,7 @@ export class Workbench implements IPartService {
serviceCollection
.
set
(
ITitleService
,
this
.
titlebarPart
);
// File Service
const
fileService
=
this
.
instantiationService
.
createInstance
(
FileService
);
const
fileService
=
this
.
instantiationService
.
createInstance
(
Remote
FileService
);
serviceCollection
.
set
(
IFileService
,
fileService
);
this
.
toDispose
.
push
(
fileService
.
onFileChanges
(
e
=>
this
.
configurationService
.
handleWorkspaceFileEvents
(
e
)));
...
...
src/vs/workbench/services/files/electron-browser/fileService.ts
浏览文件 @
2aa549d5
...
...
@@ -41,7 +41,7 @@ export class FileService implements IFileService {
private
toUnbind
:
IDisposable
[];
private
activeOutOfWorkspaceWatchers
:
ResourceMap
<
uri
>
;
pr
ivate
_onFileChanges
:
Emitter
<
FileChangesEvent
>
;
pr
otected
_onFileChanges
:
Emitter
<
FileChangesEvent
>
;
private
_onAfterOperation
:
Emitter
<
FileOperationEvent
>
;
constructor
(
...
...
src/vs/workbench/services/files/electron-browser/remoteFileService.ts
0 → 100644
浏览文件 @
2aa549d5
/*---------------------------------------------------------------------------------------------
* 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
URI
from
'
vs/base/common/uri
'
;
import
{
FileService
}
from
'
vs/workbench/services/files/electron-browser/fileService
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IMessageService
}
from
'
vs/platform/message/common/message
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
ILifecycleService
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
IStorageService
}
from
'
vs/platform/storage/common/storage
'
;
import
{
IContent
,
IStreamContent
,
IFileStat
,
IResolveContentOptions
,
IUpdateContentOptions
,
FileChangesEvent
,
FileChangeType
}
from
"
vs/platform/files/common/files
"
;
import
{
TPromise
}
from
"
vs/base/common/winjs.base
"
;
import
Event
from
"
vs/base/common/event
"
;
import
{
EventEmitter
}
from
"
events
"
;
import
{
basename
}
from
"
path
"
;
import
{
IDisposable
}
from
"
vs/base/common/lifecycle
"
;
export
interface
IRemoteFileProvider
{
onDidChange
:
Event
<
URI
>
;
resolve
(
resource
:
URI
):
TPromise
<
string
>
;
update
(
resource
:
URI
,
content
:
string
):
TPromise
<
any
>
;
}
export
class
RemoteFileService
extends
FileService
{
private
readonly
_remoteAuthority
:
string
;
private
_provider
:
IRemoteFileProvider
;
constructor
(
@
IConfigurationService
configurationService
:
IConfigurationService
,
@
IWorkspaceContextService
contextService
:
IWorkspaceContextService
,
@
IWorkbenchEditorService
editorService
:
IWorkbenchEditorService
,
@
IEnvironmentService
environmentService
:
IEnvironmentService
,
@
IEditorGroupService
editorGroupService
:
IEditorGroupService
,
@
ILifecycleService
lifecycleService
:
ILifecycleService
,
@
IMessageService
messageService
:
IMessageService
,
@
IStorageService
storageService
:
IStorageService
)
{
super
(
configurationService
,
contextService
,
editorService
,
environmentService
,
editorGroupService
,
lifecycleService
,
messageService
,
storageService
);
this
.
_remoteAuthority
=
environmentService
.
args
[
'
remote
'
];
this
.
registerProvider
(
new
class
implements
IRemoteFileProvider
{
onDidChange
:
Event
<
URI
>
=
Event
.
None
;
resolve
(
resource
:
URI
):
TPromise
<
string
>
{
return
TPromise
.
as
(
JSON
.
stringify
(
resource
,
undefined
,
4
));
}
update
(
resource
:
URI
,
content
:
string
):
TPromise
<
any
>
{
return
TPromise
.
as
(
undefined
);
}
});
}
private
_shouldIntercept
(
resource
:
URI
):
boolean
{
return
this
.
_provider
&&
resource
.
authority
===
this
.
_remoteAuthority
;
}
registerProvider
(
provider
:
IRemoteFileProvider
):
IDisposable
{
this
.
_provider
=
provider
;
const
reg
=
this
.
_provider
.
onDidChange
(
e
=>
{
// forward change events
this
.
_onFileChanges
.
fire
(
new
FileChangesEvent
([{
resource
:
e
,
type
:
FileChangeType
.
UPDATED
}]));
});
return
{
dispose
:
()
=>
{
reg
.
dispose
();
this
.
_provider
=
undefined
;
}
};
}
// --- resolve
resolveContent
(
resource
:
URI
,
options
?:
IResolveContentOptions
):
TPromise
<
IContent
>
{
if
(
this
.
_shouldIntercept
(
resource
))
{
return
this
.
_doResolveContent
(
resource
);
}
return
super
.
resolveContent
(
resource
,
options
);
}
resolveStreamContent
(
resource
:
URI
,
options
?:
IResolveContentOptions
):
TPromise
<
IStreamContent
>
{
if
(
this
.
_shouldIntercept
(
resource
))
{
return
this
.
_doResolveContent
(
resource
).
then
(
RemoteFileService
.
_asStreamContent
);
}
return
super
.
resolveStreamContent
(
resource
,
options
);
}
private
async
_doResolveContent
(
resource
:
URI
):
TPromise
<
IContent
>
{
const
stat
=
RemoteFileService
.
_createFakeStat
(
resource
);
const
value
=
await
this
.
_provider
.
resolve
(
resource
);
return
<
any
>
{
...
stat
,
value
};
}
// --- saving
updateContent
(
resource
:
URI
,
value
:
string
,
options
?:
IUpdateContentOptions
):
TPromise
<
IFileStat
>
{
if
(
this
.
_shouldIntercept
(
resource
))
{
return
this
.
_doUpdateContent
(
resource
,
value
).
then
(
RemoteFileService
.
_createFakeStat
);
}
return
super
.
updateContent
(
resource
,
value
,
options
);
}
private
async
_doUpdateContent
(
resource
:
URI
,
content
:
string
):
TPromise
<
URI
>
{
await
this
.
_provider
.
update
(
resource
,
content
);
return
resource
;
}
// --- util
private
static
_createFakeStat
(
resource
:
URI
):
IFileStat
{
return
<
IFileStat
>
{
resource
,
name
:
basename
(
resource
.
path
),
encoding
:
'
utf8
'
,
mtime
:
Date
.
now
(),
etag
:
Date
.
now
().
toString
(
16
),
isDirectory
:
false
,
hasChildren
:
false
};
}
private
static
_asStreamContent
(
content
:
IContent
):
IStreamContent
{
const
emitter
=
new
EventEmitter
();
const
{
value
}
=
content
;
const
result
=
<
IStreamContent
><
any
>
content
;
result
.
value
=
emitter
;
setTimeout
(()
=>
{
emitter
.
emit
(
'
data
'
,
value
);
emitter
.
emit
(
'
end
'
);
},
0
);
return
result
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录