-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: implement references provider
- Loading branch information
1 parent
0070dc0
commit 2f9195b
Showing
6 changed files
with
119 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"marko-vscode": patch | ||
"@marko/language-server": patch | ||
--- | ||
|
||
Implements references provider (currently for stylesheets). |
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,49 @@ | ||
import vscode from "vscode"; | ||
import snap from "mocha-snap"; | ||
import { getTestDoc, getTestEditor, updateTestDoc } from "./setup.test"; | ||
|
||
describe("references", () => { | ||
it("css custom property", async () => { | ||
await snap.inline( | ||
() => | ||
references( | ||
`style { | ||
:root { | ||
--color█: green; | ||
} | ||
body { | ||
color: var(--color); | ||
} | ||
}` | ||
), | ||
`[ | ||
{ | ||
offset: 24, | ||
value: '--color' | ||
}, | ||
{ | ||
offset: 71, | ||
value: '--color' | ||
}, | ||
[length]: 2 | ||
]` | ||
); | ||
}); | ||
}); | ||
|
||
async function references(src: string) { | ||
const doc = getTestDoc(); | ||
const editor = getTestEditor(); | ||
await updateTestDoc(src); | ||
const locations = await vscode.commands.executeCommand<vscode.Location[]>( | ||
"vscode.executeReferenceProvider", | ||
doc.uri, | ||
editor.selection.start | ||
); | ||
|
||
return locations.map((it) => ({ | ||
offset: doc.offsetAt(it.range.start), | ||
value: doc.getText(it.range), | ||
})); | ||
} |
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
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