From eafc56de237ccdea055b97868cc2bc00891b6b9e Mon Sep 17 00:00:00 2001 From: Jeff Williams Date: Sun, 7 Dec 2014 16:37:28 -0800 Subject: [PATCH] revert part of 5fa636 due to performance hit (#830) --- lib/jsdoc/augment.js | 2 +- lib/jsdoc/name.js | 34 +++++++--------------------------- test/specs/jsdoc/name.js | 33 +++++++++++---------------------- 3 files changed, 19 insertions(+), 50 deletions(-) diff --git a/lib/jsdoc/augment.js b/lib/jsdoc/augment.js index f1efde76..8d47b266 100644 --- a/lib/jsdoc/augment.js +++ b/lib/jsdoc/augment.js @@ -108,7 +108,7 @@ function parentIsClass(parent) { function staticToInstance(doclet) { var parts = name.shorten(doclet.longname); - parts.scopePunc = name.SCOPE.PUNC.INSTANCE; + parts.scope = name.SCOPE.PUNC.INSTANCE; doclet.longname = name.combineName(parts); doclet.scope = name.SCOPE.NAMES.INSTANCE; } diff --git a/lib/jsdoc/name.js b/lib/jsdoc/name.js index 5ee9ed9b..267bb7af 100644 --- a/lib/jsdoc/name.js +++ b/lib/jsdoc/name.js @@ -8,7 +8,6 @@ var _ = require('underscore'); var escape = require('escape-string-regexp'); -var util = require('util'); var hasOwnProp = Object.prototype.hasOwnProperty; @@ -150,12 +149,12 @@ exports.resolve = function(doclet) { doclet.setLongname(doclet.name); delete doclet.memberof; } - else if (about.scopePunc) { + else if (about.scope) { if (about.memberof === LONGNAMES.GLOBAL) { // via @memberof ? doclet.scope = SCOPE.NAMES.GLOBAL; } else { - doclet.scope = puncToScope[about.scopePunc]; + doclet.scope = puncToScope[about.scope]; } } else if (doclet.name && doclet.memberof && !doclet.longname) { @@ -198,25 +197,6 @@ exports.applyNamespace = function(longname, ns) { return longname; }; -function NameAtoms(props) { - var scopeDeprecated = 'The "scope" property returned by name.shorten() is deprecated. ' + - 'Use the "scopePunc" property instead.'; - var self = this; - - Object.keys(props).forEach(function(prop) { - self[prop] = props[prop]; - }); - - Object.defineProperty(this, 'scope', { - get: util.deprecate(function() { - return this.scopePunc; - }, scopeDeprecated), - set: util.deprecate(function(value) { - this.scopePunc = value; - }, scopeDeprecated) - }); -} - // TODO: docs function atomize(longname, sliceChars, forcedMemberof) { var i; @@ -280,13 +260,13 @@ function atomize(longname, sliceChars, forcedMemberof) { name = name.replace('@{' + i + '}@', tokens[i]); } - return new NameAtoms({ + return { longname: longname, memberof: memberof, - scopePunc: scopePunc, + scope: scopePunc, name: name, variation: variation - }); + }; } // TODO: deprecate exports.shorten in favor of a better name @@ -304,7 +284,7 @@ exports.shorten = function(longname, forcedMemberof) { exports.combineName = function(parts) { return '' + (parts.memberof || '') + - (parts.scopePunc || '') + + (parts.scope || '') + (parts.name || '') + (parts.variation || ''); }; @@ -330,7 +310,7 @@ function splitLongname(longname, options) { } currentNameInfo = nameInfo[previousName] = atomize(previousName, splitters); previousName = currentNameInfo.memberof; - chunks.push(currentNameInfo.scopePunc + currentNameInfo.name); + chunks.push(currentNameInfo.scope + currentNameInfo.name); } while (previousName); return { diff --git a/test/specs/jsdoc/name.js b/test/specs/jsdoc/name.js index f0d5d29d..53f529d8 100644 --- a/test/specs/jsdoc/name.js +++ b/test/specs/jsdoc/name.js @@ -91,13 +91,13 @@ describe('jsdoc/name', function() { }); describe('shorten', function() { - it('should break up a longname into the correct memberof, name and scopePunc parts', function() { + it('should break up a longname into the correct memberof, name and scope parts', function() { var startName = 'lib.Panel#open'; var parts = jsdoc.name.shorten(startName); expect(parts.name).toEqual('open'); expect(parts.memberof).toEqual('lib.Panel'); - expect(parts.scopePunc).toEqual('#'); + expect(parts.scope).toEqual('#'); }); it('should work on static names', function() { @@ -106,7 +106,7 @@ describe('jsdoc/name', function() { expect(parts.name).toEqual('getVisible'); expect(parts.memberof).toEqual('elements.selected'); - expect(parts.scopePunc).toEqual('.'); + expect(parts.scope).toEqual('.'); }); it('should work on protoyped names', function() { @@ -115,7 +115,7 @@ describe('jsdoc/name', function() { expect(parts.name).toEqual('$element'); expect(parts.memberof).toEqual('Validator'); - expect(parts.scopePunc).toEqual('#'); + expect(parts.scope).toEqual('#'); }); it('should work on inner names', function() { @@ -124,7 +124,7 @@ describe('jsdoc/name', function() { expect(parts.name).toEqual('_onclick'); expect(parts.memberof).toEqual('Button'); - expect(parts.scopePunc).toEqual('~'); + expect(parts.scope).toEqual('~'); }); it('should work on global names', function() { @@ -133,7 +133,7 @@ describe('jsdoc/name', function() { expect(parts.name).toEqual('close'); expect(parts.memberof).toEqual(''); - expect(parts.scopePunc).toEqual(''); + expect(parts.scope).toEqual(''); }); it('should work when a single property uses bracket notation', function() { @@ -142,7 +142,7 @@ describe('jsdoc/name', function() { expect(parts.name).toEqual('open'); expect(parts.memberof).toEqual('channels."#ops"'); - expect(parts.scopePunc).toEqual('#'); + expect(parts.scope).toEqual('#'); }); it('should work when consecutive properties use bracket notation', function() { @@ -151,7 +151,7 @@ describe('jsdoc/name', function() { expect(parts.name).toEqual('"log.max"'); expect(parts.memberof).toEqual('channels."#bots"'); - expect(parts.scopePunc).toEqual('.'); + expect(parts.scope).toEqual('.'); }); it('should work when a property uses single-quoted bracket notation', function() { @@ -160,7 +160,7 @@ describe('jsdoc/name', function() { expect(parts.name).toBe("'#ops'"); expect(parts.memberof).toBe('channels'); - expect(parts.scopePunc).toBe('.'); + expect(parts.scope).toBe('.'); }); it('should work on double-quoted strings', function() { @@ -170,7 +170,7 @@ describe('jsdoc/name', function() { expect(parts.name).toEqual('"foo.bar"'); expect(parts.longname).toEqual('"foo.bar"'); expect(parts.memberof).toEqual(''); - expect(parts.scopePunc).toEqual(''); + expect(parts.scope).toEqual(''); }); it('should work on single-quoted strings', function() { @@ -180,7 +180,7 @@ describe('jsdoc/name', function() { expect(parts.name).toBe("'foo.bar'"); expect(parts.longname).toBe("'foo.bar'"); expect(parts.memberof).toBe(''); - expect(parts.scopePunc).toBe(''); + expect(parts.scope).toBe(''); }); it('should find the variation', function() { @@ -191,17 +191,6 @@ describe('jsdoc/name', function() { expect(parts.name).toEqual('fadein'); expect(parts.longname).toEqual('anim.fadein(2)'); }); - - it('should have a deprecated "scope" property that matches the "scopePunc" property', function() { - var parts; - - spyOn(console, 'error'); - parts = jsdoc.name.shorten('ClassA#instanceMethod'); - - expect(parts.scope).toBeDefined(); - expect(parts.scope).toBe(parts.scopePunc); - expect(console.error).toHaveBeenCalled(); - }); }); describe('applyNamespace', function() {