Merge remote-tracking branch release-1.3

This commit is contained in:
Sheetal Nandi
2014-11-20 20:24:08 -08:00
7 changed files with 1468 additions and 1408 deletions
+1
View File
@@ -39,4 +39,5 @@ scripts/debug.bat
scripts/run.bat
scripts/word2md.js
scripts/ior.js
scripts/*.js.map
coverage/
+14 -2
View File
@@ -82,6 +82,7 @@ module ts {
isUndefinedSymbol: symbol => symbol === undefinedSymbol,
isArgumentsSymbol: symbol => symbol === argumentsSymbol,
getDiagnostics,
getDeclarationDiagnostics,
getGlobalDiagnostics,
checkProgram,
invokeEmitter,
@@ -999,6 +1000,7 @@ module ts {
// Type Reference or TypeAlias entity = Identifier
meaning = SymbolFlags.Type;
}
var firstIdentifier = getFirstIdentifier(entityName);
var symbol = resolveName(enclosingDeclaration, (<Identifier>firstIdentifier).text, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined);
@@ -8544,6 +8546,12 @@ module ts {
return getSortedDiagnostics();
}
function getDeclarationDiagnostics(targetSourceFile: SourceFile): Diagnostic[] {
var resolver = createResolver();
checkSourceFile(targetSourceFile);
return ts.getDeclarationDiagnostics(program, resolver, targetSourceFile);
}
function getGlobalDiagnostics(): Diagnostic[] {
return filter(getSortedDiagnostics(), d => !d.file);
}
@@ -9137,8 +9145,8 @@ module ts {
getSymbolDisplayBuilder().buildTypeDisplay(getReturnTypeOfSignature(signature), writer, enclosingDeclaration, flags);
}
function invokeEmitter(targetSourceFile?: SourceFile) {
var resolver: EmitResolver = {
function createResolver(): EmitResolver {
return {
getProgram: () => program,
getLocalNameOfContainer,
getExpressionNamePrefix,
@@ -9157,6 +9165,10 @@ module ts {
isEntityNameVisible,
getConstantValue,
};
}
function invokeEmitter(targetSourceFile?: SourceFile) {
var resolver = createResolver();
checkProgram();
return emitFiles(resolver, targetSourceFile);
}
+1426 -1399
View File
File diff suppressed because it is too large Load Diff
+6 -2
View File
@@ -48,13 +48,17 @@ module ts {
return skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos);
}
export function getSourceTextOfNodeFromSourceFile(sourceFile: SourceFile, node: Node): string {
var text = sourceFile.text;
return text.substring(skipTrivia(text, node.pos), node.end);
}
export function getTextOfNodeFromSourceText(sourceText: string, node: Node): string {
return sourceText.substring(skipTrivia(sourceText, node.pos), node.end);
}
export function getTextOfNode(node: Node): string {
var text = getSourceFileOfNode(node).text;
return text.substring(skipTrivia(text, node.pos), node.end);
return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node);
}
// Add an extra underscore to identifiers that start with two underscores to avoid issues with magic names like '__proto__'
+1
View File
@@ -731,6 +731,7 @@ module ts {
export interface TypeChecker {
getProgram(): Program;
getDiagnostics(sourceFile?: SourceFile): Diagnostic[];
getDeclarationDiagnostics(sourceFile: SourceFile): Diagnostic[];
getGlobalDiagnostics(): Diagnostic[];
getNodeCount(): number;
getIdentifierCount(): number;
+1 -5
View File
@@ -2256,11 +2256,7 @@ module ts {
var allDiagnostics = checker.getDiagnostics(targetSourceFile);
if (compilerOptions.declaration) {
// If '-d' is enabled, check for emitter error. One example of emitter error is export class implements non-export interface
// 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.invokeEmitter(targetSourceFile).diagnostics);
writer = savedWriter;
allDiagnostics = allDiagnostics.concat(checker.getDeclarationDiagnostics(targetSourceFile));
}
return allDiagnostics
}
@@ -0,0 +1,19 @@
/// <reference path="fourslash.ts" />
// @declaration: true
// @out: true
// @Filename: inputFile1.ts
//// module m {
//// export class C implements I { }
//// interface I { }
//// } /*1*/
// @Filename: input2.ts
//// var x = "hello world"; /*2*/
goTo.marker("1");
verify.numberOfErrorsInCurrentFile(1);
goTo.marker("2");
verify.numberOfErrorsInCurrentFile(0);