Keep track of all symbols

This avoids that we add parent namespaces of symbols that were already
added because they have their own definition in the externs.
This commit is contained in:
Andreas Hocevar
2014-08-08 18:02:47 +02:00
parent 8a56f455f1
commit e294ca1868

View File

@@ -36,7 +36,7 @@ function getInfo(callback) {
*/
function generateExterns(typedefs, symbols, externs) {
var lines = [];
var namespaces = {};
var processedSymbols = {};
var constructors = {};
function addNamespaces(name) {
@@ -46,7 +46,7 @@ function generateExterns(typedefs, symbols, externs) {
parts.forEach(function(part) {
namespace.push(part);
var partialNamespace = namespace.join('.');
if (!(partialNamespace in namespaces ||
if (!(partialNamespace in processedSymbols ||
partialNamespace in constructors)) {
lines.push('/**');
lines.push(' * @type {Object}');
@@ -58,8 +58,8 @@ function generateExterns(typedefs, symbols, externs) {
}
function nameToJS(name) {
processedSymbols[name] = true;
if (name.indexOf('.') == -1) {
namespaces[name] = true;
name = 'var ' + name;
}
return name;