-
Notifications
You must be signed in to change notification settings - Fork 472
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add clear screen and stop session code lens
- Loading branch information
Keegan Irby
committed
Nov 8, 2024
1 parent
396c54a
commit 4a7a75f
Showing
6 changed files
with
115 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
packages/core/src/awsService/cloudWatchLogs/document/liveTailCodeLensProvider.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/*! | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import * as vscode from 'vscode' | ||
import { cloudwatchLogsLiveTailScheme } from '../../../shared/constants' | ||
|
||
export class LiveTailCodeLensProvider implements vscode.CodeLensProvider { | ||
onDidChangeCodeLenses?: vscode.Event<void> | undefined | ||
|
||
provideCodeLenses( | ||
document: vscode.TextDocument, | ||
token: vscode.CancellationToken | ||
): vscode.ProviderResult<vscode.CodeLens[]> { | ||
const uri = document.uri | ||
if (uri.scheme !== cloudwatchLogsLiveTailScheme) { | ||
return [] | ||
} | ||
const codeLenses: vscode.CodeLens[] = [] | ||
codeLenses.push(this.buildClearDocumentCodeLens(document)) | ||
codeLenses.push(this.buildStopTailingCodeLens(document)) | ||
return codeLenses | ||
} | ||
|
||
private buildClearDocumentCodeLens(document: vscode.TextDocument): vscode.CodeLens { | ||
const range = new vscode.Range( | ||
new vscode.Position(document.lineCount - 1, 0), | ||
new vscode.Position(document.lineCount - 1, 0) | ||
) | ||
const command: vscode.Command = { | ||
title: 'Clear document', | ||
command: 'aws.cwl.clearDocument', | ||
arguments: [document], | ||
} | ||
return new vscode.CodeLens(range, command) | ||
} | ||
|
||
private buildStopTailingCodeLens(document: vscode.TextDocument): vscode.CodeLens { | ||
const range = new vscode.Range( | ||
new vscode.Position(document.lineCount - 1, 0), | ||
new vscode.Position(document.lineCount - 1, 0) | ||
) | ||
const command: vscode.Command = { | ||
title: 'Stop tailing', | ||
command: 'aws.cwl.stopTailingLogGroup', | ||
arguments: [document], | ||
} | ||
return new vscode.CodeLens(range, command) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters