File tree Expand file tree Collapse file tree 3 files changed +14
-6
lines changed
Expand file tree Collapse file tree 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{
5353}
5454
5555type CTagsParser struct {
56- tags []* types.CTag
56+ tags []* types.CTag
57+ mainFile string
5758}
5859
59- func (p * CTagsParser ) Parse (ctagsOutput string ) []* types.CTag {
60+ func (p * CTagsParser ) Parse (ctagsOutput string , mainFile string ) []* types.CTag {
6061 rows := strings .Split (ctagsOutput , "\n " )
6162 rows = removeEmpty (rows )
6263
64+ p .mainFile = mainFile
65+
6366 for _ , row := range rows {
6467 p .tags = append (p .tags , parseTag (row ))
6568 }
Original file line number Diff line number Diff line change @@ -48,10 +48,12 @@ func (p *CTagsParser) findLineWhereToInsertPrototypes() int {
4848 } else {
4949 return firstFunctionPointerAsArgument
5050 }
51- } else if firstFunctionLine == - 1 {
51+ } else if firstFunctionLine != - 1 {
52+ return firstFunctionLine
53+ } else if firstFunctionPointerAsArgument != - 1 {
5254 return firstFunctionPointerAsArgument
5355 } else {
54- return firstFunctionLine
56+ return 0
5557 }
5658}
5759
@@ -90,7 +92,7 @@ func (p *CTagsParser) collectFunctions() []*types.CTag {
9092
9193func (p * CTagsParser ) firstFunctionAtLine () int {
9294 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 {
9496 return tag .Line
9597 }
9698 }
Original file line number Diff line number Diff line change @@ -74,7 +74,10 @@ func (s *CTagsRunner) Run(ctx *types.Context) error {
7474 ctx .CTagsOutput = string (sourceBytes )
7575
7676 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+
7881 protos , line := parser .GeneratePrototypes ()
7982 if line != - 1 {
8083 ctx .PrototypesLineWhereToInsert = line
You can’t perform that action at this time.
0 commit comments