This repository has been archived by the owner on May 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add CodeLens for deno cached module which will show current URL
- Loading branch information
Showing
3 changed files
with
57 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { | ||
IConnection, | ||
Range, | ||
TextDocuments, | ||
Position | ||
} from "vscode-languageserver"; | ||
import { TextDocument } from "vscode-languageserver-textdocument"; | ||
import { URI } from "vscode-uri"; | ||
|
||
import { CacheModule } from "../../../core/deno_cache"; | ||
import { isInDeno } from "../../../core/deno"; | ||
|
||
export class CodeLens { | ||
constructor(connection: IConnection, documents: TextDocuments<TextDocument>) { | ||
connection.onCodeLens(params => { | ||
const { textDocument } = params; | ||
|
||
const document = documents.get(textDocument.uri); | ||
|
||
if (!document) { | ||
return []; | ||
} | ||
|
||
const filepath = URI.parse(document.uri).fsPath; | ||
|
||
if (!isInDeno(filepath)) { | ||
return []; | ||
} | ||
|
||
const cache = CacheModule.create(filepath); | ||
|
||
if (!cache) { | ||
return; | ||
} | ||
|
||
return [ | ||
{ | ||
range: Range.create(Position.create(0, 0), Position.create(0, 0)), | ||
command: { | ||
title: `Deno cached module \`${cache.url.href}\``, | ||
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