Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
1741f67d
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,发现更多精彩内容 >>
提交
1741f67d
编写于
11月 04, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
adopt ITextModelResolverService for resources
上级
4cc289a8
变更
25
隐藏空白更改
内联
并排
Showing
25 changed file
with
160 addition
and
64 deletion
+160
-64
src/vs/editor/browser/standalone/simpleServices.ts
src/vs/editor/browser/standalone/simpleServices.ts
+1
-1
src/vs/editor/browser/standalone/standaloneEditor.ts
src/vs/editor/browser/standalone/standaloneEditor.ts
+1
-1
src/vs/editor/common/services/bulkEdit.ts
src/vs/editor/common/services/bulkEdit.ts
+9
-9
src/vs/editor/contrib/goToDeclaration/browser/goToDeclaration.ts
...editor/contrib/goToDeclaration/browser/goToDeclaration.ts
+3
-2
src/vs/editor/contrib/referenceSearch/browser/referencesController.ts
...r/contrib/referenceSearch/browser/referencesController.ts
+3
-1
src/vs/editor/contrib/referenceSearch/browser/referencesModel.ts
...editor/contrib/referenceSearch/browser/referencesModel.ts
+3
-3
src/vs/editor/contrib/referenceSearch/browser/referencesWidget.ts
...ditor/contrib/referenceSearch/browser/referencesWidget.ts
+5
-5
src/vs/editor/contrib/rename/browser/rename.ts
src/vs/editor/contrib/rename/browser/rename.ts
+3
-3
src/vs/platform/textmodelResolver/common/resolver.ts
src/vs/platform/textmodelResolver/common/resolver.ts
+0
-0
src/vs/test/utils/servicesTestUtils.ts
src/vs/test/utils/servicesTestUtils.ts
+2
-2
src/vs/workbench/api/node/mainThreadDocuments.ts
src/vs/workbench/api/node/mainThreadDocuments.ts
+2
-2
src/vs/workbench/api/node/mainThreadWorkspace.ts
src/vs/workbench/api/node/mainThreadWorkspace.ts
+5
-1
src/vs/workbench/common/editor/resourceEditorInput.ts
src/vs/workbench/common/editor/resourceEditorInput.ts
+1
-1
src/vs/workbench/electron-browser/workbench.ts
src/vs/workbench/electron-browser/workbench.ts
+1
-1
src/vs/workbench/parts/contentprovider/common/contentprovider.contribution.ts
...ts/contentprovider/common/contentprovider.contribution.ts
+1
-1
src/vs/workbench/parts/files/browser/saveErrorHandler.ts
src/vs/workbench/parts/files/browser/saveErrorHandler.ts
+1
-1
src/vs/workbench/parts/html/browser/html.contribution.ts
src/vs/workbench/parts/html/browser/html.contribution.ts
+2
-1
src/vs/workbench/parts/html/browser/htmlPreviewPart.ts
src/vs/workbench/parts/html/browser/htmlPreviewPart.ts
+5
-5
src/vs/workbench/parts/search/browser/replaceService.ts
src/vs/workbench/parts/search/browser/replaceService.ts
+17
-6
src/vs/workbench/services/textfile/browser/textFileService.ts
...vs/workbench/services/textfile/browser/textFileService.ts
+12
-9
src/vs/workbench/services/textfile/common/textFileEditorModelManager.ts
...ch/services/textfile/common/textFileEditorModelManager.ts
+1
-1
src/vs/workbench/services/textfile/common/textfiles.ts
src/vs/workbench/services/textfile/common/textfiles.ts
+1
-1
src/vs/workbench/services/textfile/electron-browser/textFileService.ts
...nch/services/textfile/electron-browser/textFileService.ts
+1
-3
src/vs/workbench/services/textmodelResolver/common/textModelResolverService.ts
...ices/textmodelResolver/common/textModelResolverService.ts
+79
-3
src/vs/workbench/services/textmodelResolver/test/textModelResolverService.test.ts
...s/textmodelResolver/test/textModelResolverService.test.ts
+1
-1
未找到文件。
src/vs/editor/browser/standalone/simpleServices.ts
浏览文件 @
1741f67d
...
...
@@ -26,7 +26,7 @@ import { getDefaultValues as getDefaultConfiguration } from 'vs/platform/configu
import
{
CommandService
}
from
'
vs/platform/commands/common/commandService
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IProgressService
,
IProgressRunner
}
from
'
vs/platform/progress/common/progress
'
;
import
{
ITextModelResolverService
,
IResolveOptions
,
ITextModelContentProvider
}
from
'
vs/platform/textmodelResolver/common/
textModelResolverService
'
;
import
{
ITextModelResolverService
,
IResolveOptions
,
ITextModelContentProvider
}
from
'
vs/platform/textmodelResolver/common/
resolver
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
export
class
SimpleEditor
implements
IEditor
{
...
...
src/vs/editor/browser/standalone/standaloneEditor.ts
浏览文件 @
1741f67d
...
...
@@ -30,7 +30,7 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import
{
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
ICodeEditorService
}
from
'
vs/editor/common/services/codeEditorService
'
;
import
{
IEditorWorkerService
}
from
'
vs/editor/common/services/editorWorkerService
'
;
import
{
ITextModelResolverService
}
from
'
vs/platform/textmodelResolver/common/
textModelResolverService
'
;
import
{
ITextModelResolverService
}
from
'
vs/platform/textmodelResolver/common/
resolver
'
;
/**
* @internal
...
...
src/vs/editor/common/services/bulkEdit.ts
浏览文件 @
1741f67d
...
...
@@ -9,7 +9,7 @@ import { merge } from 'vs/base/common/arrays';
import
{
IStringDictionary
,
forEach
,
values
}
from
'
vs/base/common/collections
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
I
EditorService
}
from
'
vs/platform/editor/common/edito
r
'
;
import
{
I
TextModelResolverService
}
from
'
vs/platform/textmodelResolver/common/resolve
r
'
;
import
{
IEventService
}
from
'
vs/platform/event/common/event
'
;
import
{
EventType
as
FileEventType
,
FileChangesEvent
,
IFileChange
}
from
'
vs/platform/files/common/files
'
;
import
{
EditOperation
}
from
'
vs/editor/common/core/editOperation
'
;
...
...
@@ -157,7 +157,7 @@ class SourceModelEditTask extends EditTask {
class
BulkEditModel
{
private
_
editorService
:
IEdito
rService
;
private
_
textModelResolverService
:
ITextModelResolve
rService
;
private
_numberOfResourcesToModify
:
number
=
0
;
private
_numberOfChanges
:
number
=
0
;
private
_edits
:
IStringDictionary
<
IResourceEdit
[]
>
=
Object
.
create
(
null
);
...
...
@@ -166,8 +166,8 @@ class BulkEditModel {
private
_sourceSelections
:
Selection
[];
private
_sourceModelTask
:
SourceModelEditTask
;
constructor
(
editorService
:
IEdito
rService
,
sourceModel
:
URI
,
sourceSelections
:
Selection
[],
edits
:
IResourceEdit
[],
private
progress
:
IProgressRunner
=
null
)
{
this
.
_
editorService
=
edito
rService
;
constructor
(
textModelResolverService
:
ITextModelResolve
rService
,
sourceModel
:
URI
,
sourceSelections
:
Selection
[],
edits
:
IResourceEdit
[],
private
progress
:
IProgressRunner
=
null
)
{
this
.
_
textModelResolverService
=
textModelResolve
rService
;
this
.
_sourceModel
=
sourceModel
;
this
.
_sourceSelections
=
sourceSelections
;
this
.
_sourceModelTask
=
null
;
...
...
@@ -209,7 +209,7 @@ class BulkEditModel {
}
forEach
(
this
.
_edits
,
entry
=>
{
var
promise
=
this
.
_
editorService
.
resolveEditorModel
({
resource
:
URI
.
parse
(
entry
.
key
)
}
).
then
(
model
=>
{
var
promise
=
this
.
_
textModelResolverService
.
resolve
(
URI
.
parse
(
entry
.
key
)
).
then
(
model
=>
{
if
(
!
model
||
!
model
.
textEditorModel
)
{
throw
new
Error
(
`Cannot load file
${
entry
.
key
}
`
);
}
...
...
@@ -260,14 +260,14 @@ export interface BulkEdit {
finish
():
TPromise
<
ISelection
>
;
}
export
function
bulkEdit
(
eventService
:
IEventService
,
editorService
:
IEdito
rService
,
editor
:
ICommonCodeEditor
,
edits
:
IResourceEdit
[],
progress
:
IProgressRunner
=
null
):
TPromise
<
any
>
{
let
bulk
=
createBulkEdit
(
eventService
,
edito
rService
,
editor
);
export
function
bulkEdit
(
eventService
:
IEventService
,
textModelResolverService
:
ITextModelResolve
rService
,
editor
:
ICommonCodeEditor
,
edits
:
IResourceEdit
[],
progress
:
IProgressRunner
=
null
):
TPromise
<
any
>
{
let
bulk
=
createBulkEdit
(
eventService
,
textModelResolve
rService
,
editor
);
bulk
.
add
(
edits
);
bulk
.
progress
(
progress
);
return
bulk
.
finish
();
}
export
function
createBulkEdit
(
eventService
:
IEventService
,
editorService
:
IEdito
rService
,
editor
:
ICommonCodeEditor
):
BulkEdit
{
export
function
createBulkEdit
(
eventService
:
IEventService
,
textModelResolverService
:
ITextModelResolve
rService
,
editor
:
ICommonCodeEditor
):
BulkEdit
{
let
all
:
IResourceEdit
[]
=
[];
let
recording
=
new
ChangeRecorder
(
eventService
).
start
();
...
...
@@ -315,7 +315,7 @@ export function createBulkEdit(eventService: IEventService, editorService: IEdit
selections
=
editor
.
getSelections
();
}
let
model
=
new
BulkEditModel
(
edito
rService
,
uri
,
selections
,
all
,
progressRunner
);
let
model
=
new
BulkEditModel
(
textModelResolve
rService
,
uri
,
selections
,
all
,
progressRunner
);
return
model
.
prepare
().
then
(
_
=>
{
...
...
src/vs/editor/contrib/goToDeclaration/browser/goToDeclaration.ts
浏览文件 @
1741f67d
...
...
@@ -32,6 +32,7 @@ import { ReferencesModel } from 'vs/editor/contrib/referenceSearch/browser/refer
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
PeekContext
}
from
'
vs/editor/contrib/zoneWidget/browser/peekViewWidget
'
;
import
{
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
ITextModelResolverService
}
from
'
vs/platform/textmodelResolver/common/resolver
'
;
import
ModeContextKeys
=
editorCommon
.
ModeContextKeys
;
import
EditorContextKeys
=
editorCommon
.
EditorContextKeys
;
...
...
@@ -233,7 +234,7 @@ class GotoDefinitionWithMouseEditorContribution implements editorCommon.IEditorC
constructor
(
editor
:
ICodeEditor
,
@
I
EditorService
private
editorService
:
IEdito
rService
,
@
I
TextModelResolverService
private
textModelResolverService
:
ITextModelResolve
rService
,
@
IModeService
private
modeService
:
IModeService
)
{
this
.
toUnhook
=
[];
...
...
@@ -318,7 +319,7 @@ class GotoDefinitionWithMouseEditorContribution implements editorCommon.IEditorC
// Single result
else
{
let
result
=
results
[
0
];
this
.
editorService
.
resolveEditorModel
({
resource
:
result
.
uri
}
).
then
(
model
=>
{
this
.
textModelResolverService
.
resolve
(
result
.
uri
).
then
(
model
=>
{
let
hoverMessage
:
MarkedString
;
if
(
model
&&
model
.
textEditorModel
)
{
const
editorModel
=
<
editorCommon
.
IModel
>
model
.
textEditorModel
;
...
...
src/vs/editor/contrib/referenceSearch/browser/referencesController.ts
浏览文件 @
1741f67d
...
...
@@ -25,6 +25,7 @@ import { IPeekViewService } from 'vs/editor/contrib/zoneWidget/browser/peekViewW
import
{
ReferencesModel
,
OneReference
}
from
'
./referencesModel
'
;
import
{
ReferenceWidget
,
LayoutData
}
from
'
./referencesWidget
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
ITextModelResolverService
}
from
'
vs/platform/textmodelResolver/common/resolver
'
;
export
const
ctxReferenceSearchVisible
=
new
RawContextKey
<
boolean
>
(
'
referenceSearchVisible
'
,
false
);
...
...
@@ -55,6 +56,7 @@ export class ReferencesController implements editorCommon.IEditorContribution {
editor
:
ICodeEditor
,
@
IContextKeyService
contextKeyService
:
IContextKeyService
,
@
IEditorService
private
_editorService
:
IEditorService
,
@
ITextModelResolverService
private
_textModelResolverService
,
@
ITelemetryService
private
_telemetryService
:
ITelemetryService
,
@
IMessageService
private
_messageService
:
IMessageService
,
@
IInstantiationService
private
_instantiationService
:
IInstantiationService
,
...
...
@@ -102,7 +104,7 @@ export class ReferencesController implements editorCommon.IEditorContribution {
}));
const
storageKey
=
'
peekViewLayout
'
;
const
data
=
<
LayoutData
>
JSON
.
parse
(
this
.
_storageService
.
get
(
storageKey
,
undefined
,
'
{}
'
));
this
.
_widget
=
new
ReferenceWidget
(
this
.
_editor
,
data
,
this
.
_
edito
rService
,
this
.
_contextService
,
this
.
_instantiationService
);
this
.
_widget
=
new
ReferenceWidget
(
this
.
_editor
,
data
,
this
.
_
textModelResolve
rService
,
this
.
_contextService
,
this
.
_instantiationService
);
this
.
_widget
.
setTitle
(
nls
.
localize
(
'
labelLoading
'
,
"
Loading...
"
));
this
.
_widget
.
show
(
range
);
this
.
_disposables
.
push
(
this
.
_widget
.
onDidClose
(()
=>
{
...
...
src/vs/editor/contrib/referenceSearch/browser/referencesModel.ts
浏览文件 @
1741f67d
...
...
@@ -11,10 +11,10 @@ import * as strings from 'vs/base/common/strings';
import
URI
from
'
vs/base/common/uri
'
;
import
{
defaultGenerator
}
from
'
vs/base/common/idGenerator
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IEditorService
}
from
'
vs/platform/editor/common/editor
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
IModel
,
IPosition
,
IRange
}
from
'
vs/editor/common/editorCommon
'
;
import
{
Location
}
from
'
vs/editor/common/modes
'
;
import
{
ITextModelResolverService
}
from
'
vs/platform/textmodelResolver/common/resolver
'
;
export
class
OneReference
{
...
...
@@ -128,13 +128,13 @@ export class FileReferences {
return
this
.
_loadFailure
;
}
public
resolve
(
editorService
:
IEdito
rService
):
TPromise
<
FileReferences
>
{
public
resolve
(
textModelResolverService
:
ITextModelResolve
rService
):
TPromise
<
FileReferences
>
{
if
(
this
.
_resolved
)
{
return
TPromise
.
as
(
this
);
}
return
editorService
.
resolveEditorModel
({
resource
:
this
.
_uri
}
).
then
(
model
=>
{
return
textModelResolverService
.
resolve
(
this
.
_uri
).
then
(
model
=>
{
if
(
!
model
)
{
throw
new
Error
();
}
...
...
src/vs/editor/contrib/referenceSearch/browser/referencesWidget.ts
浏览文件 @
1741f67d
...
...
@@ -26,7 +26,6 @@ import { LeftRightWidget } from 'vs/base/browser/ui/leftRightWidget/leftRightWid
import
*
as
tree
from
'
vs/base/parts/tree/browser/tree
'
;
import
{
DefaultController
,
LegacyRenderer
}
from
'
vs/base/parts/tree/browser/treeDefaults
'
;
import
{
Tree
}
from
'
vs/base/parts/tree/browser/treeImpl
'
;
import
{
IEditorService
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
ServiceCollection
}
from
'
vs/platform/instantiation/common/serviceCollection
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
...
...
@@ -38,6 +37,7 @@ import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import
{
EmbeddedCodeEditorWidget
}
from
'
vs/editor/browser/widget/embeddedCodeEditorWidget
'
;
import
{
PeekViewWidget
,
IPeekViewService
}
from
'
vs/editor/contrib/zoneWidget/browser/peekViewWidget
'
;
import
{
FileReferences
,
OneReference
,
ReferencesModel
}
from
'
./referencesModel
'
;
import
{
ITextModelResolverService
}
from
'
vs/platform/textmodelResolver/common/resolver
'
;
class
DecorationsManager
implements
IDisposable
{
...
...
@@ -165,7 +165,7 @@ class DecorationsManager implements IDisposable {
class
DataSource
implements
tree
.
IDataSource
{
constructor
(
@
I
EditorService
private
_editorService
:
IEdito
rService
@
I
TextModelResolverService
private
_textModelResolverService
:
ITextModelResolve
rService
)
{
//
}
...
...
@@ -193,7 +193,7 @@ class DataSource implements tree.IDataSource {
if
(
element
instanceof
ReferencesModel
)
{
return
TPromise
.
as
(
element
.
groups
);
}
else
if
(
element
instanceof
FileReferences
)
{
return
element
.
resolve
(
this
.
_
edito
rService
).
then
(
val
=>
{
return
element
.
resolve
(
this
.
_
textModelResolve
rService
).
then
(
val
=>
{
if
(
element
.
failure
)
{
// refresh the element on failure so that
// we can update its rendering
...
...
@@ -501,7 +501,7 @@ export class ReferenceWidget extends PeekViewWidget {
constructor
(
editor
:
ICodeEditor
,
public
layoutData
:
LayoutData
,
private
_
editorService
:
IEdito
rService
,
private
_
textModelResolverService
:
ITextModelResolve
rService
,
private
_contextService
:
IWorkspaceContextService
,
private
_instantiationService
:
IInstantiationService
)
{
...
...
@@ -716,7 +716,7 @@ export class ReferenceWidget extends PeekViewWidget {
}
return
TPromise
.
join
([
this
.
_
editorService
.
resolveEditorModel
({
resource
:
reference
.
uri
}
),
this
.
_
textModelResolverService
.
resolve
(
reference
.
uri
),
this
.
_tree
.
reveal
(
reference
)
]).
then
(
values
=>
{
if
(
!
this
.
_model
)
{
...
...
src/vs/editor/contrib/rename/browser/rename.ts
浏览文件 @
1741f67d
...
...
@@ -10,7 +10,6 @@ import { isPromiseCanceledError } from 'vs/base/common/errors';
import
{
KeyMod
,
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
import
Severity
from
'
vs/base/common/severity
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IEditorService
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IEventService
}
from
'
vs/platform/event/common/event
'
;
import
{
RawContextKey
,
IContextKey
,
IContextKeyService
,
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IMessageService
}
from
'
vs/platform/message/common/message
'
;
...
...
@@ -22,6 +21,7 @@ import { BulkEdit, createBulkEdit } from 'vs/editor/common/services/bulkEdit';
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
rename
}
from
'
../common/rename
'
;
import
RenameInputField
from
'
./renameInputField
'
;
import
{
ITextModelResolverService
}
from
'
vs/platform/textmodelResolver/common/resolver
'
;
// --- register actions and commands
...
...
@@ -43,7 +43,7 @@ class RenameController implements IEditorContribution {
private
editor
:
ICodeEditor
,
@
IMessageService
private
_messageService
:
IMessageService
,
@
IEventService
private
_eventService
:
IEventService
,
@
I
EditorService
private
_editorService
:
IEdito
rService
,
@
I
TextModelResolverService
private
_textModelResolverService
:
ITextModelResolve
rService
,
@
IProgressService
private
_progressService
:
IProgressService
,
@
IContextKeyService
contextKeyService
:
IContextKeyService
)
{
...
...
@@ -132,7 +132,7 @@ class RenameController implements IEditorContribution {
// start recording of file changes so that we can figure out if a file that
// is to be renamed conflicts with another (concurrent) modification
let
edit
=
createBulkEdit
(
this
.
_eventService
,
this
.
_
edito
rService
,
<
ICodeEditor
>
this
.
editor
);
let
edit
=
createBulkEdit
(
this
.
_eventService
,
this
.
_
textModelResolve
rService
,
<
ICodeEditor
>
this
.
editor
);
return
rename
(
this
.
editor
.
getModel
(),
this
.
editor
.
getPosition
(),
newName
).
then
(
result
=>
{
if
(
result
.
rejectReason
)
{
...
...
src/vs/platform/textmodelResolver/common/
textModelResolverService
.ts
→
src/vs/platform/textmodelResolver/common/
resolver
.ts
浏览文件 @
1741f67d
文件已移动
src/vs/test/utils/servicesTestUtils.ts
浏览文件 @
1741f67d
...
...
@@ -23,7 +23,7 @@ import { IStorageService, StorageScope } from 'vs/platform/storage/common/storag
import
{
IQuickOpenService
}
from
'
vs/workbench/services/quickopen/common/quickOpenService
'
;
import
{
IPartService
}
from
'
vs/workbench/services/part/common/partService
'
;
import
{
TextModelResolverService
}
from
'
vs/workbench/services/textmodelResolver/common/textModelResolverService
'
;
import
{
ITextModelResolverService
}
from
'
vs/platform/textmodelResolver/common/
textModelResolverService
'
;
import
{
ITextModelResolverService
}
from
'
vs/platform/textmodelResolver/common/
resolver
'
;
import
{
IEditorInput
,
IEditorOptions
,
IEditorModel
,
Position
,
Direction
,
IEditor
,
IResourceInput
,
ITextEditorModel
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IEventService
}
from
'
vs/platform/event/common/event
'
;
import
{
IUntitledEditorService
,
UntitledEditorService
}
from
'
vs/workbench/services/untitled/common/untitledEditorService
'
;
...
...
@@ -116,7 +116,7 @@ export class TestTextFileService extends TextFileService {
@
IUntitledEditorService
untitledEditorService
:
IUntitledEditorService
,
@
IInstantiationService
instantiationService
:
IInstantiationService
)
{
super
(
lifecycleService
,
contextService
,
configurationService
,
telemetryService
,
editorGroupService
,
editorService
,
fileService
,
untitledEditorService
,
instantiationService
);
super
(
lifecycleService
,
contextService
,
configurationService
,
telemetryService
,
editorGroupService
,
fileService
,
untitledEditorService
,
instantiationService
);
}
public
setPromptPath
(
path
:
string
):
void
{
...
...
src/vs/workbench/api/node/mainThreadDocuments.ts
浏览文件 @
1741f67d
...
...
@@ -20,7 +20,7 @@ import { IFileService } from 'vs/platform/files/common/files';
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
IUntitledEditorService
}
from
'
vs/workbench/services/untitled/common/untitledEditorService
'
;
import
{
ExtHostContext
,
MainThreadDocumentsShape
,
ExtHostDocumentsShape
}
from
'
./extHost.protocol
'
;
import
{
ITextModelResolverService
}
from
'
vs/platform/textmodelResolver/common/
textModelResolverService
'
;
import
{
ITextModelResolverService
}
from
'
vs/platform/textmodelResolver/common/
resolver
'
;
export
class
MainThreadDocuments
extends
MainThreadDocumentsShape
{
private
_modelService
:
IModelService
;
...
...
@@ -187,7 +187,7 @@ export class MainThreadDocuments extends MainThreadDocumentsShape {
}
private
_handleAsResourceInput
(
uri
:
URI
):
TPromise
<
boolean
>
{
return
this
.
_
editorService
.
resolveEditorModel
({
resource
:
uri
}
).
then
(
model
=>
{
return
this
.
_
textModelResolverService
.
resolve
(
uri
).
then
(
model
=>
{
return
!!
model
;
});
}
...
...
src/vs/workbench/api/node/mainThreadWorkspace.ts
浏览文件 @
1741f67d
...
...
@@ -15,6 +15,7 @@ import { bulkEdit, IResourceEdit } from 'vs/editor/common/services/bulkEdit';
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
Uri
}
from
'
vscode
'
;
import
{
MainThreadWorkspaceShape
}
from
'
./extHost.protocol
'
;
import
{
ITextModelResolverService
}
from
'
vs/platform/textmodelResolver/common/resolver
'
;
export
class
MainThreadWorkspace
extends
MainThreadWorkspaceShape
{
...
...
@@ -23,6 +24,7 @@ export class MainThreadWorkspace extends MainThreadWorkspaceShape {
private
_workspace
:
IWorkspace
;
private
_textFileService
:
ITextFileService
;
private
_editorService
:
IWorkbenchEditorService
;
private
_textModelResolverService
:
ITextModelResolverService
;
private
_eventService
:
IEventService
;
constructor
(
...
...
@@ -30,6 +32,7 @@ export class MainThreadWorkspace extends MainThreadWorkspaceShape {
@
IWorkspaceContextService
contextService
:
IWorkspaceContextService
,
@
ITextFileService
textFileService
,
@
IWorkbenchEditorService
editorService
,
@
ITextModelResolverService
textModelResolverService
,
@
IEventService
eventService
)
{
super
();
...
...
@@ -39,6 +42,7 @@ export class MainThreadWorkspace extends MainThreadWorkspaceShape {
this
.
_textFileService
=
textFileService
;
this
.
_editorService
=
editorService
;
this
.
_eventService
=
eventService
;
this
.
_textModelResolverService
=
textModelResolverService
;
}
$startSearch
(
include
:
string
,
exclude
:
string
,
maxResults
:
number
,
requestId
:
number
):
Thenable
<
Uri
[]
>
{
...
...
@@ -95,7 +99,7 @@ export class MainThreadWorkspace extends MainThreadWorkspaceShape {
}
}
return
bulkEdit
(
this
.
_eventService
,
this
.
_
edito
rService
,
codeEditor
,
edits
)
return
bulkEdit
(
this
.
_eventService
,
this
.
_
textModelResolve
rService
,
codeEditor
,
edits
)
.
then
(()
=>
true
);
}
}
src/vs/workbench/common/editor/resourceEditorInput.ts
浏览文件 @
1741f67d
...
...
@@ -7,7 +7,7 @@
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
EditorInput
,
ITextEditorModel
}
from
'
vs/workbench/common/editor
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
ITextModelResolverService
}
from
'
vs/platform/textmodelResolver/common/
textModelResolverService
'
;
import
{
ITextModelResolverService
}
from
'
vs/platform/textmodelResolver/common/
resolver
'
;
import
{
ResourceEditorModel
}
from
'
vs/workbench/common/editor/resourceEditorModel
'
;
/**
...
...
src/vs/workbench/electron-browser/workbench.ts
浏览文件 @
1741f67d
...
...
@@ -68,7 +68,7 @@ import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import
{
TextFileService
}
from
'
vs/workbench/services/textfile/electron-browser/textFileService
'
;
import
{
ITextFileService
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
TextModelResolverService
}
from
'
vs/workbench/services/textmodelResolver/common/textModelResolverService
'
;
import
{
ITextModelResolverService
}
from
'
vs/platform/textmodelResolver/common/
textModelResolverService
'
;
import
{
ITextModelResolverService
}
from
'
vs/platform/textmodelResolver/common/
resolver
'
;
import
{
ServiceCollection
}
from
'
vs/platform/instantiation/common/serviceCollection
'
;
import
{
ILifecycleService
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
IMessageService
}
from
'
vs/platform/message/common/message
'
;
...
...
src/vs/workbench/parts/contentprovider/common/contentprovider.contribution.ts
浏览文件 @
1741f67d
...
...
@@ -13,7 +13,7 @@ import JSONContributionRegistry = require('vs/platform/jsonschemas/common/jsonCo
import
{
Registry
}
from
'
vs/platform/platform
'
;
import
{
IWorkbenchContribution
}
from
'
vs/workbench/common/contributions
'
;
import
{
IWorkbenchContributionsRegistry
,
Extensions
as
WorkbenchExtensions
}
from
'
vs/workbench/common/contributions
'
;
import
{
ITextModelResolverService
}
from
'
vs/platform/textmodelResolver/common/
textModelResolverService
'
;
import
{
ITextModelResolverService
}
from
'
vs/platform/textmodelResolver/common/
resolver
'
;
let
schemaRegistry
=
<
JSONContributionRegistry
.
IJSONContributionRegistry
>
Registry
.
as
(
JSONContributionRegistry
.
Extensions
.
JSONContribution
);
...
...
src/vs/workbench/parts/files/browser/saveErrorHandler.ts
浏览文件 @
1741f67d
...
...
@@ -29,7 +29,7 @@ import { IModelService } from 'vs/editor/common/services/modelService';
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
IWorkbenchContribution
}
from
'
vs/workbench/common/contributions
'
;
import
{
TextFileEditorModel
}
from
'
vs/workbench/services/textfile/common/textFileEditorModel
'
;
import
{
ITextModelResolverService
}
from
'
vs/platform/textmodelResolver/common/
textModelResolverService
'
;
import
{
ITextModelResolverService
}
from
'
vs/platform/textmodelResolver/common/
resolver
'
;
// A handler for save error happening with conflict resolution actions
export
class
SaveErrorHandler
implements
ISaveErrorHandler
,
IWorkbenchContribution
{
...
...
src/vs/workbench/parts/html/browser/html.contribution.ts
浏览文件 @
1741f67d
...
...
@@ -19,6 +19,7 @@ import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
isCommonCodeEditor
,
ICommonCodeEditor
,
IModel
}
from
'
vs/editor/common/editorCommon
'
;
import
{
HtmlZoneController
}
from
'
./htmlEditorZone
'
;
import
{
ITextModelResolverService
}
from
'
vs/platform/textmodelResolver/common/resolver
'
;
// --- Register Editor
(
<
IEditorRegistry
>
Registry
.
as
(
EditorExtensions
.
Editors
)).
registerEditor
(
new
EditorDescriptor
(
HtmlPreviewPart
.
ID
,
...
...
@@ -59,7 +60,7 @@ CommandsRegistry.registerCommand('_workbench.htmlZone', function (accessor: Serv
return
;
}
return
accessor
.
get
(
I
WorkbenchEditorService
).
resolveEditorModel
({
resource
:
params
.
resource
}
).
then
(
model
=>
{
return
accessor
.
get
(
I
TextModelResolverService
).
resolve
(
params
.
resource
).
then
(
model
=>
{
const
contents
=
(
<
IModel
>
model
.
textEditorModel
).
getValue
();
HtmlZoneController
.
getInstance
(
codeEditor
).
addZone
(
params
.
lineNumber
,
contents
);
});
...
...
src/vs/workbench/parts/html/browser/htmlPreviewPart.ts
浏览文件 @
1741f67d
...
...
@@ -16,11 +16,11 @@ import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
import
{
Position
}
from
'
vs/platform/editor/common/editor
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
BaseTextEditorModel
}
from
'
vs/workbench/common/editor/textEditorModel
'
;
import
{
HtmlInput
}
from
'
vs/workbench/parts/html/common/htmlInput
'
;
import
{
IThemeService
}
from
'
vs/workbench/services/themes/common/themeService
'
;
import
{
IOpenerService
}
from
'
vs/platform/opener/common/opener
'
;
import
{
ITextModelResolverService
}
from
'
vs/platform/textmodelResolver/common/resolver
'
;
import
Webview
from
'
./webview
'
;
/**
...
...
@@ -30,7 +30,7 @@ export class HtmlPreviewPart extends BaseEditor {
static
ID
:
string
=
'
workbench.editor.htmlPreviewPart
'
;
private
_
editorService
:
IWorkbenchEdito
rService
;
private
_
textModelResolverService
:
ITextModelResolve
rService
;
private
_themeService
:
IThemeService
;
private
_openerService
:
IOpenerService
;
private
_webview
:
Webview
;
...
...
@@ -45,14 +45,14 @@ export class HtmlPreviewPart extends BaseEditor {
constructor
(
@
ITelemetryService
telemetryService
:
ITelemetryService
,
@
I
WorkbenchEditorService
editorService
:
IWorkbenchEdito
rService
,
@
I
TextModelResolverService
textModelResolverService
:
ITextModelResolve
rService
,
@
IThemeService
themeService
:
IThemeService
,
@
IOpenerService
openerService
:
IOpenerService
,
@
IWorkspaceContextService
contextService
:
IWorkspaceContextService
)
{
super
(
HtmlPreviewPart
.
ID
,
telemetryService
);
this
.
_
editorService
=
edito
rService
;
this
.
_
textModelResolverService
=
textModelResolve
rService
;
this
.
_themeService
=
themeService
;
this
.
_openerService
=
openerService
;
this
.
_baseUrl
=
contextService
.
toResource
(
'
/
'
);
...
...
@@ -150,7 +150,7 @@ export class HtmlPreviewPart extends BaseEditor {
return
super
.
setInput
(
input
,
options
).
then
(()
=>
{
let
resourceUri
=
(
<
HtmlInput
>
input
).
getResource
();
return
this
.
_
editorService
.
resolveEditorModel
({
resource
:
resourceUri
}
).
then
(
model
=>
{
return
this
.
_
textModelResolverService
.
resolve
(
resourceUri
).
then
(
model
=>
{
if
(
model
instanceof
BaseTextEditorModel
)
{
this
.
_model
=
model
.
textEditorModel
;
}
...
...
src/vs/workbench/parts/search/browser/replaceService.ts
浏览文件 @
1741f67d
...
...
@@ -21,13 +21,18 @@ import { IProgressRunner } from 'vs/platform/progress/common/progress';
import
{
IDiffEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
DiffEditorInput
}
from
'
vs/workbench/common/editor/diffEditorInput
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
ITextModelResolverService
}
from
'
vs/platform/textmodelResolver/common/resolver
'
;
class
EditorInputCache
{
private
cache
:
Map
.
LinkedMap
<
URI
,
TPromise
<
DiffEditorInput
>>
;
constructor
(
private
replaceService
:
ReplaceService
,
private
editorService
:
IWorkbenchEditorService
,
private
modelService
:
IModelService
)
{
constructor
(
private
replaceService
:
ReplaceService
,
private
editorService
:
IWorkbenchEditorService
,
private
modelService
:
IModelService
,
private
textModelResolverService
:
ITextModelResolverService
)
{
this
.
cache
=
new
Map
.
LinkedMap
<
URI
,
TPromise
<
DiffEditorInput
>>
();
}
...
...
@@ -52,7 +57,7 @@ class EditorInputCache {
if
(
editorInputPromise
)
{
editorInputPromise
.
done
(()
=>
{
if
(
reloadFromSource
)
{
this
.
editorService
.
resolveEditorModel
({
resource
:
fileMatch
.
resource
()
}
).
then
(
editorModel
=>
{
this
.
textModelResolverService
.
resolve
(
fileMatch
.
resource
()
).
then
(
editorModel
=>
{
if
(
editorModel
.
textEditorModel
)
{
let
replaceResource
=
this
.
getReplaceResource
(
fileMatch
.
resource
());
this
.
modelService
.
getModel
(
replaceResource
).
setValue
(
editorModel
.
textEditorModel
.
getValue
());
...
...
@@ -103,7 +108,7 @@ class EditorInputCache {
private
createRightInput
(
element
:
FileMatch
):
TPromise
<
IEditorInput
>
{
return
new
TPromise
((
c
,
e
,
p
)
=>
{
this
.
editorService
.
resolveEditorModel
({
resource
:
element
.
resource
()
}
).
then
(
value
=>
{
this
.
textModelResolverService
.
resolve
(
element
.
resource
()
).
then
(
value
=>
{
let
model
=
value
.
textEditorModel
;
let
replaceResource
=
this
.
getReplaceResource
(
element
.
resource
());
this
.
modelService
.
createModel
(
model
.
getValue
(),
model
.
getMode
(),
replaceResource
);
...
...
@@ -128,8 +133,14 @@ export class ReplaceService implements IReplaceService {
private
cache
:
EditorInputCache
;
constructor
(
@
ITelemetryService
private
telemetryService
:
ITelemetryService
,
@
IEventService
private
eventService
:
IEventService
,
@
IEditorService
private
editorService
,
@
IModelService
private
modelService
:
IModelService
)
{
this
.
cache
=
new
EditorInputCache
(
this
,
editorService
,
modelService
);
constructor
(
@
ITelemetryService
private
telemetryService
:
ITelemetryService
,
@
IEventService
private
eventService
:
IEventService
,
@
IEditorService
private
editorService
,
@
IModelService
private
modelService
:
IModelService
,
@
ITextModelResolverService
private
textModelResolverService
:
ITextModelResolverService
)
{
this
.
cache
=
new
EditorInputCache
(
this
,
editorService
,
modelService
,
textModelResolverService
);
}
public
replace
(
match
:
Match
):
TPromise
<
any
>
...
...
src/vs/workbench/services/textfile/browser/textFileService.ts
浏览文件 @
1741f67d
...
...
@@ -19,11 +19,9 @@ import { IFileService, IResolveContentOptions, IFilesConfiguration, IFileOperati
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
IUntitledEditorService
}
from
'
vs/workbench/services/untitled/common/untitledEditorService
'
;
import
{
UntitledEditorModel
}
from
'
vs/workbench/common/editor/untitledEditorModel
'
;
import
{
BinaryEditorModel
}
from
'
vs/workbench/common/editor/binaryEditorModel
'
;
import
{
TextFileEditorModelManager
}
from
'
vs/workbench/services/textfile/common/textFileEditorModelManager
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
...
...
@@ -53,7 +51,6 @@ export abstract class TextFileService implements ITextFileService {
@
IConfigurationService
private
configurationService
:
IConfigurationService
,
@
ITelemetryService
private
telemetryService
:
ITelemetryService
,
@
IEditorGroupService
private
editorGroupService
:
IEditorGroupService
,
@
IWorkbenchEditorService
private
editorService
:
IWorkbenchEditorService
,
@
IFileService
protected
fileService
:
IFileService
,
@
IUntitledEditorService
private
untitledEditorService
:
IUntitledEditorService
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
...
...
@@ -441,21 +438,27 @@ export abstract class TextFileService implements ITextFileService {
}
private
doSaveTextFileAs
(
sourceModel
:
ITextFileEditorModel
|
UntitledEditorModel
,
resource
:
URI
,
target
:
URI
):
TPromise
<
void
>
{
// create the target file empty if it does not exist already
return
this
.
fileService
.
resolveFile
(
target
).
then
(
stat
=>
stat
,
()
=>
null
).
then
(
stat
=>
stat
||
this
.
fileService
.
createFile
(
target
)).
then
(
stat
=>
{
// resolve a model for the file (which can be binary if the file is not a text file)
return
this
.
editorService
.
resolveEditorModel
({
resource
:
target
}).
then
((
targetModel
:
ITextFileEditorModel
)
=>
{
// binary model: delete the file and run the operation again
if
(
targetModel
instanceof
BinaryEditorModel
)
{
return
this
.
fileService
.
del
(
target
).
then
(()
=>
this
.
doSaveTextFileAs
(
sourceModel
,
resource
,
target
));
}
return
this
.
models
.
loadOrCreate
(
target
).
then
((
targetModel
:
ITextFileEditorModel
)
=>
{
// t
ext model: t
ake over encoding and model value from source model
// take over encoding and model value from source model
targetModel
.
updatePreferredEncoding
(
sourceModel
.
getEncoding
());
targetModel
.
textEditorModel
.
setValue
(
sourceModel
.
getValue
());
// save model
return
targetModel
.
save
();
},
error
=>
{
// binary model: delete the file and run the operation again
if
((
<
IFileOperationResult
>
error
).
fileOperationResult
===
FileOperationResult
.
FILE_IS_BINARY
||
(
<
IFileOperationResult
>
error
).
fileOperationResult
===
FileOperationResult
.
FILE_TOO_LARGE
)
{
return
this
.
fileService
.
del
(
target
).
then
(()
=>
this
.
doSaveTextFileAs
(
sourceModel
,
resource
,
target
));
}
return
TPromise
.
wrapError
(
error
);
});
});
}
...
...
src/vs/workbench/services/textfile/common/textFileEditorModelManager.ts
浏览文件 @
1741f67d
...
...
@@ -171,7 +171,7 @@ export class TextFileEditorModelManager implements ITextFileEditorModelManager {
return
this
.
mapResourceToModel
[
resource
.
toString
()];
}
public
loadOrCreate
(
resource
:
URI
,
encoding
:
string
,
refresh
?:
boolean
):
TPromise
<
ITextFileEditorModel
>
{
public
loadOrCreate
(
resource
:
URI
,
encoding
?
:
string
,
refresh
?:
boolean
):
TPromise
<
ITextFileEditorModel
>
{
// Return early if model is currently being loaded
const
pendingLoad
=
this
.
mapResourceToPendingModelLoaders
[
resource
.
toString
()];
...
...
src/vs/workbench/services/textfile/common/textfiles.ts
浏览文件 @
1741f67d
...
...
@@ -192,7 +192,7 @@ export interface ITextFileEditorModelManager {
getAll
(
resource
?:
URI
):
ITextFileEditorModel
[];
loadOrCreate
(
resource
:
URI
,
preferredEncoding
:
string
,
refresh
?:
boolean
):
TPromise
<
ITextEditorModel
>
;
loadOrCreate
(
resource
:
URI
,
preferredEncoding
?
:
string
,
refresh
?:
boolean
):
TPromise
<
ITextEditorModel
>
;
}
export
interface
IModelSaveOptions
{
...
...
src/vs/workbench/services/textfile/electron-browser/textFileService.ts
浏览文件 @
1741f67d
...
...
@@ -21,7 +21,6 @@ import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IWindowIPCService
}
from
'
vs/workbench/services/window/electron-browser/windowService
'
;
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
...
...
@@ -43,13 +42,12 @@ export class TextFileService extends AbstractTextFileService {
@
ITelemetryService
telemetryService
:
ITelemetryService
,
@
IConfigurationService
configurationService
:
IConfigurationService
,
@
IModeService
private
modeService
:
IModeService
,
@
IWorkbenchEditorService
editorService
:
IWorkbenchEditorService
,
@
IEditorGroupService
editorGroupService
:
IEditorGroupService
,
@
IWindowIPCService
private
windowService
:
IWindowIPCService
,
@
IModelService
private
modelService
:
IModelService
,
@
IEnvironmentService
private
environmentService
:
IEnvironmentService
)
{
super
(
lifecycleService
,
contextService
,
configurationService
,
telemetryService
,
editorGroupService
,
editorService
,
fileService
,
untitledEditorService
,
instantiationService
);
super
(
lifecycleService
,
contextService
,
configurationService
,
telemetryService
,
editorGroupService
,
fileService
,
untitledEditorService
,
instantiationService
);
}
public
resolveTextContent
(
resource
:
URI
,
options
?:
IResolveContentOptions
):
TPromise
<
IRawTextContent
>
{
...
...
src/vs/workbench/services/textmodelResolver/common/textModelResolverService.ts
浏览文件 @
1741f67d
...
...
@@ -7,15 +7,22 @@
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IModel
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ITextEditorModel
}
from
'
vs/platform/editor/common/editor
'
;
import
{
ICommonCodeEditor
,
IModel
,
EditorType
,
IEditor
as
ICommonEditor
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IDiffEditor
,
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
ITextEditorModel
,
IEditorInput
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
{
sequence
}
from
'
vs/base/common/async
'
;
import
{
ResourceEditorModel
}
from
'
vs/workbench/common/editor/resourceEditorModel
'
;
import
{
ITextFileService
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
network
=
require
(
'
vs/base/common/network
'
);
import
{
ITextModelResolverService
,
ITextModelContentProvider
,
IResolveOptions
}
from
'
vs/platform/textmodelResolver/common/textModelResolverService
'
;
import
{
ITextModelResolverService
,
ITextModelContentProvider
,
IResolveOptions
}
from
'
vs/platform/textmodelResolver/common/resolver
'
;
import
{
IUntitledEditorService
}
from
'
vs/workbench/services/untitled/common/untitledEditorService
'
;
import
{
UntitledEditorInput
}
from
'
vs/workbench/common/editor/untitledEditorInput
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
types
=
require
(
'
vs/base/common/types
'
);
import
{
DiffEditorInput
}
from
'
vs/workbench/common/editor/diffEditorInput
'
;
import
{
EditorInput
}
from
'
vs/workbench/common/editor
'
;
export
class
TextModelResolverService
implements
ITextModelResolverService
{
...
...
@@ -26,6 +33,8 @@ export class TextModelResolverService implements ITextModelResolverService {
constructor
(
@
ITextFileService
private
textFileService
:
ITextFileService
,
@
IUntitledEditorService
private
untitledEditorService
:
IUntitledEditorService
,
@
IWorkbenchEditorService
private
editorService
:
IWorkbenchEditorService
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
,
@
IModelService
private
modelService
:
IModelService
)
{
...
...
@@ -38,10 +47,77 @@ export class TextModelResolverService implements ITextModelResolverService {
return
this
.
textFileService
.
models
.
loadOrCreate
(
resource
,
options
&&
options
.
encoding
,
false
/* refresh */
);
}
// Untitled Schema: go through cached input
if
(
resource
.
scheme
===
UntitledEditorInput
.
SCHEMA
)
{
return
this
.
untitledEditorService
.
createOrGet
(
resource
).
resolve
();
}
// In Memory: only works on the active editor
if
(
resource
.
scheme
===
network
.
Schemas
.
inMemory
)
{
return
this
.
resolveInMemory
(
resource
);
}
// Any other resource: use registry
return
this
.
resolveTextModelContent
(
this
.
modelService
,
resource
).
then
(()
=>
this
.
instantiationService
.
createInstance
(
ResourceEditorModel
,
resource
));
}
private
resolveInMemory
(
resource
:
URI
):
TPromise
<
ITextEditorModel
>
{
// For in-memory resources we only support to resolve the input from the current active editor
// because the workbench does not track editor models by in memory URL. This concept is only
// being used in the code editor.
const
activeEditor
=
this
.
editorService
.
getActiveEditor
();
if
(
activeEditor
)
{
const
control
=
<
ICommonEditor
>
activeEditor
.
getControl
();
if
(
types
.
isFunction
(
control
.
getEditorType
))
{
// Single Editor: If code editor model matches, return input from editor
if
(
control
.
getEditorType
()
===
EditorType
.
ICodeEditor
)
{
const
codeEditor
=
<
ICodeEditor
>
control
;
const
model
=
this
.
findModel
(
codeEditor
,
resource
);
if
(
model
)
{
return
this
.
resolveFromInput
(
activeEditor
.
input
);
}
}
// Diff Editor: If left or right code editor model matches, return associated input
else
if
(
control
.
getEditorType
()
===
EditorType
.
IDiffEditor
)
{
const
diffInput
=
<
DiffEditorInput
>
activeEditor
.
input
;
const
diffCodeEditor
=
<
IDiffEditor
>
control
;
const
originalModel
=
this
.
findModel
(
diffCodeEditor
.
getOriginalEditor
(),
resource
);
if
(
originalModel
)
{
return
this
.
resolveFromInput
(
diffInput
.
originalInput
);
}
const
modifiedModel
=
this
.
findModel
(
diffCodeEditor
.
getModifiedEditor
(),
resource
);
if
(
modifiedModel
)
{
return
this
.
resolveFromInput
(
diffInput
.
modifiedInput
);
}
}
}
}
return
TPromise
.
as
(
null
);
}
private
resolveFromInput
(
input
:
IEditorInput
):
TPromise
<
ITextEditorModel
>
{
if
(
input
instanceof
EditorInput
)
{
return
input
.
resolve
();
}
return
TPromise
.
as
(
null
);
}
private
findModel
(
editor
:
ICommonCodeEditor
,
resource
:
URI
):
IModel
{
const
model
=
editor
.
getModel
();
if
(
!
model
)
{
return
null
;
}
return
model
.
uri
.
toString
()
===
resource
.
toString
()
?
model
:
null
;
}
public
registerTextModelContentProvider
(
scheme
:
string
,
provider
:
ITextModelContentProvider
):
IDisposable
{
let
array
=
this
.
contentProviderRegistry
[
scheme
];
if
(
!
array
)
{
...
...
src/vs/workbench/services/textmodelResolver/test/textModelResolverService.test.ts
浏览文件 @
1741f67d
...
...
@@ -13,7 +13,7 @@ import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorIn
import
{
ResourceEditorModel
}
from
'
vs/workbench/common/editor/resourceEditorModel
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
workbenchInstantiationService
}
from
'
vs/test/utils/servicesTestUtils
'
;
import
{
ITextModelResolverService
}
from
'
vs/platform/textmodelResolver/common/
textModelResolverService
'
;
import
{
ITextModelResolverService
}
from
'
vs/platform/textmodelResolver/common/
resolver
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录