Skip to content

Commit

Permalink
Only display in java files
Browse files Browse the repository at this point in the history
  • Loading branch information
jdneo committed Jul 18, 2024
1 parent 7822fa7 commit 58d8da0
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/codeActionProvider.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CodeActionProvider, CodeActionProviderMetadata, CodeActionKind } from "vscode";
import { CodeActionProvider, CodeActionProviderMetadata, CodeActionKind, TextDocument } from "vscode";
import { Commands } from "./commands";

/**
Expand All @@ -18,13 +18,17 @@ export const javaRefactorKinds: Map<CodeActionKind, string> = new Map([
]);

export class RefactorDocumentProvider implements CodeActionProvider {
provideCodeActions() {
return [{
// The aim of this is to expose the source actions in the light bulb.
title: "Source Actions...",
command: "editor.action.sourceAction",
kind: CodeActionKind.Empty,
}];
provideCodeActions(document: TextDocument) {
const actions = [];
if (document.fileName.endsWith('.java')) {
actions.push({
// The aim of this is to expose the source actions in the light bulb.
title: "Source Actions...",
command: "editor.action.sourceAction",
kind: CodeActionKind.Empty,
});
}
return actions;
}

public static readonly metadata: CodeActionProviderMetadata = {
Expand Down

0 comments on commit 58d8da0

Please sign in to comment.