Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

always set CompletionItemProvider#_debugDisplayName, send display name and extension id with telemetry #185765

Merged
merged 1 commit into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/vs/editor/common/languages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -584,9 +584,12 @@ export interface CompletionContext {
export interface CompletionItemProvider {

/**
* Used to identify completions in the (debug) UI and telemetry. This isn't the extension identifier because extensions
* often contribute multiple completion item providers.
*
* @internal
*/
_debugDisplayName?: string;
_debugDisplayName: string;

triggerCharacters?: string[];
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ suite('Suggest Widget Model', () => {
});

const provider: CompletionItemProvider = {
_debugDisplayName: 'test',
triggerCharacters: ['.'],
async provideCompletionItems(model, pos) {
const word = model.getWordAtPosition(pos);
Expand Down
3 changes: 2 additions & 1 deletion src/vs/editor/contrib/snippet/browser/snippetController2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ export class SnippetController2 implements IEditorContribution {

// regster completion item provider when there is any choice element
if (this._session?.hasChoice) {
const provider = {
const provider: CompletionItemProvider = {
_debugDisplayName: 'snippetChoiceCompletions',
provideCompletionItems: (model: ITextModel, position: Position) => {
if (!this._session || model !== this._editor.getModel() || !Position.equals(this._editor.getPosition(), position)) {
return undefined;
Expand Down
13 changes: 9 additions & 4 deletions src/vs/editor/contrib/suggest/browser/suggestController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,16 +399,18 @@ export class SuggestController implements IEditorContribution {
return true;
}).then(applied => {
this._logService.trace('[suggest] async resolving of edits DONE (ms, applied?)', sw.elapsed(), applied);
type AsyncSuggestEdits = { providerId: string; applied: boolean };
type AsyncSuggestEdits = { extensionId: string; providerId: string; applied: boolean };
type AsyncSuggestEditsClassification = {
owner: 'jrieken';
comment: 'Information about async additional text edits';
extensionId: { classification: 'PublicNonPersonalData'; purpose: 'FeatureInsight'; comment: 'Extension contributing the completions item' };
providerId: { classification: 'PublicNonPersonalData'; purpose: 'FeatureInsight'; comment: 'Provider of the completions item' };
applied: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; isMeasurement: true; comment: 'If async additional text edits could be applied' };
};
if (typeof applied === 'boolean') {
this._telemetryService.publicLog2<AsyncSuggestEdits, AsyncSuggestEditsClassification>('suggest.asyncAdditionalEdits', {
providerId: item.extensionId?.value ?? 'unknown',
extensionId: item.extensionId?.value ?? 'unknown',
providerId: item.provider._debugDisplayName ?? 'unknown',
applied
});
}
Expand Down Expand Up @@ -497,12 +499,14 @@ export class SuggestController implements IEditorContribution {
}

type AcceptedSuggestion = {
providerId: string; fileExtension: string; languageId: string; basenameHash: string; kind: number;
extensionId: string; providerId: string;
fileExtension: string; languageId: string; basenameHash: string; kind: number;
resolveInfo: number; resolveDuration: number;
};
type AcceptedSuggestionClassification = {
owner: 'jrieken';
comment: 'Information accepting completion items';
extensionId: { classification: 'PublicNonPersonalData'; purpose: 'FeatureInsight'; comment: 'Extension contributing the completions item' };
providerId: { classification: 'PublicNonPersonalData'; purpose: 'FeatureInsight'; comment: 'Provider of the completions item' };
basenameHash: { classification: 'PublicNonPersonalData'; purpose: 'FeatureInsight'; comment: 'Hash of the basename of the file into which the completion was inserted' };
fileExtension: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'File extension of the file into which the completion was inserted' };
Expand All @@ -513,7 +517,8 @@ export class SuggestController implements IEditorContribution {
};

this._telemetryService.publicLog2<AcceptedSuggestion, AcceptedSuggestionClassification>('suggest.acceptedSuggestion', {
providerId: item.extensionId?.value ?? item.provider._debugDisplayName ?? 'unknown',
extensionId: item.extensionId?.value ?? 'unknown',
providerId: item.provider._debugDisplayName ?? 'unknown',
kind: item.completion.kind,
basenameHash: hash(basename(model.uri)).toString(16),
languageId: model.getLanguageId(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export function createSuggestItem(label: string | languages.CompletionItemLabel,
suggestions: [suggestion]
};
const provider: languages.CompletionItemProvider = {
_debugDisplayName: 'test',
provideCompletionItems(): any {
return;
}
Expand Down
2 changes: 2 additions & 0 deletions src/vs/editor/contrib/suggest/test/browser/suggest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ suite('Suggest', function () {
registry = new LanguageFeatureRegistry();
model = createTextModel('FOO\nbar\BAR\nfoo', undefined, undefined, URI.parse('foo:bar/path'));
registration = registry.register({ pattern: 'bar/path', scheme: 'foo' }, {
_debugDisplayName: 'test',
provideCompletionItems(_doc, pos) {
return {
incomplete: false,
Expand Down Expand Up @@ -114,6 +115,7 @@ suite('Suggest', function () {

const foo = new class implements CompletionItemProvider {

_debugDisplayName = 'test';
triggerCharacters = [];

provideCompletionItems() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ suite('SuggestController', function () {

test('postfix completion reports incorrect position #86984', async function () {
disposables.add(languageFeaturesService.completionProvider.register({ scheme: 'test-ctrl' }, {
_debugDisplayName: 'test',
provideCompletionItems(doc, pos) {
return {
suggestions: [{
Expand Down Expand Up @@ -125,6 +126,7 @@ suite('SuggestController', function () {
test('use additionalTextEdits sync when possible', async function () {

disposables.add(languageFeaturesService.completionProvider.register({ scheme: 'test-ctrl' }, {
_debugDisplayName: 'test',
provideCompletionItems(doc, pos) {
return {
suggestions: [{
Expand Down Expand Up @@ -166,6 +168,7 @@ suite('SuggestController', function () {
let resolveCallCount = 0;

disposables.add(languageFeaturesService.completionProvider.register({ scheme: 'test-ctrl' }, {
_debugDisplayName: 'test',
provideCompletionItems(doc, pos) {
return {
suggestions: [{
Expand Down Expand Up @@ -218,6 +221,7 @@ suite('SuggestController', function () {
let resolveCallCount = 0;
let resolve: Function = () => { };
disposables.add(languageFeaturesService.completionProvider.register({ scheme: 'test-ctrl' }, {
_debugDisplayName: 'test',
provideCompletionItems(doc, pos) {
return {
suggestions: [{
Expand Down Expand Up @@ -274,6 +278,7 @@ suite('SuggestController', function () {
let resolveCallCount = 0;
let resolve: Function = () => { };
disposables.add(languageFeaturesService.completionProvider.register({ scheme: 'test-ctrl' }, {
_debugDisplayName: 'test',
provideCompletionItems(doc, pos) {
return {
suggestions: [{
Expand Down Expand Up @@ -323,6 +328,7 @@ suite('SuggestController', function () {
let resolveCallCount = 0;
let resolve: Function = () => { };
disposables.add(languageFeaturesService.completionProvider.register({ scheme: 'test-ctrl' }, {
_debugDisplayName: 'test',
provideCompletionItems(doc, pos) {
return {
suggestions: [{
Expand Down Expand Up @@ -377,6 +383,7 @@ suite('SuggestController', function () {

const resolve: Function[] = [];
disposables.add(languageFeaturesService.completionProvider.register({ scheme: 'test-ctrl' }, {
_debugDisplayName: 'test',
provideCompletionItems(doc, pos) {
return {
suggestions: [{
Expand Down Expand Up @@ -434,6 +441,7 @@ suite('SuggestController', function () {


disposables.add(languageFeaturesService.completionProvider.register({ scheme: 'test-ctrl' }, {
_debugDisplayName: 'test',
provideCompletionItems(doc, pos) {
return {
suggestions: [{
Expand Down Expand Up @@ -470,6 +478,7 @@ suite('SuggestController', function () {

test('Pressing enter on autocomplete should always apply the selected dropdown completion, not a different, hidden one #161883', async function () {
disposables.add(languageFeaturesService.completionProvider.register({ scheme: 'test-ctrl' }, {
_debugDisplayName: 'test',
provideCompletionItems(doc, pos) {

const word = doc.getWordUntilPosition(pos);
Expand Down Expand Up @@ -516,6 +525,7 @@ suite('SuggestController', function () {

test('Fast autocomple typing selects the previous autocomplete suggestion, #71795', async function () {
disposables.add(languageFeaturesService.completionProvider.register({ scheme: 'test-ctrl' }, {
_debugDisplayName: 'test',
provideCompletionItems(doc, pos) {

const word = doc.getWordUntilPosition(pos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ suite('Suggest Inline Completions', function () {

insta.invokeFunction(accessor => {
accessor.get(ILanguageFeaturesService).completionProvider.register({ pattern: '*.bar', scheme: 'foo' }, new class implements CompletionItemProvider {
_debugDisplayName = 'test';

triggerCharacters?: string[] | undefined;

Expand Down
23 changes: 23 additions & 0 deletions src/vs/editor/contrib/suggest/test/browser/suggestModel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ suite('SuggestModel - TriggerAndCancelOracle', function () {
}

const alwaysEmptySupport: CompletionItemProvider = {
_debugDisplayName: 'test',
provideCompletionItems(doc, pos): CompletionList {
return {
incomplete: false,
Expand All @@ -190,6 +191,7 @@ suite('SuggestModel - TriggerAndCancelOracle', function () {
};

const alwaysSomethingSupport: CompletionItemProvider = {
_debugDisplayName: 'test',
provideCompletionItems(doc, pos): CompletionList {
return {
incomplete: false,
Expand Down Expand Up @@ -330,6 +332,7 @@ suite('SuggestModel - TriggerAndCancelOracle', function () {
test('#17400: Keep filtering suggestModel.ts after space', function () {

disposables.add(registry.register({ scheme: 'test' }, {
_debugDisplayName: 'test',
provideCompletionItems(doc, pos): CompletionList {
return {
incomplete: false,
Expand Down Expand Up @@ -380,6 +383,7 @@ suite('SuggestModel - TriggerAndCancelOracle', function () {
test('#21484: Trigger character always force a new completion session', function () {

disposables.add(registry.register({ scheme: 'test' }, {
_debugDisplayName: 'test',
provideCompletionItems(doc, pos): CompletionList {
return {
incomplete: false,
Expand All @@ -394,6 +398,7 @@ suite('SuggestModel - TriggerAndCancelOracle', function () {
}));

disposables.add(registry.register({ scheme: 'test' }, {
_debugDisplayName: 'test',
triggerCharacters: ['.'],
provideCompletionItems(doc, pos): CompletionList {
return {
Expand Down Expand Up @@ -505,6 +510,7 @@ suite('SuggestModel - TriggerAndCancelOracle', function () {
test('Incomplete suggestion results cause re-triggering when typing w/o further context, #28400 (1/2)', function () {

disposables.add(registry.register({ scheme: 'test' }, {
_debugDisplayName: 'test',
provideCompletionItems(doc, pos): CompletionList {
return {
incomplete: true,
Expand Down Expand Up @@ -542,6 +548,7 @@ suite('SuggestModel - TriggerAndCancelOracle', function () {
test('Incomplete suggestion results cause re-triggering when typing w/o further context, #28400 (2/2)', function () {

disposables.add(registry.register({ scheme: 'test' }, {
_debugDisplayName: 'test',
provideCompletionItems(doc, pos): CompletionList {
return {
incomplete: true,
Expand Down Expand Up @@ -585,6 +592,7 @@ suite('SuggestModel - TriggerAndCancelOracle', function () {
test('Trigger character is provided in suggest context', function () {
let triggerCharacter = '';
disposables.add(registry.register({ scheme: 'test' }, {
_debugDisplayName: 'test',
triggerCharacters: ['.'],
provideCompletionItems(doc, pos, context): CompletionList {
assert.strictEqual(context.triggerKind, CompletionTriggerKind.TriggerCharacter);
Expand Down Expand Up @@ -618,6 +626,7 @@ suite('SuggestModel - TriggerAndCancelOracle', function () {

test('Mac press and hold accent character insertion does not update suggestions, #35269', function () {
disposables.add(registry.register({ scheme: 'test' }, {
_debugDisplayName: 'test',
provideCompletionItems(doc, pos): CompletionList {
return {
incomplete: true,
Expand Down Expand Up @@ -690,6 +699,7 @@ suite('SuggestModel - TriggerAndCancelOracle', function () {

test('Text changes for completion CodeAction are affected by the completion #39893', function () {
disposables.add(registry.register({ scheme: 'test' }, {
_debugDisplayName: 'test',
provideCompletionItems(doc, pos): CompletionList {
return {
incomplete: true,
Expand Down Expand Up @@ -764,6 +774,7 @@ suite('SuggestModel - TriggerAndCancelOracle', function () {
let disposeB = 0;

disposables.add(registry.register({ scheme: 'test' }, {
_debugDisplayName: 'test',
provideCompletionItems(doc, pos) {
return {
incomplete: true,
Expand All @@ -779,6 +790,7 @@ suite('SuggestModel - TriggerAndCancelOracle', function () {
}
}));
disposables.add(registry.register({ scheme: 'test' }, {
_debugDisplayName: 'test',
provideCompletionItems(doc, pos) {
return {
incomplete: false,
Expand Down Expand Up @@ -833,6 +845,7 @@ suite('SuggestModel - TriggerAndCancelOracle', function () {
let countB = 0;

disposables.add(registry.register({ scheme: 'test' }, {
_debugDisplayName: 'test',
provideCompletionItems(doc, pos) {
countA += 1;
return {
Expand All @@ -847,6 +860,7 @@ suite('SuggestModel - TriggerAndCancelOracle', function () {
}
}));
disposables.add(registry.register({ scheme: 'test' }, {
_debugDisplayName: 'test',
provideCompletionItems(doc, pos) {
countB += 1;
if (!doc.getWordUntilPosition(pos).word.startsWith('a')) {
Expand Down Expand Up @@ -896,6 +910,7 @@ suite('SuggestModel - TriggerAndCancelOracle', function () {
test('registerCompletionItemProvider with letters as trigger characters block other completion items to show up #127815', async function () {

disposables.add(registry.register({ scheme: 'test' }, {
_debugDisplayName: 'test',
provideCompletionItems(doc, pos) {
return {
suggestions: [{
Expand All @@ -908,6 +923,7 @@ suite('SuggestModel - TriggerAndCancelOracle', function () {
}
}));
disposables.add(registry.register({ scheme: 'test' }, {
_debugDisplayName: 'test',
triggerCharacters: ['a', '.'],
provideCompletionItems(doc, pos) {
return {
Expand Down Expand Up @@ -951,6 +967,7 @@ suite('SuggestModel - TriggerAndCancelOracle', function () {
test('Unexpected suggest scoring #167242', async function () {
disposables.add(registry.register('*', {
// word-based
_debugDisplayName: 'test',
provideCompletionItems(doc, pos) {
const word = doc.getWordUntilPosition(pos);
return {
Expand All @@ -965,6 +982,7 @@ suite('SuggestModel - TriggerAndCancelOracle', function () {
}));
disposables.add(registry.register({ scheme: 'test' }, {
// JSON-based
_debugDisplayName: 'test',
provideCompletionItems(doc, pos) {
return {
suggestions: [{
Expand Down Expand Up @@ -1008,6 +1026,7 @@ suite('SuggestModel - TriggerAndCancelOracle', function () {
const requestCounts = [0, 0];

disposables.add(registry.register({ scheme: 'test' }, {
_debugDisplayName: 'test',

provideCompletionItems(doc, pos) {
requestCounts[0] += 1;
Expand All @@ -1027,6 +1046,7 @@ suite('SuggestModel - TriggerAndCancelOracle', function () {
}
}));
disposables.add(registry.register({ scheme: 'test' }, {
_debugDisplayName: 'test',
triggerCharacters: ['2'],
provideCompletionItems(doc, pos, ctx) {
requestCounts[1] += 1;
Expand Down Expand Up @@ -1077,6 +1097,7 @@ suite('SuggestModel - TriggerAndCancelOracle', function () {
test('Set refilter-flag, keep triggerKind', function () {

disposables.add(registry.register({ scheme: 'test' }, {
_debugDisplayName: 'test',
triggerCharacters: ['.'],
provideCompletionItems(doc, pos, ctx) {
return {
Expand Down Expand Up @@ -1132,6 +1153,7 @@ suite('SuggestModel - TriggerAndCancelOracle', function () {
test('Snippets gone from IntelliSense #173244', function () {

const snippetProvider: CompletionItemProvider = {
_debugDisplayName: 'test',
provideCompletionItems(doc, pos, ctx) {
return {
suggestions: [{
Expand All @@ -1152,6 +1174,7 @@ suite('SuggestModel - TriggerAndCancelOracle', function () {
}));

disposables.add(registry.register({ scheme: 'test' }, {
_debugDisplayName: 'test',
triggerCharacters: ['.'],
provideCompletionItems(doc, pos, ctx) {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ suite('suggest, word distance', function () {
suggestions: [suggestion]
};
const provider: languages.CompletionItemProvider = {
_debugDisplayName: 'test',
provideCompletionItems(): any {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ class SlashCommandCompletions extends Disposable {
super();

this._register(this.languageFeaturesService.completionProvider.register({ scheme: ChatInputPart.INPUT_SCHEME, hasAccessToAllModels: true }, {
_debugDisplayName: 'chatSlashCommand',
triggerCharacters: ['/'],
provideCompletionItems: async (model: ITextModel, _position: Position, _context: CompletionContext, _token: CancellationToken) => {
const widget = this.chatWidgetService.getWidgetByInputUri(model.uri);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ export class SuggestEnabledInput extends Widget {
this.setValue(options.value || '');

this._register(languageFeaturesService.completionProvider.register({ scheme: scopeHandle.scheme, pattern: '**/' + scopeHandle.path, hasAccessToAllModels: true }, {
_debugDisplayName: `suggestEnabledInput/${id}`,
triggerCharacters: validatedSuggestProvider.triggerCharacters,
provideCompletionItems: (model: ITextModel, position: Position, _context: languages.CompletionContext) => {
const query = model.getValue();
Expand Down