Skip to content

Commit

Permalink
Merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
danquirk committed Jul 8, 2015
2 parents 5fc3099 + 8cdd59f commit be1371d
Show file tree
Hide file tree
Showing 795 changed files with 22,129 additions and 2,788 deletions.
6 changes: 6 additions & 0 deletions Jakefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -715,3 +715,9 @@ task('tsc-instrumented', [loggedIOJsPath, instrumenterJsPath, tscFile], function
});
ex.run();
}, { async: true });

desc("Updates the sublime plugin's tsserver");
task("update-sublime", [serverFile], function() {
jake.cpR(serverFile, "../TypeScript-Sublime-Plugin/tsserver/");
jake.cpR(serverFile + ".map", "../TypeScript-Sublime-Plugin/tsserver/");
});
87 changes: 87 additions & 0 deletions scripts/errorCheck.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
declare var require: any;
let fs = require('fs');
let async = require('async');
let glob = require('glob');

fs.readFile('src/compiler/diagnosticMessages.json', 'utf-8', (err, data) => {
if (err) {
throw err;
}

let messages = JSON.parse(data);
let keys = Object.keys(messages);
console.log('Loaded ' + keys.length + ' errors');

for (let k of keys) {
messages[k]['seen'] = false;
}

let errRegex = /\(\d+,\d+\): error TS([^:]+):/g;

let baseDir = 'tests/baselines/reference/';
fs.readdir(baseDir, (err, files) => {
files = files.filter(f => f.indexOf('.errors.txt') > 0);
let tasks: Array<(callback: () => void) => void> = [];
files.forEach(f => tasks.push(done => {
fs.readFile(baseDir + f, 'utf-8', (err, baseline) => {
if (err) throw err;

let g: string[];
while (g = errRegex.exec(baseline)) {
var errCode = +g[1];
let msg = keys.filter(k => messages[k].code === errCode)[0];
messages[msg]['seen'] = true;
}

done();
});
}));

async.parallelLimit(tasks, 25, done => {
console.log('== List of errors not present in baselines ==');
let count = 0;
for (let k of keys) {
if (messages[k]['seen'] !== true) {
console.log(k);
count++;
}
}
console.log(count + ' of ' + keys.length + ' errors are not in baselines');
});
});
});

fs.readFile('src/compiler/diagnosticInformationMap.generated.ts', 'utf-8', (err, data) => {
let errorRegexp = /\s(\w+): \{ code/g;
let errorNames: string[] = [];
let errMatch: string[];
while (errMatch = errorRegexp.exec(data)) {
errorNames.push(errMatch[1]);
}

let allSrc: string = '';
glob('./src/**/*.ts', {}, (err, files) => {
console.log('Reading ' + files.length + ' source files');
for (let file of files) {
if (file.indexOf('diagnosticInformationMap.generated.ts') > 0) {
continue;
}

let src = fs.readFileSync(file, 'utf-8');
allSrc = allSrc + src;
}

console.log('Consumed ' + allSrc.length + ' characters of source');

let count = 0;
console.log('== List of errors not used in source ==')
for (let errName of errorNames) {
if (allSrc.indexOf(errName) < 0) {
console.log(errName);
count++;
}
}
console.log(count + ' of ' + errorNames.length + ' errors are not used in source');
});
});

20 changes: 16 additions & 4 deletions src/compiler/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,14 @@ namespace ts {
return node.name ? declarationNameToString(node.name) : getDeclarationName(node);
}

/**
* Declares a Symbol for the node and adds it to symbols. Reports errors for conflicting identifier names.
* @param symbolTable - The symbol table which node will be added to.
* @param parent - node's parent declaration.
* @param node - The declaration to be added to the symbol table
* @param includes - The SymbolFlags that node has in addition to its declaration type (eg: export, ambient, etc.)
* @param excludes - The flags which node cannot be declared alongside in a symbol table. Used to report forbidden declarations.
*/
function declareSymbol(symbolTable: SymbolTable, parent: Symbol, node: Declaration, includes: SymbolFlags, excludes: SymbolFlags): Symbol {
Debug.assert(!hasDynamicName(node));

Expand All @@ -181,10 +189,11 @@ namespace ts {

let symbol: Symbol;
if (name !== undefined) {

// Check and see if the symbol table already has a symbol with this name. If not,
// create a new symbol with this name and add it to the table. Note that we don't
// give the new symbol any flags *yet*. This ensures that it will not conflict
// witht he 'excludes' flags we pass in.
// with the 'excludes' flags we pass in.
//
// If we do get an existing symbol, see if it conflicts with the new symbol we're
// creating. For example, a 'var' symbol and a 'class' symbol will conflict within
Expand Down Expand Up @@ -314,6 +323,7 @@ namespace ts {

addToContainerChain(container);
}

else if (containerFlags & ContainerFlags.IsBlockScopedContainer) {
blockScopeContainer = node;
blockScopeContainer.locals = undefined;
Expand Down Expand Up @@ -882,7 +892,8 @@ namespace ts {
case SyntaxKind.FunctionExpression:
case SyntaxKind.ArrowFunction:
checkStrictModeFunctionName(<FunctionExpression>node);
return bindAnonymousDeclaration(<FunctionExpression>node, SymbolFlags.Function, "__function");
let bindingName = (<FunctionExpression>node).name ? (<FunctionExpression>node).name.text : "__function";
return bindAnonymousDeclaration(<FunctionExpression>node, SymbolFlags.Function, bindingName);
case SyntaxKind.ClassExpression:
case SyntaxKind.ClassDeclaration:
return bindClassLikeDeclaration(<ClassLikeDeclaration>node);
Expand Down Expand Up @@ -954,7 +965,8 @@ namespace ts {
bindBlockScopedDeclaration(node, SymbolFlags.Class, SymbolFlags.ClassExcludes);
}
else {
bindAnonymousDeclaration(node, SymbolFlags.Class, "__class");
let bindingName = node.name ? node.name.text : "__class";
bindAnonymousDeclaration(node, SymbolFlags.Class, bindingName);
}

let symbol = node.symbol;
Expand Down Expand Up @@ -1044,4 +1056,4 @@ namespace ts {
: declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes);
}
}
}
}
Loading

0 comments on commit be1371d

Please sign in to comment.