1- import { ComponentEvent } from "../../types/features/component-event " ;
1+ import { AnalyzerVisitContext } from "../../analyzer-visit-context " ;
22import { ComponentMember , ComponentMemberReflectKind } from "../../types/features/component-member" ;
3- import { ComponentMethod } from "../../types/features/component-method" ;
43import { JsDoc } from "../../types/js-doc" ;
54import { VisibilityKind } from "../../types/visibility-kind" ;
65import { parseSimpleJsDocTypeExpression } from "../../util/js-doc-util" ;
@@ -11,7 +10,7 @@ import { AnalyzerFlavor } from "../analyzer-flavor";
1110 * Refines features by looking at the jsdoc tags on the feature
1211 */
1312export const refineFeature : AnalyzerFlavor [ "refineFeature" ] = {
14- event : ( event : ComponentEvent ) => {
13+ event : ( event , context ) => {
1514 if ( event . jsDoc == null || event . jsDoc . tags == null ) return event ;
1615
1716 // Check if the feature has "@ignore" jsdoc tag
@@ -20,23 +19,26 @@ export const refineFeature: AnalyzerFlavor["refineFeature"] = {
2019 }
2120
2221 return [ applyJsDocDeprecated , applyJsDocVisibility , applyJsDocType ] . reduce (
23- ( event , applyFunc ) => ( applyFunc as Function ) ( event , event . jsDoc ) ,
22+ ( event , applyFunc ) => ( applyFunc as Function ) ( event , event . jsDoc , context ) ,
2423 event
2524 ) ;
2625 } ,
27- method : ( method : ComponentMethod ) => {
26+ method : ( method , context ) => {
2827 if ( method . jsDoc == null || method . jsDoc . tags == null ) return method ;
2928
3029 // Check if the feature has "@ignore" jsdoc tag
3130 if ( hasIgnoreJsDocTag ( method . jsDoc ) ) {
3231 return undefined ;
3332 }
3433
35- method = [ applyJsDocDeprecated , applyJsDocVisibility ] . reduce ( ( method , applyFunc ) => ( applyFunc as Function ) ( method , method . jsDoc ) , method ) ;
34+ method = [ applyJsDocDeprecated , applyJsDocVisibility ] . reduce (
35+ ( method , applyFunc ) => ( applyFunc as Function ) ( method , method . jsDoc , context ) ,
36+ method
37+ ) ;
3638
3739 return method ;
3840 } ,
39- member : ( member : ComponentMember ) => {
41+ member : ( member , context ) => {
4042 // Return right away if the member doesn't have jsdoc
4143 if ( member . jsDoc == null || member . jsDoc . tags == null ) return member ;
4244
@@ -54,7 +56,7 @@ export const refineFeature: AnalyzerFlavor["refineFeature"] = {
5456 applyJsDocType ,
5557 applyJsDocAttribute ,
5658 applyJsDocModifiers
57- ] . reduce ( ( member , applyFunc ) => ( applyFunc as Function ) ( member , member . jsDoc ) , member ) ;
59+ ] . reduce ( ( member , applyFunc ) => ( applyFunc as Function ) ( member , member . jsDoc , context ) , member ) ;
5860 }
5961} ;
6062
@@ -122,10 +124,12 @@ function applyJsDocVisibility<T extends Partial<Pick<ComponentMember, "visibilit
122124 * Applies the "@attribute" jsdoc tag
123125 * @param feature
124126 * @param jsDoc
127+ * @param context
125128 */
126129function applyJsDocAttribute < T extends Partial < Pick < ComponentMember , "propName" | "attrName" | "default" | "type" | "typeHint" > > > (
127130 feature : T ,
128- jsDoc : JsDoc
131+ jsDoc : JsDoc ,
132+ context : AnalyzerVisitContext
129133) : T {
130134 const attributeTag = jsDoc . tags ?. find ( tag => [ "attr" , "attribute" ] . includes ( tag . tag ) ) ;
131135
@@ -141,7 +145,7 @@ function applyJsDocAttribute<T extends Partial<Pick<ComponentMember, "propName"
141145 // @attr jsdoc tag can also include the type of attribute
142146 if ( parsed . type != null && result . typeHint == null ) {
143147 result . typeHint = parsed . type ;
144- result . type = feature . type ?? lazy ( ( ) => parseSimpleJsDocTypeExpression ( parsed . type || "" ) ) ;
148+ result . type = feature . type ?? lazy ( ( ) => parseSimpleJsDocTypeExpression ( parsed . type || "" , context ) ) ;
145149 }
146150
147151 return result ;
@@ -237,8 +241,9 @@ function applyJsDocReflect<T extends Partial<Pick<ComponentMember, "reflect">>>(
237241 * Applies the "@type" jsdoc tag
238242 * @param feature
239243 * @param jsDoc
244+ * @param context
240245 */
241- function applyJsDocType < T extends Partial < Pick < ComponentMember , "type" | "typeHint" > > > ( feature : T , jsDoc : JsDoc ) : T {
246+ function applyJsDocType < T extends Partial < Pick < ComponentMember , "type" | "typeHint" > > > ( feature : T , jsDoc : JsDoc , context : AnalyzerVisitContext ) : T {
242247 const typeTag = jsDoc . tags ?. find ( tag => tag . tag === "type" ) ;
243248
244249 if ( typeTag != null && feature . typeHint == null ) {
@@ -248,7 +253,7 @@ function applyJsDocType<T extends Partial<Pick<ComponentMember, "type" | "typeHi
248253 return {
249254 ...feature ,
250255 typeHint : parsed . type ,
251- type : feature . type ?? lazy ( ( ) => parseSimpleJsDocTypeExpression ( parsed . type || "" ) )
256+ type : feature . type ?? lazy ( ( ) => parseSimpleJsDocTypeExpression ( parsed . type || "" , context ) )
252257 } ;
253258 }
254259 }
0 commit comments