@@ -32,10 +32,6 @@ func (a *RustAdapter) extractComments(root *sitter.Node, src []byte, file string
3232 node := c .Node
3333 content := node .Content (src )
3434
35- if isEmptyComment (content ) {
36- continue
37- }
38-
3935 // Find Owner and Symbol Path
4036 owner := FindOwnerNode (node , src )
4137 symbolPath := ResolveSymbolPath (owner , src )
@@ -79,7 +75,17 @@ func (a *RustAdapter) extractComments(root *sitter.Node, src []byte, file string
7975 }
8076 }
8177
82- return mergeComments (comments ), nil
78+ merged := mergeComments (comments )
79+
80+ // Filter empty comments after merge
81+ var finalComments []* domain.Comment
82+ for _ , c := range merged {
83+ if ! isEmptyComment (c .SourceText ) {
84+ finalComments = append (finalComments , c )
85+ }
86+ }
87+
88+ return finalComments , nil
8389}
8490
8591// mergeComments merges consecutive comments of the same type and symbol.
@@ -143,20 +149,39 @@ func getDomainCommentType(content string) domain.CommentType {
143149
144150func isEmptyComment (content string ) bool {
145151 trimmed := strings .TrimSpace (content )
146- switch {
147- case strings .HasPrefix (trimmed , "///" ):
148- return strings .TrimSpace (strings .TrimPrefix (trimmed , "///" )) == ""
149- case strings .HasPrefix (trimmed , "//!" ):
150- return strings .TrimSpace (strings .TrimPrefix (trimmed , "//!" )) == ""
151- case strings .HasPrefix (trimmed , "//" ):
152- return strings .TrimSpace (strings .TrimPrefix (trimmed , "//" )) == ""
153- case strings .HasPrefix (trimmed , "/*" ):
152+
153+ // Block comments
154+ if strings .HasPrefix (trimmed , "/*" ) {
154155 inner := strings .TrimPrefix (trimmed , "/*" )
155156 if strings .HasSuffix (inner , "*/" ) {
156157 inner = strings .TrimSuffix (inner , "*/" )
157158 }
158159 return strings .TrimSpace (inner ) == ""
159- default :
160- return strings .TrimSpace (trimmed ) == ""
161160 }
161+
162+ // Line and Doc comments (check each line)
163+ lines := strings .Split (content , "\n " )
164+ for _ , line := range lines {
165+ t := strings .TrimSpace (line )
166+ if t == "" {
167+ continue
168+ }
169+
170+ if strings .HasPrefix (t , "///" ) {
171+ t = strings .TrimPrefix (t , "///" )
172+ } else if strings .HasPrefix (t , "//!" ) {
173+ t = strings .TrimPrefix (t , "//!" )
174+ } else if strings .HasPrefix (t , "//" ) {
175+ t = strings .TrimPrefix (t , "//" )
176+ } else {
177+ // Not a standard line comment marker, assume content
178+ return false
179+ }
180+
181+ if strings .TrimSpace (t ) != "" {
182+ return false
183+ }
184+ }
185+
186+ return true
162187}
0 commit comments