Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
97570d91
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,发现更多精彩内容 >>
提交
97570d91
编写于
1月 13, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move MainThreadModeServiceImpl to /workbench/
上级
da14669e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
151 addition
and
139 deletion
+151
-139
src/vs/editor/common/services/modeServiceImpl.ts
src/vs/editor/common/services/modeServiceImpl.ts
+2
-137
src/vs/workbench/electron-browser/shell.ts
src/vs/workbench/electron-browser/shell.ts
+2
-2
src/vs/workbench/services/mode/common/workbenchModeService.ts
...vs/workbench/services/mode/common/workbenchModeService.ts
+147
-0
未找到文件。
src/vs/editor/common/services/modeServiceImpl.ts
浏览文件 @
97570d91
...
@@ -7,18 +7,12 @@
...
@@ -7,18 +7,12 @@
import
*
as
nls
from
'
vs/nls
'
;
import
*
as
nls
from
'
vs/nls
'
;
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
*
as
paths
from
'
vs/base/common/paths
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
mime
=
require
(
'
vs/base/common/mime
'
);
import
{
IExtensionPoint
,
ExtensionsRegistry
}
from
'
vs/platform/extensions/common/extensionsRegistry
'
;
import
{
IFilesConfiguration
}
from
'
vs/platform/files/common/files
'
;
import
{
IExtensionService
}
from
'
vs/platform/extensions/common/extensions
'
;
import
{
IExtensionPoint
,
IExtensionPointUser
,
ExtensionMessageCollector
,
ExtensionsRegistry
}
from
'
vs/platform/extensions/common/extensionsRegistry
'
;
import
{
IMode
,
LanguageId
,
LanguageIdentifier
}
from
'
vs/editor/common/modes
'
;
import
{
IMode
,
LanguageId
,
LanguageIdentifier
}
from
'
vs/editor/common/modes
'
;
import
{
FrankensteinMode
}
from
'
vs/editor/common/modes/abstractMode
'
;
import
{
FrankensteinMode
}
from
'
vs/editor/common/modes/abstractMode
'
;
import
{
ModesRegistry
}
from
'
vs/editor/common/modes/modesRegistry
'
;
import
{
LanguagesRegistry
}
from
'
vs/editor/common/services/languagesRegistry
'
;
import
{
LanguagesRegistry
}
from
'
vs/editor/common/services/languagesRegistry
'
;
import
{
ILanguageExtensionPoint
,
IValidLanguageExtensionPoint
,
IModeLookupResult
,
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
ILanguageExtensionPoint
,
IModeLookupResult
,
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
export
const
languagesExtPoint
:
IExtensionPoint
<
ILanguageExtensionPoint
[]
>
=
ExtensionsRegistry
.
registerExtensionPoint
<
ILanguageExtensionPoint
[]
>
(
'
languages
'
,
[],
{
export
const
languagesExtPoint
:
IExtensionPoint
<
ILanguageExtensionPoint
[]
>
=
ExtensionsRegistry
.
registerExtensionPoint
<
ILanguageExtensionPoint
[]
>
(
'
languages
'
,
[],
{
description
:
nls
.
localize
(
'
vscode.extension.contributes.languages
'
,
'
Contributes language declarations.
'
),
description
:
nls
.
localize
(
'
vscode.extension.contributes.languages
'
,
'
Contributes language declarations.
'
),
...
@@ -80,52 +74,6 @@ export const languagesExtPoint: IExtensionPoint<ILanguageExtensionPoint[]> = Ext
...
@@ -80,52 +74,6 @@ export const languagesExtPoint: IExtensionPoint<ILanguageExtensionPoint[]> = Ext
}
}
});
});
function
isUndefinedOrStringArray
(
value
:
string
[]):
boolean
{
if
(
typeof
value
===
'
undefined
'
)
{
return
true
;
}
if
(
!
Array
.
isArray
(
value
))
{
return
false
;
}
return
value
.
every
(
item
=>
typeof
item
===
'
string
'
);
}
function
isValidLanguageExtensionPoint
(
value
:
ILanguageExtensionPoint
,
collector
:
ExtensionMessageCollector
):
boolean
{
if
(
!
value
)
{
collector
.
error
(
nls
.
localize
(
'
invalid.empty
'
,
"
Empty value for `contributes.{0}`
"
,
languagesExtPoint
.
name
));
return
false
;
}
if
(
typeof
value
.
id
!==
'
string
'
)
{
collector
.
error
(
nls
.
localize
(
'
require.id
'
,
"
property `{0}` is mandatory and must be of type `string`
"
,
'
id
'
));
return
false
;
}
if
(
!
isUndefinedOrStringArray
(
value
.
extensions
))
{
collector
.
error
(
nls
.
localize
(
'
opt.extensions
'
,
"
property `{0}` can be omitted and must be of type `string[]`
"
,
'
extensions
'
));
return
false
;
}
if
(
!
isUndefinedOrStringArray
(
value
.
filenames
))
{
collector
.
error
(
nls
.
localize
(
'
opt.filenames
'
,
"
property `{0}` can be omitted and must be of type `string[]`
"
,
'
filenames
'
));
return
false
;
}
if
(
typeof
value
.
firstLine
!==
'
undefined
'
&&
typeof
value
.
firstLine
!==
'
string
'
)
{
collector
.
error
(
nls
.
localize
(
'
opt.firstLine
'
,
"
property `{0}` can be omitted and must be of type `string`
"
,
'
firstLine
'
));
return
false
;
}
if
(
typeof
value
.
configuration
!==
'
undefined
'
&&
typeof
value
.
configuration
!==
'
string
'
)
{
collector
.
error
(
nls
.
localize
(
'
opt.configuration
'
,
"
property `{0}` can be omitted and must be of type `string`
"
,
'
configuration
'
));
return
false
;
}
if
(
!
isUndefinedOrStringArray
(
value
.
aliases
))
{
collector
.
error
(
nls
.
localize
(
'
opt.aliases
'
,
"
property `{0}` can be omitted and must be of type `string[]`
"
,
'
aliases
'
));
return
false
;
}
if
(
!
isUndefinedOrStringArray
(
value
.
mimetypes
))
{
collector
.
error
(
nls
.
localize
(
'
opt.mimetypes
'
,
"
property `{0}` can be omitted and must be of type `string[]`
"
,
'
mimetypes
'
));
return
false
;
}
return
true
;
}
export
class
ModeServiceImpl
implements
IModeService
{
export
class
ModeServiceImpl
implements
IModeService
{
public
_serviceBrand
:
any
;
public
_serviceBrand
:
any
;
...
@@ -293,86 +241,3 @@ export class ModeServiceImpl implements IModeService {
...
@@ -293,86 +241,3 @@ export class ModeServiceImpl implements IModeService {
return
this
.
_instantiatedModes
[
modeId
];
return
this
.
_instantiatedModes
[
modeId
];
}
}
}
}
export
class
MainThreadModeServiceImpl
extends
ModeServiceImpl
{
private
_configurationService
:
IConfigurationService
;
private
_extensionService
:
IExtensionService
;
private
_onReadyPromise
:
TPromise
<
boolean
>
;
constructor
(
@
IExtensionService
extensionService
:
IExtensionService
,
@
IConfigurationService
configurationService
:
IConfigurationService
)
{
super
();
this
.
_configurationService
=
configurationService
;
this
.
_extensionService
=
extensionService
;
languagesExtPoint
.
setHandler
((
extensions
:
IExtensionPointUser
<
ILanguageExtensionPoint
[]
>
[])
=>
{
let
allValidLanguages
:
IValidLanguageExtensionPoint
[]
=
[];
for
(
let
i
=
0
,
len
=
extensions
.
length
;
i
<
len
;
i
++
)
{
let
extension
=
extensions
[
i
];
if
(
!
Array
.
isArray
(
extension
.
value
))
{
extension
.
collector
.
error
(
nls
.
localize
(
'
invalid
'
,
"
Invalid `contributes.{0}`. Expected an array.
"
,
languagesExtPoint
.
name
));
continue
;
}
for
(
let
j
=
0
,
lenJ
=
extension
.
value
.
length
;
j
<
lenJ
;
j
++
)
{
let
ext
=
extension
.
value
[
j
];
if
(
isValidLanguageExtensionPoint
(
ext
,
extension
.
collector
))
{
let
configuration
=
(
ext
.
configuration
?
paths
.
join
(
extension
.
description
.
extensionFolderPath
,
ext
.
configuration
)
:
ext
.
configuration
);
allValidLanguages
.
push
({
id
:
ext
.
id
,
extensions
:
ext
.
extensions
,
filenames
:
ext
.
filenames
,
filenamePatterns
:
ext
.
filenamePatterns
,
firstLine
:
ext
.
firstLine
,
aliases
:
ext
.
aliases
,
mimetypes
:
ext
.
mimetypes
,
configuration
:
configuration
});
}
}
}
ModesRegistry
.
registerLanguages
(
allValidLanguages
);
});
this
.
_configurationService
.
onDidUpdateConfiguration
(
e
=>
this
.
onConfigurationChange
(
e
.
config
));
this
.
onDidCreateMode
((
mode
)
=>
{
this
.
_extensionService
.
activateByEvent
(
`onLanguage:
${
mode
.
getId
()}
`
).
done
(
null
,
onUnexpectedError
);
});
}
protected
_onReady
():
TPromise
<
boolean
>
{
if
(
!
this
.
_onReadyPromise
)
{
const
configuration
=
this
.
_configurationService
.
getConfiguration
<
IFilesConfiguration
>
();
this
.
_onReadyPromise
=
this
.
_extensionService
.
onReady
().
then
(()
=>
{
this
.
onConfigurationChange
(
configuration
);
return
true
;
});
}
return
this
.
_onReadyPromise
;
}
private
onConfigurationChange
(
configuration
:
IFilesConfiguration
):
void
{
// Clear user configured mime associations
mime
.
clearTextMimes
(
true
/* user configured */
);
// Register based on settings
if
(
configuration
.
files
&&
configuration
.
files
.
associations
)
{
Object
.
keys
(
configuration
.
files
.
associations
).
forEach
(
pattern
=>
{
const
langId
=
configuration
.
files
.
associations
[
pattern
];
const
mimetype
=
this
.
getMimeForMode
(
langId
)
||
`text/x-
${
langId
}
`
;
mime
.
registerTextMime
({
id
:
langId
,
mime
:
mimetype
,
filepattern
:
pattern
,
userConfigured
:
true
});
});
}
}
}
src/vs/workbench/electron-browser/shell.ts
浏览文件 @
97570d91
...
@@ -68,7 +68,7 @@ import { ICommandService } from 'vs/platform/commands/common/commands';
...
@@ -68,7 +68,7 @@ import { ICommandService } from 'vs/platform/commands/common/commands';
import
{
CommandService
}
from
'
vs/platform/commands/common/commandService
'
;
import
{
CommandService
}
from
'
vs/platform/commands/common/commandService
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
IExtensionService
}
from
'
vs/platform/extensions/common/extensions
'
;
import
{
IExtensionService
}
from
'
vs/platform/extensions/common/extensions
'
;
import
{
MainThreadModeServiceImpl
}
from
'
vs/editor/common/services/modeServiceImpl
'
;
import
{
WorkbenchModeServiceImpl
}
from
'
vs/workbench/services/mode/common/workbenchModeService
'
;
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
IUntitledEditorService
,
UntitledEditorService
}
from
'
vs/workbench/services/untitled/common/untitledEditorService
'
;
import
{
IUntitledEditorService
,
UntitledEditorService
}
from
'
vs/workbench/services/untitled/common/untitledEditorService
'
;
import
{
CrashReporter
}
from
'
vs/workbench/electron-browser/crashReporter
'
;
import
{
CrashReporter
}
from
'
vs/workbench/electron-browser/crashReporter
'
;
...
@@ -346,7 +346,7 @@ export class WorkbenchShell {
...
@@ -346,7 +346,7 @@ export class WorkbenchShell {
serviceCollection
.
set
(
IMarkerService
,
new
SyncDescriptor
(
MarkerService
));
serviceCollection
.
set
(
IMarkerService
,
new
SyncDescriptor
(
MarkerService
));
serviceCollection
.
set
(
IModeService
,
new
SyncDescriptor
(
MainThread
ModeServiceImpl
));
serviceCollection
.
set
(
IModeService
,
new
SyncDescriptor
(
Workbench
ModeServiceImpl
));
serviceCollection
.
set
(
IModelService
,
new
SyncDescriptor
(
ModelServiceImpl
));
serviceCollection
.
set
(
IModelService
,
new
SyncDescriptor
(
ModelServiceImpl
));
...
...
src/vs/workbench/services/mode/common/workbenchModeService.ts
0 → 100644
浏览文件 @
97570d91
/*---------------------------------------------------------------------------------------------
* 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
*
as
nls
from
'
vs/nls
'
;
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
*
as
paths
from
'
vs/base/common/paths
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
mime
=
require
(
'
vs/base/common/mime
'
);
import
{
IFilesConfiguration
}
from
'
vs/platform/files/common/files
'
;
import
{
IExtensionService
}
from
'
vs/platform/extensions/common/extensions
'
;
import
{
IExtensionPointUser
,
ExtensionMessageCollector
}
from
'
vs/platform/extensions/common/extensionsRegistry
'
;
import
{
ModesRegistry
}
from
'
vs/editor/common/modes/modesRegistry
'
;
import
{
ILanguageExtensionPoint
,
IValidLanguageExtensionPoint
}
from
'
vs/editor/common/services/modeService
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
languagesExtPoint
,
ModeServiceImpl
}
from
'
vs/editor/common/services/modeServiceImpl
'
;
export
class
WorkbenchModeServiceImpl
extends
ModeServiceImpl
{
private
_configurationService
:
IConfigurationService
;
private
_extensionService
:
IExtensionService
;
private
_onReadyPromise
:
TPromise
<
boolean
>
;
constructor
(
@
IExtensionService
extensionService
:
IExtensionService
,
@
IConfigurationService
configurationService
:
IConfigurationService
)
{
super
();
this
.
_configurationService
=
configurationService
;
this
.
_extensionService
=
extensionService
;
languagesExtPoint
.
setHandler
((
extensions
:
IExtensionPointUser
<
ILanguageExtensionPoint
[]
>
[])
=>
{
let
allValidLanguages
:
IValidLanguageExtensionPoint
[]
=
[];
for
(
let
i
=
0
,
len
=
extensions
.
length
;
i
<
len
;
i
++
)
{
let
extension
=
extensions
[
i
];
if
(
!
Array
.
isArray
(
extension
.
value
))
{
extension
.
collector
.
error
(
nls
.
localize
(
'
invalid
'
,
"
Invalid `contributes.{0}`. Expected an array.
"
,
languagesExtPoint
.
name
));
continue
;
}
for
(
let
j
=
0
,
lenJ
=
extension
.
value
.
length
;
j
<
lenJ
;
j
++
)
{
let
ext
=
extension
.
value
[
j
];
if
(
isValidLanguageExtensionPoint
(
ext
,
extension
.
collector
))
{
let
configuration
=
(
ext
.
configuration
?
paths
.
join
(
extension
.
description
.
extensionFolderPath
,
ext
.
configuration
)
:
ext
.
configuration
);
allValidLanguages
.
push
({
id
:
ext
.
id
,
extensions
:
ext
.
extensions
,
filenames
:
ext
.
filenames
,
filenamePatterns
:
ext
.
filenamePatterns
,
firstLine
:
ext
.
firstLine
,
aliases
:
ext
.
aliases
,
mimetypes
:
ext
.
mimetypes
,
configuration
:
configuration
});
}
}
}
ModesRegistry
.
registerLanguages
(
allValidLanguages
);
});
this
.
_configurationService
.
onDidUpdateConfiguration
(
e
=>
this
.
onConfigurationChange
(
e
.
config
));
this
.
onDidCreateMode
((
mode
)
=>
{
this
.
_extensionService
.
activateByEvent
(
`onLanguage:
${
mode
.
getId
()}
`
).
done
(
null
,
onUnexpectedError
);
});
}
protected
_onReady
():
TPromise
<
boolean
>
{
if
(
!
this
.
_onReadyPromise
)
{
const
configuration
=
this
.
_configurationService
.
getConfiguration
<
IFilesConfiguration
>
();
this
.
_onReadyPromise
=
this
.
_extensionService
.
onReady
().
then
(()
=>
{
this
.
onConfigurationChange
(
configuration
);
return
true
;
});
}
return
this
.
_onReadyPromise
;
}
private
onConfigurationChange
(
configuration
:
IFilesConfiguration
):
void
{
// Clear user configured mime associations
mime
.
clearTextMimes
(
true
/* user configured */
);
// Register based on settings
if
(
configuration
.
files
&&
configuration
.
files
.
associations
)
{
Object
.
keys
(
configuration
.
files
.
associations
).
forEach
(
pattern
=>
{
const
langId
=
configuration
.
files
.
associations
[
pattern
];
const
mimetype
=
this
.
getMimeForMode
(
langId
)
||
`text/x-
${
langId
}
`
;
mime
.
registerTextMime
({
id
:
langId
,
mime
:
mimetype
,
filepattern
:
pattern
,
userConfigured
:
true
});
});
}
}
}
function
isUndefinedOrStringArray
(
value
:
string
[]):
boolean
{
if
(
typeof
value
===
'
undefined
'
)
{
return
true
;
}
if
(
!
Array
.
isArray
(
value
))
{
return
false
;
}
return
value
.
every
(
item
=>
typeof
item
===
'
string
'
);
}
function
isValidLanguageExtensionPoint
(
value
:
ILanguageExtensionPoint
,
collector
:
ExtensionMessageCollector
):
boolean
{
if
(
!
value
)
{
collector
.
error
(
nls
.
localize
(
'
invalid.empty
'
,
"
Empty value for `contributes.{0}`
"
,
languagesExtPoint
.
name
));
return
false
;
}
if
(
typeof
value
.
id
!==
'
string
'
)
{
collector
.
error
(
nls
.
localize
(
'
require.id
'
,
"
property `{0}` is mandatory and must be of type `string`
"
,
'
id
'
));
return
false
;
}
if
(
!
isUndefinedOrStringArray
(
value
.
extensions
))
{
collector
.
error
(
nls
.
localize
(
'
opt.extensions
'
,
"
property `{0}` can be omitted and must be of type `string[]`
"
,
'
extensions
'
));
return
false
;
}
if
(
!
isUndefinedOrStringArray
(
value
.
filenames
))
{
collector
.
error
(
nls
.
localize
(
'
opt.filenames
'
,
"
property `{0}` can be omitted and must be of type `string[]`
"
,
'
filenames
'
));
return
false
;
}
if
(
typeof
value
.
firstLine
!==
'
undefined
'
&&
typeof
value
.
firstLine
!==
'
string
'
)
{
collector
.
error
(
nls
.
localize
(
'
opt.firstLine
'
,
"
property `{0}` can be omitted and must be of type `string`
"
,
'
firstLine
'
));
return
false
;
}
if
(
typeof
value
.
configuration
!==
'
undefined
'
&&
typeof
value
.
configuration
!==
'
string
'
)
{
collector
.
error
(
nls
.
localize
(
'
opt.configuration
'
,
"
property `{0}` can be omitted and must be of type `string`
"
,
'
configuration
'
));
return
false
;
}
if
(
!
isUndefinedOrStringArray
(
value
.
aliases
))
{
collector
.
error
(
nls
.
localize
(
'
opt.aliases
'
,
"
property `{0}` can be omitted and must be of type `string[]`
"
,
'
aliases
'
));
return
false
;
}
if
(
!
isUndefinedOrStringArray
(
value
.
mimetypes
))
{
collector
.
error
(
nls
.
localize
(
'
opt.mimetypes
'
,
"
property `{0}` can be omitted and must be of type `string[]`
"
,
'
mimetypes
'
));
return
false
;
}
return
true
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录