Skip to content

Commit ded27df

Browse files
Merge pull request #709 from Microsoft/navbar
Moved Navigation Bar Functionality to use the New Tree
2 parents 640dba4 + c1d15c7 commit ded27df

23 files changed

+635
-436
lines changed

Jakefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ var servicesSources = [
5757
"services.ts",
5858
"shims.ts",
5959
"signatureHelp.ts",
60-
"utilities.ts"
60+
"utilities.ts",
61+
"navigationBar.ts"
6162
].map(function (f) {
6263
return path.join(servicesDirectory, f);
6364
}));

src/compiler/binder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ module ts {
337337
break;
338338
case SyntaxKind.SourceFile:
339339
if (isExternalModule(<SourceFile>node)) {
340-
bindAnonymousDeclaration(node, SymbolFlags.ValueModule, '"' + getModuleNameFromFilename((<SourceFile>node).filename) + '"');
340+
bindAnonymousDeclaration(node, SymbolFlags.ValueModule, '"' + removeFileExtension((<SourceFile>node).filename) + '"');
341341
break;
342342
}
343343
default:

src/compiler/checker.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5658,6 +5658,10 @@ module ts {
56585658
var isConstructor = (symbol.flags & SymbolFlags.Constructor) !== 0;
56595659

56605660
function reportImplementationExpectedError(node: FunctionDeclaration): void {
5661+
if (node.name && node.name.kind === SyntaxKind.Missing) {
5662+
return;
5663+
}
5664+
56615665
var seen = false;
56625666
var subsequentNode = forEachChild(node.parent, c => {
56635667
if (seen) {

src/compiler/core.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,43 @@ module ts {
533533
return pathLen > extLen && path.substr(pathLen - extLen, extLen) === extension;
534534
}
535535

536+
var supportedExtensions = [".d.ts", ".ts", ".js"];
537+
538+
export function removeFileExtension(path: string): string {
539+
for (var i = 0; i < supportedExtensions.length; i++) {
540+
var ext = supportedExtensions[i];
541+
542+
if (fileExtensionIs(path, ext)) {
543+
return path.substr(0, path.length - ext.length);
544+
}
545+
}
546+
547+
return path;
548+
}
549+
550+
var escapedCharsRegExp = /[\t\v\f\b\0\r\n\"\\\u2028\u2029\u0085]/g;
551+
var escapedCharsMap: Map<string> = {
552+
"\t": "\\t",
553+
"\v": "\\v",
554+
"\f": "\\f",
555+
"\b": "\\b",
556+
"\0": "\\0",
557+
"\r": "\\r",
558+
"\n": "\\n",
559+
"\"": "\\\"",
560+
"\u2028": "\\u2028", // lineSeparator
561+
"\u2029": "\\u2029", // paragraphSeparator
562+
"\u0085": "\\u0085" // nextLine
563+
};
564+
565+
/** NOTE: This *does not* support the full escape characters, it only supports the subset that can be used in file names
566+
* or string literals. If the information encoded in the map changes, this needs to be revisited. */
567+
export function escapeString(s: string): string {
568+
return escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, c => {
569+
return escapedCharsMap[c] || c;
570+
}) : s;
571+
}
572+
536573
export interface ObjectAllocator {
537574
getNodeConstructor(kind: SyntaxKind): new () => Node;
538575
getSymbolConstructor(): new (flags: SymbolFlags, name: string) => Symbol;

src/compiler/emitter.ts

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ module ts {
5656

5757
function getOwnEmitOutputFilePath(sourceFile: SourceFile, extension: string) {
5858
if (compilerOptions.outDir) {
59-
var emitOutputFilePathWithoutExtension = getModuleNameFromFilename(getSourceFilePathInNewDir(compilerOptions.outDir, sourceFile));
59+
var emitOutputFilePathWithoutExtension = removeFileExtension(getSourceFilePathInNewDir(compilerOptions.outDir, sourceFile));
6060
}
6161
else {
62-
var emitOutputFilePathWithoutExtension = getModuleNameFromFilename(sourceFile.filename);
62+
var emitOutputFilePathWithoutExtension = removeFileExtension(sourceFile.filename);
6363
}
6464

6565
return emitOutputFilePathWithoutExtension + extension;
@@ -591,21 +591,6 @@ module ts {
591591
recordSourceMapSpan(comment.end);
592592
}
593593

594-
var escapedCharsRegExp = /[\t\v\f\b\0\r\n\"\u2028\u2029\u0085]/g;
595-
var escapedCharsMap: Map<string> = {
596-
"\t": "\\t",
597-
"\v": "\\v",
598-
"\f": "\\f",
599-
"\b": "\\b",
600-
"\0": "\\0",
601-
"\r": "\\r",
602-
"\n": "\\n",
603-
"\"": "\\\"",
604-
"\u2028": "\\u2028", // lineSeparator
605-
"\u2029": "\\u2029", // paragraphSeparator
606-
"\u0085": "\\u0085" // nextLine
607-
};
608-
609594
function serializeSourceMapContents(version: number, file: string, sourceRoot: string, sources: string[], names: string[], mappings: string) {
610595
if (typeof JSON !== "undefined") {
611596
return JSON.stringify({
@@ -620,14 +605,6 @@ module ts {
620605

621606
return "{\"version\":" + version + ",\"file\":\"" + escapeString(file) + "\",\"sourceRoot\":\"" + escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + escapeString(mappings) + "\"}";
622607

623-
/** This does not support the full escape characters, it only supports the subset that can be used in file names
624-
* or string literals. If the information encoded in the map changes, this needs to be revisited. */
625-
function escapeString(s: string): string {
626-
return escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, c => {
627-
return escapedCharsMap[c] || c;
628-
}) : s;
629-
}
630-
631608
function serializeStringArray(list: string[]): string {
632609
var output = "";
633610
for (var i = 0, n = list.length; i < n; i++) {
@@ -3164,7 +3141,7 @@ module ts {
31643141
? referencedFile.filename // Declaration file, use declaration file name
31653142
: shouldEmitToOwnFile(referencedFile, compilerOptions)
31663143
? getOwnEmitOutputFilePath(referencedFile, ".d.ts") // Own output file so get the .d.ts file
3167-
: getModuleNameFromFilename(compilerOptions.out) + ".d.ts";// Global out file
3144+
: removeFileExtension(compilerOptions.out) + ".d.ts";// Global out file
31683145

31693146
declFileName = getRelativePathToDirectoryOrUrl(
31703147
getDirectoryPath(normalizeSlashes(jsFilePath)),
@@ -3237,7 +3214,7 @@ module ts {
32373214
}
32383215
});
32393216
declarationOutput += synchronousDeclarationOutput.substring(appliedSyncOutputPos);
3240-
writeFile(getModuleNameFromFilename(jsFilePath) + ".d.ts", declarationOutput, compilerOptions.emitBOM);
3217+
writeFile(removeFileExtension(jsFilePath) + ".d.ts", declarationOutput, compilerOptions.emitBOM);
32413218
}
32423219
}
32433220

src/compiler/parser.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,11 @@ module ts {
1717
return node;
1818
}
1919

20-
var moduleExtensions = [".d.ts", ".ts", ".js"];
21-
2220
interface ReferenceComments {
2321
referencedFiles: FileReference[];
2422
amdDependencies: string[];
2523
}
2624

27-
export function getModuleNameFromFilename(filename: string) {
28-
for (var i = 0; i < moduleExtensions.length; i++) {
29-
var ext = moduleExtensions[i];
30-
var len = filename.length - ext.length;
31-
if (len > 0 && filename.substr(len) === ext) return filename.substr(0, len);
32-
}
33-
return filename;
34-
}
35-
3625
export function getSourceFileOfNode(node: Node): SourceFile {
3726
while (node && node.kind !== SyntaxKind.SourceFile) node = node.parent;
3827
return <SourceFile>node;
@@ -1107,7 +1096,10 @@ module ts {
11071096
return finishNode(node);
11081097
}
11091098
error(Diagnostics.Identifier_expected);
1110-
return <Identifier>createMissingNode();
1099+
1100+
var node = <Identifier>createMissingNode();
1101+
node.text = "";
1102+
return node;
11111103
}
11121104

11131105
function parseIdentifier(): Identifier {

0 commit comments

Comments
 (0)