Skip to content

Commit b73c990

Browse files
committed
Handle more cases when searching for callback reference
the tag will be searched only if its signature is void and it's not being skipped for other reasons
1 parent c8d6b78 commit b73c990

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

src/arduino.cc/builder/ctags/ctags_parser.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ func parseTag(row string) *types.CTag {
240240

241241
parts = parts[2:]
242242

243-
signature := ""
244243
returntype := ""
245244
for _, part := range parts {
246245
if strings.Contains(part, ":") {
@@ -257,7 +256,7 @@ func parseTag(row string) *types.CTag {
257256
case "typeref":
258257
tag.Typeref = value
259258
case "signature":
260-
signature = value
259+
tag.Signature = value
261260
case "returntype":
262261
returntype = value
263262
case "class":
@@ -269,7 +268,7 @@ func parseTag(row string) *types.CTag {
269268
}
270269
}
271270
}
272-
tag.Prototype = returntype + " " + tag.FunctionName + signature + ";"
271+
tag.Prototype = returntype + " " + tag.FunctionName + tag.Signature + ";"
273272

274273
if strings.Contains(row, "/^") && strings.Contains(row, "$/;") {
275274
tag.Code = row[strings.Index(row, "/^")+2 : strings.Index(row, "$/;")]

src/arduino.cc/builder/ctags/ctags_to_prototypes.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,18 @@ func functionNameUsedAsFunctionPointerIn(tag *types.CTag, functionNames []string
7979
if strings.Index(tag.Code, "&"+functionName) != -1 {
8080
return true
8181
}
82+
if strings.Index(tag.Code, functionName) != -1 {
83+
return true
84+
}
8285
}
8386
return false
8487
}
8588

8689
func collectFunctionNames(tags []*types.CTag) []string {
8790
names := []string{}
8891
for _, tag := range tags {
89-
if tag.Kind == KIND_FUNCTION {
92+
if tag.Kind == KIND_FUNCTION && !tag.SkipMe &&
93+
(tag.Signature == "()" || tag.Signature == "(void)" || tag.Signature == "") {
9094
names = append(names, tag.FunctionName)
9195
}
9296
}

src/arduino.cc/builder/types/types.go

+1
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ type CTag struct {
252252
Filename string
253253
Typeref string
254254
SkipMe bool
255+
Signature string
255256

256257
Prototype string
257258
Function string

0 commit comments

Comments
 (0)