Skip to content

Commit fda9974

Browse files
committed
Merge branch 'master' into inlineSourceMaps
2 parents 5d78dd2 + baac6d8 commit fda9974

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+739
-293
lines changed

src/compiler/checker.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ module ts {
77

88
/* @internal */ export let checkTime = 0;
99

10+
/* @internal */
11+
export function getSymbolId(symbol: Symbol): number {
12+
if (!symbol.id) {
13+
symbol.id = nextSymbolId++;
14+
}
15+
16+
return symbol.id;
17+
}
18+
1019
export function createTypeChecker(host: TypeCheckerHost, produceDiagnostics: boolean): TypeChecker {
1120
let Symbol = objectAllocator.getSymbolConstructor();
1221
let Type = objectAllocator.getTypeConstructor();
@@ -250,8 +259,8 @@ module ts {
250259

251260
function getSymbolLinks(symbol: Symbol): SymbolLinks {
252261
if (symbol.flags & SymbolFlags.Transient) return <TransientSymbol>symbol;
253-
if (!symbol.id) symbol.id = nextSymbolId++;
254-
return symbolLinks[symbol.id] || (symbolLinks[symbol.id] = {});
262+
var id = getSymbolId(symbol);
263+
return symbolLinks[id] || (symbolLinks[id] = {});
255264
}
256265

257266
function getNodeLinks(node: Node): NodeLinks {

src/compiler/program.ts

+16
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,22 @@ module ts {
1010
/** The version of the TypeScript compiler release */
1111
export let version = "1.5.0.0";
1212

13+
export function findConfigFile(searchPath: string): string {
14+
var fileName = "tsconfig.json";
15+
while (true) {
16+
if (sys.fileExists(fileName)) {
17+
return fileName;
18+
}
19+
var parentPath = getDirectoryPath(searchPath);
20+
if (parentPath === searchPath) {
21+
break;
22+
}
23+
searchPath = parentPath;
24+
fileName = "../" + fileName;
25+
}
26+
return undefined;
27+
}
28+
1329
export function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost {
1430
let currentDirectory: string;
1531
let existingDirectories: Map<boolean> = {};

src/compiler/scanner.ts

+29-4
Original file line numberDiff line numberDiff line change
@@ -318,13 +318,38 @@ module ts {
318318
let hasOwnProperty = Object.prototype.hasOwnProperty;
319319

320320
export function isWhiteSpace(ch: number): boolean {
321-
return ch === CharacterCodes.space || ch === CharacterCodes.tab || ch === CharacterCodes.verticalTab || ch === CharacterCodes.formFeed ||
322-
ch === CharacterCodes.nonBreakingSpace || ch === CharacterCodes.ogham || ch >= CharacterCodes.enQuad && ch <= CharacterCodes.zeroWidthSpace ||
323-
ch === CharacterCodes.narrowNoBreakSpace || ch === CharacterCodes.mathematicalSpace || ch === CharacterCodes.ideographicSpace || ch === CharacterCodes.byteOrderMark;
321+
// Note: nextLine is in the Zs space, and should be considered to be a whitespace.
322+
// It is explicitly not a line-break as it isn't in the exact set specified by EcmaScript.
323+
return ch === CharacterCodes.space ||
324+
ch === CharacterCodes.tab ||
325+
ch === CharacterCodes.verticalTab ||
326+
ch === CharacterCodes.formFeed ||
327+
ch === CharacterCodes.nonBreakingSpace ||
328+
ch === CharacterCodes.nextLine ||
329+
ch === CharacterCodes.ogham ||
330+
ch >= CharacterCodes.enQuad && ch <= CharacterCodes.zeroWidthSpace ||
331+
ch === CharacterCodes.narrowNoBreakSpace ||
332+
ch === CharacterCodes.mathematicalSpace ||
333+
ch === CharacterCodes.ideographicSpace ||
334+
ch === CharacterCodes.byteOrderMark;
324335
}
325336

326337
export function isLineBreak(ch: number): boolean {
327-
return ch === CharacterCodes.lineFeed || ch === CharacterCodes.carriageReturn || ch === CharacterCodes.lineSeparator || ch === CharacterCodes.paragraphSeparator || ch === CharacterCodes.nextLine;
338+
// ES5 7.3:
339+
// The ECMAScript line terminator characters are listed in Table 3.
340+
// Table 3 — Line Terminator Characters
341+
// Code Unit Value Name Formal Name
342+
// \u000A Line Feed <LF>
343+
// \u000D Carriage Return <CR>
344+
// \u2028 Line separator <LS>
345+
// \u2029 Paragraph separator <PS>
346+
// Only the characters in Table 3 are treated as line terminators. Other new line or line
347+
// breaking characters are treated as white space but not as line terminators.
348+
349+
return ch === CharacterCodes.lineFeed ||
350+
ch === CharacterCodes.carriageReturn ||
351+
ch === CharacterCodes.lineSeparator ||
352+
ch === CharacterCodes.paragraphSeparator;
328353
}
329354

330355
function isDigit(ch: number): boolean {

src/compiler/tsc.ts

+2-18
Original file line numberDiff line numberDiff line change
@@ -132,23 +132,6 @@ module ts {
132132
return typeof JSON === "object" && typeof JSON.parse === "function";
133133
}
134134

135-
function findConfigFile(): string {
136-
var searchPath = normalizePath(sys.getCurrentDirectory());
137-
var fileName = "tsconfig.json";
138-
while (true) {
139-
if (sys.fileExists(fileName)) {
140-
return fileName;
141-
}
142-
var parentPath = getDirectoryPath(searchPath);
143-
if (parentPath === searchPath) {
144-
break;
145-
}
146-
searchPath = parentPath;
147-
fileName = "../" + fileName;
148-
}
149-
return undefined;
150-
}
151-
152135
export function executeCommandLine(args: string[]): void {
153136
var commandLine = parseCommandLine(args);
154137
var configFileName: string; // Configuration file name (if any)
@@ -198,7 +181,8 @@ module ts {
198181
}
199182
}
200183
else if (commandLine.fileNames.length === 0 && isJSONSupported()) {
201-
configFileName = findConfigFile();
184+
var searchPath = normalizePath(sys.getCurrentDirectory());
185+
configFileName = findConfigFile(searchPath);
202186
}
203187

204188
if (commandLine.fileNames.length === 0 && !configFileName) {

src/harness/harnessLanguageService.ts

+3
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,9 @@ module Harness.LanguageService {
330330
getReferencesAtPosition(fileName: string, position: number): ts.ReferenceEntry[] {
331331
return unwrapJSONCallResult(this.shim.getReferencesAtPosition(fileName, position));
332332
}
333+
findReferences(fileName: string, position: number): ts.ReferencedSymbol[] {
334+
return unwrapJSONCallResult(this.shim.findReferences(fileName, position));
335+
}
333336
getOccurrencesAtPosition(fileName: string, position: number): ts.ReferenceEntry[] {
334337
return unwrapJSONCallResult(this.shim.getOccurrencesAtPosition(fileName, position));
335338
}

src/server/client.ts

+5
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,11 @@ module ts.server {
300300
});
301301
}
302302

303+
findReferences(fileName: string, position: number): ReferencedSymbol[]{
304+
// Not yet implemented.
305+
return [];
306+
}
307+
303308
getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[] {
304309
var lineOffset = this.positionToOneBasedLineOffset(fileName, position);
305310
var args: protocol.FileLocationRequestArgs = {

0 commit comments

Comments
 (0)