Skip to content

Commit

Permalink
Revert "feat: quick fix for redundant activation events (microsoft#19…
Browse files Browse the repository at this point in the history
…2495)"

This reverts commit 0b4fd71.
  • Loading branch information
chrmarti committed Sep 8, 2023
1 parent 6777698 commit e073d67
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 32 deletions.
12 changes: 1 addition & 11 deletions extensions/extension-editing/src/extensionEditingMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,14 @@ export function activate(context: vscode.ExtensionContext) {
//package.json suggestions
context.subscriptions.push(registerPackageDocumentCompletions());

//package.json code actions for lint warnings
context.subscriptions.push(registerCodeActionsProvider());

context.subscriptions.push(new ExtensionLinter());
}


function registerPackageDocumentCompletions(): vscode.Disposable {
return vscode.languages.registerCompletionItemProvider({ language: 'json', pattern: '**/package.json' }, {
provideCompletionItems(document, position, token) {
return new PackageDocument(document).provideCompletionItems(position, token);
}
});
}

function registerCodeActionsProvider(): vscode.Disposable {
return vscode.languages.registerCodeActionsProvider({ language: 'json', pattern: '**/package.json' }, {
provideCodeActions(document, range, context, token) {
return new PackageDocument(document).provideCodeActions(range, context, token);
}
});
}
4 changes: 2 additions & 2 deletions extensions/extension-editing/src/extensionLinter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ const dataUrlsNotValid = l10n.t("Data URLs are not a valid image source.");
const relativeUrlRequiresHttpsRepository = l10n.t("Relative image URLs require a repository with HTTPS protocol to be specified in the package.json.");
const relativeBadgeUrlRequiresHttpsRepository = l10n.t("Relative badge URLs require a repository with HTTPS protocol to be specified in this package.json.");
const apiProposalNotListed = l10n.t("This proposal cannot be used because for this extension the product defines a fixed set of API proposals. You can test your extension but before publishing you MUST reach out to the VS Code team.");
export const implicitActivationEvent = l10n.t("This activation event cannot be explicitly listed by your extension.");
export const redundantImplicitActivationEvent = l10n.t("This activation event can be removed as VS Code generates these automatically from your package.json contribution declarations.");
const implicitActivationEvent = l10n.t("This activation event cannot be explicitly listed by your extension.");
const redundantImplicitActivationEvent = l10n.t("This activation event can be removed as VS Code generates these automatically from your package.json contribution declarations.");
const bumpEngineForImplicitActivationEvents = l10n.t("This activation event can be removed for extensions targeting engine version ^1.75 as VS Code will generate these automatically from your package.json contribution declarations.");
const starActivation = l10n.t("Using '*' activation is usually a bad idea as it impacts performance.");
const parsingErrorHeader = l10n.t("Error parsing the when-clause:");
Expand Down
19 changes: 0 additions & 19 deletions extensions/extension-editing/src/packageDocumentHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import * as vscode from 'vscode';
import { getLocation, Location } from 'jsonc-parser';
import { implicitActivationEvent, redundantImplicitActivationEvent } from './extensionLinter';


export class PackageDocument {
Expand All @@ -22,24 +21,6 @@ export class PackageDocument {
return undefined;
}

public provideCodeActions(_range: vscode.Range, context: vscode.CodeActionContext, _token: vscode.CancellationToken): vscode.ProviderResult<vscode.CodeAction[]> {
const codeActions: vscode.CodeAction[] = [];
for (const diagnostic of context.diagnostics) {
if (diagnostic.message === implicitActivationEvent || diagnostic.message === redundantImplicitActivationEvent) {
const codeAction = new vscode.CodeAction(vscode.l10n.t("Remove activation event"), vscode.CodeActionKind.QuickFix);
codeAction.edit = new vscode.WorkspaceEdit();
const rangeForCharAfter = diagnostic.range.with(diagnostic.range.end, diagnostic.range.end.translate(0, 1));
if (this.document.getText(rangeForCharAfter) === ',') {
codeAction.edit.delete(this.document.uri, diagnostic.range.with(undefined, diagnostic.range.end.translate(0, 1)));
} else {
codeAction.edit.delete(this.document.uri, diagnostic.range);
}
codeActions.push(codeAction);
}
}
return codeActions;
}

private provideLanguageOverridesCompletionItems(location: Location, position: vscode.Position): vscode.ProviderResult<vscode.CompletionItem[]> {
let range = this.getReplaceRange(location, position);
const text = this.document.getText(range);
Expand Down

0 comments on commit e073d67

Please sign in to comment.