22
33-export ([build /3 ]).
44
5- -define (CSCOPE_VERSION , 15 ).
6-
7- % -define(DEFINEBEGIN, $\#).
8- % -define(DEFINEEND, $\)).
9- -define (FUNCTIONCALL , $` ).
10- -define (FUNCTIONDEFBEGIN , $\$ ).
11- -define (FUNCTIONDEFEND , $} ).
12- % -define(INCLUDE, $~).
13- -define (NEWFILE , $@ ).
14- % -define(RECORDDEF, $s).
15-
5+ -include (" crossref.hrl" ).
166
7+ -define (CSCOPE_VERSION , 15 ).
178
189build (SrcDirs , IncDirs , SrcFiles ) ->
1910 CscopeDb = " cscope.out" ,
@@ -72,7 +63,7 @@ build_crossref_of_file(Filename, AbsForms) ->
7263% % Outputs a deep list suitable for writing to the crossref file
7364form_to_crossref (Filename , Form ) ->
7465 case erl_syntax :type (Form ) of
75- attribute -> []; % % @fixme ignore for now
66+ attribute -> attribute_to_crossref ( Form );
7667 function -> function_to_crossref (Form );
7768
7869 error_marker ->
@@ -89,6 +80,18 @@ form_to_crossref(Filename, Form) ->
8980 []
9081 end .
9182
83+ attribute_to_crossref (Attribute ) ->
84+ case erl_syntax :atom_value (erl_syntax :attribute_name (Attribute )) of
85+ include ->
86+ StartStr = io_lib :format (" ~b -include(~n " , [erl_syntax :get_pos (Attribute )]),
87+ [File ] = erl_syntax :attribute_arguments (Attribute ),
88+ IncludeStr = io_lib :format (" \t ~c \" ~s~n " , [? INCLUDE , erl_syntax :string_value (File )]),
89+ EndStr = " \" ).\n " ,
90+ [StartStr , IncludeStr , EndStr ];
91+
92+ _ -> [] % ignore unused attributes
93+ end .
94+
9295function_to_crossref (Function ) ->
9396 StartStr = io_lib :format (" ~b ~n " , [erl_syntax :get_pos (Function )]),
9497 FunctionName = erl_syntax :atom_name (erl_syntax :function_name (Function )),
0 commit comments