File tree 2 files changed +18
-8
lines changed
2 files changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -97,10 +97,15 @@ export class ClassDeclaration extends FileDeclaration {
97
97
}
98
98
99
99
parseComments ( fileClass : ts . Node , sourceFile : ts . SourceFile ) {
100
- // getText() returns the first line without comments
101
- let firstLine : string = sourceFile . getText ( ) ;
102
- // getFullText() returns also the comments, now I need the position of the declared class
103
- let declarationPos : number = sourceFile . getFullText ( ) . indexOf ( firstLine ) ;
100
+ // Now I need the position of the declared class
101
+ let text : string = sourceFile . getFullText ( ) ;
102
+ let regex : string = 'class +(' + this . getIdentifier ( ) + ')' ;
103
+
104
+ let match = text . match ( regex ) ;
105
+
106
+ if ( match == null ) return ;
107
+
108
+ let declarationPos : number = text . indexOf ( match [ 0 ] ) ;
104
109
forEachComment (
105
110
fileClass ,
106
111
( sourceFile , comment ) => {
Original file line number Diff line number Diff line change @@ -75,10 +75,15 @@ export class InterfaceDeclaration extends FileDeclaration {
75
75
}
76
76
77
77
parseComments ( fileInterface : ts . Node , sourceFile : ts . SourceFile ) {
78
- // getText() returns the first line without comments
79
- let firstLine : string = sourceFile . getText ( ) ;
80
- // getFullText() returns also the comments, now I need the position of the declared class
81
- let declarationPos : number = sourceFile . getFullText ( ) . indexOf ( firstLine ) ;
78
+ // Now I need the position of the declared class
79
+ let text : string = sourceFile . getFullText ( ) ;
80
+ let regex : string = 'interface +(' + this . getIdentifier ( ) + ')' ;
81
+
82
+ let match = text . match ( regex ) ;
83
+
84
+ if ( match == null ) return ;
85
+
86
+ let declarationPos : number = text . indexOf ( match [ 0 ] ) ;
82
87
forEachComment (
83
88
fileInterface ,
84
89
( sourceFile , comment ) => {
You can’t perform that action at this time.
0 commit comments