1. xemacs
  2. semantic

Source

semantic / doc / tags.texi

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
@ignore
@node Semantic Tags
@chapter Semantic Tags
@end ignore

The end result of a @semantic{} parser is a list of tags per each buffer.
This chapter discusses the tag data structure and the API provided
by @semantic{} to query, process, and modify tags.

The tags list for a buffer can be obtained by calling
@code{semantic-fetch-tags} which returns
a parse tree of tags that represent the program structure.

@ignore
David said:

Tags are not sorted.  Maybe would it be clearer to say that
`semantic-fetch-tags returns a parse tree of tags that
represent the program structure.

From a grammar's developer point of view it could be worth
highlighting that the parse tree of tags should be consistent with
buffer's location.

For example, for the following definition:

(defun foo (x y) ...)

The parse tree should look like:

("foo" function
 (:arguments
  ("x" "y"))
  ...)

A bad parse tree is for example:

("foo" function
 (:arguments
  ("y" "x"))   <--- Arguments are in the reverse order
  ...)
@end ignore

@menu
* Tag Basics::
* Tag Query::
* Tag Hooks::
* Tag Overlay::
* Misc Tag Functions::
* Tag Internals::
@end menu

@node Tag Basics
@section Tag Basics
@cindex Tag Basics

Currently each tag is a list with up to five elements:
@example
(@var{name} @var{class} @var{attributes} @var{properties} @var{overlay})
@end example

Application developers should not rely on this list structure.
Instead they should rely on the provided API documented in this chapter.
The list structure is explained here primarily to help those reading
the @semantic{} source code.

@itemize @bullet
@c
@item
@var{name} is a required component for all tags, i.e., every tag
must have this component. It is also guaranteed to be a string.  This
string represents the name of the tag, usually a named definition
which the language will use elsewhere as a reference to the syntactic
element found.
@c
@item
@var{class} is the other required component for all tags.
It is a symbol representing the class of the tag.
@ignore
David said:
I think it would be better to say the category or class of tag
[rather than ``type''].  Type of tag could be confusing.  The notion
of tag type represents program data type (see the function
`semantic-tag-type').
@end ignore
Valid @var{class}es can be anything, as long is it is an Emacs Lisp
symbol.  However following are some of the well-known symbols:
@code{type}, @code{function}, @code{variable}, @code{include},
@code{package}, @code{code}.
@c
@item
@var{attributes} is a property list that keep information related
to the tag parsed from the buffer.

The symbol names in the property list can be anything, though there is
a useful set of predefined attributes.  It is best to use the API
functions to access the well-known properties.  @ref{Tag Query}.

@ignore

It could be worth enumerating the commonly used attribute names:

  :type
  :members
  :superclasses
  :interfaces
  :default-value
  :documentation
  :arguments
  :system-flag
  :detail

We could recommend to use the above names when that makes sense, and
more generally to use the Emacs keyword notation (symbol starting with
':') for attribute names.
@end ignore
@c
@item
@var{properties} is generated by the semantic parser harness,
and need not be provided by a language author.

Properties are used to store transient data on a tag unrelated to the
source of the original tag, such as hook functions, dynamic overlays,
or other data needed by programs.

The semantic incremental parser will attempt to maintain properties
when reparsing the source of a tag.
@c
@item
@var{overlay} represents positional information for this tag.  It is
automatically generated by the semantic parser harness, and need
not be provided by the language author.
@c Below is from old semantic manual: unless they provide a
@c nonterminal expansion function via
@c @code{semantic-tag-expand-function}.
Depending on the overlay in a program can be dangerous because
sometimes the overlay is replaced with an integer pair
@example
[ @var{start} @var{end} ]
@end example
when the buffer the tag belongs to is not in memory.  This happens
when a using has activated the Semantic Database
 @inforef{semanticdb, , lang-support-guide}.
@c
@end itemize

@defun semantic-tag-name tag
@anchor{semantic-tag-name}
Return the name of @var{tag}.
For functions, variables, classes, typedefs, etc., this is the identifier
that is being defined.  For tags without an obvious associated name, this
may be the statement type, e.g., this may return @code{print} for python's
print statement.
@obsolete{semantic-token-name,semantic-tag-name}
@end defun

