Merge branch 'master' into fixParsingShorthand

This commit is contained in:
Yui T 2014-11-19 13:24:22 -08:00
commit 49c8e83616
35 changed files with 8204 additions and 19952 deletions

4
bin/lib.core.d.ts vendored
View file

@ -499,6 +499,10 @@ declare var Number: {
POSITIVE_INFINITY: number;
}
interface TemplateStringsArray extends Array<string> {
raw: string[];
}
interface Math {
/** The mathematical constant e. This is Euler's number, the base of natural logarithms. */
E: number;

4
bin/lib.d.ts vendored
View file

@ -499,6 +499,10 @@ declare var Number: {
POSITIVE_INFINITY: number;
}
interface TemplateStringsArray extends Array<string> {
raw: string[];
}
interface Math {
/** The mathematical constant e. This is Euler's number, the base of natural logarithms. */
E: number;

5031
bin/tsc.js

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -75,43 +75,43 @@ module ts {
var checker: TypeChecker = {
getProgram: () => program,
getDiagnostics: getDiagnostics,
getGlobalDiagnostics: getGlobalDiagnostics,
getNodeCount: () => sum(program.getSourceFiles(), "nodeCount"),
getIdentifierCount: () => sum(program.getSourceFiles(), "identifierCount"),
getSymbolCount: () => sum(program.getSourceFiles(), "symbolCount"),
getTypeCount: () => typeCount,
checkProgram: checkProgram,
emitFiles: invokeEmitter,
getParentOfSymbol: getParentOfSymbol,
getNarrowedTypeOfSymbol: getNarrowedTypeOfSymbol,
getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol,
getPropertiesOfType: getPropertiesOfType,
getPropertyOfType: getPropertyOfType,
getSignaturesOfType: getSignaturesOfType,
getIndexTypeOfType: getIndexTypeOfType,
getReturnTypeOfSignature: getReturnTypeOfSignature,
getSymbolsInScope: getSymbolsInScope,
getSymbolInfo: getSymbolInfo,
getShorthandAssignmentValueSymbol: getShorthandAssignmentValueSymbol,
getTypeOfNode: getTypeOfNode,
typeToString: typeToString,
getSymbolDisplayBuilder: getSymbolDisplayBuilder,
symbolToString: symbolToString,
getAugmentedPropertiesOfType: getAugmentedPropertiesOfType,
getRootSymbols: getRootSymbols,
getContextualType: getContextualType,
getFullyQualifiedName: getFullyQualifiedName,
getResolvedSignature: getResolvedSignature,
getEnumMemberValue: getEnumMemberValue,
isValidPropertyAccess: isValidPropertyAccess,
getSignatureFromDeclaration: getSignatureFromDeclaration,
isImplementationOfOverload: isImplementationOfOverload,
getAliasedSymbol: resolveImport,
isUndefinedSymbol: symbol => symbol === undefinedSymbol,
isArgumentsSymbol: symbol => symbol === argumentsSymbol,
hasEarlyErrors: hasEarlyErrors,
isEmitBlocked: isEmitBlocked
getDiagnostics,
getGlobalDiagnostics,
checkProgram,
invokeEmitter,
getParentOfSymbol,
getNarrowedTypeOfSymbol,
getDeclaredTypeOfSymbol,
getPropertiesOfType,
getPropertyOfType,
getSignaturesOfType,
getIndexTypeOfType,
getReturnTypeOfSignature,
getSymbolsInScope,
getSymbolInfo,
getShorthandAssignmentValueSymbol,
getTypeOfNode,
typeToString,
getSymbolDisplayBuilder,
symbolToString,
getAugmentedPropertiesOfType,
getRootSymbols,
getContextualType,
getFullyQualifiedName,
getResolvedSignature,
getEnumMemberValue,
isValidPropertyAccess,
getSignatureFromDeclaration,
isImplementationOfOverload,
getAliasedSymbol: resolveImport,
hasEarlyErrors,
isEmitBlocked,
};
var undefinedSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "undefined");
@ -953,7 +953,7 @@ module ts {
if (forEach(symbol.declarations, declaration => !getIsDeclarationVisible(declaration))) {
return undefined;
}
return { aliasesToMakeVisible: aliasesToMakeVisible };
return { aliasesToMakeVisible };
function getIsDeclarationVisible(declaration: Declaration) {
if (!isDeclarationVisible(declaration)) {
@ -9118,22 +9118,22 @@ module ts {
function invokeEmitter(targetSourceFile?: SourceFile) {
var resolver: EmitResolver = {
getProgram: () => program,
getLocalNameOfContainer: getLocalNameOfContainer,
getExpressionNamePrefix: getExpressionNamePrefix,
getExportAssignmentName: getExportAssignmentName,
isReferencedImportDeclaration: isReferencedImportDeclaration,
getNodeCheckFlags: getNodeCheckFlags,
getEnumMemberValue: getEnumMemberValue,
isTopLevelValueImportWithEntityName: isTopLevelValueImportWithEntityName,
hasSemanticErrors: hasSemanticErrors,
isEmitBlocked: isEmitBlocked,
isDeclarationVisible: isDeclarationVisible,
isImplementationOfOverload: isImplementationOfOverload,
writeTypeAtLocation: writeTypeAtLocation,
writeReturnTypeOfSignatureDeclaration: writeReturnTypeOfSignatureDeclaration,
isSymbolAccessible: isSymbolAccessible,
isImportDeclarationEntityNameReferenceDeclarationVisibile: isImportDeclarationEntityNameReferenceDeclarationVisibile,
getConstantValue: getConstantValue,
getLocalNameOfContainer,
getExpressionNamePrefix,
getExportAssignmentName,
isReferencedImportDeclaration,
getNodeCheckFlags,
getEnumMemberValue,
isTopLevelValueImportWithEntityName,
hasSemanticErrors,
isEmitBlocked,
isDeclarationVisible,
isImplementationOfOverload,
writeTypeAtLocation,
writeReturnTypeOfSignatureDeclaration,
isSymbolAccessible,
isImportDeclarationEntityNameReferenceDeclarationVisibile,
getConstantValue,
};
checkProgram();
return emitFiles(resolver, targetSourceFile);

View file

@ -153,9 +153,9 @@ module ts {
parseStrings(commandLine);
return {
options: options,
filenames: filenames,
errors: errors
options,
filenames,
errors
};
function parseStrings(args: string[]) {

View file

@ -258,9 +258,9 @@ module ts {
}
return {
file: file,
start: start,
length: length,
file,
start,
length,
messageText: text,
category: message.category,
@ -335,12 +335,12 @@ module ts {
}
return {
file: file,
start: start,
length: length,
code: code,
category: category,
messageText: messageText
file,
start,
length,
code,
category,
messageText
};
}

View file

@ -273,6 +273,7 @@ module ts {
Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0: { code: 2455, category: DiagnosticCategory.Error, key: "Type argument candidate '{1}' is not a valid type argument because it is not a supertype of candidate '{0}'." },
Type_alias_0_circularly_references_itself: { code: 2456, category: DiagnosticCategory.Error, key: "Type alias '{0}' circularly references itself." },
Type_alias_name_cannot_be_0: { code: 2457, category: DiagnosticCategory.Error, key: "Type alias name cannot be '{0}'" },
An_AMD_module_cannot_have_multiple_name_assignments: { code: 2458, category: DiagnosticCategory.Error, key: "An AMD module cannot have multiple name assignments." },
Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." },
Type_parameter_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4001, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using name '{1}' from private module '{2}'." },
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." },

View file

@ -1089,6 +1089,10 @@
"category": "Error",
"code": 2457
},
"An AMD module cannot have multiple name assignments.": {
"category": "Error",
"code": 2458
},
"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",

View file

@ -104,9 +104,9 @@ module ts {
}
});
return {
firstAccessor: firstAccessor,
getAccessor: getAccessor,
setAccessor: setAccessor
firstAccessor,
getAccessor,
setAccessor
};
}
@ -2134,7 +2134,11 @@ module ts {
function emitAMDModule(node: SourceFile, startIndex: number) {
var imports = getExternalImportDeclarations(node);
writeLine();
write("define([\"require\", \"exports\"");
write("define(");
if(node.amdModuleName) {
write("\"" + node.amdModuleName + "\", ");
}
write("[\"require\", \"exports\"");
forEach(imports, imp => {
write(", ");
emitLiteral(imp.externalModuleName);
@ -2783,7 +2787,7 @@ module ts {
Diagnostics.Exported_type_alias_0_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1;
return {
diagnosticMessage: diagnosticMessage,
diagnosticMessage,
errorNode: node,
typeName: node.name
};
@ -2880,7 +2884,7 @@ module ts {
}
return {
diagnosticMessage: diagnosticMessage,
diagnosticMessage,
errorNode: node,
typeName: node.name
};
@ -2945,7 +2949,7 @@ module ts {
}
return {
diagnosticMessage: diagnosticMessage,
diagnosticMessage,
errorNode: node,
typeName: (<Declaration>node.parent).name
};
@ -3127,7 +3131,7 @@ module ts {
Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1;
}
return {
diagnosticMessage: diagnosticMessage,
diagnosticMessage,
errorNode: <Node>node.parameters[0],
// TODO(jfreeman): Investigate why we are passing node.name instead of node.parameters[0].name
typeName: node.name
@ -3149,7 +3153,7 @@ module ts {
Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0;
}
return {
diagnosticMessage: diagnosticMessage,
diagnosticMessage,
errorNode: <Node>node.name,
typeName: undefined
};
@ -3279,7 +3283,7 @@ module ts {
}
return {
diagnosticMessage: diagnosticMessage,
diagnosticMessage,
errorNode: <Node>node.name || node,
};
}
@ -3364,7 +3368,7 @@ module ts {
}
return {
diagnosticMessage: diagnosticMessage,
diagnosticMessage,
errorNode: node,
typeName: node.name
};
@ -3549,22 +3553,22 @@ module ts {
var hasEmitterError = forEach(diagnostics, diagnostic => diagnostic.category === DiagnosticCategory.Error);
// Check and update returnCode for syntactic and semantic
var returnCode: EmitReturnStatus;
var emitResultStatus: EmitReturnStatus;
if (isEmitBlocked) {
returnCode = EmitReturnStatus.AllOutputGenerationSkipped;
emitResultStatus = EmitReturnStatus.AllOutputGenerationSkipped;
} else if (hasEmitterError) {
returnCode = EmitReturnStatus.EmitErrorsEncountered;
emitResultStatus = EmitReturnStatus.EmitErrorsEncountered;
} else if (hasSemanticErrors && compilerOptions.declaration) {
returnCode = EmitReturnStatus.DeclarationGenerationSkipped;
emitResultStatus = EmitReturnStatus.DeclarationGenerationSkipped;
} else if (hasSemanticErrors && !compilerOptions.declaration) {
returnCode = EmitReturnStatus.JSGeneratedWithSemanticErrors;
emitResultStatus = EmitReturnStatus.JSGeneratedWithSemanticErrors;
} else {
returnCode = EmitReturnStatus.Succeeded;
emitResultStatus = EmitReturnStatus.Succeeded;
}
return {
emitResultStatus: returnCode,
errors: diagnostics,
emitResultStatus,
diagnostics,
sourceMaps: sourceMapDataList
};
}

View file

@ -20,6 +20,7 @@ module ts {
interface ReferenceComments {
referencedFiles: FileReference[];
amdDependencies: string[];
amdModuleName: string;
}
export function getSourceFileOfNode(node: Node): SourceFile {
@ -774,13 +775,12 @@ module ts {
if (matchResult) {
var start = commentRange.pos;
var end = commentRange.end;
var fileRef = {
pos: start,
end: end,
filename: matchResult[3]
};
return {
fileReference: fileRef,
fileReference: {
pos: start,
end: end,
filename: matchResult[3]
},
isNoDefaultLib: false
};
}
@ -944,11 +944,11 @@ module ts {
}
return {
addLabel: addLabel,
pushCurrentLabelSet: pushCurrentLabelSet,
pushFunctionBoundary: pushFunctionBoundary,
pop: pop,
nodeIsNestedInLabel: nodeIsNestedInLabel,
addLabel,
pushCurrentLabelSet,
pushFunctionBoundary,
pop,
nodeIsNestedInLabel,
};
})();
@ -1674,8 +1674,8 @@ module ts {
}
return {
typeParameters: typeParameters,
parameters: parameters,
typeParameters,
parameters,
type: type
};
}
@ -4249,6 +4249,7 @@ module ts {
function processReferenceComments(): ReferenceComments {
var referencedFiles: FileReference[] = [];
var amdDependencies: string[] = [];
var amdModuleName: string;
commentRanges = [];
token = scanner.scan();
@ -4268,6 +4269,15 @@ module ts {
}
}
else {
var amdModuleNameRegEx = /^\/\/\/\s*<amd-module\s+name\s*=\s*('|")(.+?)\1/gim;
var amdModuleNameMatchResult = amdModuleNameRegEx.exec(comment);
if(amdModuleNameMatchResult) {
if(amdModuleName) {
errorAtPos(range.pos, range.end - range.pos, Diagnostics.An_AMD_module_cannot_have_multiple_name_assignments);
}
amdModuleName = amdModuleNameMatchResult[2];
}
var amdDependencyRegEx = /^\/\/\/\s*<amd-dependency\s+path\s*=\s*('|")(.+?)\1/gim;
var amdDependencyMatchResult = amdDependencyRegEx.exec(comment);
if (amdDependencyMatchResult) {
@ -4277,8 +4287,9 @@ module ts {
}
commentRanges = undefined;
return {
referencedFiles: referencedFiles,
amdDependencies: amdDependencies
referencedFiles,
amdDependencies,
amdModuleName
};
}
@ -4308,6 +4319,7 @@ module ts {
var referenceComments = processReferenceComments();
file.referencedFiles = referenceComments.referencedFiles;
file.amdDependencies = referenceComments.amdDependencies;
file.amdModuleName = referenceComments.amdModuleName;
file.statements = parseList(ParsingContext.SourceElements, /*checkForStrictMode*/ true, parseSourceElement);
file.externalModuleIndicator = getExternalModuleIndicator();
file.nodeCount = nodeCount;

View file

@ -1167,13 +1167,13 @@ module ts {
hasPrecedingLineBreak: () => precedingLineBreak,
isIdentifier: () => token === SyntaxKind.Identifier || token > SyntaxKind.LastReservedWord,
isReservedWord: () => token >= SyntaxKind.FirstReservedWord && token <= SyntaxKind.LastReservedWord,
reScanGreaterToken: reScanGreaterToken,
reScanSlashToken: reScanSlashToken,
reScanTemplateToken: reScanTemplateToken,
scan: scan,
setText: setText,
setTextPos: setTextPos,
tryScan: tryScan,
reScanGreaterToken,
reScanSlashToken,
reScanTemplateToken,
scan,
setText,
setTextPos,
tryScan,
};
}
}

View file

@ -99,14 +99,14 @@ var sys: System = (function () {
}
return {
args: args,
args,
newLine: "\r\n",
useCaseSensitiveFileNames: false,
write(s: string): void {
WScript.StdOut.Write(s);
},
readFile: readFile,
writeFile: writeFile,
readFile,
writeFile,
resolvePath(path: string): string {
return fso.GetAbsolutePathName(path);
},
@ -191,8 +191,8 @@ var sys: System = (function () {
// 1 is a standard descriptor for stdout
_fs.writeSync(1, s);
},
readFile: readFile,
writeFile: writeFile,
readFile,
writeFile,
watchFile: (fileName, callback) => {
// watchFile polls a file every 250ms, picking up file notifications.
_fs.watchFile(fileName, { persistent: true, interval: 250 }, fileChanged);

View file

@ -192,12 +192,12 @@ module ts {
}
return {
getSourceFile: getSourceFile,
getSourceFile,
getDefaultLibFilename: () => combinePaths(getDirectoryPath(normalizePath(sys.getExecutingFilePath())), "lib.d.ts"),
writeFile: writeFile,
writeFile,
getCurrentDirectory: () => currentDirectory || (currentDirectory = sys.getCurrentDirectory()),
useCaseSensitiveFileNames: () => sys.useCaseSensitiveFileNames,
getCanonicalFileName: getCanonicalFileName,
getCanonicalFileName,
getNewLine: () => sys.newLine
};
}
@ -367,8 +367,8 @@ module ts {
}
else {
var emitStart = new Date().getTime();
var emitOutput = checker.emitFiles();
var emitErrors = emitOutput.errors;
var emitOutput = checker.invokeEmitter();
var emitErrors = emitOutput.diagnostics;
exitStatus = emitOutput.emitResultStatus;
var reportStart = new Date().getTime();
errors = concatenate(errors, emitErrors);
@ -394,7 +394,7 @@ module ts {
reportTimeStatistic("Total time", reportStart - parseStart);
}
return { program: program, exitStatus: exitStatus }
return { program, exitStatus };
}
function printVersion() {

View file

@ -642,6 +642,7 @@ module ts {
getPositionFromLineAndCharacter(line: number, character: number): number;
getLineStarts(): number[];
amdDependencies: string[];
amdModuleName: string;
referencedFiles: FileReference[];
syntacticErrors: Diagnostic[];
semanticErrors: Diagnostic[];
@ -700,7 +701,7 @@ module ts {
export interface EmitResult {
emitResultStatus: EmitReturnStatus;
errors: Diagnostic[];
diagnostics: Diagnostic[];
sourceMaps: SourceMapData[]; // Array of sourceMapData if compiler emitted sourcemaps
}
@ -713,7 +714,7 @@ module ts {
getSymbolCount(): number;
getTypeCount(): number;
checkProgram(): void;
emitFiles(targetSourceFile?: SourceFile): EmitResult;
invokeEmitter(targetSourceFile?: SourceFile): EmitResult;
getParentOfSymbol(symbol: Symbol): Symbol;
getNarrowedTypeOfSymbol(symbol: Symbol, node: Node): Type;
getDeclaredTypeOfSymbol(symbol: Symbol): Type;

View file

@ -749,29 +749,6 @@ module FourSlash {
}
}
public verifyImplementorsCountIs(count: number, localFilesOnly: boolean = true) {
var implementors = this.getImplementorsAtCaret();
var implementorsCount = 0;
if (localFilesOnly) {
var localFiles = this.testData.files.map<string>(file => file.fileName);
// Count only the references in local files. Filter the ones in lib and other files.
implementors.forEach((entry) => {
if (localFiles.some((filename) => filename === entry.fileName)) {
++implementorsCount;
}
});
}
else {
implementorsCount = implementors.length;
}
if (implementorsCount !== count) {
var condition = localFilesOnly ? "excluding libs" : "including libs";
this.raiseError("Expected implementors count (" + condition + ") to be " + count + ", but is actually " + implementors.length);
}
}
private getMemberListAtCaret() {
return this.languageService.getCompletionsAtPosition(this.activeFile.fileName, this.currentCaretPosition, true);
}
@ -788,10 +765,6 @@ module FourSlash {
return this.languageService.getReferencesAtPosition(this.activeFile.fileName, this.currentCaretPosition);
}
private getImplementorsAtCaret() {
return this.languageService.getImplementorsAtPosition(this.activeFile.fileName, this.currentCaretPosition);
}
private assertionMessage(name: string, actualValue: any, expectedValue: any) {
return "\nActual " + name + ":\n\t" + actualValue + "\nExpected value:\n\t" + expectedValue;
}
@ -2250,7 +2223,7 @@ module FourSlash {
if (errs.length > 0) {
throw new Error('Error compiling ' + fileName + ': ' + errs.map(e => e.messageText).join('\r\n'));
}
checker.emitFiles();
checker.invokeEmitter();
result = result || ''; // Might have an empty fourslash file
// Compile and execute the test
@ -2284,7 +2257,7 @@ module FourSlash {
// List of all the subfiles we've parsed out
var files: FourSlashFile[] = [];
// Global options
var opts: { [s: string]: string; } = {};
var globalOptions: { [s: string]: string; } = {};
// Marker positions
// Split up the input file by line
@ -2292,7 +2265,7 @@ module FourSlash {
// we have to string-based splitting instead and try to figure out the delimiting chars
var lines = contents.split('\n');
var markerMap: MarkerMap = {};
var markerPositions: MarkerMap = {};
var markers: Marker[] = [];
var ranges: Range[] = [];
@ -2333,7 +2306,7 @@ module FourSlash {
} else if (fileMetadataNamesIndex === fileMetadataNames.indexOf(testOptMetadataNames.filename)) {
// Found an @Filename directive, if this is not the first then create a new subfile
if (currentFileContent) {
var file = parseFileContent(currentFileContent, currentFileName, markerMap, markers, ranges);
var file = parseFileContent(currentFileContent, currentFileName, markerPositions, markers, ranges);
file.fileOptions = currentFileOptions;
// Store result file
@ -2353,10 +2326,10 @@ module FourSlash {
}
} else {
// Check if the match is already existed in the global options
if (opts[match[1]] !== undefined) {
if (globalOptions[match[1]] !== undefined) {
throw new Error("Global Option : '" + match[1] + "' is already existed");
}
opts[match[1]] = match[2];
globalOptions[match[1]] = match[2];
}
}
} else if (line == '' || lineLength === 0) {
@ -2365,7 +2338,7 @@ module FourSlash {
} else {
// Empty line or code line, terminate current subfile if there is one
if (currentFileContent) {
var file = parseFileContent(currentFileContent, currentFileName, markerMap, markers, ranges);
var file = parseFileContent(currentFileContent, currentFileName, markerPositions, markers, ranges);
file.fileOptions = currentFileOptions;
// Store result file
@ -2380,11 +2353,11 @@ module FourSlash {
}
return {
markerPositions: markerMap,
markers: markers,
globalOptions: opts,
files: files,
ranges: ranges
markerPositions,
markers,
globalOptions,
files,
ranges
};
}

View file

@ -589,8 +589,8 @@ module Harness {
}
},
getDefaultLibFilename: () => defaultLibFileName,
writeFile: writeFile,
getCanonicalFileName: getCanonicalFileName,
writeFile,
getCanonicalFileName,
useCaseSensitiveFileNames: () => useCaseSensitiveFileNames,
getNewLine: ()=> sys.newLine
};
@ -806,11 +806,11 @@ module Harness {
// only emit if there weren't parse errors
var emitResult: ts.EmitResult;
if (!isEmitBlocked) {
emitResult = checker.emitFiles();
emitResult = checker.invokeEmitter();
}
var errors: HarnessDiagnostic[] = [];
program.getDiagnostics().concat(checker.getDiagnostics()).concat(emitResult ? emitResult.errors : []).forEach(err => {
program.getDiagnostics().concat(checker.getDiagnostics()).concat(emitResult ? emitResult.diagnostics : []).forEach(err => {
// TODO: new compiler formats errors after this point to add . and newlines so we'll just do it manually for now
errors.push(getMinimalDiagnostic(err));
});
@ -845,7 +845,7 @@ module Harness {
declResult = compileResult;
}, settingsCallback, options);
return { declInputFiles: declInputFiles, declOtherFiles: declOtherFiles, declResult: declResult };
return { declInputFiles, declOtherFiles, declResult };
}
function addDtsFile(file: { unitName: string; content: string }, dtsFiles: { unitName: string; content: string }[]) {
@ -1169,7 +1169,7 @@ module Harness {
var settings = extractCompilerSettings(code);
// List of all the subfiles we've parsed out
var files: TestUnitData[] = [];
var testUnitData: TestUnitData[] = [];
var lines = Utils.splitContentByNewlines(code);
@ -1205,7 +1205,7 @@ module Harness {
originalFilePath: fileName,
references: refs
};
files.push(newTestFile);
testUnitData.push(newTestFile);
// Reset local data
currentFileContent = null;
@ -1230,7 +1230,7 @@ module Harness {
}
// normalize the fileName for the single file case
currentFileName = files.length > 0 ? currentFileName : Path.getFileName(fileName);
currentFileName = testUnitData.length > 0 ? currentFileName : Path.getFileName(fileName);
// EOF, push whatever remains
var newTestFile2 = {
@ -1240,9 +1240,9 @@ module Harness {
originalFilePath: fileName,
references: refs
};
files.push(newTestFile2);
testUnitData.push(newTestFile2);
return { settings: settings, testUnitData: files };
return { settings, testUnitData };
}
}
@ -1338,7 +1338,7 @@ module Harness {
actual = actual.replace(/\r\n?/g, '\n');
}
return { expected: expected, actual: actual };
return { expected, actual };
}
function writeComparison(expected: string, actual: string, relativeFilename: string, actualFilename: string, descriptionForDescribe: string) {

View file

@ -131,8 +131,8 @@ class ProjectRunner extends RunnerBase {
if (!errors.length) {
var checker = program.getTypeChecker(/*fullTypeCheck*/ true);
errors = checker.getDiagnostics();
var emitResult = checker.emitFiles();
errors = ts.concatenate(errors, emitResult.errors);
var emitResult = checker.invokeEmitter();
errors = ts.concatenate(errors, emitResult.diagnostics);
sourceMapData = emitResult.sourceMaps;
// Clean up source map data that will be used in baselining
@ -148,10 +148,10 @@ class ProjectRunner extends RunnerBase {
}
return {
moduleKind: moduleKind,
program: program,
errors: errors,
sourceMapData: sourceMapData
moduleKind,
program,
errors,
sourceMapData
};
function createCompilerOptions(): ts.CompilerOptions {
@ -183,10 +183,10 @@ class ProjectRunner extends RunnerBase {
function createCompilerHost(): ts.CompilerHost {
return {
getSourceFile: getSourceFile,
getSourceFile,
getDefaultLibFilename: () => "lib.d.ts",
writeFile: writeFile,
getCurrentDirectory: getCurrentDirectory,
writeFile,
getCurrentDirectory,
getCanonicalFileName: Harness.Compiler.getCanonicalFileName,
useCaseSensitiveFileNames: () => sys.useCaseSensitiveFileNames,
getNewLine: () => sys.newLine
@ -201,12 +201,12 @@ class ProjectRunner extends RunnerBase {
var projectCompilerResult = compileProjectFiles(moduleKind, () => testCase.inputFiles, getSourceFileText, writeFile);
return {
moduleKind: moduleKind,
moduleKind,
program: projectCompilerResult.program,
sourceMapData: projectCompilerResult.sourceMapData,
outputFiles: outputFiles,
outputFiles,
errors: projectCompilerResult.errors,
nonSubfolderDiskFiles: nonSubfolderDiskFiles,
nonSubfolderDiskFiles,
};
function getSourceFileText(filename: string): string {

View file

@ -117,14 +117,14 @@ module RWC {
});
function getHarnessCompilerInputUnit(fileName: string) {
var resolvedPath = ts.normalizeSlashes(sys.resolvePath(fileName));
var unitName = ts.normalizeSlashes(sys.resolvePath(fileName));
try {
var content = sys.readFile(resolvedPath);
var content = sys.readFile(unitName);
}
catch (e) {
// Leave content undefined.
}
return { unitName: resolvedPath, content: content };
return { unitName, content };
}
});

View file

@ -361,8 +361,8 @@ module ts.formatting {
delta = Math.min(options.IndentSize, parentDynamicIndentation.getDelta() + delta);
}
return {
indentation: indentation,
delta: delta
indentation,
delta
}
}
@ -834,7 +834,7 @@ module ts.formatting {
}
function newTextChange(start: number, len: number, newText: string): TextChange {
return { span: new TextSpan(start, len), newText: newText }
return { span: new TextSpan(start, len), newText }
}
function recordDelete(start: number, len: number) {

View file

@ -262,12 +262,12 @@ module ts.NavigationBar {
}
return {
text: text,
kind: kind,
kindModifiers: kindModifiers,
spans: spans,
childItems: childItems,
indent: indent,
text,
kind,
kindModifiers,
spans,
childItems,
indent,
bolded: false,
grayed: false
};

View file

@ -718,6 +718,7 @@ module ts {
public getPositionFromLineAndCharacter(line: number, character: number): number { return -1; }
public getLineStarts(): number[] { return undefined; }
public amdDependencies: string[];
public amdModuleName: string;
public referencedFiles: FileReference[];
public syntacticErrors: Diagnostic[];
public semanticErrors: Diagnostic[];
@ -892,7 +893,6 @@ module ts {
getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[];
getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[];
getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[];
getImplementorsAtPosition(fileName: string, position: number): ReferenceEntry[];
getNavigateToItems(searchValue: string): NavigateToItem[];
getNavigationBarItems(fileName: string): NavigationBarItem[];
@ -1369,8 +1369,8 @@ module ts {
writeSpace: text => writeKind(text, SymbolDisplayPartKind.space),
writeStringLiteral: text => writeKind(text, SymbolDisplayPartKind.stringLiteral),
writeParameter: text => writeKind(text, SymbolDisplayPartKind.parameterName),
writeSymbol: writeSymbol,
writeLine: writeLine,
writeSymbol,
writeLine,
increaseIndent: () => { indent++; },
decreaseIndent: () => { indent--; },
clear: resetWriter,
@ -1760,7 +1760,7 @@ module ts {
sourceFiles.sort((x, y) => y.refCount - x.refCount);
return {
bucket: name,
sourceFiles: sourceFiles
sourceFiles
};
});
return JSON.stringify(bucketInfoArray, null, 2);
@ -1826,10 +1826,10 @@ module ts {
}
return {
acquireDocument: acquireDocument,
updateDocument: updateDocument,
releaseDocument: releaseDocument,
reportStats: reportStats
acquireDocument,
updateDocument,
releaseDocument,
reportStats
};
}
@ -1892,7 +1892,7 @@ module ts {
processImport();
}
processTripleSlashDirectives();
return { referencedFiles: referencedFiles, importedFiles: importedFiles, isLibFile: isNoDefaultLib };
return { referencedFiles, importedFiles, isLibFile: isNoDefaultLib };
}
/// Helpers
@ -2291,7 +2291,7 @@ module ts {
// Get emitter-diagnostics requires calling TypeChecker.emitFiles so we have to define CompilerHost.writer which does nothing because emitFiles function has side effects defined by CompilerHost.writer
var savedWriter = writer;
writer = (filename: string, data: string, writeByteOrderMark: boolean) => { };
allDiagnostics = allDiagnostics.concat(checker.emitFiles(targetSourceFile).errors);
allDiagnostics = allDiagnostics.concat(checker.invokeEmitter(targetSourceFile).diagnostics);
writer = savedWriter;
}
return allDiagnostics
@ -2496,7 +2496,7 @@ module ts {
host.log("getCompletionsAtPosition: Semantic work: " + (new Date().getTime() - semanticStart));
return {
isMemberCompletion: isMemberCompletion,
isMemberCompletion,
entries: activeCompletionSession.entries
};
@ -3156,7 +3156,7 @@ module ts {
documentation = symbol.getDocumentationComment();
}
return { displayParts: displayParts, documentation: documentation, symbolKind: symbolKind };
return { displayParts, documentation, symbolKind };
function addNewLineIfDisplayPartsExist() {
if (displayParts.length) {
@ -3257,7 +3257,7 @@ module ts {
kind: symbolKind,
name: symbolName,
containerKind: undefined,
containerName: containerName
containerName
};
}
@ -4639,7 +4639,7 @@ module ts {
// Perform semantic and force a type check before emit to ensure that all symbols are updated
// EmitFiles will report if there is an error from TypeChecker and Emitter
// Depend whether we will have to emit into a single file or not either emit only selected file in the project, emit all files into a single file
var emitFilesResult = getFullTypeCheckChecker().emitFiles(targetSourceFile);
var emitFilesResult = getFullTypeCheckChecker().invokeEmitter(targetSourceFile);
emitOutput.emitOutputStatus = emitFilesResult.emitResultStatus;
// Reset writer back to undefined to make sure that we produce an error message if CompilerHost.writeFile method is called when we are not in getEmitOutput
@ -5420,46 +5420,45 @@ module ts {
return {
canRename: true,
localizedErrorMessage: undefined,
displayName: displayName,
fullDisplayName: fullDisplayName,
kind: kind,
kindModifiers: kindModifiers,
triggerSpan: triggerSpan
displayName,
fullDisplayName,
kind,
kindModifiers,
triggerSpan
};
}
}
return {
dispose: dispose,
cleanupSemanticCache: cleanupSemanticCache,
getSyntacticDiagnostics: getSyntacticDiagnostics,
getSemanticDiagnostics: getSemanticDiagnostics,
getCompilerOptionsDiagnostics: getCompilerOptionsDiagnostics,
getSyntacticClassifications: getSyntacticClassifications,
getSemanticClassifications: getSemanticClassifications,
getCompletionsAtPosition: getCompletionsAtPosition,
getCompletionEntryDetails: getCompletionEntryDetails,
getSignatureHelpItems: getSignatureHelpItems,
getQuickInfoAtPosition: getQuickInfoAtPosition,
getDefinitionAtPosition: getDefinitionAtPosition,
getReferencesAtPosition: getReferencesAtPosition,
getOccurrencesAtPosition: getOccurrencesAtPosition,
getImplementorsAtPosition: (filename, position) => [],
getNameOrDottedNameSpan: getNameOrDottedNameSpan,
getBreakpointStatementAtPosition: getBreakpointStatementAtPosition,
getNavigateToItems: getNavigateToItems,
getRenameInfo: getRenameInfo,
findRenameLocations: findRenameLocations,
getNavigationBarItems: getNavigationBarItems,
getOutliningSpans: getOutliningSpans,
getTodoComments: getTodoComments,
getBraceMatchingAtPosition: getBraceMatchingAtPosition,
getIndentationAtPosition: getIndentationAtPosition,
getFormattingEditsForRange: getFormattingEditsForRange,
getFormattingEditsForDocument: getFormattingEditsForDocument,
getFormattingEditsAfterKeystroke: getFormattingEditsAfterKeystroke,
getEmitOutput: getEmitOutput,
getSignatureAtPosition: getSignatureAtPosition,
dispose,
cleanupSemanticCache,
getSyntacticDiagnostics,
getSemanticDiagnostics,
getCompilerOptionsDiagnostics,
getSyntacticClassifications,
getSemanticClassifications,
getCompletionsAtPosition,
getCompletionEntryDetails,
getSignatureHelpItems,
getQuickInfoAtPosition,
getDefinitionAtPosition,
getReferencesAtPosition,
getOccurrencesAtPosition,
getNameOrDottedNameSpan,
getBreakpointStatementAtPosition,
getNavigateToItems,
getRenameInfo,
findRenameLocations,
getNavigationBarItems,
getOutliningSpans,
getTodoComments,
getBraceMatchingAtPosition,
getIndentationAtPosition,
getFormattingEditsForRange,
getFormattingEditsForDocument,
getFormattingEditsAfterKeystroke,
getEmitOutput,
getSignatureAtPosition,
};
}
@ -5757,9 +5756,7 @@ module ts {
}
}
return {
getClassificationsForLine: getClassificationsForLine
};
return { getClassificationsForLine };
}
function initializeServices() {

View file

@ -133,12 +133,6 @@ module ts {
*/
getOccurrencesAtPosition(fileName: string, position: number): string;
/**
* Returns a JSON-encoded value of the type:
* { fileName: string; textSpan: { start: number; length: number}; isWriteAccess: boolean }[]
*/
getImplementorsAtPosition(fileName: string, position: number): string;
/**
* Returns a JSON-encoded value of the type:
* { name: string; kind: string; kindModifiers: string; containerName: string; containerKind: string; matchKind: string; fileName: string; textSpan: { start: number; length: number}; } [] = [];
@ -696,16 +690,6 @@ module ts {
});
}
/// GET IMPLEMENTORS
public getImplementorsAtPosition(fileName: string, position: number): string {
return this.forwardJSONCall(
"getImplementorsAtPosition('" + fileName + "', " + position + ")",
() => {
return this.languageService.getImplementorsAtPosition(fileName, position);
});
}
/// COMPLETION LISTS
/**

View file

@ -221,7 +221,7 @@ module ts.SignatureHelp {
var list = getChildListThatStartsWithOpenerToken(parent, node, sourceFile);
Debug.assert(list !== undefined);
return {
list: list,
list,
listItemIndex: 0
};
}
@ -303,40 +303,40 @@ module ts.SignatureHelp {
var callTargetDisplayParts = callTargetSymbol && symbolToDisplayParts(typeInfoResolver, callTargetSymbol, /*enclosingDeclaration*/ undefined, /*meaning*/ undefined);
var items: SignatureHelpItem[] = map(candidates, candidateSignature => {
var signatureHelpParameters: SignatureHelpParameter[];
var prefixParts: SymbolDisplayPart[] = [];
var suffixParts: SymbolDisplayPart[] = [];
var prefixDisplayParts: SymbolDisplayPart[] = [];
var suffixDisplayParts: SymbolDisplayPart[] = [];
if (callTargetDisplayParts) {
prefixParts.push.apply(prefixParts, callTargetDisplayParts);
prefixDisplayParts.push.apply(prefixDisplayParts, callTargetDisplayParts);
}
if (isTypeParameterHelp) {
prefixParts.push(punctuationPart(SyntaxKind.LessThanToken));
prefixDisplayParts.push(punctuationPart(SyntaxKind.LessThanToken));
var typeParameters = candidateSignature.typeParameters;
signatureHelpParameters = typeParameters && typeParameters.length > 0 ? map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray;
suffixParts.push(punctuationPart(SyntaxKind.GreaterThanToken));
suffixDisplayParts.push(punctuationPart(SyntaxKind.GreaterThanToken));
var parameterParts = mapToDisplayParts(writer =>
typeInfoResolver.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.parameters, writer, argumentListOrTypeArgumentList));
suffixParts.push.apply(suffixParts, parameterParts);
suffixDisplayParts.push.apply(suffixDisplayParts, parameterParts);
}
else {
var typeParameterParts = mapToDisplayParts(writer =>
typeInfoResolver.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, argumentListOrTypeArgumentList));
prefixParts.push.apply(prefixParts, typeParameterParts);
prefixParts.push(punctuationPart(SyntaxKind.OpenParenToken));
prefixDisplayParts.push.apply(prefixDisplayParts, typeParameterParts);
prefixDisplayParts.push(punctuationPart(SyntaxKind.OpenParenToken));
var parameters = candidateSignature.parameters;
signatureHelpParameters = parameters.length > 0 ? map(parameters, createSignatureHelpParameterForParameter) : emptyArray;
suffixParts.push(punctuationPart(SyntaxKind.CloseParenToken));
suffixDisplayParts.push(punctuationPart(SyntaxKind.CloseParenToken));
}
var returnTypeParts = mapToDisplayParts(writer =>
typeInfoResolver.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, argumentListOrTypeArgumentList));
suffixParts.push.apply(suffixParts, returnTypeParts);
suffixDisplayParts.push.apply(suffixDisplayParts, returnTypeParts);
return {
isVariadic: candidateSignature.hasRestParameter,
prefixDisplayParts: prefixParts,
suffixDisplayParts: suffixParts,
prefixDisplayParts,
suffixDisplayParts,
separatorDisplayParts: [punctuationPart(SyntaxKind.CommaToken), spacePart()],
parameters: signatureHelpParameters,
documentation: candidateSignature.getDocumentationComment()
@ -378,11 +378,11 @@ module ts.SignatureHelp {
}
return {
items: items,
applicableSpan: applicableSpan,
selectedItemIndex: selectedItemIndex,
argumentIndex: argumentIndex,
argumentCount: argumentCount
items,
applicableSpan,
selectedItemIndex,
argumentIndex,
argumentCount
};
function createSignatureHelpParameterForParameter(parameter: Symbol): SignatureHelpParameter {
@ -394,8 +394,8 @@ module ts.SignatureHelp {
return {
name: parameter.name,
documentation: parameter.getDocumentationComment(),
displayParts: displayParts,
isOptional: isOptional
displayParts,
isOptional
};
}
@ -406,7 +406,7 @@ module ts.SignatureHelp {
return {
name: typeParameter.symbol.name,
documentation: emptyArray,
displayParts: displayParts,
displayParts,
isOptional: false
};
}

View file

@ -222,7 +222,8 @@ module ts.formatting {
if (node.parent) {
switch (node.parent.kind) {
case SyntaxKind.TypeReference:
if ((<TypeReferenceNode>node.parent).typeArguments) {
if ((<TypeReferenceNode>node.parent).typeArguments &&
rangeContainsStartEnd((<TypeReferenceNode>node.parent).typeArguments, node.getStart(sourceFile), node.getEnd())) {
return (<TypeReferenceNode>node.parent).typeArguments;
}
break;
@ -236,21 +237,28 @@ module ts.formatting {
case SyntaxKind.Method:
case SyntaxKind.CallSignature:
case SyntaxKind.ConstructSignature:
if ((<SignatureDeclaration>node.parent).typeParameters && node.end < (<SignatureDeclaration>node.parent).typeParameters.end) {
var start = node.getStart(sourceFile);
if ((<SignatureDeclaration>node.parent).typeParameters &&
rangeContainsStartEnd((<SignatureDeclaration>node.parent).typeParameters, start, node.getEnd())) {
return (<SignatureDeclaration>node.parent).typeParameters;
}
return (<SignatureDeclaration>node.parent).parameters;
if (rangeContainsStartEnd((<SignatureDeclaration>node.parent).parameters, start, node.getEnd())) {
return (<SignatureDeclaration>node.parent).parameters;
}
break;
case SyntaxKind.NewExpression:
case SyntaxKind.CallExpression:
if ((<CallExpression>node.parent).typeArguments && node.end < (<CallExpression>node.parent).typeArguments.end) {
var start = node.getStart(sourceFile);
if ((<CallExpression>node.parent).typeArguments &&
rangeContainsStartEnd((<CallExpression>node.parent).typeArguments, start, node.getEnd())) {
return (<CallExpression>node.parent).typeArguments;
}
return (<CallExpression>node.parent).arguments;
if (rangeContainsStartEnd((<CallExpression>node.parent).arguments, start, node.getEnd())) {
return (<CallExpression>node.parent).arguments;
}
break;
}
}
return undefined;
}

View file

@ -66,22 +66,22 @@ module ts {
}
export function findListItemInfo(node: Node): ListItemInfo {
var syntaxList = findContainingList(node);
var list = findContainingList(node);
// It is possible at this point for syntaxList to be undefined, either if
// node.parent had no list child, or if none of its list children contained
// the span of node. If this happens, return undefined. The caller should
// handle this case.
if (!syntaxList) {
if (!list) {
return undefined;
}
var children = syntaxList.getChildren();
var index = indexOf(children, node);
var children = list.getChildren();
var listItemIndex = indexOf(children, node);
return {
listItemIndex: index,
list: syntaxList
listItemIndex,
list
};
}

View file

@ -0,0 +1,22 @@
//// [amdModuleName1.ts]
///<amd-module name='NamedModule'/>
class Foo {
x: number;
constructor() {
this.x = 5;
}
}
export = Foo;
//// [amdModuleName1.js]
define("NamedModule", ["require", "exports"], function (require, exports) {
///<amd-module name='NamedModule'/>
var Foo = (function () {
function Foo() {
this.x = 5;
}
return Foo;
})();
return Foo;
});

View file

@ -0,0 +1,19 @@
=== tests/cases/compiler/amdModuleName1.ts ===
///<amd-module name='NamedModule'/>
class Foo {
>Foo : Foo
x: number;
>x : number
constructor() {
this.x = 5;
>this.x = 5 : number
>this.x : number
>this : Foo
>x : number
}
}
export = Foo;
>Foo : Foo

View file

@ -0,0 +1,16 @@
tests/cases/compiler/amdModuleName2.ts(2,1): error TS2458: An AMD module cannot have multiple name assignments.
==== tests/cases/compiler/amdModuleName2.ts (1 errors) ====
///<amd-module name='FirstModuleName'/>
///<amd-module name='SecondModuleName'/>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2458: An AMD module cannot have multiple name assignments.
class Foo {
x: number;
constructor() {
this.x = 5;
}
}
export = Foo;

View file

@ -0,0 +1,9 @@
//@module: amd
///<amd-module name='NamedModule'/>
class Foo {
x: number;
constructor() {
this.x = 5;
}
}
export = Foo;

View file

@ -0,0 +1,10 @@
//@module: amd
///<amd-module name='FirstModuleName'/>
///<amd-module name='SecondModuleName'/>
class Foo {
x: number;
constructor() {
this.x = 5;
}
}
export = Foo;

View file

@ -0,0 +1,27 @@
/// <reference path='fourslash.ts'/>
/////*1*/ module My.App {
/////*2*/export var appModule = angular.module("app", [
/////*3*/ ]).config([() => {
/////*4*/ configureStates
/////*5*/($stateProvider);
/////*6*/}]).run(My.App.setup);
/////*7*/ }
format.document()
goTo.marker("1");
verify.currentLineContentIs("module My.App {");
goTo.marker("2");
verify.currentLineContentIs(" export var appModule = angular.module(\"app\", [");
goTo.marker("3");
verify.currentLineContentIs(" ]).config([() => {");
goTo.marker("4");
verify.currentLineContentIs(" configureStates");
goTo.marker("5");
verify.currentLineContentIs(" ($stateProvider);");
goTo.marker("6");
verify.currentLineContentIs(" }]).run(My.App.setup);");
goTo.marker("7");
verify.currentLineContentIs("}");

View file

@ -1,8 +0,0 @@
///<reference path="fourslash.ts" />
////class C {
//// /**/p;
////}
goTo.marker();
verify.implementorsCountIs(0);

View file

@ -1,6 +0,0 @@
///<reference path="fourslash.ts" />
////function fo/**/o() {
////}
goTo.marker();
verify.implementorsCountIs(0);

View file

@ -0,0 +1,12 @@
/// <reference path='fourslash.ts'/>
////module My.App {
//// export var appModule = angular.module("app", [
//// ]).config([() => {
//// configureStates/*1*/($stateProvider);
//// }]).run(My.App.setup);
////}
goTo.marker("1")
edit.insert("\n");
verify.indentationIs(12); // 4 (module block) + 4 (function block) + 4 (call expression)