File tree Expand file tree Collapse file tree 3 files changed +29
-5
lines changed
lib/processors/jsdoc/lib/ui5 Expand file tree Collapse file tree 3 files changed +29
-5
lines changed Original file line number Diff line number Diff line change @@ -3317,11 +3317,17 @@ exports.astNodeVisitor = {
33173317 typeString = 'function' ;
33183318 // #### BEGIN: MODIFIED BY SAP
33193319 paramTypes = [ ] ;
3320+ // add only one of 'new:' or 'this:' type, 'new:' is preferred as it implies a 'this:'
33203321 if ( parsedType . new ) {
3321- paramTypes . push ( toTypeString ( parsedType . new ) ) ;
3322+ paramTypes . push ( "new:" + toTypeString ( parsedType . new ) ) ;
3323+ } else if ( parsedType . this ) {
3324+ paramTypes . push ( "this:" + toTypeString ( parsedType . this ) ) ;
33223325 }
3326+
33233327 if ( Array . isArray ( parsedType . params ) ) {
3324- paramTypes . push ( ...parsedType . params . map ( toTypeString ) ) ;
3328+ paramTypes . push ( ...parsedType . params . map ( ( paramType ) => {
3329+ return toTypeString ( paramType ) + ( paramType . optional ? "=" : "" ) ;
3330+ } ) ) ;
33253331 }
33263332 if ( paramTypes . length || parsedType . result ) {
33273333 typeString += `(${ paramTypes . join ( ", " ) } )` ;
Original file line number Diff line number Diff line change @@ -730,10 +730,18 @@ class TypeStringBuilder {
730730 str : 'Promise' + this . lt + this . safe ( fulfillmentType ) + this . gt
731731 } ;
732732 }
733- "function" ( paramTypes , returnType ) {
733+ "function" ( paramTypes , returnType , thisType , constructorType ) {
734+ paramTypes = paramTypes . map (
735+ ( type ) => type . str + ( type . optional ? "=" : "" )
736+ ) ;
737+ if ( constructorType != null ) {
738+ paramTypes . unshift ( `new:${ constructorType . str } ` ) ;
739+ } else if ( thisType != null ) {
740+ paramTypes . unshift ( `this:${ thisType . str } ` ) ;
741+ }
734742 return {
735743 simpleComponent : false ,
736- str : " function(" + paramTypes . map ( ( type ) => type . str ) . join ( ',' ) + ")" + ( returnType ? " : " + this . safe ( returnType ) : "" )
744+ str : ` function(${ paramTypes . join ( "," ) } ) ${ returnType ? " : " + this . safe ( returnType ) : "" } `
737745 } ;
738746 }
739747 structure ( structure ) {
Original file line number Diff line number Diff line change @@ -414,9 +414,19 @@ function TypeParser(defaultBuilder = new ASTBuilder()) {
414414 case "function" :
415415 const aParamTemplates = [ ] ;
416416 let aParamsimpleTypes = [ ] ;
417+ if ( Object . hasOwn ( parsed , "constructor" ) && parsed . constructor ) {
418+ const types = findSimpleTypes ( parsed . constructor ) ;
419+ aParamTemplates . push ( "new:" + types . template ) ;
420+ aParamsimpleTypes = aParamsimpleTypes . concat ( types . simpleTypes ) ;
421+ }
422+ if ( parsed . this ) {
423+ const types = findSimpleTypes ( parsed . this ) ;
424+ aParamTemplates . push ( "this:" + types . template ) ;
425+ aParamsimpleTypes = aParamsimpleTypes . concat ( types . simpleTypes ) ;
426+ }
417427 parsed . params . forEach ( function ( paramType ) {
418428 const types = findSimpleTypes ( paramType ) ;
419- aParamTemplates . push ( types . template ) ;
429+ aParamTemplates . push ( types . template + ( paramType . optional ? "?" : "" ) ) ;
420430 aParamsimpleTypes = aParamsimpleTypes . concat ( types . simpleTypes ) ;
421431 } ) ;
422432 const returnType = parsed . return ? findSimpleTypes ( parsed . return ) : { simpleTypes : [ ] } ;
You can’t perform that action at this time.
0 commit comments