Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
2e90ab00
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,发现更多精彩内容 >>
提交
2e90ab00
编写于
8月 22, 2016
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debt - perform fake typing in suggest model test
上级
72600b1f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
66 addition
and
23 deletion
+66
-23
src/vs/editor/contrib/suggest/test/common/suggestModel.test.ts
...s/editor/contrib/suggest/test/common/suggestModel.test.ts
+66
-23
未找到文件。
src/vs/editor/contrib/suggest/test/common/suggestModel.test.ts
浏览文件 @
2e90ab00
...
...
@@ -10,12 +10,35 @@ import URI from 'vs/base/common/uri';
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
Model
}
from
'
vs/editor/common/model/model
'
;
// import {Handler} from 'vs/editor/common/editorCommon';
// import {Position} from 'vs/editor/common/core/position';
import
{
ICommonCodeEditor
,
Handler
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ISuggestSupport
,
ISuggestResult
,
SuggestRegistry
}
from
'
vs/editor/common/modes
'
;
import
{
SuggestModel
,
Context
}
from
'
vs/editor/contrib/suggest/common/suggestModel
'
;
import
{
Cursor
}
from
'
vs/editor/common/controller/cursor
'
;
import
{
withMockCodeEditor
}
from
'
vs/editor/test/common/mocks/mockCodeEditor
'
;
import
{
MockCodeEditor
,
MockScopeLocation
}
from
'
vs/editor/test/common/mocks/mockCodeEditor
'
;
import
{
ICodeEditorService
}
from
'
vs/editor/common/services/codeEditorService
'
;
import
{
ServiceCollection
}
from
'
vs/platform/instantiation/common/serviceCollection
'
;
import
{
InstantiationService
}
from
'
vs/platform/instantiation/common/instantiationService
'
;
import
{
ICommandService
,
NullCommandService
}
from
'
vs/platform/commands/common/commands
'
;
import
{
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
MockKeybindingService
}
from
'
vs/platform/keybinding/test/common/mockKeybindingService
'
;
import
{
ITelemetryService
,
NullTelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
MockCodeEditorService
}
from
'
vs/editor/test/common/mocks/mockCodeEditorService
'
;
function
createMockEditor
(
model
:
Model
):
MockCodeEditor
{
const
codeEditorService
=
new
MockCodeEditorService
();
const
contextKeyService
=
new
MockKeybindingService
();
const
telemetryService
=
NullTelemetryService
;
const
commandService
=
NullCommandService
;
const
instantiationService
=
new
InstantiationService
(
new
ServiceCollection
(
[
ICodeEditorService
,
codeEditorService
],
[
IContextKeyService
,
contextKeyService
],
[
ITelemetryService
,
telemetryService
],
[
ICommandService
,
commandService
]
));
const
editor
=
new
MockCodeEditor
(
new
MockScopeLocation
(),
{},
instantiationService
,
codeEditorService
,
commandService
,
contextKeyService
,
telemetryService
);
editor
.
setModel
(
model
);
return
editor
;
}
suite
(
'
SuggestModel - Context
'
,
function
()
{
...
...
@@ -81,6 +104,21 @@ suite('SuggestModel - TriggerAndCancelOracle', function () {
}
};
const
alwaysSomethingSupport
:
ISuggestSupport
=
{
triggerCharacters
:
[],
provideCompletionItems
(
doc
,
pos
)
{
return
<
ISuggestResult
>
{
currentWord
:
''
,
incomplete
:
false
,
suggestions
:
[{
label
:
doc
.
getWordUntilPosition
(
pos
).
word
,
type
:
'
property
'
,
insertText
:
'
foofoo
'
}]
};
}
};
let
disposables
:
IDisposable
[]
=
[];
let
model
:
Model
;
...
...
@@ -90,22 +128,18 @@ suite('SuggestModel - TriggerAndCancelOracle', function () {
disposables
.
push
(
model
);
});
function
withOracle
(
callback
:
(
model
:
SuggestModel
,
cursor
:
Curs
or
)
=>
any
):
TPromise
<
any
>
{
function
withOracle
(
callback
:
(
model
:
SuggestModel
,
editor
:
ICommonCodeEdit
or
)
=>
any
):
TPromise
<
any
>
{
let
oracle
:
SuggestModel
;
return
new
TPromise
((
resolve
,
reject
)
=>
{
withMockCodeEditor
([],
{},
(
editor
,
cursor
)
=>
{
editor
.
setModel
(
model
);
oracle
=
new
SuggestModel
(
editor
);
try
{
resolve
(
callback
(
oracle
,
cursor
));
}
catch
(
err
)
{
reject
(
err
);
}
});
}).
then
(
r
=>
{
oracle
.
dispose
();
return
r
;
const
editor
=
createMockEditor
(
model
);
const
oracle
=
new
SuggestModel
(
editor
);
disposables
.
push
(
oracle
,
editor
);
try
{
resolve
(
callback
(
oracle
,
editor
));
}
catch
(
err
)
{
reject
(
err
);
}
});
}
...
...
@@ -195,13 +229,22 @@ suite('SuggestModel - TriggerAndCancelOracle', function () {
});
});
//
test('trigger - on type', function () {
test
(
'
trigger - on type
'
,
function
()
{
// return withOracle((model, cursor) => {
disposables
.
push
(
SuggestRegistry
.
register
({
scheme
:
'
test
'
},
alwaysSomethingSupport
));
// cursor.trigger('keyboard', Handler.MoveTo, { position: new Position(1, 4) });
return
withOracle
((
model
,
editor
)
=>
{
return
assertEvent
(
model
.
onDidSuggest
,
()
=>
{
editor
.
setPosition
({
lineNumber
:
1
,
column
:
4
});
editor
.
trigger
(
'
keyboard
'
,
Handler
.
Type
,
{
text
:
'
d
'
});
// });
},
event
=>
{
assert
.
equal
(
event
.
auto
,
true
);
assert
.
equal
(
event
.
completionModel
.
items
.
length
,
1
);
const
[
first
]
=
event
.
completionModel
.
items
;
// });
assert
.
equal
(
first
.
support
,
alwaysSomethingSupport
);
});
});
});
});
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录