Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
ebc76bdf
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,发现更多精彩内容 >>
提交
ebc76bdf
编写于
2月 16, 2016
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Further reduce dependencies to LanguageExtensions
上级
7712c55b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
61 addition
and
23 deletion
+61
-23
src/vs/editor/browser/standalone/standaloneCodeEditor.ts
src/vs/editor/browser/standalone/standaloneCodeEditor.ts
+3
-3
src/vs/editor/common/modes/languageExtensionPoint.ts
src/vs/editor/common/modes/languageExtensionPoint.ts
+10
-11
src/vs/editor/common/modes/modesRegistry.ts
src/vs/editor/common/modes/modesRegistry.ts
+48
-9
未找到文件。
src/vs/editor/browser/standalone/standaloneCodeEditor.ts
浏览文件 @
ebc76bdf
...
...
@@ -32,12 +32,12 @@ import {IModelService} from 'vs/editor/common/services/modelService';
import
colorizer
=
require
(
'
vs/editor/browser/standalone/colorizer
'
);
import
{
IEditorModesRegistry
,
Extensions
}
from
'
vs/editor/common/modes/modesRegistry
'
;
import
{
Registry
}
from
'
vs/platform/platform
'
;
import
{
LanguageExtensions
}
from
'
vs/editor/common/modes/languageExtensionPoint
'
;
import
{
AbstractKeybindingService
}
from
'
vs/platform/keybinding/browser/keybindingServiceImpl
'
;
import
{
ICodeEditorService
}
from
'
vs/editor/common/services/codeEditorService
'
;
import
{
IJSONSchema
}
from
'
vs/base/common/jsonSchema
'
;
import
*
as
JSONContributionRegistry
from
'
vs/platform/jsonschemas/common/jsonContributionRegistry
'
;
import
{
ILanguageExtensionPoint
}
from
'
vs/editor/common/services/modeService
'
;
import
{
registerLanguage
}
from
'
vs/editor/common/modes/modesRegistry
'
;
// Set defaults for standalone editor
DefaultConfig
.
editor
.
wrappingIndent
=
'
none
'
;
...
...
@@ -418,7 +418,7 @@ export function createCustomMode(language:MonarchTypes.ILanguage): TPromise<Mode
var
modeId
=
language
.
name
;
var
name
=
language
.
name
;
LanguageExtensions
.
registerLanguage
({
registerLanguage
({
id
:
modeId
,
aliases
:
[
name
]
});
...
...
@@ -431,7 +431,7 @@ export function createCustomMode(language:MonarchTypes.ILanguage): TPromise<Mode
}
export
function
registerStandaloneLanguage
(
language
:
ILanguageExtensionPoint
,
defModule
:
string
):
void
{
LanguageExtensions
.
registerLanguage
(
language
);
registerLanguage
(
language
);
PluginsRegistry
.
registerOneTimeActivationEventListener
(
'
onLanguage:
'
+
language
.
id
,
()
=>
{
require
([
defModule
],
(
value
:{
language
:
MonarchTypes
.
ILanguage
})
=>
{
...
...
src/vs/editor/common/modes/languageExtensionPoint.ts
浏览文件 @
ebc76bdf
...
...
@@ -15,6 +15,8 @@ import Mime = require('vs/base/common/mime');
import
Errors
=
require
(
'
vs/base/common/errors
'
);
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
ILanguageExtensionPoint
}
from
'
vs/editor/common/services/modeService
'
;
import
{
IEditorModesRegistry
,
ILegacyLanguageDefinition
,
Extensions
}
from
'
vs/editor/common/modes/modesRegistry
'
;
import
{
Registry
}
from
'
vs/platform/platform
'
;
interface
ILanguagePointData
{
knownModeIds
:
{
[
id
:
string
]:
boolean
;
};
...
...
@@ -133,17 +135,6 @@ function isValidLanguageExtensionPoint(value:ILanguageExtensionPoint, collector:
return
true
;
}
export
interface
ILegacyLanguageDefinition
{
id
:
string
;
extensions
:
string
[];
filenames
?:
string
[];
firstLine
?:
string
;
aliases
:
string
[];
mimetypes
:
string
[];
moduleId
:
string
;
ctorName
:
string
;
}
var
hasOwnProperty
=
Object
.
prototype
.
hasOwnProperty
;
export
interface
ILanguageExtensionPointHandler
{
...
...
@@ -171,6 +162,8 @@ export interface ICompatModeDescriptor {
ctorName
:
string
;
}
let
modesRegistry
=
<
IEditorModesRegistry
>
Registry
.
as
(
Extensions
.
EditorModes
);
class
LanguageExtensionPointHandler
implements
IThreadSynchronizableObject
<
ILanguagePointData
>
,
ILanguageExtensionPointHandler
{
private
knownModeIds
:
{
[
id
:
string
]:
boolean
;
};
...
...
@@ -197,6 +190,12 @@ class LanguageExtensionPointHandler implements IThreadSynchronizableObject<ILang
this
.
lowerName2Id
=
{};
this
.
id2ConfigurationFiles
=
{};
this
.
_isRegisteredWithThreadService
=
false
;
modesRegistry
.
getCompatModes
().
forEach
((
m
)
=>
this
.
registerCompatMode
(
m
));
modesRegistry
.
onDidAddCompatMode
((
m
)
=>
this
.
registerCompatMode
(
m
));
modesRegistry
.
getLanguages
().
forEach
((
m
)
=>
this
.
registerLanguage
(
m
));
modesRegistry
.
onDidAddLanguage
((
m
)
=>
this
.
registerLanguage
(
m
));
}
// -- BEGIN IThreadSynchronizableObject
...
...
src/vs/editor/common/modes/modesRegistry.ts
浏览文件 @
ebc76bdf
...
...
@@ -4,12 +4,23 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
LanguageExtensions
,
ILegacyLanguageDefinition
}
from
'
vs/editor/common/modes/languageExtensionPoint
'
;
import
Modes
=
require
(
'
vs/editor/common/modes
'
);
import
Strings
=
require
(
'
vs/base/common/strings
'
);
import
EditorCommon
=
require
(
'
vs/editor/common/editorCommon
'
);
import
{
Registry
}
from
'
vs/platform/platform
'
;
import
{
ILanguageExtensionPoint
}
from
'
vs/editor/common/services/modeService
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
export
interface
ILegacyLanguageDefinition
{
id
:
string
;
extensions
:
string
[];
filenames
?:
string
[];
firstLine
?:
string
;
aliases
:
string
[];
mimetypes
:
string
[];
moduleId
:
string
;
ctorName
:
string
;
}
// Define extension point ids
export
var
Extensions
=
{
...
...
@@ -18,6 +29,9 @@ export var Extensions = {
export
interface
IEditorModesRegistry
{
onDidAddCompatMode
:
Event
<
ILegacyLanguageDefinition
>
;
onDidAddLanguage
:
Event
<
ILanguageExtensionPoint
>
;
// --- worker participants registration
registerWorkerParticipant
(
modeId
:
string
,
moduleId
:
string
,
ctorName
?:
string
):
void
;
getWorkerParticipants
(
modeId
:
string
):
Modes
.
IWorkerParticipantDescriptor
[];
...
...
@@ -27,21 +41,34 @@ export interface IEditorModesRegistry {
// --- modes registration
registerCompatMode
(
def
:
ILegacyLanguageDefinition
):
void
;
getCompatModes
():
ILegacyLanguageDefinition
[];
registerLanguage
(
def
:
ILanguageExtensionPoint
):
void
;
getLanguages
():
ILanguageExtensionPoint
[];
}
class
EditorModesRegistry
implements
IEditorModesRegistry
{
private
workerParticipants
:
Modes
.
IWorkerParticipantDescriptor
[];
private
_workerParticipants
:
Modes
.
IWorkerParticipantDescriptor
[];
private
_compatModes
:
ILegacyLanguageDefinition
[];
private
_languages
:
ILanguageExtensionPoint
[];
private
_onDidAddCompatMode
:
Emitter
<
ILegacyLanguageDefinition
>
=
new
Emitter
<
ILegacyLanguageDefinition
>
();
public
onDidAddCompatMode
:
Event
<
ILegacyLanguageDefinition
>
=
this
.
_onDidAddCompatMode
.
event
;
private
_onDidAddLanguage
:
Emitter
<
ILanguageExtensionPoint
>
=
new
Emitter
<
ILanguageExtensionPoint
>
();
public
onDidAddLanguage
:
Event
<
ILanguageExtensionPoint
>
=
this
.
_onDidAddLanguage
.
event
;
constructor
()
{
this
.
workerParticipants
=
[];
this
.
_workerParticipants
=
[];
this
.
_compatModes
=
[];
this
.
_languages
=
[];
}
// --- worker participants registration
public
registerWorkerParticipant
(
modeId
:
string
,
moduleId
:
string
,
ctorName
?:
string
):
void
{
this
.
workerParticipants
.
push
({
this
.
_
workerParticipants
.
push
({
modeId
:
modeId
,
moduleId
:
moduleId
,
ctorName
:
ctorName
...
...
@@ -49,23 +76,35 @@ class EditorModesRegistry implements IEditorModesRegistry {
}
public
_getAllWorkerParticipants
():
Modes
.
IWorkerParticipantDescriptor
[]
{
return
this
.
workerParticipants
;
return
this
.
_
workerParticipants
;
}
public
_setWorkerParticipants
(
participants
:
Modes
.
IWorkerParticipantDescriptor
[]):
void
{
this
.
workerParticipants
=
participants
;
this
.
_
workerParticipants
=
participants
;
}
public
getWorkerParticipants
(
modeId
:
string
):
Modes
.
IWorkerParticipantDescriptor
[]
{
return
this
.
workerParticipants
.
filter
(
p
=>
p
.
modeId
===
modeId
);
return
this
.
_
workerParticipants
.
filter
(
p
=>
p
.
modeId
===
modeId
);
}
public
registerCompatMode
(
def
:
ILegacyLanguageDefinition
):
void
{
LanguageExtensions
.
registerCompatMode
(
def
);
this
.
_compatModes
.
push
(
def
);
this
.
_onDidAddCompatMode
.
fire
(
def
);
}
public
getCompatModes
():
ILegacyLanguageDefinition
[]
{
return
this
.
_compatModes
.
slice
(
0
);
}
public
registerLanguage
(
def
:
ILanguageExtensionPoint
):
void
{
LanguageExtensions
.
registerLanguage
(
def
);
this
.
_languages
.
push
(
def
);
this
.
_onDidAddLanguage
.
fire
(
def
);
}
public
getLanguages
():
ILanguageExtensionPoint
[]
{
return
this
.
_languages
.
slice
(
0
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录