forked from jest-community/vscode-jest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request jest-community#172 from CzBuCHi/master
debugger support
- Loading branch information
Showing
8 changed files
with
226 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ node_modules | |
_jest-editor/ | ||
integrations/create-react-example/node_modules | ||
/coverage/ | ||
/.vscode/symbols.json |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import * as vscode from 'vscode' | ||
import { extensionName } from './appGlobals' | ||
import { basename } from 'path' | ||
import { DecorationOptions } from './types' | ||
|
||
class CodeLens extends vscode.CodeLens { | ||
readonly identifier: string | ||
readonly fileName: string | ||
constructor(range: vscode.Range, fileName: string, identifier: string) { | ||
super(range) | ||
this.fileName = fileName | ||
this.identifier = identifier | ||
} | ||
} | ||
|
||
export class CodeLensProvider implements vscode.CodeLensProvider { | ||
private didChangeCodeLenses: vscode.EventEmitter<void> | ||
private decorations: DecorationOptions[] | ||
|
||
constructor() { | ||
this.didChangeCodeLenses = new vscode.EventEmitter() | ||
} | ||
|
||
get onDidChangeCodeLenses(): vscode.Event<void> { | ||
return this.didChangeCodeLenses.event | ||
} | ||
|
||
provideCodeLenses( | ||
document: vscode.TextDocument, | ||
_token: vscode.CancellationToken | ||
): vscode.ProviderResult<vscode.CodeLens[]> { | ||
return (this.decorations || []).map(o => { | ||
const range = new vscode.Range( | ||
o.range.start.line, | ||
o.range.start.character, | ||
o.range.start.line, | ||
o.range.start.character + 5 // lenses all have text 'Debug' | ||
) | ||
return new CodeLens(range, basename(document.fileName), o.identifier) | ||
}) | ||
} | ||
|
||
resolveCodeLens(codeLens: vscode.CodeLens, _token: vscode.CancellationToken): vscode.ProviderResult<vscode.CodeLens> { | ||
if (codeLens instanceof CodeLens) { | ||
codeLens.command = { | ||
arguments: [codeLens.fileName, codeLens.identifier], | ||
command: `${extensionName}.run-test`, | ||
title: 'Debug', | ||
} | ||
} | ||
return codeLens | ||
} | ||
|
||
updateLenses(decorations: DecorationOptions[]) { | ||
this.decorations = decorations | ||
this.didChangeCodeLenses.fire() | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import * as vscode from 'vscode' | ||
|
||
export interface DecorationOptions extends vscode.DecorationOptions { | ||
identifier: string | ||
} |
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