Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
92b91cf3
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,发现更多精彩内容 >>
提交
92b91cf3
编写于
6月 05, 2016
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove usages of richEditSupport and adopt LanguageConfigurationRegistry
上级
3719c2f6
变更
36
隐藏空白更改
内联
并排
Showing
36 changed file
with
142 addition
and
209 deletion
+142
-209
src/vs/editor/browser/standalone/standaloneLanguages.ts
src/vs/editor/browser/standalone/standaloneLanguages.ts
+3
-4
src/vs/editor/common/controller/cursor.ts
src/vs/editor/common/controller/cursor.ts
+3
-2
src/vs/editor/common/editorCommon.ts
src/vs/editor/common/editorCommon.ts
+0
-1
src/vs/editor/common/modes.ts
src/vs/editor/common/modes.ts
+1
-28
src/vs/editor/common/modes/abstractMode.ts
src/vs/editor/common/modes/abstractMode.ts
+9
-21
src/vs/editor/common/modes/languageConfigurationRegistry.ts
src/vs/editor/common/modes/languageConfigurationRegistry.ts
+6
-2
src/vs/editor/common/modes/supports/tokenizationSupport.ts
src/vs/editor/common/modes/supports/tokenizationSupport.ts
+2
-2
src/vs/editor/common/services/modeService.ts
src/vs/editor/common/services/modeService.ts
+0
-2
src/vs/editor/common/services/modeServiceImpl.ts
src/vs/editor/common/services/modeServiceImpl.ts
+9
-14
src/vs/editor/contrib/comment/test/common/blockCommentCommand.test.ts
...r/contrib/comment/test/common/blockCommentCommand.test.ts
+1
-1
src/vs/editor/contrib/comment/test/common/lineCommentCommand.test.ts
...or/contrib/comment/test/common/lineCommentCommand.test.ts
+4
-4
src/vs/editor/contrib/smartSelect/test/common/tokenSelectionSupport.test.ts
...rib/smartSelect/test/common/tokenSelectionSupport.test.ts
+4
-6
src/vs/editor/node/languageConfiguration.ts
src/vs/editor/node/languageConfiguration.ts
+2
-1
src/vs/editor/test/common/commands/shiftCommand.test.ts
src/vs/editor/test/common/commands/shiftCommand.test.ts
+3
-5
src/vs/editor/test/common/controller/cursor.test.ts
src/vs/editor/test/common/controller/cursor.test.ts
+13
-27
src/vs/editor/test/common/mocks/mockMode.ts
src/vs/editor/test/common/mocks/mockMode.ts
+1
-1
src/vs/editor/test/common/mocks/mockModeService.ts
src/vs/editor/test/common/mocks/mockModeService.ts
+0
-4
src/vs/editor/test/common/modes/tokenization.test.ts
src/vs/editor/test/common/modes/tokenization.test.ts
+1
-1
src/vs/editor/test/common/modesTestUtils.ts
src/vs/editor/test/common/modesTestUtils.ts
+0
-18
src/vs/editor/test/common/testModes.ts
src/vs/editor/test/common/testModes.ts
+6
-9
src/vs/languages/css/common/css.ts
src/vs/languages/css/common/css.ts
+2
-3
src/vs/languages/css/test/common/css-worker.test.ts
src/vs/languages/css/test/common/css-worker.test.ts
+16
-4
src/vs/languages/handlebars/common/handlebars.ts
src/vs/languages/handlebars/common/handlebars.ts
+2
-4
src/vs/languages/html/common/html.ts
src/vs/languages/html/common/html.ts
+3
-8
src/vs/languages/html/test/common/html.test.ts
src/vs/languages/html/test/common/html.test.ts
+3
-5
src/vs/languages/json/common/json.ts
src/vs/languages/json/common/json.ts
+2
-3
src/vs/languages/less/common/less.ts
src/vs/languages/less/common/less.ts
+2
-3
src/vs/languages/less/test/common/intellisense.test.ts
src/vs/languages/less/test/common/intellisense.test.ts
+14
-3
src/vs/languages/markdown/common/markdown.ts
src/vs/languages/markdown/common/markdown.ts
+2
-3
src/vs/languages/php/common/php.ts
src/vs/languages/php/common/php.ts
+2
-3
src/vs/languages/razor/common/razor.ts
src/vs/languages/razor/common/razor.ts
+3
-5
src/vs/languages/sass/common/sass.ts
src/vs/languages/sass/common/sass.ts
+2
-3
src/vs/languages/sass/test/common/sass-worker.test.ts
src/vs/languages/sass/test/common/sass-worker.test.ts
+15
-4
src/vs/languages/typescript/common/mode.ts
src/vs/languages/typescript/common/mode.ts
+2
-1
src/vs/workbench/api/node/extHost.api.impl.ts
src/vs/workbench/api/node/extHost.api.impl.ts
+2
-1
src/vs/workbench/parts/output/common/outputMode.ts
src/vs/workbench/parts/output/common/outputMode.ts
+2
-3
未找到文件。
src/vs/editor/browser/standalone/standaloneLanguages.ts
浏览文件 @
92b91cf3
...
...
@@ -25,6 +25,7 @@ import {CancellationToken} from 'vs/base/common/cancellation';
import
{
toThenable
}
from
'
vs/base/common/async
'
;
import
{
compile
}
from
'
vs/editor/common/modes/monarch/monarchCompile
'
;
import
{
createTokenizationSupport
}
from
'
vs/editor/common/modes/monarch/monarchLexer
'
;
import
{
LanguageConfigurationRegistry
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
export
function
register
(
language
:
ILanguageExtensionPoint
):
void
{
ModesRegistry
.
registerLanguage
(
language
);
...
...
@@ -50,9 +51,7 @@ export function onLanguage(languageId:string, callback:()=>void): IDisposable {
}
export
function
setLanguageConfiguration
(
languageId
:
string
,
configuration
:
IRichLanguageConfiguration
):
IDisposable
{
startup
.
initStaticServicesIfNecessary
();
let
staticPlatformServices
=
ensureStaticPlatformServices
(
null
);
return
staticPlatformServices
.
modeService
.
registerRichEditSupport
(
languageId
,
configuration
);
return
LanguageConfigurationRegistry
.
register
(
languageId
,
configuration
);
}
export
function
setTokensProvider
(
languageId
:
string
,
support
:
modes
.
TokensProvider
):
IDisposable
{
...
...
@@ -313,7 +312,7 @@ export function registerMonarchStandaloneLanguage(language:ILanguageExtensionPoi
return
createTokenizationSupport
(
modeService
,
mode
,
lexer
);
});
modeService
.
registerRichEditSupport
(
language
.
id
,
value
.
conf
);
LanguageConfigurationRegistry
.
register
(
language
.
id
,
value
.
conf
);
},
(
err
)
=>
{
console
.
error
(
'
Cannot find module
'
+
defModule
,
err
);
});
...
...
src/vs/editor/common/controller/cursor.ts
浏览文件 @
92b91cf3
...
...
@@ -16,6 +16,7 @@ import {Range} from 'vs/editor/common/core/range';
import
{
Selection
}
from
'
vs/editor/common/core/selection
'
;
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
{
IColumnSelectResult
}
from
'
vs/editor/common/controller/cursorMoveHelper
'
;
import
{
LanguageConfigurationRegistry
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
export
interface
ITypingListener
{
():
void
;
...
...
@@ -140,8 +141,8 @@ export class Cursor extends EventEmitter {
this
.
modelUnbinds
.
push
(
this
.
model
.
onDidChangeMode
((
e
)
=>
{
this
.
_onModelModeChanged
();
}));
this
.
modelUnbinds
.
push
(
this
.
model
.
onDidChangeModeSupport
((
e
)
=>
{
// TODO@Alex: react only if certain supports changed?
this
.
modelUnbinds
.
push
(
LanguageConfigurationRegistry
.
onDidChange
((
)
=>
{
// TODO@Alex: react only if certain supports changed?
(and if my model's mode changed)
this
.
_onModelModeChanged
();
}));
...
...
src/vs/editor/common/editorCommon.ts
浏览文件 @
92b91cf3
...
...
@@ -953,7 +953,6 @@ export interface IConfigurationChangedEvent {
*/
export
interface
IModeSupportChangedEvent
{
tokenizationSupport
:
boolean
;
richEditSupport
:
boolean
;
}
/**
...
...
src/vs/editor/common/modes.ts
浏览文件 @
92b91cf3
...
...
@@ -180,27 +180,6 @@ export interface ILineContext {
findIndexOfOffset
(
offset
:
number
):
number
;
}
/**
* @internal
*/
export
enum
MutableSupport
{
RichEditSupport
=
1
,
TokenizationSupport
=
2
}
/**
* @internal
*/
export
function
mutableSupportToString
(
registerableSupport
:
MutableSupport
)
{
if
(
registerableSupport
===
MutableSupport
.
RichEditSupport
)
{
return
'
richEditSupport
'
;
}
if
(
registerableSupport
===
MutableSupport
.
TokenizationSupport
)
{
return
'
tokenizationSupport
'
;
}
throw
new
Error
(
'
Illegal argument!
'
);
}
export
interface
IMode
{
...
...
@@ -221,7 +200,7 @@ export interface IMode {
* Register a support by name. Only optional.
* @internal
*/
registerSupport
?
<
T
>
(
support
:
MutableSupport
,
callback
:(
mode
:
IMode
)
=>
T
):
IDisposable
;
setTokenizationSupport
?
<
T
>
(
callback
:(
mode
:
IMode
)
=>
T
):
IDisposable
;
/**
* Optional adapter to support tokenization.
...
...
@@ -246,12 +225,6 @@ export interface IMode {
* @internal
*/
configSupport
?:
IConfigurationSupport
;
/**
* Optional adapter to support rich editing.
* @internal
*/
richEditSupport
?:
IRichEditSupport
;
}
/**
...
...
src/vs/editor/common/modes/abstractMode.ts
浏览文件 @
92b91cf3
...
...
@@ -102,17 +102,16 @@ export abstract class AbstractMode implements modes.IMode {
return
this
.
_eventEmitter
.
addListener2
(
'
modeSupportChanged
'
,
callback
);
}
public
registerSupport
<
T
>
(
supportEnum
:
modes
.
MutableSupport
,
callback
:(
mode
:
modes
.
IMode
)
=>
T
)
:
IDisposable
{
let
supportStr
=
modes
.
mutableSupportToString
(
supportEnum
);
public
setTokenizationSupport
<
T
>
(
callback
:(
mode
:
modes
.
IMode
)
=>
T
)
:
IDisposable
{
var
supportImpl
=
callback
(
this
);
this
[
supportStr
]
=
supportImpl
;
this
.
_eventEmitter
.
emit
(
'
modeSupportChanged
'
,
_createModeSupportChangedEvent
(
supportEnum
));
this
[
'
tokenizationSupport
'
]
=
supportImpl
;
this
.
_eventEmitter
.
emit
(
'
modeSupportChanged
'
,
_createModeSupportChangedEvent
());
return
{
dispose
:
()
=>
{
if
(
this
[
supportStr
]
===
supportImpl
)
{
delete
this
[
supportStr
];
this
.
_eventEmitter
.
emit
(
'
modeSupportChanged
'
,
_createModeSupportChangedEvent
(
supportEnum
));
if
(
this
[
'
tokenizationSupport
'
]
===
supportImpl
)
{
delete
this
[
'
tokenizationSupport
'
];
this
.
_eventEmitter
.
emit
(
'
modeSupportChanged
'
,
_createModeSupportChangedEvent
());
}
}
};
...
...
@@ -122,7 +121,6 @@ export abstract class AbstractMode implements modes.IMode {
class
SimplifiedMode
implements
modes
.
IMode
{
tokenizationSupport
:
modes
.
ITokenizationSupport
;
richEditSupport
:
modes
.
IRichEditSupport
;
private
_sourceMode
:
modes
.
IMode
;
private
_eventEmitter
:
EventEmitter
;
...
...
@@ -152,7 +150,6 @@ class SimplifiedMode implements modes.IMode {
private
_assignSupports
():
void
{
this
.
tokenizationSupport
=
this
.
_sourceMode
.
tokenizationSupport
;
this
.
richEditSupport
=
this
.
_sourceMode
.
richEditSupport
;
}
}
...
...
@@ -235,17 +232,8 @@ export class FrankensteinMode extends AbstractMode {
}
}
function
_createModeSupportChangedEvent
(
supportEnum
:
modes
.
MutableSupport
):
IModeSupportChangedEvent
{
let
e
:
IModeSupportChangedEvent
=
{
richEditSupport
:
false
,
tokenizationSupport
:
false
function
_createModeSupportChangedEvent
():
IModeSupportChangedEvent
{
return
{
tokenizationSupport
:
true
};
if
(
supportEnum
===
modes
.
MutableSupport
.
RichEditSupport
)
{
e
.
richEditSupport
=
true
;
return
e
;
}
else
if
(
supportEnum
===
modes
.
MutableSupport
.
TokenizationSupport
)
{
e
.
tokenizationSupport
=
true
;
return
e
;
}
throw
new
Error
(
'
Illegal argument!
'
);
}
src/vs/editor/common/modes/languageConfigurationRegistry.ts
浏览文件 @
92b91cf3
...
...
@@ -17,6 +17,7 @@ import {ITokenizedModel} from 'vs/editor/common/editorCommon';
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
export
interface
CommentRule
{
lineComment
?:
string
;
...
...
@@ -140,14 +141,17 @@ export class LanguageConfigurationRegistryImpl {
this
.
_entries
=
Object
.
create
(
null
);
}
public
register
(
languageId
:
string
,
configuration
:
IRichLanguageConfiguration
):
void
{
public
register
(
languageId
:
string
,
configuration
:
IRichLanguageConfiguration
):
IDisposable
{
let
previous
=
this
.
_entries
[
languageId
]
||
null
;
this
.
_entries
[
languageId
]
=
new
RichEditSupport
(
languageId
,
previous
,
configuration
);
this
.
_onDidChange
.
fire
(
void
0
);
return
{
dispose
:
()
=>
{}
};
}
private
_getRichEditSupport
(
mode
:
IMode
):
IRichEditSupport
{
return
/*this._entries[mode.getId()] || */
mode
.
richEditSupport
;
return
this
.
_entries
[
mode
.
getId
()]
;
}
public
getElectricCharacterSupport
(
mode
:
IMode
):
IRichEditElectricCharacter
{
...
...
src/vs/editor/common/modes/supports/tokenizationSupport.ts
浏览文件 @
92b91cf3
...
...
@@ -85,7 +85,7 @@ export class TokenizationSupport implements modes.ITokenizationSupport, IDisposa
this
.
supportsNestedModes
=
supportsNestedModes
;
this
.
_embeddedModesListeners
=
{};
if
(
this
.
supportsNestedModes
)
{
if
(
!
this
.
_mode
.
register
Support
)
{
if
(
!
this
.
_mode
.
setTokenization
Support
)
{
throw
new
Error
(
'
Cannot be a mode with nested modes unless I can emit a tokenizationSupport changed event!
'
);
}
}
...
...
@@ -239,7 +239,7 @@ export class TokenizationSupport implements modes.ITokenizationSupport, IDisposa
}
if
(
e
.
tokenizationSupport
)
{
emitting
=
true
;
this
.
_mode
.
registerSupport
(
modes
.
MutableSupport
.
TokenizationSupport
,
(
mode
)
=>
{
this
.
_mode
.
setTokenizationSupport
(
(
mode
)
=>
{
return
mode
.
tokenizationSupport
;
});
emitting
=
false
;
...
...
src/vs/editor/common/services/modeService.ts
浏览文件 @
92b91cf3
...
...
@@ -9,7 +9,6 @@ import {IDisposable} from 'vs/base/common/lifecycle';
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
ServiceIdentifier
,
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
*
as
modes
from
'
vs/editor/common/modes
'
;
import
{
IRichLanguageConfiguration
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
export
var
IModeService
=
createDecorator
<
IModeService
>
(
'
modeService
'
);
...
...
@@ -70,7 +69,6 @@ export interface IModeService {
getOrCreateModeByLanguageName
(
languageName
:
string
):
TPromise
<
modes
.
IMode
>
;
getOrCreateModeByFilenameOrFirstLine
(
filename
:
string
,
firstLine
?:
string
):
TPromise
<
modes
.
IMode
>
;
registerRichEditSupport
(
modeId
:
string
,
support
:
IRichLanguageConfiguration
):
IDisposable
;
registerTokenizationSupport
(
modeId
:
string
,
callback
:
(
mode
:
modes
.
IMode
)
=>
modes
.
ITokenizationSupport
):
IDisposable
;
registerTokenizationSupport2
(
modeId
:
string
,
support
:
modes
.
TokensProvider
):
IDisposable
;
}
src/vs/editor/common/services/modeServiceImpl.ts
浏览文件 @
92b91cf3
...
...
@@ -20,7 +20,6 @@ import {IThreadService, Remotable, ThreadAffinity} from 'vs/platform/thread/comm
import
*
as
modes
from
'
vs/editor/common/modes
'
;
import
{
FrankensteinMode
}
from
'
vs/editor/common/modes/abstractMode
'
;
import
{
ILegacyLanguageDefinition
,
ModesRegistry
}
from
'
vs/editor/common/modes/modesRegistry
'
;
import
{
IRichLanguageConfiguration
,
RichEditSupport
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
LanguagesRegistry
}
from
'
vs/editor/common/services/languagesRegistry
'
;
import
{
ILanguageExtensionPoint
,
IValidLanguageExtensionPoint
,
IModeLookupResult
,
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
...
...
@@ -388,18 +387,18 @@ export class ModeServiceImpl implements IModeService {
};
}
private
_register
ModeSupport
<
T
>
(
mode
:
modes
.
IMode
,
support
:
modes
.
MutableSupport
,
callback
:
(
mode
:
modes
.
IMode
)
=>
T
):
IDisposable
{
if
(
mode
.
register
Support
)
{
return
mode
.
registerSupport
(
support
,
callback
);
private
_register
TokenizationSupport
<
T
>
(
mode
:
modes
.
IMode
,
callback
:
(
mode
:
modes
.
IMode
)
=>
T
):
IDisposable
{
if
(
mode
.
setTokenization
Support
)
{
return
mode
.
setTokenizationSupport
(
callback
);
}
else
{
console
.
warn
(
'
Cannot register
support
'
+
modes
.
mutableSupportToString
(
support
)
+
'
on mode
'
+
mode
.
getId
()
+
'
because it does not support it.
'
);
console
.
warn
(
'
Cannot register
tokenizationSupport
on mode
'
+
mode
.
getId
()
+
'
because it does not support it.
'
);
return
EmptyDisposable
;
}
}
pr
otected
registerModeSupport
<
T
>
(
modeId
:
string
,
support
:
modes
.
MutableSupport
,
callback
:
(
mode
:
modes
.
IMode
)
=>
T
):
IDisposable
{
pr
ivate
registerModeSupport
<
T
>
(
modeId
:
string
,
callback
:
(
mode
:
modes
.
IMode
)
=>
T
):
IDisposable
{
if
(
this
.
_instantiatedModes
.
hasOwnProperty
(
modeId
))
{
return
this
.
_register
ModeSupport
(
this
.
_instantiatedModes
[
modeId
],
support
,
callback
);
return
this
.
_register
TokenizationSupport
(
this
.
_instantiatedModes
[
modeId
]
,
callback
);
}
let
cc
:
(
disposable
:
IDisposable
)
=>
void
;
...
...
@@ -410,7 +409,7 @@ export class ModeServiceImpl implements IModeService {
return
;
}
cc
(
this
.
_register
ModeSupport
(
mode
,
support
,
callback
));
cc
(
this
.
_register
TokenizationSupport
(
mode
,
callback
));
disposable
.
dispose
();
});
...
...
@@ -421,16 +420,12 @@ export class ModeServiceImpl implements IModeService {
};
}
public
registerRichEditSupport
(
modeId
:
string
,
support
:
IRichLanguageConfiguration
):
IDisposable
{
return
this
.
registerModeSupport
(
modeId
,
modes
.
MutableSupport
.
RichEditSupport
,
(
mode
)
=>
new
RichEditSupport
(
modeId
,
mode
.
richEditSupport
,
support
));
}
public
registerTokenizationSupport
(
modeId
:
string
,
callback
:
(
mode
:
modes
.
IMode
)
=>
modes
.
ITokenizationSupport
):
IDisposable
{
return
this
.
registerModeSupport
(
modeId
,
modes
.
MutableSupport
.
TokenizationSupport
,
callback
);
return
this
.
registerModeSupport
(
modeId
,
callback
);
}
public
registerTokenizationSupport2
(
modeId
:
string
,
support
:
modes
.
TokensProvider
):
IDisposable
{
return
this
.
registerModeSupport
(
modeId
,
modes
.
MutableSupport
.
TokenizationSupport
,
(
mode
)
=>
{
return
this
.
registerModeSupport
(
modeId
,
(
mode
)
=>
{
return
new
TokenizationSupport2Adapter
(
mode
,
support
);
});
}
...
...
src/vs/editor/contrib/comment/test/common/blockCommentCommand.test.ts
浏览文件 @
92b91cf3
...
...
@@ -10,7 +10,7 @@ import {testCommand} from 'vs/editor/test/common/commands/commandTestUtils';
import
{
CommentMode
}
from
'
vs/editor/test/common/testModes
'
;
function
testBlockCommentCommand
(
lines
:
string
[],
selection
:
Selection
,
expectedLines
:
string
[],
expectedSelection
:
Selection
):
void
{
var
mode
=
new
CommentMode
({
lineComment
Token
:
'
!@#
'
,
blockCommentStartToken
:
'
<0
'
,
blockCommentEndToken
:
'
0>
'
});
var
mode
=
new
CommentMode
({
lineComment
:
'
!@#
'
,
blockComment
:
[
'
<0
'
,
'
0>
'
]
});
testCommand
(
lines
,
mode
,
selection
,
(
sel
)
=>
new
BlockCommentCommand
(
sel
),
expectedLines
,
expectedSelection
);
}
...
...
src/vs/editor/contrib/comment/test/common/lineCommentCommand.test.ts
浏览文件 @
92b91cf3
...
...
@@ -13,12 +13,12 @@ import {CommentMode} from 'vs/editor/test/common/testModes';
suite
(
'
Editor Contrib - Line Comment Command
'
,
()
=>
{
function
testLineCommentCommand
(
lines
:
string
[],
selection
:
Selection
,
expectedLines
:
string
[],
expectedSelection
:
Selection
):
void
{
var
mode
=
new
CommentMode
({
lineComment
Token
:
'
!@#
'
,
blockCommentStartToken
:
'
<!@#
'
,
blockCommentEndToken
:
'
#@!>
'
});
var
mode
=
new
CommentMode
({
lineComment
:
'
!@#
'
,
blockComment
:
[
'
<!@#
'
,
'
#@!>
'
]
});
testCommand
(
lines
,
mode
,
selection
,
(
sel
)
=>
new
LineCommentCommand
(
sel
,
4
,
Type
.
Toggle
),
expectedLines
,
expectedSelection
);
}
function
testAddLineCommentCommand
(
lines
:
string
[],
selection
:
Selection
,
expectedLines
:
string
[],
expectedSelection
:
Selection
):
void
{
var
mode
=
new
CommentMode
({
lineComment
Token
:
'
!@#
'
,
blockCommentStartToken
:
'
<!@#
'
,
blockCommentEndToken
:
'
#@!>
'
});
var
mode
=
new
CommentMode
({
lineComment
:
'
!@#
'
,
blockComment
:
[
'
<!@#
'
,
'
#@!>
'
]
});
testCommand
(
lines
,
mode
,
selection
,
(
sel
)
=>
new
LineCommentCommand
(
sel
,
4
,
Type
.
ForceAdd
),
expectedLines
,
expectedSelection
);
}
...
...
@@ -520,7 +520,7 @@ suite('Editor Contrib - Line Comment Command', () => {
suite
(
'
Editor Contrib - Line Comment As Block Comment
'
,
()
=>
{
function
testLineCommentCommand
(
lines
:
string
[],
selection
:
Selection
,
expectedLines
:
string
[],
expectedSelection
:
Selection
):
void
{
var
mode
=
new
CommentMode
({
lineComment
Token
:
''
,
blockCommentStartToken
:
'
(
'
,
blockCommentEndToken
:
'
)
'
});
var
mode
=
new
CommentMode
({
lineComment
:
''
,
blockComment
:
[
'
(
'
,
'
)
'
]
});
testCommand
(
lines
,
mode
,
selection
,
(
sel
)
=>
new
LineCommentCommand
(
sel
,
4
,
Type
.
Toggle
),
expectedLines
,
expectedSelection
);
}
...
...
@@ -630,7 +630,7 @@ suite('Editor Contrib - Line Comment As Block Comment', () => {
suite
(
'
Editor Contrib - Line Comment As Block Comment 2
'
,
()
=>
{
function
testLineCommentCommand
(
lines
:
string
[],
selection
:
Selection
,
expectedLines
:
string
[],
expectedSelection
:
Selection
):
void
{
var
mode
=
new
CommentMode
({
lineComment
Token
:
null
,
blockCommentStartToken
:
'
<!@#
'
,
blockCommentEndToken
:
'
#@!>
'
});
var
mode
=
new
CommentMode
({
lineComment
:
null
,
blockComment
:
[
'
<!@#
'
,
'
#@!>
'
]
});
testCommand
(
lines
,
mode
,
selection
,
(
sel
)
=>
new
LineCommentCommand
(
sel
,
4
,
Type
.
Toggle
),
expectedLines
,
expectedSelection
);
}
...
...
src/vs/editor/contrib/smartSelect/test/common/tokenSelectionSupport.test.ts
浏览文件 @
92b91cf3
...
...
@@ -7,20 +7,18 @@
import
*
as
assert
from
'
assert
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
IMode
,
I
RichEditSupport
,
I
ndentAction
}
from
'
vs/editor/common/modes
'
;
import
{
IMode
,
IndentAction
}
from
'
vs/editor/common/modes
'
;
import
{
TokenSelectionSupport
}
from
'
vs/editor/contrib/smartSelect/common/tokenSelectionSupport
'
;
import
{
createMockModelService
}
from
'
vs/editor/test/common/servicesTestUtils
'
;
import
{
MockTokenizingMode
}
from
'
vs/editor/test/common/mocks/mockMode
'
;
import
{
RichEditSupport
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
LanguageConfigurationRegistry
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
class
MockJSMode
extends
MockTokenizingMode
{
public
richEditSupport
:
IRichEditSupport
;
constructor
()
{
super
(
'
js
'
,
'
mock-js
'
);
super
(
'
js
-tokenSelectionSupport
'
,
'
mock-js
'
);
this
.
richEditSupport
=
new
RichEditSupport
(
this
.
getId
(),
null
,
{
LanguageConfigurationRegistry
.
register
(
this
.
getId
()
,
{
brackets
:
[
[
'
(
'
,
'
)
'
],
[
'
{
'
,
'
}
'
],
...
...
src/vs/editor/node/languageConfiguration.ts
浏览文件 @
92b91cf3
...
...
@@ -10,6 +10,7 @@ import {readFile} from 'vs/base/node/pfs';
import
{
IRichLanguageConfiguration
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
IAutoClosingPair
}
from
'
vs/editor/common/modes
'
;
import
{
LanguageConfigurationRegistry
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
type
CharacterPair
=
[
string
,
string
];
...
...
@@ -88,7 +89,7 @@ export class LanguageConfigurationFileHandler {
richEditConfig
.
surroundingPairs
=
this
.
_mapCharacterPairs
(
configuration
.
surroundingPairs
);
}
this
.
_modeService
.
registerRichEditSupport
(
modeId
,
richEditConfig
);
LanguageConfigurationRegistry
.
register
(
modeId
,
richEditConfig
);
}
private
_mapCharacterPairs
(
pairs
:
CharacterPair
[]):
IAutoClosingPair
[]
{
...
...
src/vs/editor/test/common/commands/shiftCommand.test.ts
浏览文件 @
92b91cf3
...
...
@@ -8,8 +8,8 @@ import * as assert from 'assert';
import
{
ShiftCommand
}
from
'
vs/editor/common/commands/shiftCommand
'
;
import
{
Selection
}
from
'
vs/editor/common/core/selection
'
;
import
{
IIdentifiedSingleEditOperation
}
from
'
vs/editor/common/editorCommon
'
;
import
{
I
RichEditSupport
,
I
ndentAction
}
from
'
vs/editor/common/modes
'
;
import
{
RichEditSupport
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
IndentAction
}
from
'
vs/editor/common/modes
'
;
import
{
LanguageConfigurationRegistry
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
createSingleEditOp
,
getEditOperation
,
testCommand
}
from
'
vs/editor/test/common/commands/commandTestUtils
'
;
import
{
withEditorModel
}
from
'
vs/editor/test/common/editorTestUtils
'
;
import
{
MockMode
}
from
'
vs/editor/test/common/mocks/mockMode
'
;
...
...
@@ -32,11 +32,9 @@ function testUnshiftCommand(lines: string[], selection: Selection, expectedLines
class
DocBlockCommentMode
extends
MockMode
{
public
richEditSupport
:
IRichEditSupport
;
constructor
()
{
super
();
this
.
richEditSupport
=
new
RichEditSupport
(
this
.
getId
(),
null
,
{
LanguageConfigurationRegistry
.
register
(
this
.
getId
()
,
{
brackets
:
[
[
'
(
'
,
'
)
'
],
[
'
{
'
,
'
}
'
],
...
...
src/vs/editor/test/common/controller/cursor.test.ts
浏览文件 @
92b91cf3
...
...
@@ -16,10 +16,11 @@ import {
ITokenizedModel
,
IEditOperationBuilder
,
ICursorStateComputerData
}
from
'
vs/editor/common/editorCommon
'
;
import
{
Model
}
from
'
vs/editor/common/model/model
'
;
import
{
IMode
,
I
RichEditSupport
,
I
ndentAction
}
from
'
vs/editor/common/modes
'
;
import
{
RichEditSupport
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
IMode
,
IndentAction
}
from
'
vs/editor/common/modes
'
;
import
{
LanguageConfigurationRegistry
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
MockConfiguration
}
from
'
vs/editor/test/common/mocks/mockConfiguration
'
;
import
{
BracketMode
}
from
'
vs/editor/test/common/testModes
'
;
import
{
MockMode
}
from
'
vs/editor/test/common/mocks/mockMode
'
;
let
H
=
Handler
;
...
...
@@ -1062,41 +1063,26 @@ suite('Editor Controller - Cursor', () => {
});
});
class
TestMode
{
public
getId
():
string
{
return
'
testing
'
;
}
public
toSimplifiedMode
():
IMode
{
return
this
;
}
}
class
SurroundingMode
extends
TestMode
{
public
richEditSupport
:
IRichEditSupport
;
class
SurroundingMode
extends
MockMode
{
constructor
()
{
super
();
this
.
richEditSupport
=
new
RichEditSupport
(
this
.
getId
(),
null
,
{
LanguageConfigurationRegistry
.
register
(
this
.
getId
()
,
{
autoClosingPairs
:
[{
open
:
'
(
'
,
close
:
'
)
'
}]
});
}
}
class
OnEnterMode
extends
TestMode
{
public
richEditSupport
:
IRichEditSupport
;
class
OnEnterMode
extends
MockMode
{
constructor
(
indentAction
:
IndentAction
)
{
super
();
this
.
richEditSupport
=
{
onEnter
:
{
onEnter
:
(
model
,
position
)
=>
{
return
{
indentAction
:
indentAction
};
LanguageConfigurationRegistry
.
register
(
this
.
getId
(),
{
onEnterRules
:
[{
beforeText
:
/.*/
,
action
:
{
indentAction
:
indentAction
}
}
};
}
]
}
)
;
}
}
...
...
src/vs/editor/test/common/mocks/mockMode.ts
浏览文件 @
92b91cf3
...
...
@@ -12,7 +12,7 @@ export class MockMode implements IMode {
private
static
instanceCount
=
0
;
private
_id
:
string
;
constructor
(
id
:
string
=
'
mockMode
'
)
{
constructor
(
id
?:
string
)
{
if
(
typeof
id
===
'
undefined
'
)
{
id
=
'
mockMode
'
+
(
++
MockMode
.
instanceCount
);
}
...
...
src/vs/editor/test/common/mocks/mockModeService.ts
浏览文件 @
92b91cf3
...
...
@@ -9,7 +9,6 @@ import {IDisposable} from 'vs/base/common/lifecycle';
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
ServiceIdentifier
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
*
as
modes
from
'
vs/editor/common/modes
'
;
import
{
IRichLanguageConfiguration
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
IModeService
,
IModeLookupResult
}
from
'
vs/editor/common/services/modeService
'
;
export
class
MockModeService
implements
IModeService
{
...
...
@@ -80,9 +79,6 @@ export class MockModeService implements IModeService {
throw
new
Error
(
'
Not implemented
'
);
}
registerRichEditSupport
(
modeId
:
string
,
support
:
IRichLanguageConfiguration
):
IDisposable
{
throw
new
Error
(
'
Not implemented
'
);
}
registerTokenizationSupport
(
modeId
:
string
,
callback
:
(
mode
:
modes
.
IMode
)
=>
modes
.
ITokenizationSupport
):
IDisposable
{
throw
new
Error
(
'
Not implemented
'
);
}
...
...
src/vs/editor/test/common/modes/tokenization.test.ts
浏览文件 @
92b91cf3
...
...
@@ -104,7 +104,7 @@ export class SwitchingMode extends MockMode {
this
.
tokenizationSupport
=
new
TokenizationSupport
(
this
,
this
,
true
,
false
);
}
registerSupport
<
T
>
(
support
:
modes
.
MutableSupport
,
callback
:(
mode
:
modes
.
IMode
)
=>
T
):
IDisposable
{
setTokenizationSupport
<
T
>
(
callback
:(
mode
:
modes
.
IMode
)
=>
T
):
IDisposable
{
return
EmptyDisposable
;
}
...
...
src/vs/editor/test/common/modesTestUtils.ts
浏览文件 @
92b91cf3
...
...
@@ -6,26 +6,8 @@
import
{
Arrays
}
from
'
vs/editor/common/core/arrays
'
;
import
*
as
modes
from
'
vs/editor/common/modes
'
;
import
{
RichEditSupport
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
MockMode
}
from
'
vs/editor/test/common/mocks/mockMode
'
;
import
{
ModeTransition
}
from
'
vs/editor/common/core/modeTransition
'
;
class
ModeWithRichEditSupport
extends
MockMode
{
public
richEditSupport
:
modes
.
IRichEditSupport
;
constructor
(
id
:
string
,
wordRegExp
:
RegExp
)
{
super
(
id
);
this
.
richEditSupport
=
new
RichEditSupport
(
id
,
null
,
{
wordPattern
:
wordRegExp
});
}
}
export
function
createMockMode
(
id
:
string
,
wordRegExp
:
RegExp
=
null
):
modes
.
IMode
{
return
new
ModeWithRichEditSupport
(
id
,
wordRegExp
);
}
export
interface
TokenText
{
text
:
string
;
type
:
string
;
...
...
src/vs/editor/test/common/testModes.ts
浏览文件 @
92b91cf3
...
...
@@ -6,7 +6,7 @@
import
*
as
modes
from
'
vs/editor/common/modes
'
;
import
{
AbstractState
}
from
'
vs/editor/common/modes/abstractState
'
;
import
{
RichEditSupport
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
LanguageConfigurationRegistry
,
CommentRule
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
TokenizationSupport
}
from
'
vs/editor/common/modes/supports/tokenizationSupport
'
;
import
{
MockMode
}
from
'
vs/editor/test/common/mocks/mockMode
'
;
...
...
@@ -33,17 +33,16 @@ export class CommentState extends AbstractState {
export
class
CommentMode
extends
MockMode
{
public
tokenizationSupport
:
modes
.
ITokenizationSupport
;
public
richEditSupport
:
modes
.
IRichEditSupport
;
constructor
(
commentsConfig
:
modes
.
ICommentsConfiguration
)
{
constructor
(
commentsConfig
:
CommentRule
)
{
super
();
this
.
tokenizationSupport
=
new
TokenizationSupport
(
this
,
{
getInitialState
:
()
=>
new
CommentState
(
this
,
0
)
},
false
,
false
);
this
.
richEditSupport
=
{
comments
:
commentsConfig
};
LanguageConfigurationRegistry
.
register
(
this
.
getId
(),
{
comments
:
commentsConfig
}
)
;
}
}
...
...
@@ -141,11 +140,9 @@ export class ModelMode2 extends MockMode {
export
class
BracketMode
extends
MockMode
{
public
richEditSupport
:
modes
.
IRichEditSupport
;
constructor
()
{
super
();
this
.
richEditSupport
=
new
RichEditSupport
(
this
.
getId
(),
null
,
{
LanguageConfigurationRegistry
.
register
(
this
.
getId
()
,
{
brackets
:
[
[
'
{
'
,
'
}
'
],
[
'
[
'
,
'
]
'
],
...
...
src/vs/languages/css/common/css.ts
浏览文件 @
92b91cf3
...
...
@@ -17,7 +17,7 @@ import {AbstractState} from 'vs/editor/common/modes/abstractState';
import
{
IMarker
}
from
'
vs/platform/markers/common/markers
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IThreadService
,
ThreadAffinity
}
from
'
vs/platform/thread/common/thread
'
;
import
{
RichEditSupport
,
IRichLanguageConfiguration
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
LanguageConfigurationRegistry
,
IRichLanguageConfiguration
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
TokenizationSupport
}
from
'
vs/editor/common/modes/supports/tokenizationSupport
'
;
import
{
wireCancellationToken
}
from
'
vs/base/common/async
'
;
...
...
@@ -302,7 +302,6 @@ export class CSSMode extends AbstractMode {
};
public
tokenizationSupport
:
modes
.
ITokenizationSupport
;
public
richEditSupport
:
modes
.
IRichEditSupport
;
public
inplaceReplaceSupport
:
modes
.
IInplaceReplaceSupport
;
public
configSupport
:
modes
.
IConfigurationSupport
;
...
...
@@ -322,7 +321,7 @@ export class CSSMode extends AbstractMode {
getInitialState
:
()
=>
new
State
(
this
,
States
.
Selector
,
false
,
null
,
false
,
0
)
},
false
,
false
);
this
.
richEditSupport
=
new
RichEditSupport
(
this
.
getId
(),
null
,
CSSMode
.
LANG_CONFIG
);
LanguageConfigurationRegistry
.
register
(
this
.
getId
()
,
CSSMode
.
LANG_CONFIG
);
this
.
inplaceReplaceSupport
=
this
;
this
.
configSupport
=
this
;
...
...
src/vs/languages/css/test/common/css-worker.test.ts
浏览文件 @
92b91cf3
...
...
@@ -14,12 +14,24 @@ import Modes = require('vs/editor/common/modes');
import
WinJS
=
require
(
'
vs/base/common/winjs.base
'
);
import
cssErrors
=
require
(
'
vs/languages/css/common/parser/cssErrors
'
);
import
servicesUtil2
=
require
(
'
vs/editor/test/common/servicesTestUtils
'
);
import
modesUtil
=
require
(
'
vs/editor/test/common/modesTestUtils
'
);
import
{
NULL_THREAD_SERVICE
}
from
'
vs/platform/test/common/nullThreadService
'
;
import
{
IMarker
}
from
'
vs/platform/markers/common/markers
'
;
import
{
MockMode
}
from
'
vs/editor/test/common/mocks/mockMode
'
;
import
{
LanguageConfigurationRegistry
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
export
class
CSSMockMode
extends
MockMode
{
constructor
()
{
super
(
'
css-mock-mode-id
'
);
LanguageConfigurationRegistry
.
register
(
this
.
getId
(),
{
wordPattern
:
/
(
#
?
-
?\d
*
\.\d\w
*%
?)
|
([
@#.:!
]?[\w
-?
]
+%
?)
|
[
@#.!
]
/g
});
}
}
var
cssMockMode
=
new
CSSMockMode
();
export
function
mockMirrorModel
(
content
:
string
,
url
:
URI
=
null
)
:
mm
.
MirrorModel
{
return
mm
.
createTestMirrorModelFromString
(
content
,
modesUtil
.
createMockMode
(
'
mock.mode.id
'
,
/
(
#
?
-
?\d
*
\.\d\w
*%
?)
|
([
@#.:!
]?[\w
-?
]
+%
?)
|
[
@#.!
]
/g
)
,
url
);
return
mm
.
createTestMirrorModelFromString
(
content
,
cssMockMode
,
url
);
}
suite
(
'
Validation - CSS
'
,
()
=>
{
...
...
@@ -39,7 +51,7 @@ suite('Validation - CSS', () => {
resourceService
:
resourceService
,
markerService
:
markerService
});
var
worker
=
new
cssWorker
.
CSSWorker
(
'
mock.mode.
id
'
,
services
.
resourceService
,
services
.
markerService
);
var
worker
=
new
cssWorker
.
CSSWorker
(
'
css-mock-mode-
id
'
,
services
.
resourceService
,
services
.
markerService
);
worker
.
doValidate
([
url
]);
var
markers
=
markerService
.
read
({
resource
:
url
});
...
...
@@ -61,7 +73,7 @@ suite('Validation - CSS', () => {
markerService
:
markerService
});
var
worker
=
new
cssWorker
.
CSSWorker
(
'
mock.mode.
id
'
,
services
.
resourceService
,
services
.
markerService
);
var
worker
=
new
cssWorker
.
CSSWorker
(
'
css-mock-mode-
id
'
,
services
.
resourceService
,
services
.
markerService
);
worker
.
doValidate
([
url
]);
var
markers
=
markerService
.
read
({
resource
:
url
});
...
...
src/vs/languages/handlebars/common/handlebars.ts
浏览文件 @
92b91cf3
...
...
@@ -10,7 +10,7 @@ import handlebarsTokenTypes = require('vs/languages/handlebars/common/handlebars
import
htmlWorker
=
require
(
'
vs/languages/html/common/htmlWorker
'
);
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
RichEditSupport
,
IRichLanguageConfiguration
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
LanguageConfigurationRegistry
,
IRichLanguageConfiguration
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
createWordRegExp
}
from
'
vs/editor/common/modes/abstractMode
'
;
import
{
ILeavingNestedModeData
}
from
'
vs/editor/common/modes/supports/tokenizationSupport
'
;
import
{
IThreadService
}
from
'
vs/platform/thread/common/thread
'
;
...
...
@@ -191,10 +191,8 @@ export class HandlebarsMode extends htmlMode.HTMLMode<htmlWorker.HTMLWorker> {
return
wireCancellationToken
(
token
,
this
.
_provideLinks
(
model
.
uri
));
}
},
true
);
}
protected
_createRichEditSupport
():
modes
.
IRichEditSupport
{
return
new
RichEditSupport
(
this
.
getId
(),
null
,
HandlebarsMode
.
LANG_CONFIG
);
LanguageConfigurationRegistry
.
register
(
this
.
getId
(),
HandlebarsMode
.
LANG_CONFIG
);
}
public
getInitialState
()
:
modes
.
IState
{
...
...
src/vs/languages/html/common/html.ts
浏览文件 @
92b91cf3
...
...
@@ -16,7 +16,7 @@ import {IModeService} from 'vs/editor/common/services/modeService';
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
*
as
htmlTokenTypes
from
'
vs/languages/html/common/htmlTokenTypes
'
;
import
{
EMPTY_ELEMENTS
}
from
'
vs/languages/html/common/htmlEmptyTagsShared
'
;
import
{
RichEditSupport
,
IRichLanguageConfiguration
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
LanguageConfigurationRegistry
,
IRichLanguageConfiguration
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
TokenizationSupport
,
IEnteringNestedModeData
,
ILeavingNestedModeData
,
ITokenizationCustomization
}
from
'
vs/editor/common/modes/supports/tokenizationSupport
'
;
import
{
IThreadService
}
from
'
vs/platform/thread/common/thread
'
;
import
{
wireCancellationToken
}
from
'
vs/base/common/async
'
;
...
...
@@ -328,7 +328,6 @@ export class HTMLMode<W extends htmlWorker.HTMLWorker> extends AbstractMode impl
};
public
tokenizationSupport
:
modes
.
ITokenizationSupport
;
public
richEditSupport
:
modes
.
IRichEditSupport
;
public
configSupport
:
modes
.
IConfigurationSupport
;
private
modeService
:
IModeService
;
...
...
@@ -350,8 +349,6 @@ export class HTMLMode<W extends htmlWorker.HTMLWorker> extends AbstractMode impl
this
.
tokenizationSupport
=
new
TokenizationSupport
(
this
,
this
,
true
,
true
);
this
.
configSupport
=
this
;
this
.
richEditSupport
=
this
.
_createRichEditSupport
();
this
.
_registerSupports
();
}
...
...
@@ -404,6 +401,8 @@ export class HTMLMode<W extends htmlWorker.HTMLWorker> extends AbstractMode impl
return
wireCancellationToken
(
token
,
this
.
_provideLinks
(
model
.
uri
));
}
},
true
);
LanguageConfigurationRegistry
.
register
(
this
.
getId
(),
HTMLMode
.
LANG_CONFIG
);
}
protected
_createModeWorkerManager
(
descriptor
:
modes
.
IModeDescriptor
,
instantiationService
:
IInstantiationService
):
ModeWorkerManager
<
W
>
{
...
...
@@ -414,10 +413,6 @@ export class HTMLMode<W extends htmlWorker.HTMLWorker> extends AbstractMode impl
return
this
.
_modeWorkerManager
.
worker
(
runner
);
}
protected
_createRichEditSupport
():
modes
.
IRichEditSupport
{
return
new
RichEditSupport
(
this
.
getId
(),
null
,
HTMLMode
.
LANG_CONFIG
);
}
// TokenizationSupport
public
getInitialState
():
modes
.
IState
{
...
...
src/vs/languages/html/test/common/html.test.ts
浏览文件 @
92b91cf3
...
...
@@ -21,16 +21,14 @@ import {InstantiationService} from 'vs/platform/instantiation/common/instantiati
import
{
HTMLMode
}
from
'
vs/languages/html/common/html
'
;
import
htmlWorker
=
require
(
'
vs/languages/html/common/htmlWorker
'
);
import
{
MockTokenizingMode
}
from
'
vs/editor/test/common/mocks/mockMode
'
;
import
{
RichEditSupport
,
LanguageConfigurationRegistry
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
LanguageConfigurationRegistry
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
class
MockJSMode
extends
MockTokenizingMode
{
public
richEditSupport
:
Modes
.
IRichEditSupport
;
constructor
()
{
super
(
'
js
'
,
'
mock-js
'
);
super
(
'
html-js-mock
'
,
'
mock-js
'
);
this
.
richEditSupport
=
new
RichEditSupport
(
this
.
getId
(),
null
,
{
LanguageConfigurationRegistry
.
register
(
this
.
getId
()
,
{
brackets
:
[
[
'
(
'
,
'
)
'
],
[
'
{
'
,
'
}
'
],
...
...
src/vs/languages/json/common/json.ts
浏览文件 @
92b91cf3
...
...
@@ -16,7 +16,7 @@ import {OneWorkerAttr, AllWorkersAttr} from 'vs/platform/thread/common/threadSer
import
{
IThreadService
,
ThreadAffinity
}
from
'
vs/platform/thread/common/thread
'
;
import
{
IJSONContributionRegistry
,
Extensions
,
ISchemaContributions
}
from
'
vs/platform/jsonschemas/common/jsonContributionRegistry
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
RichEditSupport
,
IRichLanguageConfiguration
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
LanguageConfigurationRegistry
,
IRichLanguageConfiguration
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
wireCancellationToken
}
from
'
vs/base/common/async
'
;
export
class
JSONMode
extends
AbstractMode
{
...
...
@@ -42,7 +42,6 @@ export class JSONMode extends AbstractMode {
};
public
tokenizationSupport
:
modes
.
ITokenizationSupport
;
public
richEditSupport
:
modes
.
IRichEditSupport
;
public
configSupport
:
modes
.
IConfigurationSupport
;
public
inplaceReplaceSupport
:
modes
.
IInplaceReplaceSupport
;
...
...
@@ -60,7 +59,7 @@ export class JSONMode extends AbstractMode {
this
.
tokenizationSupport
=
tokenization
.
createTokenizationSupport
(
this
,
true
);
this
.
richEditSupport
=
new
RichEditSupport
(
this
.
getId
(),
null
,
JSONMode
.
LANG_CONFIG
);
LanguageConfigurationRegistry
.
register
(
this
.
getId
()
,
JSONMode
.
LANG_CONFIG
);
modes
.
HoverProviderRegistry
.
register
(
this
.
getId
(),
{
provideHover
:
(
model
,
position
,
token
):
Thenable
<
modes
.
Hover
>
=>
{
...
...
src/vs/languages/less/common/less.ts
浏览文件 @
92b91cf3
...
...
@@ -21,7 +21,7 @@ import {IModelService} from 'vs/editor/common/services/modelService';
import
{
IEditorWorkerService
}
from
'
vs/editor/common/services/editorWorkerService
'
;
import
{
wireCancellationToken
}
from
'
vs/base/common/async
'
;
import
{
createTokenizationSupport
}
from
'
vs/editor/common/modes/monarch/monarchLexer
'
;
import
{
RichEditSupport
,
IRichLanguageConfiguration
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
LanguageConfigurationRegistry
,
IRichLanguageConfiguration
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
export
var
language
:
Types
.
ILanguage
=
<
Types
.
ILanguage
>
{
defaultToken
:
''
,
...
...
@@ -189,7 +189,6 @@ export class LESSMode extends AbstractMode {
public
inplaceReplaceSupport
:
modes
.
IInplaceReplaceSupport
;
public
configSupport
:
modes
.
IConfigurationSupport
;
public
tokenizationSupport
:
modes
.
ITokenizationSupport
;
public
richEditSupport
:
modes
.
IRichEditSupport
;
private
modeService
:
IModeService
;
private
_modeWorkerManager
:
ModeWorkerManager
<
lessWorker
.
LessWorker
>
;
...
...
@@ -249,7 +248,7 @@ export class LESSMode extends AbstractMode {
this
.
tokenizationSupport
=
createTokenizationSupport
(
modeService
,
this
,
lexer
);
this
.
richEditSupport
=
new
RichEditSupport
(
this
.
getId
(),
null
,
LESSMode
.
LANG_CONFIG
);
LanguageConfigurationRegistry
.
register
(
this
.
getId
()
,
LESSMode
.
LANG_CONFIG
);
}
public
creationDone
():
void
{
...
...
src/vs/languages/less/test/common/intellisense.test.ts
浏览文件 @
92b91cf3
...
...
@@ -13,23 +13,34 @@ import WinJS = require('vs/base/common/winjs.base');
import
EditorCommon
=
require
(
'
vs/editor/common/editorCommon
'
);
import
Modes
=
require
(
'
vs/editor/common/modes
'
);
import
servicesUtil2
=
require
(
'
vs/editor/test/common/servicesTestUtils
'
);
import
modesUtil
=
require
(
'
vs/editor/test/common/modesTestUtils
'
);
import
{
MockMode
}
from
'
vs/editor/test/common/mocks/mockMode
'
;
import
{
LanguageConfigurationRegistry
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
class
LessMockMode
extends
MockMode
{
constructor
()
{
super
(
'
less-mock-mode-id
'
);
LanguageConfigurationRegistry
.
register
(
this
.
getId
(),
{
wordPattern
:
/
(
-
?\d
*
\.\d
+
)
|
([\w
-
]
+
)
/g
});
}
}
suite
(
'
LESS - Intellisense
'
,
()
=>
{
let
mockMode
=
new
LessMockMode
();
//------------ TEST suggestions ----------------
var
testSuggestionsFor
=
function
(
value
:
string
,
stringBefore
:
string
):
WinJS
.
TPromise
<
Modes
.
ISuggestResult
>
{
var
resourceService
=
new
ResourceService
.
ResourceService
();
var
url
=
URI
.
parse
(
'
test://1
'
);
resourceService
.
insert
(
url
,
mm
.
createTestMirrorModelFromString
(
value
,
mo
desUtil
.
createMockMode
(
'
mock.mode.id
'
,
/
(
-
?\d
*
\.\d
+
)
|
([\w
-
]
+
)
/g
)
,
url
));
resourceService
.
insert
(
url
,
mm
.
createTestMirrorModelFromString
(
value
,
mo
ckMode
,
url
));
let
services
=
servicesUtil2
.
createMockEditorWorkerServices
({
resourceService
:
resourceService
,
});
var
worker
=
new
lessWorker
.
LessWorker
(
'
mock.mode.
id
'
,
services
.
resourceService
,
services
.
markerService
);
var
worker
=
new
lessWorker
.
LessWorker
(
'
less-mock-mode-
id
'
,
services
.
resourceService
,
services
.
markerService
);
var
position
:
EditorCommon
.
IPosition
;
if
(
stringBefore
===
null
)
{
position
=
{
column
:
1
,
lineNumber
:
1
};
...
...
src/vs/languages/markdown/common/markdown.ts
浏览文件 @
92b91cf3
...
...
@@ -20,7 +20,7 @@ import {IConfigurationService} from 'vs/platform/configuration/common/configurat
import
{
IEditorWorkerService
}
from
'
vs/editor/common/services/editorWorkerService
'
;
import
{
AbstractMode
,
ModeWorkerManager
}
from
'
vs/editor/common/modes/abstractMode
'
;
import
{
createTokenizationSupport
}
from
'
vs/editor/common/modes/monarch/monarchLexer
'
;
import
{
RichEditSupport
,
IRichLanguageConfiguration
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
LanguageConfigurationRegistry
,
IRichLanguageConfiguration
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
wireCancellationToken
}
from
'
vs/base/common/async
'
;
export
const
language
=
...
...
@@ -210,7 +210,6 @@ export class MarkdownMode extends AbstractMode implements Modes.IEmitOutputSuppo
public
emitOutputSupport
:
Modes
.
IEmitOutputSupport
;
public
configSupport
:
Modes
.
IConfigurationSupport
;
public
tokenizationSupport
:
Modes
.
ITokenizationSupport
;
public
richEditSupport
:
Modes
.
IRichEditSupport
;
private
_modeWorkerManager
:
ModeWorkerManager
<
MarkdownWorker
.
MarkdownWorker
>
;
private
_threadService
:
IThreadService
;
...
...
@@ -234,7 +233,7 @@ export class MarkdownMode extends AbstractMode implements Modes.IEmitOutputSuppo
this
.
tokenizationSupport
=
createTokenizationSupport
(
modeService
,
this
,
lexer
);
this
.
richEditSupport
=
new
RichEditSupport
(
this
.
getId
(),
null
,
MarkdownMode
.
LANG_CONFIG
);
LanguageConfigurationRegistry
.
register
(
this
.
getId
()
,
MarkdownMode
.
LANG_CONFIG
);
Modes
.
SuggestRegistry
.
register
(
this
.
getId
(),
{
triggerCharacters
:
[],
...
...
src/vs/languages/php/common/php.ts
浏览文件 @
92b91cf3
...
...
@@ -10,7 +10,7 @@ import Modes = require('vs/editor/common/modes');
import
{
AbstractMode
,
isDigit
,
createWordRegExp
}
from
'
vs/editor/common/modes/abstractMode
'
;
import
{
AbstractState
}
from
'
vs/editor/common/modes/abstractState
'
;
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
RichEditSupport
,
IRichLanguageConfiguration
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
LanguageConfigurationRegistry
,
IRichLanguageConfiguration
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
TokenizationSupport
,
ILeavingNestedModeData
,
ITokenizationCustomization
}
from
'
vs/editor/common/modes/supports/tokenizationSupport
'
;
import
{
TextualSuggestSupport
}
from
'
vs/editor/common/modes/supports/suggestSupport
'
;
import
{
IEditorWorkerService
}
from
'
vs/editor/common/services/editorWorkerService
'
;
...
...
@@ -476,7 +476,6 @@ export class PHPMode extends AbstractMode implements ITokenizationCustomization
};
public
tokenizationSupport
:
Modes
.
ITokenizationSupport
;
public
richEditSupport
:
Modes
.
IRichEditSupport
;
private
modeService
:
IModeService
;
...
...
@@ -491,7 +490,7 @@ export class PHPMode extends AbstractMode implements ITokenizationCustomization
this
.
tokenizationSupport
=
new
TokenizationSupport
(
this
,
this
,
true
,
false
);
this
.
richEditSupport
=
new
RichEditSupport
(
this
.
getId
(),
null
,
PHPMode
.
LANG_CONFIG
);
LanguageConfigurationRegistry
.
register
(
this
.
getId
()
,
PHPMode
.
LANG_CONFIG
);
if
(
editorWorkerService
)
{
Modes
.
SuggestRegistry
.
register
(
this
.
getId
(),
new
TextualSuggestSupport
(
editorWorkerService
,
configurationService
),
true
);
...
...
src/vs/languages/razor/common/razor.ts
浏览文件 @
92b91cf3
...
...
@@ -12,7 +12,7 @@ import razorTokenTypes = require('vs/languages/razor/common/razorTokenTypes');
import
{
RAZORWorker
}
from
'
vs/languages/razor/common/razorWorker
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
RichEditSupport
,
IRichLanguageConfiguration
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
LanguageConfigurationRegistry
,
IRichLanguageConfiguration
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
ILeavingNestedModeData
}
from
'
vs/editor/common/modes/supports/tokenizationSupport
'
;
import
{
IThreadService
}
from
'
vs/platform/thread/common/thread
'
;
import
{
wireCancellationToken
}
from
'
vs/base/common/async
'
;
...
...
@@ -139,16 +139,14 @@ export class RAZORMode extends htmlMode.HTMLMode<RAZORWorker> {
return
wireCancellationToken
(
token
,
this
.
_provideLinks
(
model
.
uri
));
}
},
true
);
LanguageConfigurationRegistry
.
register
(
this
.
getId
(),
RAZORMode
.
LANG_CONFIG
);
}
protected
_createModeWorkerManager
(
descriptor
:
modes
.
IModeDescriptor
,
instantiationService
:
IInstantiationService
):
ModeWorkerManager
<
RAZORWorker
>
{
return
new
ModeWorkerManager
<
RAZORWorker
>
(
descriptor
,
'
vs/languages/razor/common/razorWorker
'
,
'
RAZORWorker
'
,
'
vs/languages/html/common/htmlWorker
'
,
instantiationService
);
}
protected
_createRichEditSupport
():
modes
.
IRichEditSupport
{
return
new
RichEditSupport
(
this
.
getId
(),
null
,
RAZORMode
.
LANG_CONFIG
);
}
public
getInitialState
():
modes
.
IState
{
return
new
RAZORState
(
this
,
htmlMode
.
States
.
Content
,
''
,
''
,
''
,
''
,
''
);
}
...
...
src/vs/languages/sass/common/sass.ts
浏览文件 @
92b91cf3
...
...
@@ -21,7 +21,7 @@ import {IModelService} from 'vs/editor/common/services/modelService';
import
{
IEditorWorkerService
}
from
'
vs/editor/common/services/editorWorkerService
'
;
import
{
wireCancellationToken
}
from
'
vs/base/common/async
'
;
import
{
createTokenizationSupport
}
from
'
vs/editor/common/modes/monarch/monarchLexer
'
;
import
{
RichEditSupport
,
IRichLanguageConfiguration
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
LanguageConfigurationRegistry
,
IRichLanguageConfiguration
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
export
var
language
=
<
Types
.
ILanguage
>
{
defaultToken
:
''
,
...
...
@@ -291,7 +291,6 @@ export class SASSMode extends AbstractMode {
public
inplaceReplaceSupport
:
modes
.
IInplaceReplaceSupport
;
public
configSupport
:
modes
.
IConfigurationSupport
;
public
tokenizationSupport
:
modes
.
ITokenizationSupport
;
public
richEditSupport
:
modes
.
IRichEditSupport
;
private
modeService
:
IModeService
;
private
_modeWorkerManager
:
ModeWorkerManager
<
sassWorker
.
SassWorker
>
;
...
...
@@ -350,7 +349,7 @@ export class SASSMode extends AbstractMode {
this
.
tokenizationSupport
=
createTokenizationSupport
(
modeService
,
this
,
lexer
);
this
.
richEditSupport
=
new
RichEditSupport
(
this
.
getId
(),
null
,
SASSMode
.
LANG_CONFIG
);
LanguageConfigurationRegistry
.
register
(
this
.
getId
()
,
SASSMode
.
LANG_CONFIG
);
}
public
creationDone
():
void
{
...
...
src/vs/languages/sass/test/common/sass-worker.test.ts
浏览文件 @
92b91cf3
...
...
@@ -9,24 +9,35 @@ import mm = require('vs/editor/common/model/mirrorModel');
import
sassWorker
=
require
(
'
vs/languages/sass/common/sassWorker
'
);
import
URI
from
'
vs/base/common/uri
'
;
import
ResourceService
=
require
(
'
vs/editor/common/services/resourceServiceImpl
'
);
import
EditorCommon
=
require
(
'
vs/editor/common/editorCommon
'
);
import
Modes
=
require
(
'
vs/editor/common/modes
'
);
import
WinJS
=
require
(
'
vs/base/common/winjs.base
'
);
import
servicesUtil2
=
require
(
'
vs/editor/test/common/servicesTestUtils
'
);
import
modesUtil
=
require
(
'
vs/editor/test/common/modesTestUtils
'
);
import
{
MockMode
}
from
'
vs/editor/test/common/mocks/mockMode
'
;
import
{
LanguageConfigurationRegistry
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
class
SassMockMode
extends
MockMode
{
constructor
()
{
super
(
'
sass-mock-mode-id
'
);
LanguageConfigurationRegistry
.
register
(
this
.
getId
(),
{
wordPattern
:
/
(
#
?
-
?\d
*
\.\d\w
*%
?)
|
([
$@#!
]?[\w
-?
]
+%
?)
|
[
$@#!
]
/g
});
}
}
suite
(
'
SASS - Worker
'
,
()
=>
{
var
mockMode
=
new
SassMockMode
();
var
mockSASSWorkerEnv
=
function
(
url
:
URI
,
content
:
string
)
:
{
worker
:
sassWorker
.
SassWorker
;
model
:
mm
.
MirrorModel
}
{
var
resourceService
=
new
ResourceService
.
ResourceService
();
var
model
=
mm
.
createTestMirrorModelFromString
(
content
,
mo
desUtil
.
createMockMode
(
'
mock.mode.id
'
,
/
(
#
?
-
?\d
*
\.\d\w
*%
?)
|
([
$@#!
]?[\w
-?
]
+%
?)
|
[
$@#!
]
/g
)
,
url
);
var
model
=
mm
.
createTestMirrorModelFromString
(
content
,
mo
ckMode
,
url
);
resourceService
.
insert
(
url
,
model
);
let
services
=
servicesUtil2
.
createMockEditorWorkerServices
({
resourceService
:
resourceService
,
});
var
worker
=
new
sassWorker
.
SassWorker
(
'
mock.mode.
id
'
,
services
.
resourceService
,
services
.
markerService
);
var
worker
=
new
sassWorker
.
SassWorker
(
'
sass-mock-mode-
id
'
,
services
.
resourceService
,
services
.
markerService
);
return
{
worker
:
worker
,
model
:
model
};
};
...
...
src/vs/languages/typescript/common/mode.ts
浏览文件 @
92b91cf3
...
...
@@ -16,6 +16,7 @@ import {LanguageServiceDefaults, typeScriptDefaults, javaScriptDefaults, Languag
import
{
register
}
from
'
./languageFeatures
'
;
import
{
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
*
as
workerManager
from
'
vs/languages/typescript/common/workerManager
'
;
import
{
LanguageConfigurationRegistry
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
function
setupMode
(
modelService
:
IModelService
,
markerService
:
IMarkerService
,
modeService
:
IModeService
,
defaults
:
LanguageServiceDefaults
,
modeId
:
string
,
language
:
Language
):
void
{
...
...
@@ -33,7 +34,7 @@ function setupMode(modelService:IModelService, markerService:IMarkerService, mod
);
disposables
.
push
(
registration
);
disposables
.
push
(
modeService
.
registerRichEditSupport
(
modeId
,
richEditConfiguration
));
disposables
.
push
(
LanguageConfigurationRegistry
.
register
(
modeId
,
richEditConfiguration
));
disposables
.
push
(
modeService
.
registerTokenizationSupport2
(
modeId
,
createTokenizationSupport2
(
language
)));
}
...
...
src/vs/workbench/api/node/extHost.api.impl.ts
浏览文件 @
92b91cf3
...
...
@@ -42,6 +42,7 @@ import vscode = require('vscode');
import
{
TextEditorRevealType
}
from
'
vs/workbench/api/node/mainThreadEditors
'
;
import
*
as
paths
from
'
vs/base/common/paths
'
;
import
{
ITelemetryService
,
ITelemetryInfo
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
LanguageConfigurationRegistry
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
/**
* This class implements the API described in vscode.d.ts,
...
...
@@ -503,6 +504,6 @@ export class MainProcessVSCodeAPIHelper {
}
public
Modes_RichEditSupport_register
(
disposeToken
:
string
,
modeId
:
string
,
configuration
:
vscode
.
LanguageConfiguration
):
void
{
this
.
_token2Dispose
[
disposeToken
]
=
this
.
_modeService
.
registerRichEditSupport
(
modeId
,
<
any
>
configuration
);
this
.
_token2Dispose
[
disposeToken
]
=
LanguageConfigurationRegistry
.
register
(
modeId
,
configuration
);
}
}
\ No newline at end of file
src/vs/workbench/parts/output/common/outputMode.ts
浏览文件 @
92b91cf3
...
...
@@ -18,7 +18,7 @@ import * as modes from 'vs/editor/common/modes';
import
{
IEditorWorkerService
}
from
'
vs/editor/common/services/editorWorkerService
'
;
import
{
AbstractMode
,
ModeWorkerManager
}
from
'
vs/editor/common/modes/abstractMode
'
;
import
{
createTokenizationSupport
}
from
'
vs/editor/common/modes/monarch/monarchLexer
'
;
import
{
RichEditSupport
,
IRichLanguageConfiguration
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
LanguageConfigurationRegistry
,
IRichLanguageConfiguration
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
wireCancellationToken
}
from
'
vs/base/common/async
'
;
export
const
language
:
types
.
ILanguage
=
{
...
...
@@ -59,7 +59,6 @@ export class OutputMode extends AbstractMode {
};
public
tokenizationSupport
:
modes
.
ITokenizationSupport
;
public
richEditSupport
:
modes
.
IRichEditSupport
;
private
_modeWorkerManager
:
ModeWorkerManager
<
OutputWorker
>
;
...
...
@@ -76,7 +75,7 @@ export class OutputMode extends AbstractMode {
this
.
tokenizationSupport
=
createTokenizationSupport
(
modeService
,
this
,
lexer
);
this
.
richEditSupport
=
new
RichEditSupport
(
this
.
getId
(),
null
,
OutputMode
.
LANG_CONFIG
);
LanguageConfigurationRegistry
.
register
(
this
.
getId
()
,
OutputMode
.
LANG_CONFIG
);
modes
.
LinkProviderRegistry
.
register
(
this
.
getId
(),
{
provideLinks
:
(
model
,
token
):
Thenable
<
modes
.
ILink
[]
>
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录