Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
徽霖
Vscode
提交
3af5cc78
V
Vscode
项目概览
徽霖
/
Vscode
通知
9
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,发现更多精彩内容 >>
提交
3af5cc78
编写于
4月 07, 2016
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Each test instantiates its own mode
上级
84503d54
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
166 addition
and
66 deletion
+166
-66
src/vs/editor/contrib/smartSelect/common/tokenTree.ts
src/vs/editor/contrib/smartSelect/common/tokenTree.ts
+12
-6
src/vs/editor/contrib/smartSelect/test/common/tokenSelectionSupport.test.ts
...rib/smartSelect/test/common/tokenSelectionSupport.test.ts
+46
-12
src/vs/editor/test/common/modesUtil.ts
src/vs/editor/test/common/modesUtil.ts
+0
-12
src/vs/languages/css/test/common/css.test.ts
src/vs/languages/css/test/common/css.test.ts
+19
-9
src/vs/languages/html/test/common/html-worker.test.ts
src/vs/languages/html/test/common/html-worker.test.ts
+20
-6
src/vs/languages/html/test/common/html.test.ts
src/vs/languages/html/test/common/html.test.ts
+1
-1
src/vs/languages/json/test/common/json.test.ts
src/vs/languages/json/test/common/json.test.ts
+19
-7
src/vs/languages/razor/test/common/razor.test.ts
src/vs/languages/razor/test/common/razor.test.ts
+23
-6
src/vs/languages/sass/test/common/sass.test.ts
src/vs/languages/sass/test/common/sass.test.ts
+26
-7
未找到文件。
src/vs/editor/contrib/smartSelect/common/tokenTree.ts
浏览文件 @
3af5cc78
...
...
@@ -164,6 +164,7 @@ class TokenScanner {
let
tokenType
=
this
.
_currentLineTokens
.
getTokenType
(
this
.
_currentTokenIndex
);
let
tokenEndIndex
=
this
.
_currentLineTokens
.
getTokenEndIndex
(
this
.
_currentTokenIndex
,
this
.
_currentLineText
.
length
);
let
tmpTokenEndIndex
=
tokenEndIndex
;
let
nextBracket
:
Range
=
null
;
if
(
this
.
_currentModeBrackets
&&
!
ignoreBracketsInToken
(
tokenType
))
{
...
...
@@ -172,7 +173,7 @@ class TokenScanner {
if
(
nextBracket
&&
this
.
_currentTokenStart
<
nextBracket
.
startColumn
-
1
)
{
// found a bracket, but it is not at the beginning of the token
tokenEndIndex
=
nextBracket
.
startColumn
-
1
;
t
mpT
okenEndIndex
=
nextBracket
.
startColumn
-
1
;
nextBracket
=
null
;
}
...
...
@@ -192,13 +193,18 @@ class TokenScanner {
startLineNumber
:
this
.
_currentLineNumber
,
startColumn
:
1
+
this
.
_currentTokenStart
,
endLineNumber
:
this
.
_currentLineNumber
,
endColumn
:
1
+
tokenEndIndex
endColumn
:
1
+
t
mpT
okenEndIndex
}
};
// console.log('TOKEN: <<' + this._currentLineText.substring(this._currentTokenStart, tokenEndIndex) + '>>');
this
.
_currentTokenIndex
+=
1
;
this
.
_currentTokenStart
=
(
this
.
_currentTokenIndex
<
this
.
_currentLineTokens
.
getTokenCount
()
?
this
.
_currentLineTokens
.
getTokenStartIndex
(
this
.
_currentTokenIndex
)
:
0
);
// console.log('TOKEN: <<' + this._currentLineText.substring(this._currentTokenStart, tmpTokenEndIndex) + '>>');
if
(
tmpTokenEndIndex
<
tokenEndIndex
)
{
// there is a bracket somewhere in this token...
this
.
_currentTokenStart
=
tmpTokenEndIndex
;
}
else
{
this
.
_currentTokenIndex
+=
1
;
this
.
_currentTokenStart
=
(
this
.
_currentTokenIndex
<
this
.
_currentLineTokens
.
getTokenCount
()
?
this
.
_currentLineTokens
.
getTokenStartIndex
(
this
.
_currentTokenIndex
)
:
0
);
}
return
token
;
}
...
...
src/vs/editor/contrib/smartSelect/test/common/tokenSelectionSupport.test.ts
浏览文件 @
3af5cc78
...
...
@@ -4,27 +4,61 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
'
vs/languages/typescript/common/typescript.contribution
'
;
import
*
as
assert
from
'
assert
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
IMode
}
from
'
vs/editor/common/modes
'
;
import
{
IMode
,
IRichEditSupport
,
IndentAction
}
from
'
vs/editor/common/modes
'
;
import
{
TokenSelectionSupport
}
from
'
vs/editor/contrib/smartSelect/common/tokenSelectionSupport
'
;
import
{
load
}
from
'
vs/editor/test/common/modesUtil
'
;
import
{
createMockModelService
}
from
'
vs/editor/test/common/servicesTestUtils
'
;
import
{
MockTokenizingMode
}
from
'
vs/editor/test/common/mocks/mockMode
'
;
import
{
RichEditSupport
}
from
'
vs/editor/common/modes/supports/richEditSupport
'
;
class
MockJSMode
extends
MockTokenizingMode
{
public
richEditSupport
:
IRichEditSupport
;
constructor
()
{
super
(
'
js
'
,
'
mock-js
'
);
this
.
richEditSupport
=
new
RichEditSupport
(
this
.
getId
(),
null
,
{
brackets
:
[
[
'
(
'
,
'
)
'
],
[
'
{
'
,
'
}
'
],
[
'
[
'
,
'
]
'
]
],
onEnterRules
:
[
{
// e.g. /** | */
beforeText
:
/^
\s
*
\/\*\*(?!\/)([^\*]
|
\*(?!\/))
*$/
,
afterText
:
/^
\s
*
\*\/
$/
,
action
:
{
indentAction
:
IndentAction
.
IndentOutdent
,
appendText
:
'
*
'
}
},
{
// e.g. /** ...|
beforeText
:
/^
\s
*
\/\*\*(?!\/)([^\*]
|
\*(?!\/))
*$/
,
action
:
{
indentAction
:
IndentAction
.
None
,
appendText
:
'
*
'
}
},
{
// e.g. * ...|
beforeText
:
/^
(\t
|
(\ \ ))
*
\ \*(\ ([^\*]
|
\*(?!\/))
*
)?
$/
,
action
:
{
indentAction
:
IndentAction
.
None
,
appendText
:
'
*
'
}
},
{
// e.g. */|
beforeText
:
/^
(\t
|
(\ \ ))
*
\ \*\/\s
*$/
,
action
:
{
indentAction
:
IndentAction
.
None
,
removeText
:
1
}
}
]
});
}
}
suite
(
'
TokenSelectionSupport
'
,
()
=>
{
let
modelService
=
createMockModelService
();
let
tokenSelectionSupport
=
new
TokenSelectionSupport
(
modelService
);
let
_mode
:
IMode
;
suiteSetup
((
done
)
=>
{
load
(
'
javascript
'
).
then
(
mode
=>
{
_mode
=
mode
;
done
();
});
});
let
_mode
:
IMode
=
new
MockJSMode
();
function
assertGetRangesToPosition
(
text
:
string
[],
lineNumber
:
number
,
column
:
number
,
ranges
:
Range
[]):
void
{
let
uri
=
URI
.
file
(
'
test.js
'
);
...
...
@@ -62,7 +96,7 @@ suite('TokenSelectionSupport', () => {
new
Range
(
3
,
11
,
3
,
26
),
new
Range
(
3
,
17
,
3
,
26
),
new
Range
(
3
,
18
,
3
,
25
),
new
Range
(
3
,
19
,
3
,
20
)
//
new Range(3, 19, 3, 20)
]);
});
});
\ No newline at end of file
src/vs/editor/test/common/modesUtil.ts
浏览文件 @
3af5cc78
...
...
@@ -28,18 +28,6 @@ export function assertWords(actual:string[], expected:string[], message?:string)
assert
.
deepEqual
(
actual
,
expected
,
message
);
}
export
function
load
(
modeId
:
string
,
preloadModes
:
string
[]
=
[]
):
TPromise
<
modes
.
IMode
>
{
var
toLoad
:
string
[]
=
[].
concat
(
preloadModes
).
concat
([
modeId
]);
var
modeService
=
createMockModeService
();
var
promises
=
toLoad
.
map
(
modeId
=>
modeService
.
getOrCreateMode
(
modeId
));
return
TPromise
.
join
(
promises
).
then
(
modes
=>
{
return
modes
[
modes
.
length
-
1
];
});
}
export
function
assertTokenization
(
tokenizationSupport
:
modes
.
ITokenizationSupport
,
tests
:
ITestItem
[]):
void
{
var
state
=
tokenizationSupport
.
getInitialState
();
for
(
var
i
=
0
,
len
=
tests
.
length
;
i
<
len
;
i
++
)
{
...
...
src/vs/languages/css/test/common/css.test.ts
浏览文件 @
3af5cc78
...
...
@@ -4,12 +4,13 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
'
vs/languages/css/common/css.contribution
'
;
import
cssMode
=
require
(
'
vs/languages/css/common/css
'
);
import
EditorCommon
=
require
(
'
vs/editor/common/editorCommon
'
);
import
Modes
=
require
(
'
vs/editor/common/modes
'
);
import
modesUtil
=
require
(
'
vs/editor/test/common/modesUtil
'
);
import
{
cssTokenTypes
}
from
'
vs/languages/css/common/css
'
;
import
{
cssTokenTypes
,
CSSMode
}
from
'
vs/languages/css/common/css
'
;
import
{
NULL_THREAD_SERVICE
}
from
'
vs/platform/test/common/nullThreadService
'
;
import
{
createInstantiationService
}
from
'
vs/platform/instantiation/common/instantiationService
'
;
suite
(
'
CSS Colorizing
'
,
()
=>
{
...
...
@@ -18,14 +19,23 @@ suite('CSS Colorizing', () => {
var
tokenizationSupport
:
Modes
.
ITokenizationSupport
;
var
assertOnEnter
:
modesUtil
.
IOnEnterAsserter
;
suiteSetup
((
done
)
=>
{
modesUtil
.
load
(
'
css
'
).
then
(
mode
=>
{
tokenizationSupport
=
mode
.
tokenizationSupport
;
assertOnEnter
=
modesUtil
.
createOnEnterAsserter
(
mode
.
getId
(),
mode
.
richEditSupport
);
wordDefinition
=
mode
.
richEditSupport
.
wordDefinition
;
done
();
(
function
()
{
let
threadService
=
NULL_THREAD_SERVICE
;
let
inst
=
createInstantiationService
({
threadService
:
threadService
,
});
});
threadService
.
setInstantiationService
(
inst
);
let
mode
=
new
CSSMode
(
{
id
:
'
css
'
},
inst
,
threadService
);
tokenizationSupport
=
mode
.
tokenizationSupport
;
assertOnEnter
=
modesUtil
.
createOnEnterAsserter
(
mode
.
getId
(),
mode
.
richEditSupport
);
wordDefinition
=
mode
.
richEditSupport
.
wordDefinition
;
})();
test
(
'
Skip whitespace
'
,
()
=>
{
modesUtil
.
assertTokenization
(
tokenizationSupport
,
[{
...
...
src/vs/languages/html/test/common/html-worker.test.ts
浏览文件 @
3af5cc78
...
...
@@ -4,7 +4,6 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
'
vs/languages/html/common/html.contribution
'
;
import
assert
=
require
(
'
assert
'
);
import
mm
=
require
(
'
vs/editor/common/model/mirrorModel
'
);
import
htmlWorker
=
require
(
'
vs/languages/html/common/htmlWorker
'
);
...
...
@@ -16,17 +15,32 @@ import WinJS = require('vs/base/common/winjs.base');
import
modesUtil
=
require
(
'
vs/editor/test/common/modesUtil
'
);
import
servicesUtil2
=
require
(
'
vs/editor/test/common/servicesTestUtils
'
);
import
{
NULL_THREAD_SERVICE
}
from
'
vs/platform/test/common/nullThreadService
'
;
import
{
HTMLMode
}
from
'
vs/languages/html/common/html
'
;
import
{
createInstantiationService
}
from
'
vs/platform/instantiation/common/instantiationService
'
;
import
{
MockModeService
}
from
'
vs/editor/test/common/mocks/mockModeService
'
;
suite
(
'
HTML - worker
'
,
()
=>
{
var
mode
:
Modes
.
IMode
;
suiteSetup
((
done
)
=>
{
modesUtil
.
load
(
'
html
'
).
then
(
_mode
=>
{
mode
=
_mode
;
done
();
(
function
()
{
let
threadService
=
NULL_THREAD_SERVICE
;
let
modeService
=
new
MockModeService
();
let
inst
=
createInstantiationService
({
threadService
:
threadService
,
modeService
:
modeService
});
});
threadService
.
setInstantiationService
(
inst
);
mode
=
new
HTMLMode
<
htmlWorker
.
HTMLWorker
>
(
{
id
:
'
html
'
},
inst
,
modeService
,
threadService
);
})();
var
mockHtmlWorkerEnv
=
function
(
url
:
URI
,
content
:
string
):
{
worker
:
htmlWorker
.
HTMLWorker
;
model
:
mm
.
MirrorModel
;
}
{
var
resourceService
=
new
ResourceService
.
ResourceService
();
...
...
src/vs/languages/html/test/common/html.test.ts
浏览文件 @
3af5cc78
...
...
@@ -22,7 +22,7 @@ import htmlWorker = require('vs/languages/html/common/htmlWorker');
import
{
MockTokenizingMode
}
from
'
vs/editor/test/common/mocks/mockMode
'
;
import
{
RichEditSupport
}
from
'
vs/editor/common/modes/supports/richEditSupport
'
;
export
class
MockJSMode
extends
MockTokenizingMode
{
class
MockJSMode
extends
MockTokenizingMode
{
public
richEditSupport
:
Modes
.
IRichEditSupport
;
...
...
src/vs/languages/json/test/common/json.test.ts
浏览文件 @
3af5cc78
...
...
@@ -4,26 +4,38 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
'
vs/languages/json/common/json.contribution
'
;
import
jsonMode
=
require
(
'
vs/languages/json/common/json
'
);
import
EditorCommon
=
require
(
'
vs/editor/common/editorCommon
'
);
import
Modes
=
require
(
'
vs/editor/common/modes
'
);
import
modesUtil
=
require
(
'
vs/editor/test/common/modesUtil
'
);
import
tokenization
=
require
(
'
vs/languages/json/common/features/tokenization
'
);
import
jsonTokenTypes
=
require
(
'
vs/languages/json/common/features/jsonTokenTypes
'
);
import
{
NULL_THREAD_SERVICE
}
from
'
vs/platform/test/common/nullThreadService
'
;
import
{
createInstantiationService
}
from
'
vs/platform/instantiation/common/instantiationService
'
;
suite
(
'
JSON - tokenization
'
,
()
=>
{
var
tokenizationSupport
:
Modes
.
ITokenizationSupport
;
var
assertOnEnter
:
modesUtil
.
IOnEnterAsserter
;
setup
((
done
)
=>
{
modesUtil
.
load
(
'
json
'
).
then
(
mode
=>
{
tokenizationSupport
=
mode
.
tokenizationSupport
;
assertOnEnter
=
modesUtil
.
createOnEnterAsserter
(
mode
.
getId
(),
mode
.
richEditSupport
);
done
();
(
function
()
{
let
threadService
=
NULL_THREAD_SERVICE
;
let
inst
=
createInstantiationService
({
threadService
:
threadService
});
});
threadService
.
setInstantiationService
(
inst
);
let
mode
=
new
jsonMode
.
JSONMode
(
{
id
:
'
json
'
},
inst
,
threadService
)
tokenizationSupport
=
mode
.
tokenizationSupport
;
assertOnEnter
=
modesUtil
.
createOnEnterAsserter
(
mode
.
getId
(),
mode
.
richEditSupport
);
})();
test
(
''
,
()
=>
{
modesUtil
.
executeTests
(
tokenizationSupport
,[
...
...
src/vs/languages/razor/test/common/razor.test.ts
浏览文件 @
3af5cc78
...
...
@@ -4,21 +4,38 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
'
vs/languages/razor/common/razor.contribution
'
;
import
modesUtil
=
require
(
'
vs/editor/test/common/modesUtil
'
);
import
Modes
=
require
(
'
vs/editor/common/modes
'
);
import
razorTokenTypes
=
require
(
'
vs/languages/razor/common/razorTokenTypes
'
);
import
{
htmlTokenTypes
}
from
'
vs/languages/html/common/html
'
;
import
{
RAZORMode
}
from
'
vs/languages/razor/common/razor
'
;
import
{
NULL_THREAD_SERVICE
}
from
'
vs/platform/test/common/nullThreadService
'
;
import
{
MockModeService
}
from
'
vs/editor/test/common/mocks/mockModeService
'
;
import
{
createInstantiationService
}
from
'
vs/platform/instantiation/common/instantiationService
'
;
suite
(
'
Syntax Highlighting - Razor
'
,
()
=>
{
var
tokenizationSupport
:
Modes
.
ITokenizationSupport
;
setup
((
done
)
=>
{
modesUtil
.
load
(
'
razor
'
).
then
(
mode
=>
{
tokenizationSupport
=
mode
.
tokenizationSupport
;
done
();
(
function
()
{
let
threadService
=
NULL_THREAD_SERVICE
;
let
modeService
=
new
MockModeService
();
let
inst
=
createInstantiationService
({
threadService
:
threadService
,
modeService
:
modeService
});
});
threadService
.
setInstantiationService
(
inst
);
let
mode
=
new
RAZORMode
(
{
id
:
'
razor
'
},
inst
,
modeService
,
threadService
);
tokenizationSupport
=
mode
.
tokenizationSupport
;
})();
test
(
''
,
()
=>
{
modesUtil
.
executeTests
(
tokenizationSupport
,[
...
...
src/vs/languages/sass/test/common/sass.test.ts
浏览文件 @
3af5cc78
...
...
@@ -4,24 +4,43 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
'
vs/languages/sass/common/sass.contribution
'
;
import
SASS
=
require
(
'
vs/languages/sass/common/sass
'
);
import
modesUtil
=
require
(
'
vs/editor/test/common/modesUtil
'
);
import
Modes
=
require
(
'
vs/editor/common/modes
'
);
import
*
as
sassTokenTypes
from
'
vs/languages/sass/common/sassTokenTypes
'
;
import
{
NULL_THREAD_SERVICE
}
from
'
vs/platform/test/common/nullThreadService
'
;
import
{
MockModeService
}
from
'
vs/editor/test/common/mocks/mockModeService
'
;
import
{
createInstantiationService
}
from
'
vs/platform/instantiation/common/instantiationService
'
;
suite
(
'
Sass Colorizer
'
,
()
=>
{
var
tokenizationSupport
:
Modes
.
ITokenizationSupport
;
var
assertOnEnter
:
modesUtil
.
IOnEnterAsserter
;
setup
((
done
)
=>
{
modesUtil
.
load
(
'
sass
'
).
then
(
mode
=>
{
tokenizationSupport
=
mode
.
tokenizationSupport
;
assertOnEnter
=
modesUtil
.
createOnEnterAsserter
(
mode
.
getId
(),
mode
.
richEditSupport
);
done
();
(
function
()
{
let
threadService
=
NULL_THREAD_SERVICE
;
let
modeService
=
new
MockModeService
();
let
inst
=
createInstantiationService
({
threadService
:
threadService
,
modeService
:
modeService
});
});
threadService
.
setInstantiationService
(
inst
);
let
mode
=
new
SASS
.
SASSMode
(
{
id
:
'
sass
'
},
inst
,
threadService
,
modeService
,
null
,
null
);
tokenizationSupport
=
mode
.
tokenizationSupport
;
assertOnEnter
=
modesUtil
.
createOnEnterAsserter
(
mode
.
getId
(),
mode
.
richEditSupport
);
})();
test
(
''
,
()
=>
{
modesUtil
.
executeTests
(
tokenizationSupport
,
[
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录