@@ -110,31 +110,73 @@ func (p *CTagsParser) prototypeAndCodeDontMatch(tag *types.CTag) bool {
110
110
code = removeEverythingAfterClosingRoundBracket (code )
111
111
// Get how many characters are "missing"
112
112
n := strings .Index (prototype , code )
113
+ line := 0
113
114
// Add these characters to "code" string
114
- code = getFunctionProtoWithNPreviousCharacters (tag , code , n )
115
+ code , line = getFunctionProtoWithNPreviousCharacters (tag , code , n )
115
116
// Check again for perfect matching
116
117
ret = strings .Index (code , prototype )
118
+ if ret != - 1 {
119
+ tag .Line = line
120
+ }
117
121
}
118
122
119
123
return ret == - 1
120
124
}
121
125
126
+ func findTemplateMultiline (tag * types.CTag ) string {
127
+ code , _ := getFunctionProtoUntilTemplateToken (tag , tag .Code )
128
+ return removeEverythingAfterClosingRoundBracket (code )
129
+ }
130
+
122
131
func removeEverythingAfterClosingRoundBracket (s string ) string {
123
132
n := strings .Index (s , ")" )
124
133
return s [0 : n + 1 ]
125
134
}
126
135
127
- func getFunctionProtoWithNPreviousCharacters (tag * types.CTag , code string , n int ) string {
136
+ func getFunctionProtoUntilTemplateToken (tag * types.CTag , code string ) (string , int ) {
137
+
138
+ /* FIXME I'm ugly */
139
+ line := 0
140
+
141
+ file , err := os .Open (tag .Filename )
142
+ if err == nil {
143
+ defer file .Close ()
144
+
145
+ scanner := bufio .NewScanner (file )
146
+ multilinecomment := false
147
+ var textBuffer []string
148
+
149
+ // buffer lines until we get to the start of this tag
150
+ for scanner .Scan () && line < (tag .Line - 1 ) {
151
+ line ++
152
+ text := scanner .Text ()
153
+ textBuffer = append (textBuffer , text )
154
+ }
155
+
156
+ for line > 0 && ! strings .Contains (code , TEMPLATE ) {
157
+
158
+ line = line - 1
159
+ text := textBuffer [line ]
160
+
161
+ text , multilinecomment = removeComments (text , multilinecomment )
162
+
163
+ code = text + code
164
+ }
165
+ }
166
+ return code , line
167
+ }
168
+
169
+ func getFunctionProtoWithNPreviousCharacters (tag * types.CTag , code string , n int ) (string , int ) {
128
170
129
171
/* FIXME I'm ugly */
130
172
expectedPrototypeLen := len (code ) + n
173
+ line := 0
131
174
132
175
file , err := os .Open (tag .Filename )
133
176
if err == nil {
134
177
defer file .Close ()
135
178
136
179
scanner := bufio .NewScanner (file )
137
- line := 0
138
180
multilinecomment := false
139
181
var textBuffer []string
140
182
@@ -156,7 +198,7 @@ func getFunctionProtoWithNPreviousCharacters(tag *types.CTag, code string, n int
156
198
code = removeSpacesAndTabs (code )
157
199
}
158
200
}
159
- return code
201
+ return code , line
160
202
}
161
203
162
204
func removeComments (text string , multilinecomment bool ) (string , bool ) {
0 commit comments