@@ -33,30 +33,7 @@ function createAnnotation(name: string, args: string[]): Annotation | undefined
3333
3434export type AnnotationsMap = Map < AnnotationKind , Annotation > ;
3535
36- function collectAnnotations (
37- context : TransformationContext ,
38- source : ts . Symbol | ts . Signature ,
39- annotationsMap : AnnotationsMap
40- ) : void {
41- const comments = source . getDocumentationComment ( context . checker ) ;
42- const oldStyleAnnotations = comments
43- . filter ( comment => comment . kind === "text" )
44- . map ( comment => comment . text . split ( "\n" ) )
45- . reduce ( ( a , b ) => a . concat ( b ) , [ ] )
46- . map ( line => line . trim ( ) )
47- . filter ( comment => comment [ 0 ] === "!" ) ;
48-
49- for ( const line of oldStyleAnnotations ) {
50- const [ name , ...args ] = line . slice ( 1 ) . split ( " " ) ;
51- const annotation = createAnnotation ( name , args ) ;
52- if ( annotation ) {
53- annotationsMap . set ( annotation . kind , annotation ) ;
54- console . warn ( `[Deprecated] Annotations with ! are being deprecated, use '@${ annotation . kind } ' instead` ) ;
55- } else {
56- console . warn ( `Encountered unknown annotation '${ line } '.` ) ;
57- }
58- }
59-
36+ function collectAnnotations ( source : ts . Symbol | ts . Signature , annotationsMap : AnnotationsMap ) : void {
6037 for ( const tag of source . getJsDocTags ( ) ) {
6138 const annotation = createAnnotation ( tag . name , tag . text ? tag . text . split ( " " ) : [ ] ) ;
6239 if ( annotation ) {
@@ -65,17 +42,17 @@ function collectAnnotations(
6542 }
6643}
6744
68- export function getSymbolAnnotations ( context : TransformationContext , symbol : ts . Symbol ) : AnnotationsMap {
45+ export function getSymbolAnnotations ( symbol : ts . Symbol ) : AnnotationsMap {
6946 const annotationsMap : AnnotationsMap = new Map ( ) ;
70- collectAnnotations ( context , symbol , annotationsMap ) ;
47+ collectAnnotations ( symbol , annotationsMap ) ;
7148 return annotationsMap ;
7249}
7350
74- export function getTypeAnnotations ( context : TransformationContext , type : ts . Type ) : AnnotationsMap {
51+ export function getTypeAnnotations ( type : ts . Type ) : AnnotationsMap {
7552 const annotationsMap : AnnotationsMap = new Map ( ) ;
7653
77- if ( type . symbol ) collectAnnotations ( context , type . symbol , annotationsMap ) ;
78- if ( type . aliasSymbol ) collectAnnotations ( context , type . aliasSymbol , annotationsMap ) ;
54+ if ( type . symbol ) collectAnnotations ( type . symbol , annotationsMap ) ;
55+ if ( type . aliasSymbol ) collectAnnotations ( type . aliasSymbol , annotationsMap ) ;
7956
8057 return annotationsMap ;
8158}
@@ -116,14 +93,14 @@ export function getFileAnnotations(sourceFile: ts.SourceFile): AnnotationsMap {
11693
11794export function getSignatureAnnotations ( context : TransformationContext , signature : ts . Signature ) : AnnotationsMap {
11895 const annotationsMap : AnnotationsMap = new Map ( ) ;
119- collectAnnotations ( context , signature , annotationsMap ) ;
96+ collectAnnotations ( signature , annotationsMap ) ;
12097
12198 // Function properties on interfaces have the JSDoc tags on the parent PropertySignature
12299 const declaration = signature . getDeclaration ( ) ;
123100 if ( declaration && declaration . parent && ts . isPropertySignature ( declaration . parent ) ) {
124101 const symbol = context . checker . getSymbolAtLocation ( declaration . parent . name ) ;
125102 if ( symbol ) {
126- collectAnnotations ( context , symbol , annotationsMap ) ;
103+ collectAnnotations ( symbol , annotationsMap ) ;
127104 }
128105 }
129106
@@ -154,7 +131,7 @@ export function isTupleReturnCall(context: TransformationContext, node: ts.Node)
154131 }
155132
156133 const type = context . checker . getTypeAtLocation ( node . expression ) ;
157- return getTypeAnnotations ( context , type ) . has ( AnnotationKind . TupleReturn ) ;
134+ return getTypeAnnotations ( type ) . has ( AnnotationKind . TupleReturn ) ;
158135}
159136
160137export function isInTupleReturnFunction ( context : TransformationContext , node : ts . Node ) : boolean {
@@ -185,20 +162,20 @@ export function isInTupleReturnFunction(context: TransformationContext, node: ts
185162 return true ;
186163 }
187164
188- return getTypeAnnotations ( context , functionType ) . has ( AnnotationKind . TupleReturn ) ;
165+ return getTypeAnnotations ( functionType ) . has ( AnnotationKind . TupleReturn ) ;
189166}
190167
191168export function isLuaIteratorType ( context : TransformationContext , node : ts . Node ) : boolean {
192169 const type = context . checker . getTypeAtLocation ( node ) ;
193- return getTypeAnnotations ( context , type ) . has ( AnnotationKind . LuaIterator ) ;
170+ return getTypeAnnotations ( type ) . has ( AnnotationKind . LuaIterator ) ;
194171}
195172
196173export function isVarArgType ( context : TransformationContext , node : ts . Node ) : boolean {
197174 const type = context . checker . getTypeAtLocation ( node ) ;
198- return getTypeAnnotations ( context , type ) . has ( AnnotationKind . VarArg ) ;
175+ return getTypeAnnotations ( type ) . has ( AnnotationKind . VarArg ) ;
199176}
200177
201178export function isForRangeType ( context : TransformationContext , node : ts . Node ) : boolean {
202179 const type = context . checker . getTypeAtLocation ( node ) ;
203- return getTypeAnnotations ( context , type ) . has ( AnnotationKind . ForRange ) ;
180+ return getTypeAnnotations ( type ) . has ( AnnotationKind . ForRange ) ;
204181}
0 commit comments