mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-14 19:16:17 -06:00
More tests
This commit is contained in:
parent
34624a0587
commit
424f2c9e00
@ -2709,8 +2709,8 @@ Actual: ${stringify(fullActual)}`);
|
||||
return this.languageService.getDocumentHighlights(this.activeFile.fileName, this.currentCaretPosition, filesToSearch);
|
||||
}
|
||||
|
||||
public verifyRangesAreOccurrences(isWriteAccess?: boolean) {
|
||||
const ranges = this.getRanges();
|
||||
public verifyRangesAreOccurrences(isWriteAccess?: boolean, ranges?: Range[]) {
|
||||
ranges = ranges || this.getRanges();
|
||||
for (const r of ranges) {
|
||||
this.goToRangeStart(r);
|
||||
this.verifyOccurrencesAtPositionListCount(ranges.length);
|
||||
@ -4084,8 +4084,8 @@ namespace FourSlashInterface {
|
||||
this.state.verifyOccurrencesAtPositionListCount(expectedCount);
|
||||
}
|
||||
|
||||
public rangesAreOccurrences(isWriteAccess?: boolean) {
|
||||
this.state.verifyRangesAreOccurrences(isWriteAccess);
|
||||
public rangesAreOccurrences(isWriteAccess?: boolean, ranges?: FourSlash.Range[]) {
|
||||
this.state.verifyRangesAreOccurrences(isWriteAccess, ranges);
|
||||
}
|
||||
|
||||
public rangesWithSameTextAreRenameLocations() {
|
||||
|
||||
@ -228,7 +228,7 @@ declare namespace FourSlashInterface {
|
||||
*/
|
||||
referenceGroups(starts: ArrayOrSingle<string> | ArrayOrSingle<Range>, parts: ReadonlyArray<ReferenceGroup>): void;
|
||||
singleReferenceGroup(definition: ReferencesDefinition, ranges?: Range[]): void;
|
||||
rangesAreOccurrences(isWriteAccess?: boolean): void;
|
||||
rangesAreOccurrences(isWriteAccess?: boolean, ranges?: Range[]): void;
|
||||
rangesWithSameTextAreRenameLocations(): void;
|
||||
rangesAreRenameLocations(options?: Range[] | { findInStrings?: boolean, findInComments?: boolean, ranges?: Range[] });
|
||||
findReferencesDefinitionDisplayPartsAtCaretAre(expected: ts.SymbolDisplayPart[]): void;
|
||||
|
||||
@ -6,12 +6,12 @@
|
||||
// @Filename: Foo.js
|
||||
//// class Foo {
|
||||
//// constructor() {
|
||||
//// this.[|union|] = 'foo';
|
||||
//// this.[|union|] = 100;
|
||||
//// [|this.[|{| "declarationRangeIndex": 0 |}union|] = 'foo';|]
|
||||
//// [|this.[|{| "declarationRangeIndex": 2 |}union|] = 100;|]
|
||||
//// }
|
||||
//// method() { return this.[|union|]; }
|
||||
//// }
|
||||
//// var x = new Foo();
|
||||
//// x.[|union|];
|
||||
|
||||
verify.rangesAreRenameLocations();
|
||||
verify.rangesAreRenameLocations(test.rangesByText().get("union"));
|
||||
|
||||
@ -7,11 +7,12 @@
|
||||
/////**
|
||||
//// * @param /*use*/[|foo|] I pity the foo
|
||||
//// */
|
||||
////function f([|/*def*/{| "isWriteAccess": true, "isDefinition": true |}foo|]: I) {
|
||||
////function f([|[|/*def*/{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 1 |}foo|]: I|]) {
|
||||
//// return [|foo|];
|
||||
////}
|
||||
|
||||
const ranges = test.ranges();
|
||||
const [r0, r1Def, r1, r2] = test.ranges();
|
||||
const ranges = [r0, r1, r2];
|
||||
goTo.marker("use");
|
||||
verify.goToDefinitionIs("def");
|
||||
verify.goToType("use", "I");
|
||||
@ -19,6 +20,6 @@ verify.goToType("use", "I");
|
||||
goTo.marker("use");
|
||||
verify.quickInfoIs("(parameter) foo: I", "I pity the foo");
|
||||
|
||||
verify.singleReferenceGroup("(parameter) foo: I");
|
||||
verify.rangesAreDocumentHighlights();
|
||||
verify.rangesAreRenameLocations();
|
||||
verify.singleReferenceGroup("(parameter) foo: I", ranges);
|
||||
verify.rangesAreDocumentHighlights(ranges);
|
||||
verify.rangesAreRenameLocations(ranges);
|
||||
|
||||
@ -3,14 +3,14 @@
|
||||
// @allowJs: true
|
||||
// @Filename: a.js
|
||||
|
||||
/////** @typedef {number} [|{| "isWriteAccess": true, "isDefinition": true |}T|] */
|
||||
/////** [|@typedef {number} [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}T|]|] */
|
||||
|
||||
////const [|{| "isWriteAccess": true, "isDefinition": true |}T|] = 1;
|
||||
////[|const [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 2 |}T|] = 1;|]
|
||||
|
||||
/////** @type {[|T|]} */
|
||||
////const n = [|T|];
|
||||
|
||||
const [t0, v0, t1, v1] = test.ranges();
|
||||
const [t0Def, t0, v0Def, v0, t1, v1] = test.ranges();
|
||||
|
||||
verify.singleReferenceGroup("type T = number", [t0, t1]);
|
||||
verify.singleReferenceGroup("const T: 1", [v0, v1]);
|
||||
|
||||
@ -4,9 +4,9 @@
|
||||
// @Filename: a.js
|
||||
|
||||
/////** @typedef {number} */
|
||||
////const [|{| "isWriteAccess": true, "isDefinition": true |}T|] = 1;
|
||||
////[|const [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}T|] = 1;|]
|
||||
|
||||
/////** @type {[|T|]} */
|
||||
////const n = [|T|];
|
||||
|
||||
verify.singleReferenceGroup("type T = number\nconst T: 1");
|
||||
verify.singleReferenceGroup("type T = number\nconst T: 1", test.rangesByText().get("T"));
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
|
||||
/////**
|
||||
//// * Doc comment
|
||||
//// * @typedef /*def*/[|{| "isWriteAccess": true, "isDefinition": true |}Product|]
|
||||
//// * [|@typedef /*def*/[|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}Product|]
|
||||
//// * @property {string} title
|
||||
//// */
|
||||
//// |]*/
|
||||
|
||||
/////**
|
||||
//// * @type {[|/*use*/Product|]}
|
||||
@ -18,11 +18,12 @@ const desc = `type Product = {
|
||||
title: string;
|
||||
}`;
|
||||
|
||||
const [r0Def, ...ranges] = test.ranges();
|
||||
verify.quickInfoAt("use", desc, "Doc comment");
|
||||
|
||||
verify.goToDefinition("use", "def");
|
||||
|
||||
verify.rangesAreOccurrences();
|
||||
verify.rangesAreDocumentHighlights();
|
||||
verify.singleReferenceGroup(desc);
|
||||
verify.rangesAreRenameLocations();
|
||||
verify.rangesAreOccurrences(/*isWriteAccesss*/ undefined, ranges);
|
||||
verify.rangesAreDocumentHighlights(ranges);
|
||||
verify.singleReferenceGroup(desc, ranges);
|
||||
verify.rangesAreRenameLocations(ranges);
|
||||
|
||||
@ -14,8 +14,9 @@
|
||||
//// }
|
||||
//// }
|
||||
////
|
||||
//// var [|/*dst*/nn|]: {name?: string; size?: number};
|
||||
//// [|var [|/*dst*/{| "declarationRangeIndex": 0 |}nn|]: {name?: string; size?: number};|]
|
||||
//// var x = <MyClass {...[|n/*src*/n|]}></MyClass>;
|
||||
|
||||
verify.goToDefinition("src", "dst");
|
||||
verify.rangesAreRenameLocations();
|
||||
const [rDef, ...ranges] = test.ranges();
|
||||
verify.rangesAreRenameLocations(ranges);
|
||||
|
||||
@ -2,9 +2,9 @@
|
||||
|
||||
// @Filename: file1.ts
|
||||
//// class Foo {
|
||||
//// constructor(private [|{| "isWriteAccess": true, "isDefinition": true, "type": "number" |}privateParam|]: number,
|
||||
//// public [|{| "isWriteAccess": true, "isDefinition": true, "type": "string" |}publicParam|]: string,
|
||||
//// protected [|{| "isWriteAccess": true, "isDefinition": true, "type": "boolean" |}protectedParam|]: boolean) {
|
||||
//// constructor([|private [|{| "isWriteAccess": true, "isDefinition": true, "type": "number", "declarationRangeIndex": 0 |}privateParam|]: number|],
|
||||
//// [|public [|{| "isWriteAccess": true, "isDefinition": true, "type": "string", "declarationRangeIndex": 2 |}publicParam|]: string|],
|
||||
//// [|protected [|{| "isWriteAccess": true, "isDefinition": true, "type": "boolean", "declarationRangeIndex": 4 |}protectedParam|]: boolean|]) {
|
||||
////
|
||||
//// let localPrivate = [|privateParam|];
|
||||
//// this.[|{| "isWriteAccess": true |}privateParam|] += 10;
|
||||
@ -18,6 +18,8 @@
|
||||
//// }
|
||||
|
||||
test.rangesByText().forEach((ranges, text) => {
|
||||
if (text !== "privateParam" && text !== "publicParam" && text !== "protectedParam") return;
|
||||
|
||||
const [r0, r1, r2] = ranges;
|
||||
const type = r0.marker.data.type;
|
||||
verify.referenceGroups(ranges, [
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user