@@ -7,6 +7,7 @@ var testValue = require('test-value');
77var data ;
88exports . createConstructor = createConstructor ;
99exports . insertConstructors = insertConstructors ;
10+ exports . fixConstructorMemberLongnames = fixConstructorMemberLongnames ;
1011exports . setIsExportedFlag = setIsExportedFlag ;
1112exports . setCodename = setCodename ;
1213exports . setID = setID ;
@@ -94,27 +95,10 @@ function createConstructor(class_) {
9495
9596function insertConstructors ( data ) {
9697 var replacements = [ ] ;
97- var toDelete = [ ] ;
9898
9999 data . forEach ( function ( identifier , index ) {
100- if ( isES5Class ( identifier ) ) {
100+ if ( identifier . kind === 'class' ) {
101101 replacements . push ( { index : index , items : createConstructor ( identifier ) } ) ;
102- } else if ( isES6Class ( identifier ) ) {
103- var es6constructor = getEs6Constructor ( data , identifier ) ;
104- if ( es6constructor ) {
105- if ( ! ( es6constructor . description || es6constructor . params && es6constructor . params . length ) ) {
106- toDelete . push ( es6constructor ) ;
107- }
108- es6constructor . kind = 'constructor' ;
109- es6constructor . memberof = identifier . longname ;
110- var constructorChildren = a . where ( data , { memberof : es6constructor . longname } ) ;
111- constructorChildren . forEach ( function ( i ) {
112- i . memberof = identifier . longname ;
113- } ) ;
114- identifier . description = identifier . classdesc ;
115- delete identifier . classdesc ;
116- delete identifier . params ;
117- }
118102 }
119103 } ) ;
120104
@@ -123,15 +107,13 @@ function insertConstructors(data) {
123107 data . splice . apply ( data , spliceArgs ) ;
124108 } ) ;
125109
126- toDelete . forEach ( function ( d ) {
127- data . splice ( data . indexOf ( d ) , 1 ) ;
128- } ) ;
129-
130110 return data ;
131111}
132112
133- function getEs6Constructor ( data , identifier ) {
134- return a . findWhere ( data , isES6Constructor ) ;
113+ function getEs6Constructor ( data , parent ) {
114+ return a . findWhere ( data , function ( i ) {
115+ return isES6Constructor ( i ) && i . memberof === parent . longname ;
116+ } ) ;
135117}
136118function isES5Class ( identifier ) {
137119 return testValue ( identifier , {
@@ -178,10 +160,11 @@ function updateIDReferences(identifier, newID) {
178160}
179161
180162function removeQuotes ( identifier ) {
181- if ( identifier . name ) identifier . name = identifier . name . replace ( / " / g, '' ) ;
182- if ( identifier . memberof ) identifier . memberof = identifier . memberof . replace ( / " / g, '' ) ;
183- if ( identifier . longname ) identifier . longname = identifier . longname . replace ( / " / g, '' ) ;
184- if ( identifier . id ) identifier . id = identifier . id . replace ( / " / g, '' ) ;
163+ var re = / [ " ' ] / g;
164+ if ( identifier . name ) identifier . name = identifier . name . replace ( re , '' ) ;
165+ if ( identifier . memberof ) identifier . memberof = identifier . memberof . replace ( re , '' ) ;
166+ if ( identifier . longname ) identifier . longname = identifier . longname . replace ( re , '' ) ;
167+ if ( identifier . id ) identifier . id = identifier . id . replace ( re , '' ) ;
185168 return identifier ;
186169}
187170
@@ -329,4 +312,19 @@ function removeMemberofFromModule(identifier) {
329312 delete identifier . scope ;
330313 }
331314 return identifier ;
315+ }
316+
317+ function fixConstructorMemberLongnames ( data ) {
318+ data . forEach ( function ( i ) {
319+ if ( isES6Class ( i ) ) {
320+ var es6constructor = getEs6Constructor ( data , i ) ;
321+ if ( es6constructor ) {
322+ var constructorChildren = a . where ( data , { memberof : es6constructor . longname } ) ;
323+ constructorChildren . forEach ( function ( child ) {
324+ child . memberof = i . longname ;
325+ } ) ;
326+ }
327+ }
328+ } ) ;
329+ return data ;
332330}
0 commit comments