extensions/wtf-injector-chrome/wtf-process.js
function getFunctionName(node) {
    function cleanupName(name) {
      return name.replace(/[ \n]/g, '');
    };

    // Simple case of:
    // function foo() {}
    if (node.id) {
      return cleanupName(node.id.name);
    }

    // get foo() {};
    if (node.parent.kind == 'get' || node.parent.kind == 'set') {
      return cleanupName(node.parent.key.name);
    }

    // var foo = function() {};
    if (node.parent.type == 'VariableDeclarator') {
      if (node.parent.id) {
        return cleanupName(node.parent.id.name);
      }
      log('unknown var decl', node.parent);
      return null;
    }

    // {foo: function() {}}
    // {"foo": function() {}}
    // {1: function() {}}
    if (node.parent.type == 'Property') {
      return cleanupName(node.parent.key.name || ''+node.parent.key.value);
    }

    // foo = function() {};
    // Bar.foo = function() {};
    if (node.parent.type == 'AssignmentExpression') {
      // We are the RHS, LHS is something else.
      var left = node.parent.left;
      if (left.type == 'MemberExpression') {
        // Bar.foo = function() {};
        // left.object {type: 'Identifier', name: 'Bar'}
        // left.property {type: 'Identifier', name: 'foo'}
        // Object can be recursive MemberExpression's:
        // Bar.prototype.foo = function() {};
        // left.object {type: 'MemberExpression', ...}
        // left.property {type: 'Identifier', name: 'foo'}
        return cleanupName(left.source());
      } else if (left.type == 'Identifier') {
        return cleanupName(left.name);
      }
      log('unknown assignment LHS', left);
    }

    //log('unknown fn construct', node);

    // TODO(benvanik): support jscompiler prototype alias:
    // _.$JSCompiler_prototypeAlias$$ = _.$something;
    // ...
    // _.$JSCompiler_prototypeAlias$$.$unnamed = function() {};

    // Recognize dart2js names.
    var ret = null;
    while (node.parent != null) {
      node = node.parent;
      if (node.type == 'Property') {
        if (!ret) {
          ret = node.key.name;
        } else {
          ret = node.key.name + '.' + ret;
        }
      }
    }
    return ret;
  }
function getFunctionName(node) {
    function cleanupName(name) {
      return name.replace(/[ \n]/g, '');
    };

    // Simple case of:
    // function foo() {}
    if (node.id) {
      return cleanupName(node.id.name);
    }

    // get foo() {};
    if (node.parent.kind == 'get' || node.parent.kind == 'set') {
      return cleanupName(node.parent.key.name);
    }

    // var foo = function() {};
    if (node.parent.type == 'VariableDeclarator') {
      if (node.parent.id) {
        return cleanupName(node.parent.id.name);
      }
      log('unknown var decl', node.parent);
      return null;
    }

    // {foo: function() {}}
    // {"foo": function() {}}
    // {1: function() {}}
    if (node.parent.type == 'Property') {
      return cleanupName(node.parent.key.name || ''+node.parent.key.value);
    }

    // foo = function() {};
    // Bar.foo = function() {};
    if (node.parent.type == 'AssignmentExpression') {
      // We are the RHS, LHS is something else.
      var left = node.parent.left;
      if (left.type == 'MemberExpression') {
        // Bar.foo = function() {};
        // left.object {type: 'Identifier', name: 'Bar'}
        // left.property {type: 'Identifier', name: 'foo'}
        // Object can be recursive MemberExpression's:
        // Bar.prototype.foo = function() {};
        // left.object {type: 'MemberExpression', ...}
        // left.property {type: 'Identifier', name: 'foo'}
        return cleanupName(left.source());
      } else if (left.type == 'Identifier') {
        return cleanupName(left.name);
      }
      log('unknown assignment LHS', left);
    }

    //log('unknown fn construct', node);

    // TODO(benvanik): support jscompiler prototype alias:
    // _.$JSCompiler_prototypeAlias$$ = _.$something;
    // ...
    // _.$JSCompiler_prototypeAlias$$.$unnamed = function() {};

    // Recognize dart2js names.
    var ret = null;
    while (node.parent != null) {
      node = node.parent;
      if (node.type == 'Property') {
        if (!ret) {
          ret = node.key.name;
        } else {
          ret = node.key.name + '.' + ret;
        }
      }
    }
    return ret;
  }
function getFunctionName ( node ) { function cleanupName ( name ) { return name . replace ( / [ \n] / g , '' ) ; } ; // Simple case of: // function foo() {} if ( node . id ) { return cleanupName ( node . id . name ) ; } // get foo() {}; if ( node . parent . kind == 'get' || node . parent . kind == 'set' ) { return cleanupName ( node . parent . key . name ) ; } // var foo = function() {}; if ( node . parent . type == 'VariableDeclarator' ) { if ( node . parent . id ) { return cleanupName ( node . parent . id . name ) ; } log ( 'unknown var decl' , node . parent ) ; return null ; } // {foo: function() {}} // {"foo": function() {}} // {1: function() {}} if ( node . parent . type == 'Property' ) { return cleanupName ( node . parent . key . name || '' + node . parent . key . value ) ; } // foo = function() {}; // Bar.foo = function() {}; if ( node . parent . type == 'AssignmentExpression' ) { // We are the RHS, LHS is something else. var left = node . parent . left ; if ( left . type == 'MemberExpression' ) { // Bar.foo = function() {}; // left.object {type: 'Identifier', name: 'Bar'} // left.property {type: 'Identifier', name: 'foo'} // Object can be recursive MemberExpression's: // Bar.prototype.foo = function() {}; // left.object {type: 'MemberExpression', ...} // left.property {type: 'Identifier', name: 'foo'} return cleanupName ( left . source ( ) ) ; } else if ( left . type == 'Identifier' ) { return cleanupName ( left . name ) ; } log ( 'unknown assignment LHS' , left ) ; } //log('unknown fn construct', node); // TODO(benvanik): support jscompiler prototype alias: // _.$JSCompiler_prototypeAlias$$ = _.$something; // ... // _.$JSCompiler_prototypeAlias$$.$unnamed = function() {}; // Recognize dart2js names. var ret = null ; while ( node . parent != null ) { node = node . parent ; if ( node . type == 'Property' ) { if ( ! ret ) { ret = node . key . name ; } else { ret = node . key . name + '.' + ret ; } } } return ret ; }
Attempt to guess the names of functions.
Attempt to guess the names of functions .