Skip to content

Commit 4b35f01

Browse files
committed
Merge branch 'master' of https://github.com/Microsoft/TypeScript into importsInCompletion
2 parents 8749bf3 + 7ead44f commit 4b35f01

16 files changed

+89
-276
lines changed

Jakefile.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts
330330
options += " --lib " + opts.lib
331331
}
332332
else {
333-
options += " --lib es5,scripthost"
333+
options += " --lib es5"
334334
}
335335
options += " --noUnusedLocals --noUnusedParameters";
336336

@@ -584,13 +584,13 @@ var cancellationTokenFile = path.join(builtLocalDirectory, "cancellationToken.js
584584
compileFile(cancellationTokenFile, cancellationTokenSources, [builtLocalDirectory].concat(cancellationTokenSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], outDir: builtLocalDirectory, noOutFile: true, lib: "es6" });
585585

586586
var typingsInstallerFile = path.join(builtLocalDirectory, "typingsInstaller.js");
587-
compileFile(typingsInstallerFile, typingsInstallerSources, [builtLocalDirectory].concat(typingsInstallerSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], outDir: builtLocalDirectory, noOutFile: false, lib: "es6,scripthost" });
587+
compileFile(typingsInstallerFile, typingsInstallerSources, [builtLocalDirectory].concat(typingsInstallerSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], outDir: builtLocalDirectory, noOutFile: false, lib: "es6" });
588588

589589
var watchGuardFile = path.join(builtLocalDirectory, "watchGuard.js");
590590
compileFile(watchGuardFile, watchGuardSources, [builtLocalDirectory].concat(watchGuardSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], outDir: builtLocalDirectory, noOutFile: false, lib: "es6" });
591591

592592
var serverFile = path.join(builtLocalDirectory, "tsserver.js");
593-
compileFile(serverFile, serverSources, [builtLocalDirectory, copyright, cancellationTokenFile, typingsInstallerFile, watchGuardFile].concat(serverSources).concat(servicesSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], preserveConstEnums: true, lib: "es6,scripthost" });
593+
compileFile(serverFile, serverSources, [builtLocalDirectory, copyright, cancellationTokenFile, typingsInstallerFile, watchGuardFile].concat(serverSources).concat(servicesSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], preserveConstEnums: true, lib: "es6" });
594594
var tsserverLibraryFile = path.join(builtLocalDirectory, "tsserverlibrary.js");
595595
var tsserverLibraryDefinitionFile = path.join(builtLocalDirectory, "tsserverlibrary.d.ts");
596596
compileFile(
@@ -714,7 +714,7 @@ compileFile(
714714
/*prereqs*/[builtLocalDirectory, tscFile].concat(libraryTargets).concat(servicesSources).concat(harnessSources),
715715
/*prefixes*/[],
716716
/*useBuiltCompiler:*/ true,
717-
/*opts*/ { inlineSourceMap: true, types: ["node", "mocha", "chai"], lib: "es6,scripthost" });
717+
/*opts*/ { inlineSourceMap: true, types: ["node", "mocha", "chai"], lib: "es6" });
718718

719719
var internalTests = "internal/";
720720

