mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-29 16:29:19 -05:00
Merge pull request #4139 from hoanhtien/documentHighlights
Expose document highlighting to server.
This commit is contained in:
@@ -421,6 +421,14 @@ module FourSlashInterface {
|
||||
FourSlash.currentTestState.verifyOccurrencesAtPositionListCount(expectedCount);
|
||||
}
|
||||
|
||||
public documentHighlightsAtPositionContains(range: Range, fileNamesToSearch: string[], kind?: string) {
|
||||
FourSlash.currentTestState.verifyDocumentHighlightsAtPositionListContains(range.fileName, range.start, range.end, fileNamesToSearch, kind);
|
||||
}
|
||||
|
||||
public documentHighlightsAtPositionCount(expectedCount: number, fileNamesToSearch: string[]) {
|
||||
FourSlash.currentTestState.verifyDocumentHighlightsAtPositionListCount(expectedCount, fileNamesToSearch);
|
||||
}
|
||||
|
||||
public completionEntryDetailIs(entryName: string, text: string, documentation?: string, kind?: string) {
|
||||
FourSlash.currentTestState.verifyCompletionEntryDetails(entryName, text, documentation, kind);
|
||||
}
|
||||
|
||||
18
tests/cases/fourslash/server/documentHighlights01.ts
Normal file
18
tests/cases/fourslash/server/documentHighlights01.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
/// <reference path="../fourslash.ts"/>
|
||||
|
||||
// @Filename: a.ts
|
||||
////function [|f|](x: typeof [|f|]) {
|
||||
//// [|f|]([|f|]);
|
||||
////}
|
||||
|
||||
let ranges = test.ranges();
|
||||
|
||||
for (let r of ranges) {
|
||||
goTo.position(r.start);
|
||||
verify.documentHighlightsAtPositionCount(ranges.length, ["a.ts"]);
|
||||
|
||||
for (let range of ranges) {
|
||||
verify.documentHighlightsAtPositionContains(range, ["a.ts"]);
|
||||
}
|
||||
}
|
||||
|
||||
35
tests/cases/fourslash/server/documentHighlights02.ts
Normal file
35
tests/cases/fourslash/server/documentHighlights02.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
/// <reference path="../fourslash.ts"/>
|
||||
|
||||
// @Filename: a.ts
|
||||
////function [|foo|] () {
|
||||
//// return 1;
|
||||
////}
|
||||
////[|foo|]();
|
||||
|
||||
// @Filename: b.ts
|
||||
/////// <reference path="a.ts"/>
|
||||
////foo();
|
||||
|
||||
// open two files
|
||||
goTo.file("a.ts");
|
||||
goTo.file("b.ts");
|
||||
|
||||
let ranges = test.ranges();
|
||||
|
||||
for (let i = 0; i < ranges.length; ++i) {
|
||||
let r = ranges[i];
|
||||
|
||||
if (i < 2) {
|
||||
goTo.file("a.ts");
|
||||
}
|
||||
else {
|
||||
goTo.file("b.ts");
|
||||
}
|
||||
|
||||
goTo.position(r.start);
|
||||
verify.documentHighlightsAtPositionCount(3, ["a.ts", "b.ts"]);
|
||||
|
||||
for (let range of ranges) {
|
||||
verify.documentHighlightsAtPositionContains(range, ["a.ts", "b.ts"]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user