Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
d166de9a
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,发现更多精彩内容 >>
提交
d166de9a
编写于
10月 23, 2020
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
log/telemetry for completion durations,
https://github.com/microsoft/vscode/issues/109167
上级
96d61842
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
55 addition
and
18 deletion
+55
-18
src/vs/editor/contrib/suggest/suggest.ts
src/vs/editor/contrib/suggest/suggest.ts
+4
-2
src/vs/editor/contrib/suggest/suggestController.ts
src/vs/editor/contrib/suggest/suggestController.ts
+1
-5
src/vs/editor/contrib/suggest/suggestModel.ts
src/vs/editor/contrib/suggest/suggestModel.ts
+46
-10
src/vs/editor/contrib/suggest/test/suggestModel.test.ts
src/vs/editor/contrib/suggest/test/suggestModel.test.ts
+4
-1
未找到文件。
src/vs/editor/contrib/suggest/suggest.ts
浏览文件 @
d166de9a
...
@@ -166,7 +166,7 @@ export function setSnippetSuggestSupport(support: modes.CompletionItemProvider):
...
@@ -166,7 +166,7 @@ export function setSnippetSuggestSupport(support: modes.CompletionItemProvider):
}
}
export
interface
CompletionDurationEntry
{
export
interface
CompletionDurationEntry
{
readonly
provider
:
modes
.
CompletionItemProvider
;
readonly
provider
Name
:
string
;
readonly
elapsedProvider
:
number
;
readonly
elapsedProvider
:
number
;
readonly
elapsedOverall
:
number
;
readonly
elapsedOverall
:
number
;
}
}
...
@@ -228,7 +228,9 @@ export async function provideSuggestionItems(
...
@@ -228,7 +228,9 @@ export async function provideSuggestionItems(
if
(
isDisposable
(
container
))
{
if
(
isDisposable
(
container
))
{
disposables
.
add
(
container
);
disposables
.
add
(
container
);
}
}
durations
.
push
({
provider
,
elapsedProvider
:
container
.
duration
??
-
1
,
elapsedOverall
:
sw
.
elapsed
()
});
durations
.
push
({
providerName
:
provider
.
_debugDisplayName
??
'
unkown_provider
'
,
elapsedProvider
:
container
.
duration
??
-
1
,
elapsedOverall
:
sw
.
elapsed
()
});
};
};
// ask for snippets in parallel to asking "real" providers. Only do something if configured to
// ask for snippets in parallel to asking "real" providers. Only do something if configured to
...
...
src/vs/editor/contrib/suggest/suggestController.ts
浏览文件 @
d166de9a
...
@@ -30,7 +30,6 @@ import { State, SuggestModel } from './suggestModel';
...
@@ -30,7 +30,6 @@ import { State, SuggestModel } from './suggestModel';
import
{
ISelectedSuggestion
,
SuggestWidget
}
from
'
./suggestWidget
'
;
import
{
ISelectedSuggestion
,
SuggestWidget
}
from
'
./suggestWidget
'
;
import
{
WordContextKey
}
from
'
vs/editor/contrib/suggest/wordContextKey
'
;
import
{
WordContextKey
}
from
'
vs/editor/contrib/suggest/wordContextKey
'
;
import
{
Event
}
from
'
vs/base/common/event
'
;
import
{
Event
}
from
'
vs/base/common/event
'
;
import
{
IEditorWorkerService
}
from
'
vs/editor/common/services/editorWorkerService
'
;
import
{
IdleValue
}
from
'
vs/base/common/async
'
;
import
{
IdleValue
}
from
'
vs/base/common/async
'
;
import
{
isObject
,
assertType
}
from
'
vs/base/common/types
'
;
import
{
isObject
,
assertType
}
from
'
vs/base/common/types
'
;
import
{
CommitCharacterController
}
from
'
./suggestCommitCharacters
'
;
import
{
CommitCharacterController
}
from
'
./suggestCommitCharacters
'
;
...
@@ -43,7 +42,6 @@ import { MenuRegistry } from 'vs/platform/actions/common/actions';
...
@@ -43,7 +42,6 @@ import { MenuRegistry } from 'vs/platform/actions/common/actions';
import
{
CancellationTokenSource
}
from
'
vs/base/common/cancellation
'
;
import
{
CancellationTokenSource
}
from
'
vs/base/common/cancellation
'
;
import
{
ILogService
}
from
'
vs/platform/log/common/log
'
;
import
{
ILogService
}
from
'
vs/platform/log/common/log
'
;
import
{
StopWatch
}
from
'
vs/base/common/stopwatch
'
;
import
{
StopWatch
}
from
'
vs/base/common/stopwatch
'
;
import
{
IClipboardService
}
from
'
vs/platform/clipboard/common/clipboardService
'
;
// sticky suggest widget which doesn't disappear on focus out and such
// sticky suggest widget which doesn't disappear on focus out and such
let
_sticky
=
false
;
let
_sticky
=
false
;
...
@@ -117,16 +115,14 @@ export class SuggestController implements IEditorContribution {
...
@@ -117,16 +115,14 @@ export class SuggestController implements IEditorContribution {
constructor
(
constructor
(
editor
:
ICodeEditor
,
editor
:
ICodeEditor
,
@
IEditorWorkerService
editorWorker
:
IEditorWorkerService
,
@
ISuggestMemoryService
private
readonly
_memoryService
:
ISuggestMemoryService
,
@
ISuggestMemoryService
private
readonly
_memoryService
:
ISuggestMemoryService
,
@
ICommandService
private
readonly
_commandService
:
ICommandService
,
@
ICommandService
private
readonly
_commandService
:
ICommandService
,
@
IContextKeyService
private
readonly
_contextKeyService
:
IContextKeyService
,
@
IContextKeyService
private
readonly
_contextKeyService
:
IContextKeyService
,
@
IInstantiationService
private
readonly
_instantiationService
:
IInstantiationService
,
@
IInstantiationService
private
readonly
_instantiationService
:
IInstantiationService
,
@
ILogService
private
readonly
_logService
:
ILogService
,
@
ILogService
private
readonly
_logService
:
ILogService
,
@
IClipboardService
clipboardService
:
IClipboardService
,
)
{
)
{
this
.
editor
=
editor
;
this
.
editor
=
editor
;
this
.
model
=
new
SuggestModel
(
this
.
editor
,
editorWorker
,
clipboardService
);
this
.
model
=
_instantiationService
.
createInstance
(
SuggestModel
,
this
.
editor
,
);
this
.
widget
=
this
.
_toDispose
.
add
(
new
IdleValue
(()
=>
{
this
.
widget
=
this
.
_toDispose
.
add
(
new
IdleValue
(()
=>
{
...
...
src/vs/editor/contrib/suggest/suggestModel.ts
浏览文件 @
d166de9a
...
@@ -14,7 +14,7 @@ import { Selection } from 'vs/editor/common/core/selection';
...
@@ -14,7 +14,7 @@ import { Selection } from 'vs/editor/common/core/selection';
import
{
ITextModel
,
IWordAtPosition
}
from
'
vs/editor/common/model
'
;
import
{
ITextModel
,
IWordAtPosition
}
from
'
vs/editor/common/model
'
;
import
{
CompletionItemProvider
,
StandardTokenType
,
CompletionContext
,
CompletionProviderRegistry
,
CompletionTriggerKind
,
CompletionItemKind
}
from
'
vs/editor/common/modes
'
;
import
{
CompletionItemProvider
,
StandardTokenType
,
CompletionContext
,
CompletionProviderRegistry
,
CompletionTriggerKind
,
CompletionItemKind
}
from
'
vs/editor/common/modes
'
;
import
{
CompletionModel
}
from
'
./completionModel
'
;
import
{
CompletionModel
}
from
'
./completionModel
'
;
import
{
CompletionItem
,
getSuggestionComparator
,
provideSuggestionItems
,
getSnippetSuggestSupport
,
SnippetSortOrder
,
CompletionOptions
}
from
'
./suggest
'
;
import
{
CompletionItem
,
getSuggestionComparator
,
provideSuggestionItems
,
getSnippetSuggestSupport
,
SnippetSortOrder
,
CompletionOptions
,
CompletionDurations
}
from
'
./suggest
'
;
import
{
SnippetController2
}
from
'
vs/editor/contrib/snippet/snippetController2
'
;
import
{
SnippetController2
}
from
'
vs/editor/contrib/snippet/snippetController2
'
;
import
{
CancellationTokenSource
}
from
'
vs/base/common/cancellation
'
;
import
{
CancellationTokenSource
}
from
'
vs/base/common/cancellation
'
;
import
{
IEditorWorkerService
}
from
'
vs/editor/common/services/editorWorkerService
'
;
import
{
IEditorWorkerService
}
from
'
vs/editor/common/services/editorWorkerService
'
;
...
@@ -22,6 +22,9 @@ import { WordDistance } from 'vs/editor/contrib/suggest/wordDistance';
...
@@ -22,6 +22,9 @@ import { WordDistance } from 'vs/editor/contrib/suggest/wordDistance';
import
{
EditorOption
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
EditorOption
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
isLowSurrogate
,
isHighSurrogate
}
from
'
vs/base/common/strings
'
;
import
{
isLowSurrogate
,
isHighSurrogate
}
from
'
vs/base/common/strings
'
;
import
{
IClipboardService
}
from
'
vs/platform/clipboard/common/clipboardService
'
;
import
{
IClipboardService
}
from
'
vs/platform/clipboard/common/clipboardService
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
generateUuid
}
from
'
vs/base/common/uuid
'
;
import
{
ILogService
}
from
'
vs/platform/log/common/log
'
;
export
interface
ICancelEvent
{
export
interface
ICancelEvent
{
readonly
retrigger
:
boolean
;
readonly
retrigger
:
boolean
;
...
@@ -117,8 +120,10 @@ export class SuggestModel implements IDisposable {
...
@@ -117,8 +120,10 @@ export class SuggestModel implements IDisposable {
constructor
(
constructor
(
private
readonly
_editor
:
ICodeEditor
,
private
readonly
_editor
:
ICodeEditor
,
private
readonly
_editorWorkerService
:
IEditorWorkerService
,
@
IEditorWorkerService
private
readonly
_editorWorkerService
:
IEditorWorkerService
,
private
readonly
_clipboardService
:
IClipboardService
@
IClipboardService
private
readonly
_clipboardService
:
IClipboardService
,
@
ITelemetryService
private
readonly
_telemetryService
:
ITelemetryService
,
@
ILogService
private
readonly
_logService
:
ILogService
,
)
{
)
{
this
.
_currentSelection
=
this
.
_editor
.
getSelection
()
||
new
Selection
(
1
,
1
,
1
,
1
);
this
.
_currentSelection
=
this
.
_editor
.
getSelection
()
||
new
Selection
(
1
,
1
,
1
,
1
);
...
@@ -249,10 +254,8 @@ export class SuggestModel implements IDisposable {
...
@@ -249,10 +254,8 @@ export class SuggestModel implements IDisposable {
cancel
(
retrigger
:
boolean
=
false
):
void
{
cancel
(
retrigger
:
boolean
=
false
):
void
{
if
(
this
.
_state
!==
State
.
Idle
)
{
if
(
this
.
_state
!==
State
.
Idle
)
{
this
.
_triggerQuickSuggest
.
cancel
();
this
.
_triggerQuickSuggest
.
cancel
();
if
(
this
.
_requestToken
)
{
this
.
_requestToken
?.
cancel
();
this
.
_requestToken
.
cancel
();
this
.
_requestToken
=
undefined
;
this
.
_requestToken
=
undefined
;
}
this
.
_state
=
State
.
Idle
;
this
.
_state
=
State
.
Idle
;
this
.
_completionModel
=
undefined
;
this
.
_completionModel
=
undefined
;
this
.
_context
=
undefined
;
this
.
_context
=
undefined
;
...
@@ -421,10 +424,10 @@ export class SuggestModel implements IDisposable {
...
@@ -421,10 +424,10 @@ export class SuggestModel implements IDisposable {
break
;
break
;
}
}
le
t
itemKindFilter
=
SuggestModel
.
_createItemKindFilter
(
this
.
_editor
);
cons
t
itemKindFilter
=
SuggestModel
.
_createItemKindFilter
(
this
.
_editor
);
le
t
wordDistance
=
WordDistance
.
create
(
this
.
_editorWorkerService
,
this
.
_editor
);
cons
t
wordDistance
=
WordDistance
.
create
(
this
.
_editorWorkerService
,
this
.
_editor
);
le
t
completions
=
provideSuggestionItems
(
cons
t
completions
=
provideSuggestionItems
(
model
,
model
,
this
.
_editor
.
getPosition
(),
this
.
_editor
.
getPosition
(),
new
CompletionOptions
(
snippetSortOrder
,
itemKindFilter
,
onlyFrom
),
new
CompletionOptions
(
snippetSortOrder
,
itemKindFilter
,
onlyFrom
),
...
@@ -473,9 +476,42 @@ export class SuggestModel implements IDisposable {
...
@@ -473,9 +476,42 @@ export class SuggestModel implements IDisposable {
this
.
_onNewContext
(
ctx
);
this
.
_onNewContext
(
ctx
);
// finally report telemetry about durations
this
.
_reportDurationsTelemetry
(
completions
.
durations
);
}).
catch
(
onUnexpectedError
);
}).
catch
(
onUnexpectedError
);
}
}
private
_reportDurationsTelemetry
(
durations
:
CompletionDurations
):
void
{
type
DurationEntry
=
{
session
:
string
;
providerName
:
string
;
elapsedProvider
:
number
;
elapsedOverall
:
number
;
};
type
Durations
=
{
session
:
string
;
elapsedAll
:
number
;
};
type
PerformanceAndHealth
<
T
>
=
{
[
P
in
keyof
T
]:
{
classification
:
'
SystemMetaData
'
,
purpose
:
'
PerformanceAndHealth
'
}
};
type
DurationEntryClassification
=
PerformanceAndHealth
<
DurationEntry
>
;
type
DurationsClassification
=
PerformanceAndHealth
<
Durations
>
;
setTimeout
(()
=>
{
this
.
_logService
.
trace
(
'
suggest.durations
'
,
durations
);
const
session
=
generateUuid
();
this
.
_telemetryService
.
publicLog2
<
Durations
,
DurationsClassification
>
(
'
suggest.durations.all
'
,
{
session
,
elapsedAll
:
durations
.
elapsed
});
for
(
let
item
of
durations
.
entries
)
{
this
.
_telemetryService
.
publicLog2
<
DurationEntry
,
DurationEntryClassification
>
(
'
suggest.durations.entry
'
,
{
session
,
...
item
});
}
});
}
private
static
_createItemKindFilter
(
editor
:
ICodeEditor
):
Set
<
CompletionItemKind
>
{
private
static
_createItemKindFilter
(
editor
:
ICodeEditor
):
Set
<
CompletionItemKind
>
{
// kind filter and snippet sort rules
// kind filter and snippet sort rules
const
result
=
new
Set
<
CompletionItemKind
>
();
const
result
=
new
Set
<
CompletionItemKind
>
();
...
...
src/vs/editor/contrib/suggest/test/suggestModel.test.ts
浏览文件 @
d166de9a
...
@@ -35,6 +35,7 @@ import { MockKeybindingService } from 'vs/platform/keybinding/test/common/mockKe
...
@@ -35,6 +35,7 @@ import { MockKeybindingService } from 'vs/platform/keybinding/test/common/mockKe
import
{
createTextModel
}
from
'
vs/editor/test/common/editorTestUtils
'
;
import
{
createTextModel
}
from
'
vs/editor/test/common/editorTestUtils
'
;
import
{
IClipboardService
}
from
'
vs/platform/clipboard/common/clipboardService
'
;
import
{
IClipboardService
}
from
'
vs/platform/clipboard/common/clipboardService
'
;
import
{
mock
}
from
'
vs/base/test/common/mock
'
;
import
{
mock
}
from
'
vs/base/test/common/mock
'
;
import
{
NullLogService
}
from
'
vs/platform/log/common/log
'
;
function
createMockEditor
(
model
:
TextModel
):
ITestCodeEditor
{
function
createMockEditor
(
model
:
TextModel
):
ITestCodeEditor
{
...
@@ -201,7 +202,9 @@ suite('SuggestModel - TriggerAndCancelOracle', function () {
...
@@ -201,7 +202,9 @@ suite('SuggestModel - TriggerAndCancelOracle', function () {
readText
()
{
readText
()
{
return
Promise
.
resolve
(
'
CLIPPY
'
);
return
Promise
.
resolve
(
'
CLIPPY
'
);
}
}
}
},
NullTelemetryService
,
new
NullLogService
()
);
);
disposables
.
push
(
oracle
,
editor
);
disposables
.
push
(
oracle
,
editor
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录