mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 03:23:08 -06:00
Fix ordering in fourslash tests
This commit is contained in:
parent
7f4ac292b9
commit
97a842feb2
@ -119,9 +119,11 @@ namespace Harness.LanguageService {
|
||||
export abstract class LanguageServiceAdapterHost {
|
||||
public typesRegistry: ts.Map<void> | undefined;
|
||||
public readonly vfs = new vfs.FileSystem(/*ignoreCase*/ true, { cwd: virtualFileSystemRoot });
|
||||
private scriptInfos: core.SortedMap<string, ScriptInfo>;
|
||||
|
||||
constructor(protected cancellationToken = DefaultHostCancellationToken.instance,
|
||||
protected settings = ts.getDefaultCompilerOptions()) {
|
||||
this.scriptInfos = new core.SortedMap({ comparer: this.vfs.stringComparer, sort: "insertion" });
|
||||
}
|
||||
|
||||
public getNewLine(): string {
|
||||
@ -130,36 +132,35 @@ namespace Harness.LanguageService {
|
||||
|
||||
public getFilenames(): string[] {
|
||||
const fileNames: string[] = [];
|
||||
this.vfs.scanSync("/", "descendants-or-self", {
|
||||
accept: (path, stats) => {
|
||||
if (stats.isFile()) {
|
||||
const scriptInfo = this.vfs.filemeta(path).get("scriptInfo") as ScriptInfo;
|
||||
if (scriptInfo && scriptInfo.isRootFile) {
|
||||
// only include root files here
|
||||
// usually it means that we won't include lib.d.ts in the list of root files so it won't mess the computation of compilation root dir.
|
||||
fileNames.push(scriptInfo.fileName);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
this.scriptInfos.forEach(scriptInfo => {
|
||||
if (scriptInfo.isRootFile) {
|
||||
// only include root files here
|
||||
// usually it means that we won't include lib.d.ts in the list of root files so it won't mess the computation of compilation root dir.
|
||||
fileNames.push(scriptInfo.fileName);
|
||||
}
|
||||
});
|
||||
// this.vfs.scanSync("/", "descendants-or-self", {
|
||||
// accept: (path, stats) => {
|
||||
// if (stats.isFile()) {
|
||||
// const scriptInfo = this.vfs.filemeta(path).get("scriptInfo") as ScriptInfo;
|
||||
// if (scriptInfo && scriptInfo.isRootFile) {
|
||||
// fileNames.push(scriptInfo.fileName);
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
// });
|
||||
return fileNames;
|
||||
}
|
||||
|
||||
public getScriptInfo(fileName: string): ScriptInfo {
|
||||
try {
|
||||
const meta = this.vfs.filemeta(fileName);
|
||||
return meta ? meta.get("scriptInfo") : undefined;
|
||||
}
|
||||
catch {
|
||||
return undefined;
|
||||
}
|
||||
return this.scriptInfos.get(vpath.resolve(this.vfs.cwd(), fileName));
|
||||
}
|
||||
|
||||
public addScript(fileName: string, content: string, isRootFile: boolean): void {
|
||||
this.vfs.mkdirpSync(vpath.dirname(fileName));
|
||||
this.vfs.writeFileSync(fileName, content);
|
||||
this.vfs.filemeta(fileName).set("scriptInfo", new ScriptInfo(fileName, content, isRootFile));
|
||||
this.scriptInfos.set(vpath.resolve(this.vfs.cwd(), fileName), new ScriptInfo(fileName, content, isRootFile));
|
||||
}
|
||||
|
||||
public editScript(fileName: string, start: number, end: number, newText: string) {
|
||||
|
||||
@ -3,11 +3,11 @@
|
||||
// @declaration: true
|
||||
// @out: out.js
|
||||
// @allowJs: true
|
||||
// @Filename: a.js
|
||||
// @Filename: b.js
|
||||
// @emitThisFile: true
|
||||
////function foo() { return 10; }/*1*/
|
||||
|
||||
// @Filename: b.ts
|
||||
// @Filename: a.ts
|
||||
// @emitThisFile: true
|
||||
////function foo() { return 30; }/*2*/
|
||||
|
||||
|
||||
@ -16,8 +16,8 @@
|
||||
|
||||
const ranges = test.ranges();
|
||||
const [r0, r1, r2, r3] = ranges;
|
||||
verify.referenceGroups(r0, [{ definition: "(property) searchProp: number", ranges: [r0, r1, r3, r2] }]);
|
||||
verify.referenceGroups([r1, r2], [{ definition: "(property) searchProp: number", ranges: [r0, r1, r3, r2] }]);
|
||||
verify.referenceGroups(r0, [{ definition: "(property) searchProp: number", ranges }]);
|
||||
verify.referenceGroups([r1, r2], [{ definition: "(property) searchProp: number", ranges }]);
|
||||
verify.referenceGroups(r3, [
|
||||
{ definition: "(property) searchProp: number", ranges: [r0, r1, r2] },
|
||||
{ definition: '(property) "searchProp": number', ranges: [r3] }
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
|
||||
const ranges = test.ranges();
|
||||
const [r0, r1, r2, r3] = ranges;
|
||||
verify.referenceGroups([r0, r1, r2], [{ definition: "(property) 42: number", ranges: [r0, r1, r3, r2] }]);
|
||||
verify.referenceGroups([r0, r1, r2], [{ definition: "(property) 42: number", ranges }]);
|
||||
verify.referenceGroups(r3, [
|
||||
{ definition: "(property) 42: number", ranges: [r0, r1, r2] },
|
||||
{ definition: '(property) "42": number', ranges: [r3] }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user