@defun semantic-tag-class tag
@anchor{semantic-tag-class}
Return the class of @var{tag}.
That is, the symbol @code{'variable}, @code{'function}, @code{'type}, or other.
There is no limit to the symbols that may represent the class of a tag.
Each parser generates tags with classes defined by it.

For functional languages, typical tag classes are:

@table @code
@item type
Data types, named map for a memory block.
@item function
A function or method, or named execution location.
@item variable
A variable, or named storage for data.
@item include
Statement that represents a file from which more tags can be found.
@item package
Statement that declairs this file's package name.
@item code
Code that has not name or binding to any other symbol, such as in a script.
@end table

@obsolete{semantic-token-token,semantic-tag-class}
@end defun

Several functions that deal with @var{attributes} component are given
in @ref{Tag Attributes Internals,Tag Attributes Internals}.
However functions listed in @ref{Tag Query,Tag Query}
should provide most needs of the application developer.

Similarly functions that deal with @var{properties} component are given
in @ref{Tag Properties Internals,Tag Properties Internals}.
The application developer should not need to use any of these.

Finally @ref{Tag Overlay,Tag Overlay} lists functions dealing with
the @var{overlay} component.

@node Tag Query
@section Tag Query
@cindex Tag Query

This section lists functions that answers simple questions
regarding a given tag.

@subsection Tag Predicates

@defun semantic-tag-p tag
@anchor{semantic-tag-p}
Return non-@code{nil} if @var{tag} is most likely a semantic tag.
@obsolete{semantic-token-p,semantic-tag-p}
@end defun

@defun semantic-equivalent-tag-p tag1 tag2
@anchor{semantic-equivalent-tag-p}
Compare @var{tag1} and @var{tag2} and return non-@code{nil} if they are equivalent.
Use @dfn{eq} to test of two tags are the same.  Use this function if tags
are being copied and regrouped to test for if two tags represent the
same thing, but may be constructed of different cons cells.
@obsolete{semantic-equivalent-tokens-p,semantic-equivalent-tag-p}
@end defun

@defun semantic-tag-of-class-p tag class
@anchor{semantic-tag-of-class-p}
Return non-@code{nil} if class of @var{tag} is @var{class}.
@end defun

@defun semantic-tag-faux-p tag
@anchor{semantic-tag-faux-p}
Return non-@code{nil} if @var{tag} is a @var{faux} tag.
@var{faux} tags are created to represent a construct that is
not known to exist in the code.
@end defun

@defun semantic-tag-type-compound-p tag
@anchor{semantic-tag-type-compound-p}
Return non-@code{nil} the type of @var{tag} is compound.
Compound implies a structure or similar data type.
Returns the list of tag members if it is compound.
@end defun

@subsection Documentation

@defun semantic-tag-docstring tag &optional buffer
@anchor{semantic-tag-docstring}
Return the documentation of @var{tag}.
That is the value defined by the `:documentation' attribute.
Optional argument @var{buffer} indicates where to get the text from.
If not provided, then only the @var{position} can be provided.
@obsolete{semantic-token-docstring,semantic-tag-docstring}
@end defun

@subsection Common Flags

@defun semantic-tag-variable-constant-p tag
@anchor{semantic-tag-variable-constant-p}
Return non-@code{nil} if the variable that @var{tag} describes is a constant.
That is the value of the attribute `:constant-flag'.
@obsolete{semantic-token-variable-const,semantic-tag-variable-constant-p}
@end defun

@defun semantic-tag-function-destructor-p tag
@anchor{semantic-tag-function-destructor-p}
Return non-@code{nil} if @var{tag} describes a destructor function.
That is the value of the `:destructor-flag' attribute.
@obsolete{semantic-token-function-destructor,semantic-tag-function-destructor-p}
@end defun

@defun semantic-tag-function-throws tag
@anchor{semantic-tag-function-throws}
Return the exceptions the function that @var{tag} describes can throw.
That is the value of the `:throws' attribute.
@obsolete{semantic-token-function-throws,semantic-tag-function-throws}
@end defun

@defun semantic-tag-modifiers tag
@anchor{semantic-tag-modifiers}
Return the value of the `:typemodifiers' attribute of @var{tag}.
@obsolete{semantic-token-type-modifiers,semantic-tag-modifiers}
@obsolete{semantic-token-variable-modifiers,semantic-tag-modifiers}
@obsolete{semantic-token-function-modifiers,semantic-tag-modifiers}
@end defun

@subsection Functions

@defun semantic-tag-function-arguments tag
@anchor{semantic-tag-function-arguments}
Return the arguments of the function that @var{tag} describes.
That is the value of the `:arguments' attribute.
@obsolete{semantic-token-function-args,semantic-tag-function-arguments}
@end defun

@subsection Variables

@defun semantic-tag-variable-default tag
@anchor{semantic-tag-variable-default}
Return the default value of the variable that @var{tag} describes.
That is the value of the attribute `:default-value'.
@obsolete{semantic-token-variable-default,semantic-tag-variable-default}
@end defun

@subsection Data Types

@defun semantic-tag-type tag
@anchor{semantic-tag-type}
Return the value of the `:type' attribute of @var{tag}.
@obsolete{semantic-token-type,semantic-tag-type}
@end defun

@defun semantic-tag-of-type-p tag type
@anchor{semantic-tag-of-type-p}
Compare TAG's type against @var{type}.  Non @code{nil} if equivalent.
@var{type} can be a string, or a tag of class @code{'type}.
@end defun

@subsection Inheritance and Hierarchy

@defun semantic-tag-named-parent tag
@anchor{semantic-tag-named-parent}
Return the parent of @var{tag}.
That is the value of the `:parent' attribute.
If a definition can occur outside an actual parent structure, but
refers to that parent by name, then the @code{:parent} attribute should be used.
@end defun

@defun semantic-tag-function-parent tag
@anchor{semantic-tag-function-parent}
Return the parent of the function that @var{tag} describes.
That is the value of the `:parent' attribute.
A function has a parent if it is a method of a class, and if the
function does not appear in body of it's parent class.
@obsolete{semantic-token-function-parent,semantic-tag-function-parent}
@end defun

@defun semantic-tag-type-superclasses tag
@anchor{semantic-tag-type-superclasses}
Return the list of superclasses of the type that @var{tag} describes.
@obsolete{semantic-token-type-parent-superclass,semantic-tag-type-superclasses}
@obsolete{semantic-token-type-parent,semantic-tag-type-superclasses}
@end defun

@defun semantic-tag-type-interfaces tag
@anchor{semantic-tag-type-interfaces}
Return the list of interfaces of the type that @var{tag} describes.
@obsolete{semantic-token-type-parent-implement,semantic-tag-type-interfaces}
@obsolete{semantic-token-type-parent,semantic-tag-type-interfaces}
@end defun

@defun semantic-tag-type-members tag
@anchor{semantic-tag-type-members}
Return the members of the type that @var{tag} describes.
That is the value of the `:members' attribute.
@obsolete{semantic-token-type-parts,semantic-tag-type-members}
@end defun

@subsection Includes

@defun semantic-tag-include-system-p tag
@anchor{semantic-tag-include-system-p}
Return non-@code{nil} if the include that @var{tag} describes is a system include.
That is the value of the attribute `:system-flag'.
@obsolete{semantic-token-include-system,semantic-tag-include-system-p}
@end defun

@defun semantic-tag-include-filename tag
@anchor{semantic-tag-include-filename}
Return a filename representation of @var{tag}.
The default action is to return the @dfn{semantic-tag-name}.
Some languages do not use full filenames in their include statements.
Override this method to translate the code represenation
into a filename.  (A relative filename if necessary.)

See @dfn{semantic-dependency-tag-file} to expand an include
tag to a full file name.
This function can be overloaded (see @dfn{define-mode-local-override} for details).
@end defun

@subsection Code

@defun semantic-tag-code-detail tag
@anchor{semantic-tag-code-detail}
Return detail information from code that @var{tag} describes.
That is the value of the attribute `:detail'.
@end defun

@subsection Tag Children

@defun semantic-tag-components tag
@anchor{semantic-tag-components}
Return a list of components for @var{tag}.
A Component is a part of @var{tag} which itself may be a @var{tag}.
Examples include the elements of a structure in a 
tag of class `type, or the list of arguments to a
tag of class @code{'function}.
This function can be overloaded (see @dfn{define-mode-local-override} for details).
@end defun

@defun semantic-tag-components-default tag
@anchor{semantic-tag-components-default}
Return a list of components for @var{tag}.
Perform the described task in @dfn{semantic-tag-components}.
@end defun

@defun semantic-tag-children-compatibility tag &optional positiononly
@anchor{semantic-tag-children-compatibility}
Return children of @var{tag}.
If @var{positiononly} is @code{nil}, use @dfn{semantic-tag-components}.
If @var{positiononly} is non-@code{nil}, use @dfn{semantic-tag-components-with-overlays}.
@var{do} @var{not} use this fcn in new code.  Use one of the above instead.
@obsolete{semantic-nonterminal-children,semantic-tag-children-compatibility}
@end defun

@subsection Location

@node Tag Overlay
@section Tag Overlay
@cindex Tag Overlay

The functions in this answer questions regarding the overly such as
the buffer in which the tags is located, the start and/or end position
of the tag, and the overlay itself which spans the tags.

@defun semantic-tag-start tag
@anchor{semantic-tag-start}
Return the start location of @var{tag}.
@obsolete{semantic-token-start,semantic-tag-start}
@end defun

@defun semantic-tag-end tag
@anchor{semantic-tag-end}
Return the end location of @var{tag}.
@obsolete{semantic-token-end,semantic-tag-end}
@end defun

@defun semantic-tag-bounds tag
@anchor{semantic-tag-bounds}
Return the location (@var{start} @var{end}) of data @var{tag} describes.
@obsolete{semantic-token-extent,semantic-tag-bounds}
@end defun

@defun semantic-tag-buffer tag
@anchor{semantic-tag-buffer}
Return the buffer @var{tag} resides in.
If @var{tag} has an originating file, read that file into a (maybe new)
buffer, and return it.
Return @code{nil} if there is no buffer for this tag.
@obsolete{semantic-token-buffer,semantic-tag-buffer}
@end defun

@defun semantic-tag-file-name tag
@anchor{semantic-tag-file-name}
Return the name of the file from which @var{tag} originated.
Return @code{nil} if that information can't be obtained.
If @var{tag} is from a loaded buffer, then that buffer's filename is used.
If @var{tag} is unlinked, but has a @code{:filename} property, then that is used.
@end defun

@defun semantic-tag-overlay tag
@anchor{semantic-tag-overlay}
Return the @var{overlay} part of @var{tag}.
That is, an overlay or an unloaded buffer representation.
This function can also return an array of the form [ @var{start} @var{end} ].
This occurs for tags that are not currently linked into a buffer.
@obsolete{semantic-token-overlay,semantic-tag-overlay}
@end defun

@defun semantic-tag-with-position-p tag
@anchor{semantic-tag-with-position-p}
Return non-@code{nil} if @var{tag} has positional information.
@obsolete{semantic-token-with-position-p,semantic-tag-with-position-p}
@end defun

@defun semantic-tag-components-with-overlays tag
@anchor{semantic-tag-components-with-overlays}
Return the list of top level components belonging to @var{tag}.
Children are any sub-tags which contain overlays.

Default behavior is to get @dfn{semantic-tag-components} in addition
to the components of an anonymous types (if applicable.)

@table @strong
@item Language authors, please note:
  If a mode defines a language tag that has tags in it with overlays
you should still return them with this function.
Ignoring this step will prevent several features from working correctly.
This function can be overloaded (see @dfn{define-mode-local-override} for details).
@end table
@end defun

@defun semantic-tag-components-with-overlays-default tag
@anchor{semantic-tag-components-with-overlays-default}
Return the list of top level components belonging to @var{tag}.
Children are any sub-tags which contain overlays.
The default action collects regular components of @var{tag}, in addition
to any components beloning to an anonymous type.
@end defun

@node Tag Hooks
@section Tag Hooks
@cindex Tag Hooks

Individual tags can have hooks associated with them.  Hooks are saved
as properties, but can cause specific tags to have special behaviors
after a hook is added.

You can manipulate tag hooks with these functions:

@defun semantic-tag-add-hook tag hook function &optional append
@anchor{semantic-tag-add-hook}
Onto @var{tag}, add to the value of @var{hook} the function @var{function}.
@var{function} is added (if necessary) at the beginning of the hook list
unless the optional argument @var{append} is non-@code{nil}, in which case
@var{function} is added at the end.
@var{hook} should be a symbol, and @var{function} may be any valid function.
See also the function @dfn{add-hook}.
@end defun

@defun semantic-tag-remove-hook tag hook function
@anchor{semantic-tag-remove-hook}
Onto @var{tag}, remove from the value of @var{hook} the function @var{function}.
@var{hook} should be a symbol, and @var{function} may be any valid function.  If
@var{function} isn't the value of @var{hook}, or, if @var{function} doesn't appear in
the list of hooks to run in @var{hook}, then nothing is done.
See also the function @dfn{remove-hook}.
@end defun

For a developer, if you have an application for which you want to
support a special kind of hook on a per tag basis, you can use this
to run those hooks.

@defun semantic--tag-run-hooks tag hook &rest args
@anchor{semantic--tag-run-hooks}
Run for @var{tag} all expressions saved on the property @var{hook}.
Each hook expression must take at least one argument, the @var{tag}.
For any given situation, additional @var{args} may be passed.
@end defun

Semantic supports two TAG specific hooks at this time:

@table @code
@item link-hook
This hook is run whenever a tag is linked into a buffer.  This occurs
just after parsing, and whenever a tag is loaded into memory.  This
hook also executes after a datase save, when all tags are first
unlinked from the current buffer before the save.
@item unlink-hook
This hook is run whenever a tag is unlinked from a buffer.  This
ocucrs during a database save, or when a tag is modified by the
incremental parser.
@item unlink-copy-hook
This hook is run whenever a tag is copied.  This occurs in the
function @code{semantic-tag-copy}.  Use this hook to remove properties
from the tag that link it to a buffer, as this tag should no longer
have direct buffer links.
@end table

@node Misc Tag Functions
@section Misc Tag Functions
@cindex Misc Tag Functions

@deffn Command semantic-narrow-to-tag &optional tag
@anchor{semantic-narrow-to-tag}
Narrow to the region specified by the bounds of @var{tag}.
See @dfn{semantic-tag-bounds}.
@obsolete{semantic-narrow-to-token,semantic-narrow-to-tag}
@end deffn

@defun semantic-with-buffer-narrowed-to-current-tag &rest body
@anchor{semantic-with-buffer-narrowed-to-current-tag}
Execute @var{body} with the buffer narrowed to the current tag.
@obsolete{semantic-with-buffer-narrowed-to-current-token,semantic-with-buffer-narrowed-to-current-tag}
@end defun

@defun semantic-with-buffer-narrowed-to-tag tag &rest body
@anchor{semantic-with-buffer-narrowed-to-tag}
Narrow to @var{tag}, and execute @var{body}.
@obsolete{semantic-with-buffer-narrowed-to-token,semantic-with-buffer-narrowed-to-tag}
@end defun

@node Tag Internals
@section Tag Internals
@cindex Tag Internals

@menu
* Tag Attributes Internals::
* Tag Properties Internals::
* Tag Overlay Internals::
* Creating Tags::
* Misc Tag Internals::
@end menu

@node Tag Attributes Internals
@subsection Tag Attributes Internals

@ignore
Attribute Accessor Method          | Property Symbol
----------------------------------------------------
semantic-tag-variable-constant-p   | :constant-flag
semantic-tag-function-destructor-p | :destructor-flag
semantic-tag-function-parent       | :parent
semantic-tag-function-throws       | :throws
semantic-tag-modifiers             | :typemodifiers
semantic-tag-function-arguments    | :arguments
semantic-tag-variable-default      | :default-value
semantic-tag-docstring             | :documentation
semantic-tag-type-interfaces       | :interfaces
semantic-tag-type-members          | :members
semantic-tag-type-superclasses     | :superclasses
semantic-tag-include-system-p      | :system-flag
semantic-tag-type                  | :type
@end ignore

@defun semantic-tag-attributes tag
@anchor{semantic-tag-attributes}
Return the list of public attributes of @var{tag}.
That is a property list: (@var{attribute-1} @var{value-1} @var{attribute-2} @var{value-2}@dots{}).
@obsolete{semantic-token-extra-specs,semantic-tag-attributes}
@obsolete{semantic-token-function-extra-specs,semantic-tag-attributes}
@obsolete{semantic-token-variable-extra-specs,semantic-tag-attributes}
@obsolete{semantic-token-type-extra-specs,semantic-tag-attributes}
@end defun

@defun semantic-tag-get-attribute tag attribute
@anchor{semantic-tag-get-attribute}
From @var{tag}, return the value of @var{attribute}.
@var{attribute} is a symbol whose specification value to get.
Return the value found, or @code{nil} if @var{attribute} is not one of the
attributes of @var{tag}.
@obsolete{semantic-token-extra-spec,semantic-tag-get-attribute}
@obsolete{semantic-token-function-extra-spec,semantic-tag-get-attribute}
@obsolete{semantic-token-variable-extra-spec,semantic-tag-get-attribute}
@end defun

@defun semantic-tag-put-attribute tag attribute value
@anchor{semantic-tag-put-attribute}
Change value in @var{tag} of @var{attribute} to @var{value}.
If @var{attribute} already exists, its value is set to @var{value}, otherwise the
new @var{attribute} @var{value} pair is added.
Return @var{tag}.
Use this function in a parser when not all attributes are known at the
same time.
@obsolete{semantic-token-add-extra-spec,semantic-tag-put-attribute}
@end defun

@defun semantic-tag-put-attribute-no-side-effect tag attribute value
@anchor{semantic-tag-put-attribute-no-side-effect}
Change value in @var{tag} of @var{attribute} to @var{value} without side effects.
All cons cells in the attribute list are replicated so that there
are no side effects if @var{tag} is in shared lists.
If @var{attribute} already exists, its value is set to @var{value}, otherwise the
new @var{attribute} @var{value} pair is added.
Return @var{tag}.
@end defun

@node Tag Properties Internals
@subsection Tag Properties Internals

@ignore
Property symbols:
  reparse-symbol
  :filename
  secondary-overlays

Related functions not yet documented:
  semantic-brute-find-tag-by-property
  semantic-tag-add-hook
  semantic-tag-remove-hook
  semantic-show-label
@end ignore

@defun semantic-tag-properties tag
@anchor{semantic-tag-properties}
Return the list of private properties of @var{tag}.
That is a property list: (@var{property-1} @var{value-1} @var{property-2} @var{value-2}@dots{}).
@obsolete{semantic-token-properties,semantic-tag-properties}
@end defun

@defun semantic--tag-put-property tag property value
@anchor{semantic--tag-put-property}
Change value in @var{tag} of @var{property} to @var{value}.
If @var{property} already exists, its value is set to @var{value}, otherwise the
new @var{property} @var{value} pair is added.
Return @var{tag}.
That function is for internal use only.
@obsolete{semantic-token-put,semantic--tag-put-property}
@end defun

@defun semantic--tag-get-property tag property
@anchor{semantic--tag-get-property}
From @var{tag}, extract the value of @var{property}.
Return the value found, or @code{nil} if @var{property} is not one of the
properties of @var{tag}.
That function is for internal use only.
@obsolete{semantic-token-get,semantic--tag-get-property}
@end defun

@defun semantic--tag-put-property-no-side-effect tag property value
@anchor{semantic--tag-put-property-no-side-effect}
Change value in @var{tag} of @var{property} to @var{value} without side effects.
All cons cells in the property list are replicated so that there
are no side effects if @var{tag} is in shared lists.
If @var{property} already exists, its value is set to @var{value}, otherwise the
new @var{property} @var{value} pair is added.
Return @var{tag}.
That function is for internal use only.
@obsolete{semantic-token-put-no-side-effect,semantic--tag-put-property-no-side-effect}
@end defun

@defun semantic-tag-make-plist args
@anchor{semantic-tag-make-plist}
Create a property list with @var{args}.
Args is a property list of the form (@var{key1} @var{value1} @dots{} @var{keyn} @var{valuen}).
Where @var{key} is a symbol, and @var{value} is the value for that symbol.
The return value will be a new property list, with these @var{key}/@var{value}
pairs eliminated:

  - @var{key} associated to @code{nil} @var{value}.
  - @var{key} associated to an empty string @var{value}.
  - @var{key} associated to a zero @var{value}.
@obsolete{semantic-tag-make-assoc-list,semantic-tag-make-plist}
@end defun

@node Tag Overlay Internals
@subsection Tag Overlay Internals

Many of the overlay related functions were already documented in
@ref{Tag Overlay,Tag Overlay}.

@ignore
Functions not yet documented:
  semantic--tag-overlay-cdr
  semantic--tag-set-overlay
@end ignore

@defun semantic-tag-set-bounds tag start end
@anchor{semantic-tag-set-bounds}
In @var{tag}, set the @var{start} and @var{end} location of data it describes.
@end defun

@node Creating Tags
@subsection Creating Tags

@defun semantic-tag name class &rest attributes
@anchor{semantic-tag}
Create a generic semantic tag.
@var{name} is a string representing the name of this tag.
@var{class} is the symbol that represents the class of tag this is,
such as @code{'variable}, or @code{'function}.
@var{attributes} is a list of additional attributes belonging to this tag.
@obsolete{semantic-token,semantic-tag}
@end defun

@defun semantic-tag-new-variable name type default-value &rest attributes
@anchor{semantic-tag-new-variable}
Create a semantic tag of class @code{'variable}.
@var{name} is the name of this variable.
@var{type} is a string or semantic tag representing the type of this variable.
@var{default-value} is a string representing the default value of this variable.
@var{attributes} is a list of additional attributes belonging to this tag.
@obsolete{semantic-token-new-variable,semantic-tag-new-variable}
@end defun

@defun semantic-tag-new-function name type arg-list &rest attributes
@anchor{semantic-tag-new-function}
Create a semantic tag of class @code{'function}.
@var{name} is the name of this function.
@var{type} is a string or semantic tag representing the type of this function.
@var{arg-list} is a list of strings or semantic tags representing the
arguments of this function.
@var{attributes} is a list of additional attributes belonging to this tag.
@obsolete{semantic-token-new-function,semantic-tag-new-function}
@end defun

@defun semantic-tag-new-type name type members parents &rest attributes
@anchor{semantic-tag-new-type}
Create a semantic tag of class @code{'type}.
@var{name} is the name of this type.
@var{type} is a string or semantic tag representing the type of this type.
@var{members} is a list of strings or semantic tags representing the
elements that make up this type if it is a composite type.
@var{parents} is a cons cell.  (@var{explicit-parents} . @var{interface-parents})
@var{explicit-parents} can be a single string (Just one parent) or a
list of parents (in a multiple inheritance situation).  It can also
be @code{nil}.
@var{interface-parents} is a list of strings representing the names of
all @var{interfaces}, or abstract classes inherited from.  It can also be
@code{nil}.
This slot can be interesting because the form:
     ( @code{nil} ``string'')
is a valid parent where there is no explicit parent, and only an
interface.
@var{attributes} is a list of additional attributes belonging to this tag.
@obsolete{semantic-token-new-type,semantic-tag-new-type}
@end defun

@defun semantic-tag-new-include name system-flag &rest attributes
@anchor{semantic-tag-new-include}
Create a semantic tag of class @code{'include}.
@var{name} is the name of this include.
@var{system-flag} represents that we were able to identify this include as belonging
to the system, as opposed to belonging to the local project.
@var{attributes} is a list of additional attributes belonging to this tag.
@obsolete{semantic-token-new-include,semantic-tag-new-include}
@end defun

@defun semantic-tag-new-package name detail &rest attributes
@anchor{semantic-tag-new-package}
Create a semantic tag of class @code{'package}.
@var{name} is the name of this package.
@var{detail} is extra information about this package, such as a location where
it can be found.
@var{attributes} is a list of additional attributes belonging to this tag.
@obsolete{semantic-token-new-package,semantic-tag-new-package}
@end defun

@defun semantic-tag-new-code name detail &rest attributes
@anchor{semantic-tag-new-code}
Create a semantic tag of class @code{'code}.
@var{name} is a name for this code.
@var{detail} is extra information about the code.
@var{attributes} is a list of additional attributes belonging to this tag.
@end defun

@defun semantic-tag-clone tag &optional name
@anchor{semantic-tag-clone}
Clone @var{tag}, creating a new @var{tag}.
If optional argument @var{name} is not @code{nil} it specifies a new name for the
cloned tag.
@obsolete{semantic-clone-tag,semantic-tag-clone}
@end defun

@defun semantic-tag-copy tag &optional name keep-file
@anchor{semantic-tag-copy}
Return a copy of @var{tag} unlinked from the originating buffer.
If optional argument @var{name} is non-@code{nil} it specifies a new name for the
copied tag.
If optional argument @var{keep-file} is non-@code{nil}, and @var{tag} was linked to a
buffer, the originating buffer file name is kept in the `:filename'
property of the copied tag.
This runs the tag hook `unlink-copy-hook`.
@end defun

@node Misc Tag Internals
@subsection Misc Tag Internals

@defun semantic--tag-run-hooks tag hook &rest args
Run for @var{tag} all expressions saved on the property @var{hook}.
Each hook expression must take at least one argument, the @var{tag}.
For any given situation, additional @var{args} may be passed.
@end defun

@defun semantic--tag-unlink-from-buffer tag
Convert @var{tag} from using an overlay to using an overlay proxy.
This function is for internal use only.  This runs the tag hook
@code{unlink-hook}.  @ref{Tag Hooks}
@end defun

@defun semantic--tag-link-to-buffer tag
Convert @var{tag} from using an overlay proxy to using an overlay.
This function is for internal use only.  This runs the tag hook
@code{link-hook}.  @ref{Tag Hooks}
@end defun

@defun semantic--tag-unlink-list-from-buffer tags
Convert @var{tags} from using an overlay to using an overlay proxy.
This function is for internal use only.
@end defun

@defun semantic--tag-link-list-to-buffer tags
Convert @var{tags} from using an overlay proxy to using an overlay.
This function is for internal use only.
@end defun

@defun semantic--tag-unlink-cache-from-buffer
Convert all tags in the current cache to use overlay proxys.
This function is for internal use only.
@end defun

@defun semantic--tag-link-cache-to-buffer
Convert all tags in the current cache to use overlays.
This function is for internal use only.
@end defun

@defun semantic--tag-expanded-p tag
Return non-@code{nil} if @var{tag} is expanded.
This function is for internal use only.
See also the function @code{semantic--expand-tag}.
@end defun

@defun semantic--tag-expand tag
Convert @var{tag} from a raw state to a cooked state, and expand it.
Returns a list of cooked tags.

The parser returns raw tags with positional data @var{start} @var{end} at the
end of the tag data structure (a list for now).  We convert it from
that to a cooked state that uses an overlay proxy, that is, a vector
[@var{start} @var{end}].

The raw tag is changed with side effects and maybe expanded in
several derived tags when the variable @code{semantic-tag-expand-function}
is set.

This function is for internal use only.
@end defun

@ignore
@c @node Semantic Functions Called within ECB
@c @section Semantic Functions Called within ECB
@c @cindex Semantic Functions Called within ECB

I was curious as to what semantic functions were called by a real
semantic application such as ECB.  So I searched ECB and listed all
functions that ECB calls that start with ``semantic-''.  Then as I
document one by one, I deleted them.  The functions below are ones
that I have not yet gone through. -ryk8/13/03.

semantic-active-p
semantic-adopt-external-members
semantic-after-partial-cache-change-hook
semantic-after-toplevel-cache-change-hook
semantic-bucketize
semantic-c-template-string
semantic-clear-toplevel-cache
semantic-colorize-text
semantic-current-nonterminal
semantic-find-dependency
semantic-name-nonterminal
semantic-nonterminal-children
semantic-nonterminal-protection
semantic-overlay-live-p
semantic-overlay-p
semantic-prototype-nonterminal
semantic-require-version
semantic-token-buffer
semantic-token-end
semantic-token-function-parent
semantic-token-get
semantic-token-name
semantic-token-overlay
semantic-token-put
semantic-token-start
semantic-token-token
semantic-token-type-parent
@end ignore