@@ -321,6 +321,7 @@ export default class Visitor {
321321 result . params = requestTypes . param !== undefined ? asJsonType ( requestTypes . param ) : undefined ;
322322 result . partialResult = asJsonType ( requestTypes . partialResult ) ;
323323 result . errorData = asJsonType ( requestTypes . errorData ) ;
324+ result . registrationMethod = this . getRegistrationMethodName ( symbol ) ;
324325 result . registrationOptions = asJsonType ( requestTypes . registrationOptions ) ;
325326 this . fillDocProperties ( node , result ) ;
326327 return result ;
@@ -353,6 +354,7 @@ export default class Visitor {
353354 } ;
354355 const result : JsonNotification = { method : methodName } ;
355356 result . params = notificationTypes . param !== undefined ? asJsonType ( notificationTypes . param ) : undefined ;
357+ result . registrationMethod = this . getRegistrationMethodName ( symbol ) ;
356358 result . registrationOptions = asJsonType ( notificationTypes . registrationOptions ) ;
357359 this . fillDocProperties ( node , result ) ;
358360 return result ;
@@ -456,6 +458,30 @@ export default class Visitor {
456458 return this . removeQuotes ( text ) ;
457459 }
458460
461+ private getRegistrationMethodName ( namespace : ts . Symbol ) : string | undefined {
462+ const registrationMethod = namespace . exports ?. get ( 'registrationMethod' as ts . __String ) ;
463+ if ( registrationMethod === undefined ) {
464+ return undefined ;
465+ }
466+ const declaration = this . getFirstDeclaration ( registrationMethod ) ;
467+ if ( declaration === undefined || ! ts . isVariableDeclaration ( declaration ) || declaration . initializer === undefined || ! ts . isPropertyAccessExpression ( declaration . initializer ) ) {
468+ return undefined ;
469+ }
470+ const initializerSymbol = this . typeChecker . getSymbolAtLocation ( declaration . initializer . name ) ;
471+ if ( initializerSymbol === undefined || initializerSymbol . valueDeclaration === undefined ) {
472+ return undefined ;
473+ }
474+ const valueDeclaration = initializerSymbol . valueDeclaration ;
475+ if ( ! ts . isVariableDeclaration ( valueDeclaration ) ) {
476+ return undefined ;
477+ }
478+ if ( valueDeclaration . initializer === undefined || ( ! ts . isStringLiteral ( valueDeclaration . initializer ) && ! ts . isNoSubstitutionTemplateLiteral ( valueDeclaration . initializer ) ) ) {
479+ return undefined ;
480+ }
481+
482+ return this . removeQuotes ( valueDeclaration . initializer . getText ( ) ) ;
483+ }
484+
459485 private getRequestTypes ( symbol : ts . Symbol ) : RequestTypes | undefined {
460486 const declaration = this . getFirstDeclaration ( symbol ) ;
461487 if ( declaration === undefined ) {
0 commit comments