src/compiler/diagnosticMessages.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2413,10 +2413,6 @@
24132413
"category": "Error",
24142414
"code": 5012
24152415
},
2416-
"Unsupported file encoding.": {
2417-
"category": "Error",
2418-
"code": 5013
2419-
},
24202416
"Failed to parse file '{0}': {1}.": {
24212417
"category": "Error",
24222418
"code": 5014

src/compiler/program.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,6 @@ namespace ts {
8787
return sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase();
8888
}
8989

90-
// returned by CScript sys environment
91-
const unsupportedFileEncodingErrorCode = -2147024809;
92-
9390
function getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile {
9491
let text: string;
9592
try {
@@ -100,9 +97,7 @@ namespace ts {
10097
}
10198
catch (e) {
10299
if (onError) {
103-
onError(e.number === unsupportedFileEncodingErrorCode
104-
? createCompilerDiagnostic(Diagnostics.Unsupported_file_encoding).messageText
105-
: e.message);
100+
onError(e.message);
106101
}
107102
text = "";
108103
}

src/compiler/sys.ts

Lines changed: 0 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,6 @@ namespace ts {
7474
return parseInt(version.substring(1, dot));
7575
}
7676

77-
declare class Enumerator {
78-
public atEnd(): boolean;
79-
public moveNext(): boolean;
80-
public item(): any;
81-
constructor(o: any);
82-
}
83-
8477
declare var ChakraHost: {
8578
args: string[];
8679
currentDirectory: string;
@@ -104,152 +97,6 @@ namespace ts {
10497
};
10598

10699
export let sys: System = (function() {
107-
108-
function getWScriptSystem(): System {
109-
110-
const fso = new ActiveXObject("Scripting.FileSystemObject");
111-
const shell = new ActiveXObject("WScript.Shell");
112-
113-
const fileStream = new ActiveXObject("ADODB.Stream");
114-
fileStream.Type = 2 /*text*/;
115-
116-
const binaryStream = new ActiveXObject("ADODB.Stream");
117-
binaryStream.Type = 1 /*binary*/;
118-
119-
const args: string[] = [];
120-
for (let i = 0; i < WScript.Arguments.length; i++) {
121-
args[i] = WScript.Arguments.Item(i);
122-
}
123-
124-
function readFile(fileName: string, encoding?: string): string {
125-
if (!fso.FileExists(fileName)) {
126-
return undefined;
127-
}
128-
fileStream.Open();
129-
try {
130-
if (encoding) {
131-
fileStream.Charset = encoding;
132-
fileStream.LoadFromFile(fileName);
133-
}
134-
else {
135-
// Load file and read the first two bytes into a string with no interpretation
136-
fileStream.Charset = "x-ansi";
137-
fileStream.LoadFromFile(fileName);
138-
const bom = fileStream.ReadText(2) || "";
139-
// Position must be at 0 before encoding can be changed
140-
fileStream.Position = 0;
141-
// [0xFF,0xFE] and [0xFE,0xFF] mean utf-16 (little or big endian), otherwise default to utf-8
142-
fileStream.Charset = bom.length >= 2 && (bom.charCodeAt(0) === 0xFF && bom.charCodeAt(1) === 0xFE || bom.charCodeAt(0) === 0xFE && bom.charCodeAt(1) === 0xFF) ? "unicode" : "utf-8";
143-
}
144-
// ReadText method always strips byte order mark from resulting string
145-
return fileStream.ReadText();
146-
}
147-
catch (e) {
148-
throw e;
149-
}
150-
finally {
151-
fileStream.Close();
152-
}
153-
}
154-
155-
function writeFile(fileName: string, data: string, writeByteOrderMark?: boolean): void {
156-
fileStream.Open();
157-
binaryStream.Open();
158-
try {
159-
// Write characters in UTF-8 encoding
160-
fileStream.Charset = "utf-8";
161-
fileStream.WriteText(data);
162-
// If we don't want the BOM, then skip it by setting the starting location to 3 (size of BOM).
163-
// If not, start from position 0, as the BOM will be added automatically when charset==utf8.
164-
if (writeByteOrderMark) {
165-
fileStream.Position = 0;
166-
}
167-
else {
168-
fileStream.Position = 3;
169-
}
170-
fileStream.CopyTo(binaryStream);
171-
binaryStream.SaveToFile(fileName, 2 /*overwrite*/);
172-
}
173-
finally {
174-
binaryStream.Close();
175-
fileStream.Close();
176-
}
177-
}
178-
179-
function getNames(collection: any): string[] {
180-
const result: string[] = [];
181-
for (const e = new Enumerator(collection); !e.atEnd(); e.moveNext()) {
182-
result.push(e.item().Name);
183-
}
184-
return result.sort();
185-
}
186-
187-
function getDirectories(path: string): string[] {
188-
const folder = fso.GetFolder(path);
189-
return getNames(folder.subfolders);
190-
}
191-
192-
function getAccessibleFileSystemEntries(path: string): FileSystemEntries {
193-
try {
194-
const folder = fso.GetFolder(path || ".");
195-
const files = getNames(folder.files);
196-
const directories = getNames(folder.subfolders);
197-
return { files, directories };
198-
}
199-
catch (e) {
200-
return { files: [], directories: [] };
201-
}
202-
}
203-
204-
function readDirectory(path: string, extensions?: string[], excludes?: string[], includes?: string[]): string[] {
205-
return matchFiles(path, extensions, excludes, includes, /*useCaseSensitiveFileNames*/ false, shell.CurrentDirectory, getAccessibleFileSystemEntries);
206-
}
207-
208-
const wscriptSystem: System = {
209-
args,
210-
newLine: "\r\n",
211-
useCaseSensitiveFileNames: false,
212-
write(s: string): void {
213-
WScript.StdOut.Write(s);
214-
},
215-
readFile,
216-
writeFile,
217-
resolvePath(path: string): string {
218-
return fso.GetAbsolutePathName(path);
219-
},
220-
fileExists(path: string): boolean {
221-
return fso.FileExists(path);
222-
},
223-
directoryExists(path: string) {
224-
return fso.FolderExists(path);
225-
},
226-
createDirectory(directoryName: string) {
227-
if (!wscriptSystem.directoryExists(directoryName)) {
228-
fso.CreateFolder(directoryName);
229-
}
230-
},
231-
getExecutingFilePath() {
232-
return WScript.ScriptFullName;
233-
},
234-
getCurrentDirectory() {
235-
return shell.CurrentDirectory;
236-
},
237-
getDirectories,
238-
getEnvironmentVariable(name: string) {
239-
return new ActiveXObject("WScript.Shell").ExpandEnvironmentStrings(`%${name}%`);
240-
},
241-
readDirectory,
242-
exit(exitCode?: number): void {
243-
try {
244-
WScript.Quit(exitCode);
245-
}
246-
catch (e) {
247-
}
248-
}
249-
};
250-
return wscriptSystem;
251-
}
252-
253100
function getNodeSystem(): System {
254101
const _fs = require("fs");
255102
const _path = require("path");
@@ -646,9 +493,6 @@ namespace ts {
646493
if (typeof ChakraHost !== "undefined") {
647494
sys = getChakraSystem();
648495
}
649-
else if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") {
650-
sys = getWScriptSystem();
651-
}
652496
else if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") {
653497
// process and process.nextTick checks if current environment is node-like
654498
// process.browser check excludes webpack and browserify

src/harness/fourslash.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -928,9 +928,13 @@ namespace FourSlash {
928928
}
929929

930930
function rangeToReferenceEntry(r: Range) {
931-
let { isWriteAccess, isDefinition } = (r.marker && r.marker.data) || { isWriteAccess: false, isDefinition: false };
931+
let { isWriteAccess, isDefinition, isInString } = (r.marker && r.marker.data) || { isWriteAccess: false, isDefinition: false, isInString: undefined };
932932
isWriteAccess = !!isWriteAccess; isDefinition = !!isDefinition;
933-
return { fileName: r.fileName, textSpan: { start: r.start, length: r.end - r.start }, isWriteAccess, isDefinition };
933+
const result: any = { fileName: r.fileName, textSpan: { start: r.start, length: r.end - r.start }, isWriteAccess, isDefinition };
934+
if (isInString !== undefined) {
935+
result.isInString = isInString;
936+
}
937+
return result;
934938
}
935939
}
936940

0 commit comments

Comments
 (0)