From f84d2af9e7e885c6725e966200aed8971cff917c Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 13 Aug 2014 11:24:46 -0700 Subject: [PATCH] disable resolution for now --- src/harness/fourslash.ts | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 0fa27f0d1f..e201bce19b 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -204,30 +204,29 @@ module FourSlash { this.cancellationToken = new TestCancellationToken(); this.languageServiceShimHost = new Harness.LanguageService.TypeScriptLS(this.cancellationToken); - var harnessCompiler = Harness.Compiler.getCompiler(); var inputFiles: { unitName: string; content: string }[] = []; testData.files.forEach(file => { var fixedPath = file.fileName.substr(file.fileName.indexOf('tests/')); - harnessCompiler.addInputFile({ unitName: fixedPath, content: file.content }); }); + // NEWTODO: disable resolution for now. // If the last unit contains require( or /// reference then consider it the only input file // and the rest will be added via resolution. If not, then assume we have multiple files // with 0 references in any of them. We could be smarter here to allow scenarios like // 2 files without references and 1 file with a reference but we have 0 tests like that // at the moment and an exhaustive search of the test files for that content could be quite slow. var lastFile = testData.files[testData.files.length - 1]; - if (/require\(/.test(lastFile.content) || /reference\spath/.test(lastFile.content)) { - inputFiles.push({ unitName: lastFile.fileName, content: lastFile.content }); - } else { + //if (/require\(/.test(lastFile.content) || /reference\spath/.test(lastFile.content)) { + // inputFiles.push({ unitName: lastFile.fileName, content: lastFile.content }); + //} else { inputFiles = testData.files.map(file => { return { unitName: file.fileName, content: file.content }; }); - } + //} + // NEWTODO: Re-implement commented-out section - //harnessCompiler.addInputFiles(inputFiles); //try { // var resolvedFiles = harnessCompiler.resolve(); @@ -606,19 +605,19 @@ module FourSlash { if (localFilesOnly) { var localFiles = this.testData.files.map(file => file.fileName); // Count only the references in local files. Filter the ones in lib and other files. - references.forEach((entry) => { + ts.forEach(references, entry => { if (localFiles.some((filename) => filename === entry.fileName)) { ++referencesCount; } }); } else { - referencesCount = references.length; + referencesCount = references && references.length || 0; } if (referencesCount !== count) { var condition = localFilesOnly ? "excluding libs" : "including libs"; - throw new Error("Expected references count (" + condition + ") to be " + count + ", but is actually " + references.length); + throw new Error("Expected references count (" + condition + ") to be " + count + ", but is actually " + referencesCount); } } @@ -944,6 +943,18 @@ module FourSlash { Harness.IO.log(JSON.stringify(completions)); } + public printReferences() { + var references = this.getReferencesAtCaret(); + ts.forEach(references, entry => { + Harness.IO.log(JSON.stringify(entry)); + }); + } + + public printContext() { + var fileNames: string[] = JSON.parse(this.languageServiceShimHost.getScriptFileNames()); + ts.forEach(fileNames, f => Harness.IO.log(f)); + } + private editCheckpoint(filename: string) { // TODO: What's this for? It is being called by deleteChar // this.languageService.getScriptLexicalStructure(filename);