File tree 3 files changed +14
-6
lines changed
3 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -53,13 +53,16 @@ var KNOWN_TAG_KINDS = map[string]bool{
53
53
}
54
54
55
55
type CTagsParser struct {
56
- tags []* types.CTag
56
+ tags []* types.CTag
57
+ mainFile string
57
58
}
58
59
59
- func (p * CTagsParser ) Parse (ctagsOutput string ) []* types.CTag {
60
+ func (p * CTagsParser ) Parse (ctagsOutput string , mainFile string ) []* types.CTag {
60
61
rows := strings .Split (ctagsOutput , "\n " )
61
62
rows = removeEmpty (rows )
62
63
64
+ p .mainFile = mainFile
65
+
63
66
for _ , row := range rows {
64
67
p .tags = append (p .tags , parseTag (row ))
65
68
}
Original file line number Diff line number Diff line change @@ -48,10 +48,12 @@ func (p *CTagsParser) findLineWhereToInsertPrototypes() int {
48
48
} else {
49
49
return firstFunctionPointerAsArgument
50
50
}
51
- } else if firstFunctionLine == - 1 {
51
+ } else if firstFunctionLine != - 1 {
52
+ return firstFunctionLine
53
+ } else if firstFunctionPointerAsArgument != - 1 {
52
54
return firstFunctionPointerAsArgument
53
55
} else {
54
- return firstFunctionLine
56
+ return 0
55
57
}
56
58
}
57
59
@@ -90,7 +92,7 @@ func (p *CTagsParser) collectFunctions() []*types.CTag {
90
92
91
93
func (p * CTagsParser ) firstFunctionAtLine () int {
92
94
for _ , tag := range p .tags {
93
- if ! tagIsUnknown (tag ) && isHandled (tag ) && tag .Kind == KIND_FUNCTION {
95
+ if ! tagIsUnknown (tag ) && isHandled (tag ) && tag .Kind == KIND_FUNCTION && tag . Filename == p . mainFile {
94
96
return tag .Line
95
97
}
96
98
}
Original file line number Diff line number Diff line change @@ -74,7 +74,10 @@ func (s *CTagsRunner) Run(ctx *types.Context) error {
74
74
ctx .CTagsOutput = string (sourceBytes )
75
75
76
76
parser := & ctags.CTagsParser {}
77
- ctx .CTagsOfPreprocessedSource = parser .Parse (ctx .CTagsOutput )
77
+ ctx .CTagsOfPreprocessedSource = parser .Parse (ctx .CTagsOutput , ctx .Sketch .MainFile .Name )
78
+
79
+ parser .FixCLinkageTagsDeclarations (ctx .CTagsOfPreprocessedSource )
80
+
78
81
protos , line := parser .GeneratePrototypes ()
79
82
if line != - 1 {
80
83
ctx .PrototypesLineWhereToInsert = line
You can’t perform that action at this time.
0 commit comments