1. xemacs
  2. semantic

Source

semantic / doc / app-dev-guide.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
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
\input texinfo  @c -*-texinfo-*-
@c %**start of header
@setfilename semantic-appdev.info
@set TITLE  Semantic Application Development Manual
@set AUTHOR Eric M. Ludlam, David Ponce, and Richard Y. Kim
@settitle @value{TITLE}

@c *************************************************************************
@c @ Header
@c *************************************************************************

@c Merge all indexes into a single index for now.
@c We can always separate them later into two or more as needed.
@syncodeindex vr cp
@syncodeindex fn cp
@syncodeindex ky cp
@syncodeindex pg cp
@syncodeindex tp cp

@c @footnotestyle separate
@c @paragraphindent 2
@c @@smallbook
@c %**end of header

@copying
This manual documents Application Development with Semantic.

Copyright @copyright{} 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007 Eric M. Ludlam
Copyright @copyright{} 2001, 2002, 2003, 2004 David Ponce
Copyright @copyright{} 2002, 2003 Richard Y. Kim

@quotation
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.1 or
any later version published by the Free Software Foundation; with the
Invariant Sections being list their titles, with the Front-Cover Texts
being list, and with the Back-Cover Texts being list.  A copy of the
license is included in the section entitled ``GNU Free Documentation
License''.
@end quotation
@end copying

@ifinfo
@dircategory Emacs
@direntry
* Semantic Application Writer's guide: (semantic-appdev).
@end direntry
@end ifinfo

@iftex
@finalout
@end iftex

@c @setchapternewpage odd
@c @setchapternewpage off

@ifinfo
This file documents Application Development with Semantic.
@emph{Infrastructure for parser based text analysis in Emacs}

Copyright @copyright{} 1999, 2000, 2001, 2002, 2003, 2004 @value{AUTHOR}
@end ifinfo

@titlepage
@sp 10
@title @value{TITLE}
@author by @value{AUTHOR}
@vskip 0pt plus 1 fill
Copyright @copyright{} 1999, 2000, 2001, 2002, 2003, 2004 @value{AUTHOR}
@page
@vskip 0pt plus 1 fill
@insertcopying
@end titlepage
@page

@c MACRO inclusion
@include semanticheader.texi


@c *************************************************************************
@c @ Document
@c *************************************************************************
@contents

@node top
@top @value{TITLE}

A @semantic{} application takes the semantic tags generated
by semantic parsers then provides useful services to the user.
For a list of such applications,
@inforef{the Semantic User's Guide, , semantic-user}.

An application developer needs to know
@itemize @bullet
@item when to invoke the parser to generate or regenerate the tag lists.
@item how to access the tag lists.
@item how to access information about each tag.
@end itemize

This chapter describes @semantic{} fuctions and concepts an application
developer needs to know to perform all of the tasks just listed.

@menu
* Semantic Tags::               
* Searching Tag Tables::        Searching tag tables.
* Tags at Point::               Finding tags at point.
* Tag Decoration::              Decorating tags
* Tag Sorting::                 Reorganizing streams.
* Tag Completion::              Completing read functions.
* Override Methods::            Language dependent functions covering
                                conversion to text strings, language dependent
                                queries and local context information
* Parser Features::             Application available parser features.
* Semantic Database::           Persistant storage of tags.
* Idle Scheduling::             Scheduling jobs in idle time.
* Example Programs::            Simple programming examples.
* Current Context::             Local context analysis.
* App Debugger::                Application Debugger
* GNU Free Documentation License::  
* Index::                       
@end menu

@node Semantic Tags
@chapter Semantic Tags

@include tags.texi

@node Searching Tag Tables
@chapter Searching Tag Tables

These functions take some key, and returns information found in a tag
table.  Some will return one tag (the first matching item found.)
Others will return a list of all items matching a given criterion.
Most of these functions work regardless of a buffer being in memory or
not.

Any specialty search routine that claims to use a function that is an
overload method will need to execute in a buffer of the same mode as
the tags being searched.

@menu
* Breadth Search::              Searching only one level of tags.
* Deep Search::                 Deep searches into types or argument lists.
* Specialty Search::            Specialty Searches.
* Custom Search::               Write custom search routines.
@end menu

@node Breadth Search
@section Breadth Search

Searching the breadth of a list of tags means that only one level of
the tags will be searched.  If one of the tags is a datatype with
additional members, those members are not searched.

@defun semantic-find-first-tag-by-name name &optional table
@anchor{semantic-find-first-tag-by-name}
Find the first tag with @var{NAME} in @var{TABLE}.
@var{NAME} is a string.
@var{TABLE} is a semantic tags table.  See @dfn{semantic-something-to-tag-table}.
This routine uses @dfn{assoc} to quickly find the first matching entry.
@end defun

@defun semantic-find-tags-by-name name &optional table
@anchor{semantic-find-tags-by-name}
Find all tags with @var{NAME} in @var{TABLE}.
@var{NAME} is a string.
@var{TABLE} is a tag table.  See @dfn{semantic-something-to-tag-table}.
@end defun

@defun semantic-find-tags-for-completion prefix &optional table
@anchor{semantic-find-tags-for-completion}
Find all tags whos name begins with @var{PREFIX} in @var{TABLE}.
@var{PREFIX} is a string.
@var{TABLE} is a tag table.  See @dfn{semantic-something-to-tag-table}.
While it would be nice to use @dfn{try-completion} or @dfn{all-completions},
those functions do not return the tags, only a string.
Uses @dfn{compare-strings} for fast comparison.
@end defun

@defun semantic-find-tags-by-name-regexp regexp &optional table
@anchor{semantic-find-tags-by-name-regexp}
Find all tags with name matching @var{REGEXP} in @var{TABLE}.
@var{REGEXP} is a string containing a regular expression,
@var{TABLE} is a tag table.  See @dfn{semantic-something-to-tag-table}.
Consider using @dfn{semantic-find-tags-for-completion} if you are
attempting to do completions.
@end defun

@defun semantic-find-tags-by-class class &optional table
@anchor{semantic-find-tags-by-class}
Find all tags of class @var{CLASS} in @var{TABLE}.
@var{CLASS} is a symbol representing the class of the token, such as
@code{'variable}, of 'function..
@var{TABLE} is a tag table.  See @dfn{semantic-something-to-tag-table}.
@end defun

@defun semantic-find-tags-by-type type &optional table
@anchor{semantic-find-tags-by-type}
Find all tags of with a type @var{TYPE} in @var{TABLE}.
@var{TYPE} is a string or tag representing a data type as defined in the
language the tags were parsed from, such as ``int'', or perhaps
a tag whose name is that of a struct or class.
@var{TABLE} is a tag table.  See @dfn{semantic-something-to-tag-table}.
@end defun

@defun semantic-find-tags-included &optional table
@anchor{semantic-find-tags-included}
Find all tags in @var{TABLE} that are of the @code{'include} class.
@var{TABLE} is a tag table.  See @dfn{semantic-something-to-tag-table}.
@end defun

@node Deep Search
@section Deep Search

@defun semantic-brute-find-first-tag-by-name name streamorbuffer &optional search-parts search-include
Find a tag @var{NAME} within @var{STREAMORBUFFER}.  @var{NAME} is a string.
If @var{SEARCH-PARTS} is non-@code{nil}, search children of tags.
If @var{SEARCH-INCLUDE} is non-@code{nil}, search include files.

Use @dfn{semantic-find-first-tag-by-name} instead.

@obsolete{semantic-find-nonterminal-by-name,semantic-brute-find-first-tag-by-name}
@end defun

@defun semantic-brute-find-tag-by-property property value streamorbuffer &optional search-parts search-includes
Find all tags with @var{PROPERTY} equal to @var{VALUE} in @var{STREAMORBUFFER}.
Optional argument @var{SEARCH-PARTS} and @var{SEARCH-INCLUDES} are passed to
@dfn{semantic-brute-find-tag-by-function}.

@obsolete{semantic-find-nonterminal-by-property,semantic-brute-find-tag-by-property}
@end defun

@defun semantic-brute-find-tag-by-attribute attr streamorbuffer &optional search-parts search-includes
Find all tags with a given @var{ATTR} in @var{STREAMORBUFFER}.
@var{ATTR} is a symbol key into the attributes list.
Optional argument @var{SEARCH-PARTS} and @var{SEARCH-INCLUDES} are passed to
@dfn{semantic-brute-find-tag-by-function}.

@obsolete{semantic-find-nonterminal-by-extra-spec,semantic-brute-find-tag-by-attribute}
@end defun

@defun semantic-brute-find-tag-by-attribute-value attr value streamorbuffer &optional search-parts search-includes
Find all tags with a given @var{ATTR} equal to @var{VALUE} in @var{STREAMORBUFFER}.
@var{ATTR} is a symbol key into the attributes list.
@var{VALUE} is the value that @var{ATTR} should match.
Optional argument @var{SEARCH-PARTS} and @var{SEARCH-INCLUDES} are passed to
@dfn{semantic-brute-find-tag-by-function}.

@obsolete{semantic-find-nonterminal-by-extra-spec-value,semantic-brute-find-tag-by-attribute-value}
@end defun

@defun semantic-brute-find-tag-by-position position streamorbuffer &optional nomedian
Find a nonterminal covering @var{POSITION} within @var{STREAMORBUFFER}.
@var{POSITION} is a number, or marker.  If @var{NOMEDIAN} is non-@code{nil}, don't do
the median calculation, and return nil.

@obsolete{semantic-find-nonterminal-by-position,semantic-brute-find-tag-by-position}
@end defun

@defun semantic-brute-find-innermost-tag-by-position position streamorbuffer &optional nomedian
Find a list of tags covering @var{POSITION} within @var{STREAMORBUFFER}.
@var{POSITION} is a number, or marker.  If @var{NOMEDIAN} is non-@code{nil}, don't do
the median calculation, and return nil.
This function will find the topmost item, and recurse until no more
details are available of findable.

@obsolete{semantic-find-innermost-nonterminal-by-position,semantic-brute-find-innermost-tag-by-position}
@end defun

@defun semantic-brute-find-tag-by-class class streamorbuffer &optional search-parts search-includes
Find all tags with a class @var{CLASS} within @var{STREAMORBUFFER}.
@var{CLASS} is a symbol representing the class of the tags to find.
See @dfn{semantic-tag-class}.
Optional argument @var{SEARCH-PARTS} and @var{SEARCH-INCLUDES} are passed to
@dfn{semantic-brute-find-tag-by-function}.

Use @code{semantic-find-tag-by-class} instead.

@obsolete{semantic-find-nonterminal-by-token,semantic-brute-find-tag-by-class}
@end defun

@defun semantic-brute-find-tag-standard streamorbuffer &optional search-parts search-includes
Find all tags in @var{STREAMORBUFFER} which define simple class types.
See @dfn{semantic-tag-class}.
Optional argument @var{SEARCH-PARTS} and @var{SEARCH-INCLUDES} are passed to
@dfn{semantic-brute-find-tag-by-function}.

@obsolete{semantic-find-nonterminal-standard,semantic-brute-find-tag-standard}
@end defun

@defun semantic-brute-find-tag-by-type type streamorbuffer &optional search-parts search-includes
Find all tags with type @var{TYPE} within @var{STREAMORBUFFER}.
@var{TYPE} is a string which is the name of the type of the tags returned.
See @dfn{semantic-tag-type}.
Optional argument @var{SEARCH-PARTS} and @var{SEARCH-INCLUDES} are passed to
@dfn{semantic-brute-find-tag-by-function}.

@obsolete{semantic-find-nonterminal-by-type,semantic-brute-find-tag-by-type}
@end defun

@defun semantic-brute-find-tag-by-function function streamorbuffer &optional search-parts search-includes
Find all tags for which FUNCTION's value is non-@code{nil} within @var{STREAMORBUFFER}.
@var{FUNCTION} must return non-@code{nil} if an element of @var{STREAM} will be included
in the new list.

If optional argument @var{SEARCH-PARTS} is non-@code{nil}, all sub-parts of tags
are searched.  The overloadable function @code{semantic-tag-componenets} is
used for the searching child lists.  If @var{SEARCH-PARTS} is the symbol
@code{'positiononly}, then only children that have positional information are
searched.

If @var{SEARCH-INCLUDES} is non-@code{nil}, then all include files are also
searched for matches.  This parameter hasn't be active for a while
and is obsolete.

@obsolete{semantic-find-nonterminal-by-function,semantic-brute-find-tag-by-function}
@end defun

@defun semantic-brute-find-first-tag-by-function function streamorbuffer &optional search-parts search-includes
Find the first nonterminal which @var{FUNCTION} match within @var{STREAMORBUFFER}.
@var{FUNCTION} must return non-@code{nil} if an element of @var{STREAM} will be included
in the new list.

The following parameters were never implemented.

If optional argument @var{SEARCH-PARTS}, all sub-parts of tags are searched.
The overloadable function @dfn{semantic-tag-components} is used for
searching.
If @var{SEARCH-INCLUDES} is non-@code{nil}, then all include files are also
searched for matches.

@obsolete{semantic-find-nonterminal-by-function-first-match,semantic-brute-find-first-tag-by-function}
@end defun

@node Specialty Search
@section Specialty Search

There are some specialty searches needed by some semantic tools that
could prove useful.  These specialty searches often do not match
against some single attribute as most breadth searches do.

@defun semantic-find-tags-of-compound-type &optional table
@anchor{semantic-find-tags-of-compound-type}
Find all tags which are a compound type in @var{TABLE}.
Compound types are structures, or other data type which
is not of a primitive nature, such as int or double.
Used in completion.
@end defun

@defun semantic-find-tags-by-scope-protection scopeprotection parent &optional table
@anchor{semantic-find-tags-by-scope-protection}
Find all tags accessable by @var{SCOPEPROTECTION}.
@var{SCOPEPROTECTION} is a symbol which can be returned by the method
@dfn{semantic-tag-protection}.  @var{A} hard-coded order is used to determine a match.
@var{PARENT} is a tag representing the @var{PARENT} slot needed for
@dfn{semantic-tag-protection}.
@var{TABLE} is a list of tags (a subset of @var{PARENT} members) to scan.  If @var{TABLE} is @code{nil},
the type members of @var{PARENT} are used.
See @dfn{semantic-tag-protected-p} for details on which tags are returned.
@end defun

@defun semantic-find-tags-external-children-of-type type &optional table
@anchor{semantic-find-tags-external-children-of-type}
Find all tags in whose parent is @var{TYPE} in @var{TABLE}.
These tags are defined outside the scope of the original @var{TYPE} declaration.
@var{TABLE} is a tag table.  See @dfn{semantic-something-to-tag-table}.
@end defun

@node Custom Search
@section Custom Search

The searching framework for semantic for tag tables has two basic
root methods.  One is a function and the other is a macro.  The
functional version is needed if some sort of macro conflict arrises.
The macro version is useful because it eliminates a level of function
call, and is faster.

@defun semantic--find-tags-by-function predicate &optional table
@anchor{semantic--find-tags-by-function}
Find tags for which @var{PREDICATE} is non-@code{nil} in @var{TABLE}.
@var{PREDICATE} is a lambda expression which accepts on @var{TAG}.
@var{TABLE} is a semantic tags table.  See @dfn{semantic-something-to-tag-table}.
@end defun

@defun semantic--find-tags-by-macro form &optional table
@anchor{semantic--find-tags-by-macro}
Find tags for which @var{FORM} is non-@code{nil} in @var{TABLE}.
@var{TABLE} is a semantic tags table.  See @dfn{semantic-something-to-tag-table}.
@end defun

@c @defun semantic-recursive-find-nonterminal-by-name name buffer
@c Recursivly find the first occurance of @var{NAME}.
@c Start search with @var{BUFFER}.  Recurse through all dependencies till
@c found.  The return item is of the form (@var{BUFFER} @var{TOKEN})
@c where @var{BUFFER} is the buffer in which @var{TOKEN} (the token found
@c to match @var{NAME}) was found.
@c 
@c @var{THIS} ISN'T @var{USED} @var{IN} @var{SEMANTIC}.  @var{DELETE}
@c @var{ME} @var{SOON}.
@c @end defun

@node Tags at Point
@chapter Tags at Point

When you need to get the tag the cursor is on, there is a more
efficient mechanism than using
@code{semantic-brute-find-tag-by-position}.  This mechanism directly
queries the overlays the parsing step leaves in the buffer.  This
provides for very rapid retrieval of what function or variable the
cursor is currently in.
@refill

These functions query the current buffer's overlay system for tags.

@defun semantic-find-tag-by-overlay &optional positionormarker buffer
Find all tags covering @var{POSITIONORMARKER} by using overlays.
If @var{POSITIONORMARKER} is @code{nil}, use the current point.
Optional @var{BUFFER} is used if @var{POSITIONORMARKER} is a number, otherwise the current
buffer is used.  This finds all tags covering the specified position
by checking for all overlays covering the current spot.  They are then sorted
from largest to smallest via the start location.

@obsolete{semantic-find-nonterminal-by-overlay,semantic-find-tag-by-overlay}
@end defun

@defun semantic-find-tag-by-overlay-in-region start end &optional buffer
Find all tags which exist in whole or in part between @var{START} and @var{END}.
Uses overlays to determine positin.
Optional @var{BUFFER} argument specifies the buffer to use.

@obsolete{semantic-find-nonterminal-by-overlay-in-region,semantic-find-tag-by-overlay-in-region}
@end defun

@defun semantic-find-tag-by-overlay-next &optional start buffer
Find the next tag after @var{START} in @var{BUFFER}.
If @var{START} is in an overlay, find the tag which starts next,
not the current tag.
@end defun

@defun semantic-find-tag-by-overlay-prev &optional start buffer
Find the next tag before @var{START} in @var{BUFFER}.
If @var{START} is in an overlay, find the tag which starts next,
not the current tag.
@end defun

@defun semantic-current-tag
Return the current tag in the current buffer.
If there are more than one in the same location, return the
smallest tag.  Return @code{nil} if there is no tag here.

@obsolete{semantic-current-nonterminal,semantic-current-tag}
@end defun

@defun semantic-current-tag-parent
Return the current tags parent in the current buffer.
@var{A} tag's parent would be a containing structure, such as a type
containing a field.  Return @code{nil} if there is no parent.

@obsolete{semantic-current-nonterminal-parent,semantic-current-tag-parent}
@end defun

@node Tag Decoration
@chapter Tag Decoration

Tags can be decorated in different ways.  One way a user can control
it is through @code{semantic-decoration-mode}.
@inforef{semantic-user,,Tag Decoration Mode}

Applications can use the same routines to decorate tags as well.

@menu
* Tag Highlighting::            Highlighting a tag
* Tag Visible Properties::      Invisible, intangible and read only
* Tag Secondary Overlays::      Decorating parts of a tag text
* Tag Folding::                 Visibly Folding up tags
@end menu

@node Tag Highlighting
@section Highlighting

@defun semantic-highlight-tag tag &optional face
@anchor{semantic-highlight-tag}
Specify that @var{tag} should be highlighted.
Optional @var{face} specifies the face to use.
@obsolete{semantic-highlight-token,semantic-highlight-tag}
@end defun

@defun semantic-unhighlight-tag tag
@anchor{semantic-unhighlight-tag}
Unhighlight @var{tag}, restoring it's previous face.
@obsolete{semantic-unhighlight-token,semantic-unhighlight-tag}
@end defun

@defun semantic-momentary-highlight-tag tag &optional face
@anchor{semantic-momentary-highlight-tag}
Highlight @var{tag}, removing highlighting when the user hits a key.
Optional argument @var{face} is the face to use for highlighting.
If @var{face} is not specified, then @code{highlight} will be used.
@obsolete{semantic-momentary-highlight-token,semantic-momentary-highlight-tag}
@end defun

The highlighting routines do their work by changing the face property
of the tag overlay.  The raw routine is:

@defun semantic-set-tag-face tag face
@anchor{semantic-set-tag-face}
Specify that @var{tag} should use @var{face} for display.
@obsolete{semantic-set-token-face,semantic-set-tag-face}
@end defun

@node Tag Visible Properties
@section Changing a tag's visible properties

You can give a tag other properties as well, such as making it
invisible or intangible.  You can control how code is edited
programatically through these routines.

@defun semantic-set-tag-invisible tag &optional visible
@anchor{semantic-set-tag-invisible}
Enable the text in @var{tag} to be made invisible.
If @var{visible} is non-@code{nil}, make the text visible.
@obsolete{semantic-set-token-invisible,semantic-set-tag-invisible}
@end defun

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

@defun semantic-set-tag-intangible tag &optional tangible
@anchor{semantic-set-tag-intangible}
Enable the text in @var{tag} to be made intangible.
If @var{tangible} is non-@code{nil}, make the text visible.
This function does not have meaning in XEmacs because it seems that
the extent 'intangible' property does not exist.
@obsolete{semantic-set-token-intangible,semantic-set-tag-intangible}
@end defun

@defun semantic-tag-intangible-p tag
@anchor{semantic-tag-intangible-p}
Return non-@code{nil} if @var{tag} is intangible.
This function does not have meaning in XEmacs because it seems that
the extent 'intangible' property does not exist.
@obsolete{semantic-token-intangible-p,semantic-tag-intangible-p}
@end defun

@defun semantic-set-tag-read-only tag &optional writable
@anchor{semantic-set-tag-read-only}
Enable the text in @var{tag} to be made read-only.
Optional argument @var{writable} should be non-@code{nil} to make the text writable
instead of read-only.
@obsolete{semantic-set-token-read-only,semantic-set-tag-read-only}
@end defun

@defun semantic-tag-read-only-p tag
@anchor{semantic-tag-read-only-p}
Return non-@code{nil} if the current @var{tag} is marked read only.
@obsolete{semantic-token-read-only-p,semantic-tag-read-only-p}
@end defun

@node Tag Secondary Overlays
@section Secondary Overlays

Each tag which is being visited in a buffer has one overlay.  This
overlay is used to track where the tag is while a user is editing, and
can also be used for fast tag identification, and some simple
decoration techniques.

A secondary overlay associates a new overlay object with a tag which
does not cover the entire body of a tag.  You can then put visible
features on that overlay to decorate portions of a tag.  This is how
tag boundaries are drawn.

@subsection Creation and Deletion

@defun semantic-tag-create-secondary-overlay tag &optional link-hook
@anchor{semantic-tag-create-secondary-overlay}
Create a secondary overlay for @var{tag}.
Returns an overlay.  The overlay is also saved in @var{tag}.
@var{link-hook} is a function called whenever @var{tag} is to be linked into
a buffer.  It should take @var{tag} and @var{overlay} as arguments.
The @var{link-hook} should be used to position and set properties on the
generated secondary overlay.
@end defun

@defun semantic-tag-delete-secondary-overlay tag overlay-or-property
@anchor{semantic-tag-delete-secondary-overlay}
Delete from @var{tag} the secondary overlay @var{overlay-or-property}.
If @var{overlay-or-property} is an overlay, delete that overlay.
If @var{overlay-or-property} is a symbol, find the overlay with that property.
@end defun

@subsection Queries

@defun semantic-tag-get-secondary-overlay tag property
@anchor{semantic-tag-get-secondary-overlay}
Return secondary overlays from @var{tag} with @var{property}.
@var{property} is a symbol and all overlays with that symbol are returned..
@end defun

@defun semantic-tag-secondary-overlays tag
@anchor{semantic-tag-secondary-overlays}
Return a list of secondary overlays active on @var{tag}.
@end defun

@subsection Linking and Unlinking

When a tag's file is put in a buffer, that tag is ``linked'' into the
buffer.  When the buffer is deleted, the tag is ``unlinked''.  This
process adds and removes the default overlay on the tag.  Secondary
overlays use @code{semantic-tag-add-hook} and
@code{semantic-tag-remove-hook} too apply link and unlink hooks.

This allows the secondary overlays to be automatically removed or
added by the seconary overlay system whenever a tag's file goes in or
out of a buffer.

@node Tag Folding
@section Folding

Using secondary overlays, a set of tag folding routines are made
available.  These routines are similar to the tag visible properties.

@defun semantic-set-tag-folded tag &optional folded
@anchor{semantic-set-tag-folded}
Fold @var{tag}, such that only the first line of text is shown.
Optional argument @var{folded} should be non-@code{nil} to fold the tag.
@code{nil} implies the tag should be fully shown.
@end defun

@defun semantic-tag-folded-p tag
@anchor{semantic-tag-folded-p}
Non-@code{nil} if @var{tag} is currently folded.
@end defun

@node Tag Sorting
@chapter Tag Sorting

Sometimes it is important to reorganize a tag stream into a form that
is better for display to a user.  It is important to not use functions
with side effects that could effect the tag cache.

There are some existing utility functions which will reorganize the
tag list for you.

@defun semantic-unique-tag-table tags
@anchor{semantic-unique-tag-table}
Scan a list of @var{TAGS}, removing duplicates.
This must first sort the tags by position ascending.
@var{TAGS} are removed only if they are equivalent, as can happen when
multiple tag sources are scanned.
@end defun

@defun semantic-unique-tag-table-by-name tags
@anchor{semantic-unique-tag-table-by-name}
Scan a list of @var{TAGS}, removing duplicate names.
This must first sort the tags by name alphabetically ascending.
@end defun

@defun semantic-bucketize tags &optional parent filter
@anchor{semantic-bucketize}
Sort @var{tags} into a group of buckets based on tag class.
Unknown classes are placed in a Misc bucket.
Type bucket names are defined by either @code{semantic-symbol->name-assoc-list}.
If @var{parent} is specified, then @var{tags} belong to this @var{parent} in some way.
This will use @code{semantic-symbol->name-assoc-list-for-type-parts} to
generate bucket names.
Optional argument @var{filter} is a filter function to be applied to each bucket.
The filter function will take one argument, which is a list of tokens, and
may re-organize the list with side-effects.
@end defun

@defvar semantic-bucketize-tag-class
@anchor{semantic-bucketize-tag-class}
Function used to get a symbol describing the class of a tag.
This function must take one argument of a semantic tag.
It should return a symbol found in @code{semantic-symbol->name-assoc-list}
which @dfn{semantic-bucketize} uses to bin up tokens.
To create new bins for an application augment
@code{semantic-symbol->name-assoc-list}, and
@code{semantic-symbol->name-assoc-list-for-type-parts} in addition
to setting this variable (locally in your function).
@end defvar

@defun semantic-adopt-external-members tags
@anchor{semantic-adopt-external-members}
Rebuild @var{tags} so that externally defined members are regrouped.
Some languages such as @var{c}++ and @var{clos} permit the declaration of member
functions outside the definition of the class.  It is easier to study
the structure of a program when such methods are grouped together
more logically.

This function uses @dfn{semantic-tag-external-member-p} to
determine when a potential child is an externally defined member.

Note: Applications which use this function must account for token
types which do not have a position, but have children which *do*
have positions.

Applications should use @code{semantic-mark-external-member-function}
to modify all tags which are found as externally defined to some
type.  For example, changing the token type for generating extra
buckets with the bucket function.
@end defun

@defvar semantic-orphaned-member-metaparent-type
@anchor{semantic-orphaned-member-metaparent-type}
In @dfn{semantic-adopt-external-members}, the type of @code{'type} for metaparents.
A metaparent is a made-up type semantic token used to hold the child list
of orphaned members of a named type.
@end defvar

@defvar semantic-mark-external-member-function
@anchor{semantic-mark-external-member-function}
Function called when an externally defined orphan is found.
By default, the token is always marked with the @code{adopted} property.
This function should be locally bound by a program that needs
to add additional behaviors into the token list.
This function is called with two arguments.  The first is @var{token} which is
a shallow copy of the token to be modified.  The second is the @var{parent}
which is adopting @var{token}.  This function should return @var{token} (or a copy of it)
which is then integrated into the revised token list.
@end defvar

@node Tag Completion
@chapter Tag Completion

Often time, it is useful to ask the user for the name of some tag.
This can be as simple as just prompting for a name, but often time,
the semantics can be quite complex.  If two tags have the same name,
which do you choose?

Semantic provides a completion engine for prompting for tags by name,
and providing fancy ways to display completion lists that allow the
user to choose a tag if several have the same name.

To use a completion function in your interactive function, you can
augment the @dfn{interactive} command like this:

@example
(defun my-function (tag)
   "Do something to TAG."
   (interactive (list (my-completion-function "Tag: ")))
   ...)
@end example

@menu
* Tag Completion Convenience Functions::  Provided functions
* Custom Tag Completion Functions::  Build your own completion function
* Old Tag Completion::          Completion functions from older releases
@end menu

@node Tag Completion Convenience Functions
@section Tag Completion Convenience Functions

There are some pre written completion functions that can be used in your
programs.

@defun semantic-complete-read-tag-buffer-deep prompt &optional default-tag initial-input history
Ask for a tag by name from the current buffer.
Available tags are from the current buffer, at any level.
Completion options are presented in a traditional way, with highlighting
to resolve same-name collisions.
@var{PROMPT} is a string to prompt with.
@var{DEFAULT-TAG} is a semantic tag or string to use as the default value.
If @var{INITIAL-INPUT} is non-@code{nil}, insert it in the minibuffer initially.
@var{HISTORY} is a symbol representing a variable to story the history in.
@end defun

@defun semantic-complete-read-tag-project prompt &optional default-tag initial-input history
@anchor{semantic-complete-read-tag-project}
Ask for a tag by name from the current project.
Available tags are from the current project, at the top level.
Completion options are presented in a traditional way, with highlighting
to resolve same-name collisions.
@var{prompt} is a string to prompt with.
@var{default-tag} is a semantic tag or string to use as the default value.
If @var{initial-input} is non-@code{nil}, insert it in the minibuffer initially.
@var{history} is a symbol representing a variable to store the history in.
@end defun

@defun semantic-complete-read-tag-analyzer prompt &optional context history
@anchor{semantic-complete-read-tag-analyzer}
Ask for a tag by name based on the current context.
The function @dfn{semantic-analyze-current-context} is used to
calculate the context.  @dfn{semantic-analyze-possible-completions} is used 
to generate the list of possible completions.
@var{prompt} is the first part of the prompt.  Additional prompt
is added based on the contexts full prefix.
@var{context} is the semantic analyzer context to start with.
@var{history} is a symbol representing a variable to stor the history in.
usually a default-tag and initial-input are available for completion
prompts.  these are calculated from the @var{context} variable passed in.
@end defun

@defun semantic-complete-inline-analyzer context
@anchor{semantic-complete-inline-analyzer}
Complete a symbol name by name based on the current context.
This is similar to @code{semantic-complete-read-tag-analyze}, except
that the completion interaction is in the buffer where the context
was calculated from.
@var{context} is the semantic analyzer context to start with.
See @code{semantic-complete-inline-tag-engine} for details on how
completion works.
@end defun

@node Custom Tag Completion Functions
@section Custom Tag Completion Functions

There aren't many built in completion functions, but there are many
parts that can be put together into custom completion functions.

A completion function is built up of three important parts.

@table @asis
@item Tag Collection
Something that selects tags, and provides some list of tags
available, such as all functions, or all classes named ``bob''.
@item Typing and selecting
The prompt where you can type in the name of a tag.
@item Displaying possible completion values
A mechanism for displaying completion lists.
@end table

There is one typing and selecting routine that can be used to create
your custom completion prompt.

@defun semantic-complete-read-tag-engine collector displayor prompt default-tag initial-input history
@anchor{semantic-complete-read-tag-engine}
Read a semantic tag, and return a tag for the selection.
Argument @var{collector} is an object which can be used to to calculate
a list of possible hits.  See @code{semantic-completion-collector-engine}
for details on @var{collector}.
Argumeng @var{displayor} is an object used to display a list of possible
completions for a given prefix.  See@code{semantic-completion-display-engine}
for details on @var{displayor}.
@var{prompt} is a string to prompt with.
@var{default-tag} is a semantic tag or string to use as the default value.
If @var{initial-input} is non-@code{nil}, insert it in the minibuffer initially.
@var{history} is a symbol representing a variable to story the history in.
@end defun

As you can see, this takes one @dfn{collector}, and one
@dfn{displayor}.  These are objects created for this prompt at
runtime.  The completion engine then uses to perform their tasks.

For example:

@example
(defun semantic-complete-read-tag-buffer-deep (prompt &optional
						      default-tag initial-input history)
  "Ask for a tag by name from the current buffer.
PROMPT is a string to prompt with.
DEFAULT-TAG is a semantic tag or string to use as the default value.
If INITIAL-INPUT is non-nil, insert it in the minibuffer initially.
HISTORY is a symbol representing a variable to story the history in."
  (semantic-complete-read-tag-engine
   (semantic-collector-buffer-deep prompt :buffer (current-buffer))
   (semantic-displayor-traditional-with-focus-highlight "simple")
   ;;(semantic-displayor-tooltip "simple")
   prompt
   default-tag
   initial-input
   history)
  )
@end example

@menu
* Tag Collectors::              
* Tag Displayors::              
@end menu

@node Tag Collectors
@subsection Tag Collectors

A tag collector is an object that inherits from
@dfn{semantic-collector-abstract}.  A new collector is needed for
each specialized type of prompt that draws from a different selection
of tags.

You can have a collector that satisfies multiple purposes using slots
filled in the initializer for that object.

Collectors inherit from some of the following:

@deffn Type semantic-collector-abstract
@anchor{semantic-collector-abstract}
Root class for completion engines.
The baseclass provides basic functionality for interacting with
a completion displayor object, and tracking the current progress
of a completion.
@end deffn

@deffn Type semantic-collector-buffer-abstract
@anchor{semantic-collector-buffer-abstract}
Root class for per-buffer completion engines.
These collectors track themselves on a per-buffer basis.
@end deffn

@deffn Type semantic-collector-project-abstract
@anchor{semantic-collector-project-abstract}
Root class for project wide completion engines.
Uses semanticdb for searching all tags in the current project.
@end deffn

Available instantiable classes are:

@deffn Type semantic-collector-buffer-deep
@anchor{semantic-collector-buffer-deep}
Completion engine for tags in the current buffer.
When searching for a tag, uses semantic  deep searche functions.
Basics search only in the current buffer.
@end deffn

@deffn Type semantic-collector-project
@anchor{semantic-collector-project}
Completion engine for tags in a project.
@end deffn

@deffn Type semantic-collector-project-brutish
@anchor{semantic-collector-project-brutish}
Completion engine for tags in a project.
@end deffn

@deffn Type semantic-collector-analyze-completions
@anchor{semantic-collector-analyze-completions}
Completion engine that uses the context analyzer to provide options.
The only options available for completion are those which can be logically
inserted into the current context.
@end deffn

NOTE: Add sections for writing new collectors.

@c (eieiodoc-class semantic-collector-abstract "cc")

@c END OF COLLECTOR

@node Tag Displayors
@subsection Tag Displayors

When a user is interacting with the prompt, and requests completion,
those tags are drawn from the collector.  If the user asks for a list
of completion by hitting a complete key twice, then the list of
completions heeds to be displayed in some way.

Displayors can be used to manage the display of all tags currently
available, AND often needs to be used to @b{focus} one one particular
tag of many in a visible way.

All displayors inherit from the displayor baseclass that defines the
default behaviors:

@deffn Type semantic-displayor-abstract
@anchor{semantic-displayor-abstract}
Manages the display of some number of tags.
Provides the basics for a displayor, including interacting with
a collector, and tracking tables of completion to display.
@end deffn

@deffn Type semantic-displayor-focus-abstract
@anchor{semantic-displayor-focus-abstract}
A displayor which has the ability to focus in on one tag.
Focusing is a way of differentiationg between multiple tags
which have the same name.
@end deffn

Distinct implementations of displayors include:

@deffn Type semantic-displayor-traditional
@anchor{semantic-displayor-traditional}
Traditional display mechanism for a list of possible completions.
Completions are showin in a new buffer and listed with the ability
to click on the items to aid in completion.
@end deffn

@deffn Type semantic-displayor-traditional-with-focus-highlight
@anchor{semantic-displayor-traditional-with-focus-highlight}
A traditional displayor which can focus on a tag by showing it.
Same as @code{semantic-displayor-traditional}, but with selection between
multiple tags with the same name done by 'focusing' on the source
location of the different tags to differentiate them.

@end deffn

@deffn Type semantic-displayor-tooltip
@anchor{semantic-displayor-tooltip}
Display mechanism using tooltip for a list of possible completions.
@end deffn

NOTE: Add sections for writing new collectors.

@c (eieiodoc-class semantic-displayor-abstract "cd")

@c END OF DISPLAYOR


@node Old Tag Completion
@section Older Tag Completion functions

These are older completion functions.  They may still be useful.

@defun semantic-read-symbol prompt &optional default stream filter
@anchor{semantic-read-symbol}
Read a symbol name from the user for the current buffer.
@var{prompt} is the prompt to use.
Optional arguments:
@var{default} is the default choice.  If no default is given, one is read
from under point.
@var{stream} is the list of tokens to complete from.
@var{filter} is provides a filter on the types of things to complete.
@var{filter} must be a function to call on each element.
@end defun

@defun semantic-read-variable prompt &optional default stream
@anchor{semantic-read-variable}
Read a variable name from the user for the current buffer.
@var{prompt} is the prompt to use.
Optional arguments:
@var{default} is the default choice.  If no default is given, one is read
from under point.
@var{stream} is the list of tokens to complete from.
@end defun

@defun semantic-read-function prompt &optional default stream
@anchor{semantic-read-function}
Read a function name from the user for the current buffer.
@var{prompt} is the prompt to use.
Optional arguments:
@var{default} is the default choice.  If no default is given, one is read
from under point.
@var{stream} is the list of tags to complete from.
@end defun

@defun semantic-read-type prompt &optional default stream
@anchor{semantic-read-type}
Read a type name from the user for the current buffer.
@var{prompt} is the prompt to use.
Optional arguments:
@var{default} is the default choice.  If no default is given, one is read
from under point.
@var{stream} is the list of tags to complete from.
@end defun

@node Override Methods
@chapter Override Methods

These functions are called `override methods' because they provide
generic behaviors, which a given language can override.  For example,
finding a dependency file in Emacs lisp can be done with the
`locate-library' command (which overrides the default behavior.)  In C,
a dependency can be found by searching a generic search path which can
be passed in via a variable.

If you plan to use one of these functions from a buffer that is not
of the same major-mode as the original tag, you can use this form to
make sure the correct action takes place:

@defun semantic-with-mode-bindings mode &rest body
@anchor{semantic-with-mode-bindings}
Evaluate @var{BODY} with the local bindings of @var{MODE}.
The current mode bindings are saved, @var{BODY} is evaluated, and the saved
bindings are restored, even in case of an abnormal exit.
Value is what @var{BODY} returns.
@end defun

For more on override methods, @inforef{Semantic Overload Mechanism, , lang-support-guide}.

@menu
* Format Tag::                  Converting Tokens into text strings
* Tag Members::                 Tags in tags
* Tag Details::                 Arbitrary token detail fetching
* Making New Methods::          How to add your own methods for a tool
@end menu

@node Format Tag
@section Format Tag

Any given tag consists of Meta information which is best viewed in
some textual form.  This could be as simple as the tag's name, or as
a prototype to be added to header file in C.  Not only are there
several default converters from a Tag into text, but there is also
some convenient variables that can be used with them.  Use these
variables to allow options on output forms when displaying tags in
your programs.

@defvar semantic-format-tag-functions
@anchor{semantic-format-tag-functions}
List of functions which convert a tag to text.
Each function must take the parameters @var{tag} &optional @var{parent} @var{color}.
@var{tag} is the tag to convert.
@var{parent} is a parent tag or name which refers to the structure
or class which contains @var{tag}.  @var{parent} is @var{not} a class which a @var{tag}
would claim as a parent.
@var{color} indicates that the generated text should be colored using
@code{font-lock}.
@end defvar

@defvar semantic-format-tag-custom-list
@anchor{semantic-format-tag-custom-list}
A List used by customizeable variables to choose a tag to text function.
Use this variable in the @code{:type} field of a customizable variable.
@end defvar

Every tag to text conversion function must take the same parameters,
which are @var{TAG}, the tag to be converted, @var{PARENT}, the
containing parent (like a structure which contains a variable), and
@var{COLOR}, which is a flag specifying that color should be applied
to the returned string.

When creating, or using these strings, particularly with color, use
@dfn{concat} to build up larger strings instead of @dfn{format}.  This
will preserve text properties.

@defun semantic-format-tag-name tag &optional parent color
@anchor{semantic-format-tag-name}
Return the name string describing @var{tag}.
The name is the shortest possible representation.
Optional argument @var{parent} is the parent type if @var{tag} is a detail.
Optional argument @var{color} means highlight the prototype with font-lock colors.
This function can be overloaded (see @dfn{define-mode-local-override} for details).
@obsolete{semantic-name-nonterminal,semantic-format-tag-name}
@end defun

@defun semantic-format-tag-abbreviate tag &optional parent color
@anchor{semantic-format-tag-abbreviate}
Return an abbreviated string describing @var{tag}.
The abbreviation is to be short, with possible symbols indicating
the type of tag, or other information.
Optional argument @var{parent} is the parent type if @var{tag} is a detail.
Optional argument @var{color} means highlight the prototype with font-lock colors.
This function can be overloaded (see @dfn{define-mode-local-override} for details).
@obsolete{semantic-abbreviate-nonterminal,semantic-format-tag-abbreviate}
@end defun

@defun semantic-format-tag-summarize tag &optional parent color
@anchor{semantic-format-tag-summarize}
Summarize @var{tag} in a reasonable way.
Optional argument @var{parent} is the parent type if @var{tag} is a detail.
Optional argument @var{color} means highlight the prototype with font-lock colors.
This function can be overloaded (see @dfn{define-mode-local-override} for details).
@obsolete{semantic-summerize-nonterminal,semantic-format-tag-summarize}
@end defun

@defun semantic-format-tag-prototype tag &optional parent color
@anchor{semantic-format-tag-prototype}
Return a prototype for @var{tag}.
This function should be overloaded, though it need not be used.
This is because it can be used to create code by language independent
tools.
Optional argument @var{parent} is the parent type if @var{tag} is a detail.
Optional argument @var{color} means highlight the prototype with font-lock colors.
This function can be overloaded (see @dfn{define-mode-local-override} for details).
@obsolete{semantic-prototype-nonterminal,semantic-format-tag-prototype}
@end defun

@defun semantic-format-tag-concise-prototype tag &optional parent color
@anchor{semantic-format-tag-concise-prototype}
Return a concise prototype for @var{tag}.
Optional argument @var{parent} is the parent type if @var{tag} is a detail.
Optional argument @var{color} means highlight the prototype with font-lock colors.
This function can be overloaded (see @dfn{define-mode-local-override} for details).
@obsolete{semantic-concise-prototype-nonterminal,semantic-format-tag-concise-prototype}
@end defun

@defun semantic-format-tag-uml-abbreviate tag &optional parent color
@anchor{semantic-format-tag-uml-abbreviate}
Return a @var{uml} style abbreviation for @var{tag}.
Optional argument @var{parent} is the parent type if @var{tag} is a detail.
Optional argument @var{color} means highlight the prototype with font-lock colors.
This function can be overloaded (see @dfn{define-mode-local-override} for details).
@obsolete{semantic-uml-abbreviate-nonterminal,semantic-format-tag-uml-abbreviate}
@end defun

@defun semantic-format-tag-uml-prototype tag &optional parent color
@anchor{semantic-format-tag-uml-prototype}
Return a @var{uml} style prototype for @var{tag}.
Optional argument @var{parent} is the parent type if @var{tag} is a detail.
Optional argument @var{color} means highlight the prototype with font-lock colors.
This function can be overloaded (see @dfn{define-mode-local-override} for details).
@obsolete{semantic-uml-prototype-nonterminal,semantic-format-tag-uml-prototype}
@end defun

@defun semantic-format-tag-uml-concise-prototype tag &optional parent color
@anchor{semantic-format-tag-uml-concise-prototype}
Return a @var{uml} style concise prototype for @var{tag}.
Optional argument @var{parent} is the parent type if @var{tag} is a detail.
Optional argument @var{color} means highlight the prototype with font-lock colors.
This function can be overloaded (see @dfn{define-mode-local-override} for details).
@obsolete{semantic-uml-concise-prototype-nonterminal,semantic-format-tag-uml-concise-prototype}
@end defun

@defun semantic-format-tag-prin1 tag &optional parent color
@anchor{semantic-format-tag-prin1}
Convert @var{tag} to a string that is the print name for @var{tag}.
@var{parent} and @var{color} are ignored.
@obsolete{semantic-prin1-nonterminal,semantic-format-tag-prin1}
@end defun

An additional utility will return a string for just the data type of
a tag.  This function is used in the above routines as well.

@defun semantic-format-tag-type tag color
@anchor{semantic-format-tag-type}
Convert the data type of @var{tag} to a string usable in tag formatting.
It is presumed that @var{type} is a string or semantic tag.
This function can be overloaded (see @dfn{define-mode-local-override} for details).
@end defun

@node Tag Members
@section Tag Members

Tags are often in a hierarchical form, meaning that a tag found in
the top-level list may itself contain additional members.

The following overridable functions can fetch those tags.

@defun semantic-tag-components tag
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-with-overlays tag
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.)

Note for language authors:
  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 defun

Some languages can define parts of a tag outside the actual scope of
the parent tag.  You can fetch information about them with these
overload functions.


@defun semantic-tag-external-member-p parent tag
@anchor{semantic-tag-external-member-p}
Return non-@code{nil} if @var{parent} is the parent of @var{tag}.
@var{tag} is an external member of @var{parent} when it is somehow tagged
as having @var{parent} as it's parent.
@var{parent} and @var{tag} must both be semantic tags.

The default behavior, if not overridden with
@code{tag-external-member-p} is to match @code{:parent} attribute in
the name of @var{tag}.

If this function is overridden, use
@code{semantic-tag-external-member-children-p-default} to also
include the default behavior, and merely extend your own.
This function can be overloaded (see @dfn{define-mode-local-override} for details).
@obsolete{semantic-nonterminal-external-member-p,semantic-tag-external-member-p}
@end defun

@defun semantic-tag-external-member-children tag &optional usedb
@anchor{semantic-tag-external-member-children}
Return the list of children which are not *in* @var{tag}.
If optional argument @var{usedb} is non-@code{nil}, then also search files in
the Semantic Database.  If @var{usedb} is a list of databases, search those
databases.

Children in this case are functions or types which are members of
@var{tag}, such as the parts of a type, but which are not defined inside
the class.  @var{c}++ and @var{clos} both permit methods of a class to be defined
outside the bounds of the class' definition.

The default behavior, if not overridden with
@code{tag-external-member-children} is to search using
@dfn{semantic-tag-external-member-p} in all top level definitions
with a parent of @var{tag}.

If this function is overridden, use
@dfn{semantic-tag-external-member-children-default} to also
include the default behavior, and merely extend your own.
This function can be overloaded (see @dfn{define-mode-local-override} for details).
@obsolete{semantic-nonterminal-external-member-children,semantic-tag-external-member-children}
@end defun

@node Tag Details
@section Tag Details

These functions help derive information about tags that may not
be obvious for non-traditional languages with their own token types.

@defun semantic-tag-protection tag &optional parent
@anchor{semantic-tag-protection}
Return protection information about @var{tag} with optional @var{parent}.
This function returns on of the following symbols:
   @code{nil}        - No special protection.  Language dependent.
   @code{'public}    - Anyone can access this @var{tag}.
   @code{'private}   - Only methods in the local scope can access @var{tag}.
   @code{'protected} - Like private for outside scopes, like public for child
                classes.
Some languages may choose to provide additional return symbols specific
to themselves.  Use of this function should allow for this.

The default behavior (if not overridden with @code{tag-protection}
is to return a symbol based on type modifiers.
This function can be overloaded (see @dfn{define-mode-local-override} for details).
It makes the overload @dfn{semantic-nonterminal-protection} obsolete.
@obsolete{semantic-nonterminal-protection,semantic-tag-protection}
@end defun

@defun semantic-tag-protected-p tag protection &optional parent
@anchor{semantic-tag-protected-p}
Non-@code{nil} if @var{tag} is is protected.
@var{protection} is a symbol which can be returned by the method
@dfn{semantic-tag-protection}.
@var{parent} is the parent data type which contains @var{tag}.

For these PROTECTIONs, true is returned if @var{tag} is:
@table @asis
@item @code{nil}
  Always true
@item  private
  True if @code{nil}.
@item protected
  True if private or @code{nil}.
@item public
  True if private, protected, or @code{nil}.
@end table
@end defun

@defun semantic-tag-abstract-p tag &optional parent
@anchor{semantic-tag-abstract-p}
Return non @code{nil} if @var{tag} is abstract.
Optional @var{parent} is the parent tag of @var{tag}.
In @var{uml}, abstract methods and classes have special meaning and behavior
in how methods are overridden.  In @var{uml}, abstract methods are italicized.

The default behavior (if not overridden with @code{tag-abstract-p}
is to return true if @code{abstract} is in the type modifiers.
This function can be overloaded (see @dfn{define-mode-local-override} for details).
It makes the overload @dfn{semantic-nonterminal-abstract} obsolete.
@obsolete{semantic-nonterminal-abstract,semantic-tag-abstract-p}
@end defun

@defun semantic-tag-leaf-p tag &optional parent
@anchor{semantic-tag-leaf-p}
Return non @code{nil} if @var{tag} is leaf.
Optional @var{parent} is the parent tag of @var{tag}.
In @var{uml}, leaf methods and classes have special meaning and behavior.

The default behavior (if not overridden with @code{tag-leaf-p}
is to return true if @code{leaf} is in the type modifiers.
This function can be overloaded (see @dfn{define-mode-local-override} for details).
It makes the overload @dfn{semantic-nonterminal-leaf} obsolete.
@obsolete{semantic-tag-leaf,semantic-tag-leaf-p}
@end defun

@defun semantic-tag-static-p tag &optional parent
@anchor{semantic-tag-static-p}
Return non @code{nil} if @var{tag} is static.
Optional @var{parent} is the parent tag of @var{tag}.
In @var{uml}, static methods and attributes mean that they are allocated
in the parent class, and are not instance specific.
@var{uml} notation specifies that @var{static} entries are underlined.
This function can be overloaded (see @dfn{define-mode-local-override} for details).
@obsolete{semantic-tag-static,semantic-tag-static-p}
@end defun

@defvar semantic-dependency-include-path
@anchor{semantic-dependency-include-path}
Defines the include path used when searching for files.
This should be a list of directories to search which is specific
to the file being included.

If @dfn{semantic-dependency-tag-file} is overridden for a given
language, this path is most likely ignored.

This function, reguardless of being overriden, caches the located
dependency file location in the tag property @code{dependency-file}.
If you override this function, you do not need to implement your
own cache.  Each time the buffer is fully reparsed, the cache
will be reset.

@var{todo}: use ffap.el to locate such items.
@end defvar

@defun semantic-dependency-tag-file &optional tag
@anchor{semantic-dependency-tag-file}
Find the filename represented from @var{tag}.
Depends on @code{semantic-dependency-include-path} for searching.  Always searches
@code{.} first, then searches additional paths.
This function can be overloaded (see @dfn{define-mode-local-override} for details).
It makes the overload @dfn{semantic-find-dependency} obsolete.
@obsolete{semantic-find-dependency,semantic-dependency-tag-file}
@end defun

@defun semantic-prototype-file buffer
@anchor{semantic-prototype-file}
Return a file in which prototypes belonging to @var{buffer} should be placed.
Default behavior (if not overridden) looks for a token specifying the
prototype file, or the existence of an @var{ede} variable indicating which
file prototypes belong in.
This function can be overloaded (see @dfn{define-mode-local-override} for details).
@end defun

@defun semantic-go-to-tag tag &optional parent
@anchor{semantic-go-to-tag}
Go to the location of @var{tag}.
@var{tag} may be a stripped element, in which case @var{parent} specifies a
parent tag that has position information.
Different behaviors are provided depending on the type of tag.
For example, dependencies (includes) will seek out the file that is
depended on (see @dfn{semantic-dependency-tag-file}.
This function can be overloaded (see @dfn{define-mode-local-override} for details).
It makes the overload @dfn{semantic-find-nonterminal} obsolete.
@obsolete{semantic-find-nonterminal,semantic-go-to-tag}
@end defun

@defun semantic-texi-find-documentation name &optional type
@anchor{semantic-texi-find-documentation}
Find the function or variable @var{name} of @var{type} in the texinfo source.
@var{name} is a string representing some functional symbol.
@var{type} is a string, such as ``variable`` or ''Command'' used to find
the correct definition in case @var{name} qualifies as several things.
When this function exists, @var{point} is at the definition.
If the doc was not found, an error is thrown.
Note: @var{type} not yet implemented.
@end defun

@node Making New Methods
@section Making New Methods

To create your own application specific mode local function, you
should use @dfn{define-overload}.  This function creates the
framework needed for different mode-authors to customize your
applications.

Once a function has been defined as mode-local, you should use
@dfn{define-mode-local-override} to add a mode specific feature.

@defun define-overload name args docstring &rest body
@anchor{define-overload}
Define a new function, as with @dfn{defun} which can be overloaded.
@var{name} is the name of the function to create.
@var{args} are the arguments to the function.
@var{docstring} is a documentation string to describe the function.  The
docstring will automatically had details about its overload symbol
appended to the end.
@var{body} is code that would be run when there is no override defined.  The
default is to call the function @code{NAME-default} with the appropriate
arguments.

@var{body} can also include an override form that specifies which part of
@var{body} is specifically overridden.  This permits to specify common code
run for both default and overridden implementations.
An override form is one of:

  @var{1}. (:override [@var{overbody}])
  @var{2}. (:override-with-args @var{overargs} [@var{overbody}])

@var{overbody} is the code that would be run when there is no override
defined.  The default is to call the function @code{NAME-default} with the
appropriate arguments deduced from @var{args}.
@var{overargs} is a list of arguments passed to the override and
@code{NAME-default} function, in place of those deduced from @var{args}.
@end defun

@defun define-mode-local-override name mode args docstring &rest body
@anchor{define-mode-local-override}
Define a mode specific override of the function overload @var{name}.
Has meaning only if @var{name} has been created with @dfn{define-overload}.
@var{mode} is the major mode this override is being defined for.
@var{args} are the function arguments, which should match those of the same
named function created with @dfn{define-overload}.
@var{docstring} is the documentation string.
@var{body} is the implementation of this function.
@obsolete{define-mode-overload-implementation,define-mode-local-override}
@end defun

@node Parser Features
@chapter Parser Features

If you write a program that uses a tag table in a persistent
display or database, it is necessary to know when tag tables change so
that your displays can be updated.  This is especially important as
tags can be replaced, changed, or deleted, and the associated
overlays will then throw errors when you try to use them.  Complete
integration with tag changes can be achieved via several hooks.

If you write an application that frequenly accesses the tags tables,
it is important to make sure those tags are up to date, and to make
sure you application does not adversely effect all the other minor
modes that may be running.

The semantic parser has many features and hooks that applications can
use to provide a good user experience.

@menu
* Editing Buffers::             Let the parser know you are changing a buffer.
* Parser State::                Knowing if the tag table is out of date
* Parser Hooks::                Knowing when tags change
* Lexical Safety::              Preventing lexical errors from making a mess
@end menu

@node Editing Buffers
@section Editing Buffers

One interesting way to interact with the parser is to let it know that
changes you are going to make will not require re-parsing.

@defvar semantic-edits-are-safe
When non-@code{nil}, modifications do not require a reparse.
This prevents tokens from being marked dirty, and it
prevents top level edits from causing a cache check.
Use this when writing programs that could cause a full
reparse, but will not change the tag structure, such
as adding or updating top-level comments.
@end defvar

@node Parser State
@section Parser State

It is sometimes useful to know what the current parsing state
is.  These function can let you know what level of re-parsing may be
needed.  Careful choices on when to reparse can make your program much
faster.

@defun semantic-parse-tree-needs-update-p
@anchor{semantic-parse-tree-needs-update-p}
Return non-@code{nil} if the current parse tree needs to be updated.
@end defun

@defun semantic-parse-tree-needs-rebuild-p
@anchor{semantic-parse-tree-needs-rebuild-p}
Return non-@code{nil} if the current parse tree needs to be rebuilt.
@end defun

@defun semantic-parse-tree-unparseable-p
@anchor{semantic-parse-tree-unparseable-p}
Return non-@code{nil} if the current buffer has been marked unparseable.
@end defun

@defun semantic-parse-tree-up-to-date-p
@anchor{semantic-parse-tree-up-to-date-p}
Return non-@code{nil} if the current parse tree is up to date.
@end defun

@node Parser Hooks
@section Parser Hooks

If you just want to know when a buffer changes, use this hook.

@defvar semantic-after-toplevel-cache-change-hook
@anchor{semantic-after-toplevel-cache-change-hook}
Hooks run after the buffer tag list has changed.
This list will change when a buffer is reparsed, or when the tag list
in a buffer is cleared.  It is *@var{not}* called if the current tag list is
partially reparsed.

Hook functions must take one argument, which is the new list of tags
associated with this buffer.

For language specific hooks, make sure you define this as a local hook.
@end defvar

If you want tighter interaction with how the user is editing
different tags, you can use this hook instead.

@defvar semantic-after-partial-cache-change-hook
@anchor{semantic-after-partial-cache-change-hook}
Hooks run after the buffer cache has been updated.

This hook will run when the cache has been partially reparsed.
Partial reparses are incurred when a user edits a buffer, and only the
modified sections are rescanned.

Hook functions must take one argument, which is the list of tokens
updated in the current buffer.

For language specific hooks, make sure you define this as a local hook.
@end defvar

It is also useful to clean up any data your application is using when
semantic flushes its tags table.

@defvar semantic-before-toplevel-cache-flush-hook
@anchor{semantic-before-toplevel-cache-flush-hook}
Hooks run before the toplevel nonterminal cache is flushed.
For language specific hooks, make sure you define this as a local
hook.  This hook is called before a corresponding
@code{semantic-after-toplevel-cache-change-hook} which is also called
during a flush when the cache is given a new value of @code{nil}.
@end defvar

@node Lexical Safety
@section Lexical Safety

If you application frequenly requests lists of tags upon user request,
it may be important to avoid lexical problems that frequenly occur
when the user has partially written an expression, such as starting a
string, or argument list.

You can protect your code from lexical problems with this macro:

@defun semantic-lex-catch-errors symbol &rest forms
@anchor{semantic-lex-catch-errors}
Using @var{SYMBOL}, execute @var{FORMS} catching lexical errors.
If @var{FORMS} results in a call to the parser that throws a lexical error,
the error will be caught here without the buffer's cache being thrown
out of date.
If there is an error, the syntax that failed is returned.
If there is no error, then the last value of @var{FORMS} is returned.
@end defun

It is important to provide a good @var{SYMBOL} so that these macros
can nest correctly.

If you want your code to run anyway, even if there is a lexical
error, using this macro like this:

@example
(semantic-lex-catch-errors
   (semantic-fetch-tags))
@end example

will put the parser into the 'unparseable' state, and allow other
routines to request the tag table without incurring additional parser
attempts.

@node Semantic Database
@chapter Semantic Database

Semanticdb is a database mechanism for storing tags parsed by
@semantic{}.  The database operates in the background, saving tags as
they are parsed between sessions.  When a file is read in, and there
is a previously created set of tags available for it, sematnicdb will
save time by not parsing the file, and using the cached copy.

In applications, semanticdb can provide access to the sum of all tags
in a project or in the basic system.  This database can they be
searched using a set of special routines.

@menu
* Semanticdb in Programs::      Basic usage.
* Semanticdb Tag Queries::      Searching for tokens in the databases.
* System Databases::            Special kinds of databases for system tags.
@end menu

@node Semanticdb in Programs
@section Semanticdb in Programs::

If you write a program using semanticdb, you will probably want to
make sure it is active in your program.

@defun semanticdb-minor-mode-p
@anchor{semanticdb-minor-mode-p}
Return non-@code{nil} if @code{semanticdb-minor-mode} is active.
@end defun

Since semanticdb is optional, it is best if a program can gracefully
degrade service when semanticdb is not available, or to throw an
error letting the user know it is required to be active.

At the simplest level, you can ask if a given file is in the
database, recieving a tag table.  Semanticdb will give you an
accurate set of tags just by asking.

@defun semanticdb-file-stream file
@anchor{semanticdb-file-stream}
Return a list of tags belonging to @var{file}.
If file has database tags available in the database, return them.
If file does not have tags available, then load the file, and create them.
@end defun

Alternately, you can get at the table object for a file by asking for
it.

@defun semanticdb-file-table-object file &optional dontload
@anchor{semanticdb-file-table-object}
Return a semanticdb table belonging to @var{file}.
If file has database tags available in the database, return it.
If file does not have tags available, and @var{dontload} is @code{nil},
then load the tags for @var{file}, and create a new table object for it.
@var{dontload} does not affect the creation of new database objects.
@end defun

@node Semanticdb Tag Queries
@section Semanticdb Tag Queries

You can search for tags in the semantic database using the
semanticdb-find API.  It is important to note that database search
functions do not return a plain list of tags.  This is because some
tags may not be loaded in a buffer, which means that the found tag
would not have an overlay, and no way to determine where it came from.

As such, all search functions return a special Database Results list.

There are several types of searches, divided into groups by
implementation.  While it is possible to add new types of searches,
or write custom searches, the built in searches are usually the only
ones available in system backends @ref{System Databases}.

When the term @b{brute} or @b{brutish} is used as a search criteria,
that is distinguishing between an include-path based search, and a
search that scans everything available in a project.

Non-brute force searches assume that all symbols available in a given
buffer are on the search path, or in some file that has been
included, imported, or otherwise indicated in the source file
itself.  While not always true for interpreted languages (such as
Emacs Lisp), it is common among declaritive languages.

Sometimes a brute force approach is needed, scanning every file
available to the database.  You may want to do this if your
application is collecting data unrelated to a file currently being
worked on.

@menu
* DB Results::                  Accessing the results of a search.
* DB Search Paths::             The list of tables to search.
* DB Basic Name Search::        Searches based on name.
* DB Basic Brute Search::       Searches on common tag attributes.
* DB Advanced Search::          Complex searches on associations
* DB Generic Brute Search::     Do It Yourself search criteria
@end menu

@node DB Results
@subsection DB Results

The successful results of a search returns a special list of the
following form:

@example
   ( (DATABASE TAG1 TAG2 ...) (DATABASE2 TAG3 TAG4 ...) ...)
@end example

It should not be necessary to access the results in this way,
however, as there are several routines that can be used to access
this list.

To turn a semanticdb search result into a simple tag table, use:

@defun semanticdb-strip-find-results results &optional find-file-match
@anchor{semanticdb-strip-find-results}
Strip a semanticdb search @var{results} to exclude objects.
This makes it appear more like the results of a @code{semantic-find-} call.
Optional @var{find-file-match} loads all files associated with @var{results}
into buffers.  This has the side effect of enabling @dfn{semantic-tag-buffer} to
return a value.
@end defun

To write a function that accepts a tag table, or a semanticdb search
result, use this to test if it is a semanticdb search result:

@defun semanticdb-find-results-p resultp
@anchor{semanticdb-find-results-p}
Non-@code{nil} if @var{resultp} is in the form of a semanticdb search result.
This query only really tests the first entry in the list that is @var{resultp},
but should be good enough for debugging assertions.
@end defun

@defun semanticdb-find-result-with-nil-p resultp
@anchor{semanticdb-find-result-with-nil-p}
Non-@code{nil} of @var{resultp} is in the form of a semanticdb search result.
@code{nil} is a valid value where a @var{table} usually is, but only if the @var{tag}
results include overlays.
This query only really tests the first entry in the list that is @var{resultp},
but should be good enough for debugging assertions.
@end defun

To operate on the search results as though it were a simple tags
table, or plain list, use these routines.

@defun semanticdb-find-result-length result
@anchor{semanticdb-find-result-length}
Number of tags found in @var{result}.
@end defun

@defun semanticdb-find-result-nth result n
@anchor{semanticdb-find-result-nth}
In @var{result}, return the Nth search result.
This is a @var{0} based search result, with the first match being element @var{0}.

The returned value is a cons cell: (@var{tag} . @var{table}) where @var{tag}
is the tag at the Nth position.  @var{table} is the semanticdb table where
the @var{tag} was found.  Sometimes @var{table} can be @code{nil}.
@end defun

@defun semanticdb-find-result-nth-in-buffer result n
@anchor{semanticdb-find-result-nth-in-buffer}
In @var{result}, return the Nth search result.
Like @dfn{semanticdb-find-result-nth}, except that only the @var{tag}
is returned, and the buffer it is found it will be made current.
If the result tag has no position information, the originating buffer
is still made current.
@end defun

@node DB Search Paths
@subsection DB Search Paths

For searches based on an include path (non-brutish) a path of tables
needs to be generated.  Searching a lot of tables is slow, which is
why a brutish search is not always recommended.  An include-based
approach can also generate a lot of tables, so you can control how
detailed a search is with a throttle variable.

Ideally, each language mode will have a mode-specific value for
this throttle value.  A user can also specify their own values if the
default is not good enough.

@defvar semanticdb-find-default-throttle
@anchor{semanticdb-find-default-throttle}
The default throttle for @code{semanticdb-find} routines.
The throttle controls how detailed the list of database
tables is for a symbol lookup.  The value is a list with
the following keys:

@table @code
@item file
The file the search is being performed from.  This option is here for
completeness only, and is assumed to always be on.
@item local
Tables from the same local directory are included.  This includes
files directly referenced by a file name which might be in a different
directory.
@item project
Tables from the same local project are included If @code{project} is
specified, then @code{local} is assumed.
@item unloaded
If a table is not in memory, load it.  If it is not cached on disk
either, get the source, parse it, and create the table.
@item system
Tables from system databases.  These are specifically tables
from system header files, or language equivalent.
@item recursive
For include based searches, includes tables referenced by included
files.
@item omniscience
Included system databases which are omniscience, or somehow know
everything.  Omniscience databases are found in
@code{semanticdb-project-system-databases}.  The Emacs Lisp system
@var{db} is an omniscience database.
@end table

@end defvar



You can use the command @code{semanticdb-find-test-translate-path} to
interactively test out how the path translator is working.  The path
translation routines are:

@defun semanticdb-find-translate-path path brutish
@anchor{semanticdb-find-translate-path}
Translate @var{path} into a list of semantic tables.
Path translation involves identifying the @var{path} input argument
in one of the following ways:
  @code{nil} - Take the current buffer, and use it's include list
  buffer - Use that buffer's include list.
  filename - Use that file's include list.  If the file is not
      in a buffer, see of there is a semanticdb table for it.  If
      not, read that file into a buffer.
  tag - Get that tag's buffer of file file.  See above.
  table - Search that table, and it's include list.
  find result - Search the results of a previous find.

In addition, once the base path is found, there is the possibility of
each added table adding yet more tables to the path, so this routine
can return a lengthy list.

If argument @var{brutish} is non-@code{nil}, then instead of using the include
list, use all tables found in the parent project of the table
identified by translating @var{path}.  Such searches use brute force to
scan every available table.

The return value is a list of objects of type @dfn{semanticdb-table} or
it's children.  In the case of passing in a find result, the result
is returned unchanged.

This routine uses @dfn{semanticdb-find-table-for-include} to translate
specific include tags into a semanticdb table.
This function can be overloaded (see @dfn{define-mode-local-override} for details).
@end defun

@defun semanticdb-find-table-for-include includetag &optional table
@anchor{semanticdb-find-table-for-include}
For a single @var{includetag} found in @var{table}, find a @dfn{semanticdb-table} object
@var{includetag} is a semantic @var{tag} of class @code{'include}.
@var{table} as defined by @dfn{semantic-something-to-tag-table} to identify
where the tag came from.  @var{table} is optional if @var{includetag} has an
overlay of @code{:filename} attribute.
This function can be overloaded (see @dfn{define-mode-local-override} for details).
@end defun

@node DB Basic Name Search
@subsection DB Basic Name Search

 These searches scan a database table collection for tags based on
name.  They are divided into normal and deep searches.  A deep
search, as with in buffer tag scanning, implies that all entries are
scanned, including those in type declarations.

Normal Searches:

@defun semanticdb-find-tags-by-name name &optional path find-file-match
@anchor{semanticdb-find-tags-by-name}
Search for all tags matching @var{name} on @var{path}.
See @dfn{semanticdb-find-translate-path} for details on @var{path}.
@var{find-file-match} indicates that any time a match is found, the file
associated with that tag should be loaded into a buffer.
@end defun

@defun semanticdb-find-tags-by-name-regexp regexp &optional path find-file-match
@anchor{semanticdb-find-tags-by-name-regexp}
Search for all tags matching @var{regexp} on @var{path}.
See @dfn{semanticdb-find-translate-path} for details on @var{path}.
@var{find-file-match} indicates that any time a match is found, the file
associated with that tag should be loaded into a buffer.
@end defun

@defun semanticdb-find-tags-for-completion prefix &optional path find-file-match
@anchor{semanticdb-find-tags-for-completion}
Search for all tags matching @var{prefix} on @var{path}.
See @dfn{semanticdb-find-translate-path} for details on @var{path}.
@var{find-file-match} indicates that any time a match is found, the file
associated with that tag should be loaded into a buffer.
@end defun

@defun semanticdb-find-tags-by-class class &optional path find-file-match
@anchor{semanticdb-find-tags-by-class}
Search for all tags of @var{class} on @var{path}.
See @dfn{semanticdb-find-translate-path} for details on @var{path}.
@var{find-file-match} indicates that any time a match is found, the file
associated with that tag should be loaded into a buffer.
@end defun

Deep Searches:

@defun semanticdb-deep-find-tags-by-name name &optional path find-file-match
@anchor{semanticdb-deep-find-tags-by-name}
Search for all tags matching @var{name} on @var{path}.
Search also in all components of top level tags founds.
See @dfn{semanticdb-find-translate-path} for details on @var{path}.
@var{find-file-match} indicates that any time a match is found, the file
associated with that tag should be loaded into a buffer.
@end defun

@defun semanticdb-deep-find-tags-by-name-regexp regexp &optional path find-file-match
@anchor{semanticdb-deep-find-tags-by-name-regexp}
Search for all tags matching @var{regexp} on @var{path}.
Search also in all components of top level tags founds.
See @dfn{semanticdb-find-translate-path} for details on @var{path}.
@var{find-file-match} indicates that any time a match is found, the file
associated with that tag should be loaded into a buffer.
@end defun

@defun semanticdb-deep-find-tags-for-completion prefix &optional path find-file-match
@anchor{semanticdb-deep-find-tags-for-completion}
Search for all tags matching @var{prefix} on @var{path}.
Search also in all components of top level tags founds.
See @dfn{semanticdb-find-translate-path} for details on @var{path}.
@var{find-file-match} indicates that any time a match is found, the file
associated with that tag should be loaded into a buffer.
@end defun

@node DB Basic Brute Search
@subsection DB Basic Brute Search

 These searches allow searching on specific attributes of tags,
 such as name, type, or other attribute.

@defun semanticdb-brute-deep-find-tags-by-name name &optional path find-file-match
@anchor{semanticdb-brute-deep-find-tags-by-name}
Search for all tags matching @var{name} on @var{path}.
See @dfn{semanticdb-find-translate-path} for details on @var{path}.
The argument @var{brutish} will be set so that searching includes all tables
in the current project.
@var{find-file-match} indicates that any time a matchi is found, the file
associated wit that tag should be loaded into a buffer.
@end defun

@node DB Advanced Search
@subsection DB Advanced Search

 These are searches that were needed to accomplish some
 specialized tasks as discovered in utilities.  Advanced searches
 include matching methods defined outside some parent class.

 The reason for advanced searches are so that external
 repositories such as the Emacs obarray, or java @file{.class} files can
 quickly answer these needed questions without dumping the entire
 symbol list into Emacs for a regular semanticdb search.

@defun semanticdb-find-tags-external-children-of-type type &optional path find-file-match
@anchor{semanticdb-find-tags-external-children-of-type}
Search for all tags defined outside of @var{type} w/ @var{type} as a parent.
See @dfn{semanticdb-find-translate-path} for details on @var{path}.
@var{find-file-match} indicates that any time a match is found, the file
associated with that tag should be loaded into a buffer.
@end defun

@node DB Generic Brute Search
@subsection DB Generic Brute Search

 The generic search, @dfn{semanticdb-find-nonterminal-by-function}
 will call your function with every tag available.  (Very slow for
 system databases.)

NOTE:  There is no such function.  Hopefully we can get away without
implementing one, which will make system databases more useful.  If
you are really stuck, you can use the following, though I don't
recommend it.

@defun semanticdb-find-tags-collector function &optional path find-file-match brutish
@anchor{semanticdb-find-tags-collector}
Search for all tags returned by @var{function} over @var{path}.
See @dfn{semanticdb-find-translate-path} for details on @var{path}.
@var{find-file-match} indicates that any time a match is found, the file
associated with that tag should be loaded into a buffer.
If optional argument @var{brutish} is non-@code{nil}, then ignore include statements,
and search all tables in this project tree.
@end defun

@node System Databases
@section System Databases

System Databases are special implementations of the database and
table API which make some external tag source appear as though it
were a normal buffer with semantic parsed tags available.

Search routines for these databases return a special type of table
not associated with a file.  It is important to be aware of this
possible return value.


@deffn Type semanticdb-project-database-emacs-lisp
@anchor{semanticdb-project-database-emacs-lisp}
Database representing Emacs core.
@end deffn

This Emacs database is loaded automatically.


@deffn Type semanticdb-project-database-ebrowse
@anchor{semanticdb-project-database-ebrowse}
Semantic Database deriving tags using the @var{ebrowse} tool.
@var{ebrowse} is a C/C++ parser for use with @code{ebrowse} Emacs program.
@end deffn

To create new EBROWSE project databases, use:

@deffn Command semanticdb-create-ebrowse-database dir
@anchor{semanticdb-create-ebrowse-database}
Create an @var{ebrose} database for directory @var{dir}.
The database file is stored in ~/.semanticdb, or whichever directory
is specified by @code{semanticdb-default-system-save-directory}.
@end deffn

@subsection Semantic Parsed System Databases

Another kind of system database is one created by the semantic tools,
but saved in a special way.  These databases are created with a
script, or at some other convenient time.  They can then be searched
normally.  They will appear on the same list of system databases as
back ends that refer to object files indirectly.

A simple way to create one from Emacs is with this function:

@deffn Command semanticdb-create-system-database path &optional class
@anchor{semanticdb-create-system-database}
Create a system database starting at @var{path}.
@var{path} should be a top level directory for a series of files containing
declarations for @var{system} files.  In @var{c}, this would be header filaes.
@var{class} is the class for the database to create.  Only child classes
of symbol @dfn{semanticdb-project-database-system} are accepted.
@end deffn

@node Idle Scheduling
@chapter Idle Scheduling

The Semantic Idle Scheduler is a minor mode which performs semantic
specific tasks in idle time.
See @inforef{Idle Scheduler, , semantic-user.info}.

It performs the following tasks in order:

@enumerate
@item 
Reprarse the current buffer if needed
@item
Reparse other buffers that need it
@item
Execute other scheduled semantic related operations.
@end enumerate

Care is take in the idle scheduler to exit immediatly if user input
is detected, improving editing performance.

The reason for grouping these tasks together is so that the automatic
reparsing code executes before other idle services.  This allows
lexically broken buffers to be detected so that the other
applications that follow do not accidentally reparse the buffer
leaving unmatched syntax all over.

You can create new minor modes that are automatically scheduled by
the semantic idle scheduler.  Create the new minor mode with:

@defun define-semantic-idle-service name doc &rest forms
@anchor{define-semantic-idle-service}
Create a new idle services with @var{NAME}.
@var{DOC} will be a documentation string describing @var{FORMS}.
@var{FORMS} will be called during idle time after the current buffer's
semantic tag information has been updated.
This routines creates the following functions and variables:
@end defun

@section User Input Handling

When writing an idle service, it is important for tasks that can take
a long time to correctly exit upon user input.

You can test for user input in your idle handler with the following
routines:

@defun semantic-throw-on-input from
@anchor{semantic-throw-on-input}
Exit with @dfn{throw} when in @dfn{semantic-exit-on-input} on user input.
@var{FROM} is an indication of where this function is called from as a value
to pass to @dfn{throw}.  It is recommended to use the name of the function
calling this one.
@end defun

If you need to carefully extract from your function, you can wrap
just a section of your function to exit on user input by wrapping it
with this macro:

@defun semantic-exit-on-input symbol &rest forms
@anchor{semantic-exit-on-input}
Using @var{SYMBOL} as an argument to @dfn{throw}, execute @var{FORMS}.
If @var{FORMS} includes a call to @code{semantic-thow-on-input}, then
if a user presses any key during execution, this form macro
will exit with the value passed to @dfn{semantic-throw-on-input}.
If @var{FORMS} completes, then the return value is the same as @dfn{progn}.
@end defun

Upon catching user input, you can try to detect if there was an exit
from the return argument, and continue throwing with an additional
call to @code{semantic-throw-on-input}.

@node Example Programs
@chapter Programming Examples

  *** NOTE ***  These examples are for semantic 1.4.
Using the below functions will generate compile time warnings with
advice on what functions to use in semantic 2.0.


Here are some simple examples that use different aspects of the
semantic library APIs.  For fully functional example programs with
lots of comments, see the file @file{semantic-examples.el}.

@heading Interactively querying for a token name

If you need a command that asks the user for a token name, you can
get full range completion using the query functions
@ref{Tag Completion}.

@example
(interactive (list (semantic-read-symbol "Symbol: ")))
@end example

@heading Finding a symbol in a buffer

If you have the name of a function or variable, and need to find its
location in a buffer, you need a search function.  There is a wide
range of searches you can perform @ref{Searching Tag Tables}.

@example
(semantic-find-nonterminal-by-name
 "some-name"
 (current-buffer)
 t    ;; look inside structures and classes for these symbols
 nil) ;; do not look inside header files.
@end example

@heading Finding a symbol in a project

If you have the name of a function or variable, and need to find its
location somewhere in a project, you need to use the Semantic Database
@inforef{semanticdb, , semanticdb}.  There are many search functions similar to the
ones found in @ref{Searching Tag Tables}.

The Semantic Database is interesting in that the return structure is
not

@heading Locating a token in a buffer

If you have a nonterminal token, or a list of them, you may want to
find their position in a buffer.

@example
(semanticdb-find-nonterminal-by-name
 "symbol"
 nil   ;; Defaults to the current project's database list.
 t     ;; Search inside types
 nil   ;; Do not search include files
 nil   ;; Only search files in the same mode (all C files)
 t     ;; When a token is found, make sure it is loaded in a buffer.
 )
@end example

Of interesting note above, semanticdb can find symbols in files that
are not loaded into an Emacs buffer.  These tokens do not have an
associated overlay, and the function @dfn{semantic-token-buffer} will
fail.

The last parameter's tells the search function to
@dfn{find-file-noselect} any file in which a matching token was
found.  This will allow you to merge all the tokens into a completion
list, or other flat list needed by most functions that use
association lists.

If you do not ask semanticdb to load those files, you will need to
explicitly request the database object (found in the @code{car} of
each sublist) get the file loaded.  It is useful to not auto find all
files if you don't need to jump to that token.

@heading Converting a token into a human readable string.

A tag is a rather unpleasant Lisp structure when trying
to decipher what is going on.  As such, there is a wide range of
functions available that can convert a token into a human readable,
and colorful string @ref{Format Tag}.

If you program interfaces with lots of users, you will probably want
to have your program define a configurable variable that will let
users change the visible portion of your program.

@example
(defcustom my-summary-function 'semantic-uml-prototype-nonterminal
  "*Function to use when showing info about my tag."
  :group 'my-program
  :type semantic-format-tag-custom-list)
@end example

Note the special type provided by Semantic.

Next, you can call this function to create a string.

@example
(funcall my-summary-function tag
                             tag-parent
                             t ; use color
                             )
@end example

In this case, @var{tag-parent} is an optional argument.  In many
cases, parent is not used by the outputting function.  The parent must
be a tag whose @code{semantic-tag-componenets} contains @var{tag}, or
nil for top-level definitions.  In particular, C++ needs the parent to
correctly calculate the protection of each method.


@node Current Context
@chapter Deriving the Current Context

This chapter deals with how to derive the current context, and also
how a language maintainer can get the current context API to work
with their language.

By default, the behavior will function in C like languages.  This
means languages with parenthetical blocks, and type dereferencing
which uses a similar form.

@menu
* Blocks::                      
* Local Variables::             Getting lists of local variables.
* Derived Context::             What goes at a given location?
* Context Analysis::            Analysis information about the local context.
@end menu

@node Blocks
@section Blocks and Navigation

Source code is typically built up of control structures, and blocks of
context, or lexical scope.  Semantic terms these lexical scopes as a
``context''.  The following functions can be used to navigate contexts.
Some of them are override functions.  Language authors can override
a subset of them to make them work for their language.

@defun semantic-up-context &optional point bounds-type
@anchor{semantic-up-context}
Move point up one context from @var{point}.
Return non-@code{nil} if there are no more context levels.
Overloaded functions using @code{up-context} take no parameters.
@var{bounds-type} is a symbol representing a tag class to restrict
movement to.  If this is @code{nil}, @code{'function} is used.
This will find the smallest tag of that class (function, variable,
type, etc) and make sure non-@code{nil} is returned if you cannot
go up past the bounds of that tag.
This function can be overloaded (see @dfn{define-mode-local-override} for details).
@end defun

@defun semantic-beginning-of-context &optional point
@anchor{semantic-beginning-of-context}
Move @var{point} to the beginning of the current context.
Return non-@code{nil} if there is no upper context.
The default behavior uses @dfn{semantic-up-context}.
This function can be overloaded (see @dfn{define-mode-local-override} for details).
@end defun

@defun semantic-end-of-context &optional point
@anchor{semantic-end-of-context}
Move @var{point} to the end of the current context.
Return non-@code{nil} if there is no upper context.
Be default, this uses @dfn{semantic-up-context}, and assumes parenthetical
block delimiters.
This function can be overloaded (see @dfn{define-mode-local-override} for details).
@end defun

These next set of functions can be used to navigate across commands.

@defun semantic-end-of-command
@anchor{semantic-end-of-command}
Move to the end of the current command.
Be default, uses @code{semantic-command-separation-character}.
This function can be overloaded (see @dfn{define-mode-local-override} for details).
@end defun

@defun semantic-beginning-of-command
@anchor{semantic-beginning-of-command}
Move to the beginning of the current command.
Be default, uses @code{semantic-command-separation-character}.
This function can be overloaded (see @dfn{define-mode-local-override} for details).
@end defun

@node Local Variables
@section Deriving local variables

Within a given context, or block of code, local variables are often
defined.  These functions can be used to retrieve lists of locally
scoped variables.

@defun semantic-get-local-variables &optional point
@anchor{semantic-get-local-variables}
Get the local variables based on POINT's context.
Local variables are returned in Semantic tag format.
This can be overriden with @code{get-local-variables}.
This function can be overloaded (see @dfn{define-mode-local-override} for details).
@end defun

@defun semantic-get-local-arguments &optional point
@anchor{semantic-get-local-arguments}
Get arguments (variables) from the current context at @var{point}.
Parameters are available if the point is in a function or method.
Return a list of tags unlinked from the originating buffer.
Arguments are obtained by overriding @code{get-local-arguments}, or by the
default function @dfn{semantic-get-local-arguments-default}.  This, must
return a list of tags, or a list of strings that will be converted to
tags.
This function can be overloaded (see @dfn{define-mode-local-override} for details).
@end defun

@defun semantic-get-all-local-variables &optional point
@anchor{semantic-get-all-local-variables}
Get all local variables for this context, and parent contexts.
Local variables are returned in Semantic tag format.
Be default, this gets local variables, and local arguments.
Optional argument @var{point} is the location to start getting the variables from.
This function can be overloaded (see @dfn{define-mode-local-override} for details).
@end defun

@node Derived Context
@section Deriving the Current Context

While a context has already been used to describe blocks of code,
other context include more local details, such as the symbol the
cursor is on, or the fact we are assigning into some other variable.

These context deriving functions can be overridden to provide language
specific behavior.  By default, it assumes a C like language.

@defun semantic-ctxt-current-symbol &optional point
@anchor{semantic-ctxt-current-symbol}
Return the current symbol the cursor is on at @var{point} in a list.
This will include a list of type/field names when applicable.
This function can be overloaded (see @dfn{define-mode-local-override} for details).
@end defun

@defun semantic-ctxt-current-assignment &optional point
@anchor{semantic-ctxt-current-assignment}
Return the current assignment near the cursor at @var{point}.
Return a list as per @dfn{semantic-ctxt-current-symbol}.
Return @code{nil} if there is nothing relevant.
This function can be overloaded (see @dfn{define-mode-local-override} for details).
@end defun

@defun semantic-ctxt-current-function &optional point
@anchor{semantic-ctxt-current-function}
Return the current function call the cursor is in at @var{point}.
The function returned is the one accepting the arguments that
the cursor is currently in.  It will not return function symbol if the
cursor is on the text representing that function.
This function can be overloaded (see @dfn{define-mode-local-override} for details).
@end defun

@defun semantic-ctxt-current-argument &optional point
@anchor{semantic-ctxt-current-argument}
Return the index of the argument position the cursor is on at @var{point}.
This function can be overloaded (see @dfn{define-mode-local-override} for details).
@end defun

@defun semantic-ctxt-current-thing
@anchor{semantic-ctxt-current-thing}
Calculate a thing identified by the current cursor position.
Calls previously defined @code{semantic-ctxt-current-@dots{}} calls until something
gets a match.  See @dfn{semantic-ctxt-current-symbol},
@dfn{semantic-ctxt-current-function}, and @dfn{semantic-ctxt-current-assignment}
for details on the return value.
@end defun

@defun semantic-ctxt-current-class-list &optional point
@anchor{semantic-ctxt-current-class-list}
Return a list of tag classes that are allowed at @var{point}.
If @var{point} is @code{nil}, the current buffer location is used.
For example, in Emacs Lisp, the symbol after a ( is most likely
a function.  In a makefile, symbols after a : are rules, and symbols
after a $( are variables.
This function can be overloaded (see @dfn{define-mode-local-override} for details).
@end defun

@defun semantic-ctxt-scoped-types &optional point
@anchor{semantic-ctxt-scoped-types}
Return a list of type names currently in scope at @var{point}.
The return value can be a mixed list of either strings (names of
types that are in scope) or actual tags (type declared locally
that may or may not have a name.)
This function can be overloaded (see @dfn{define-mode-local-override} for details).
@end defun

@node Context Analysis
@section Analysis of the current context

The context parsing API is used in a context analysis library.  This
library provides high level routines for scanning through token
databases to create lists of token associates.  At it's core is a set
of EIEIO classes defining a context.  The context contains information
about what was parsed at a given position, such as the strings there,
and they type of assignment.  The analysis library then searches the
databases to determine the types and names available.

Two high level functions which can be run interactively are:

@deffn Command semantic-analyze-current-context &optional position
@anchor{semantic-analyze-current-context}
Analyze the current context at optional @var{position}.
If called interactively, display interesting information about @var{position}
in a separate buffer.
Returns an object based on symbol @dfn{semantic-analyze-context}.

This function can be overriden with the symbol @code{analyze-context}.
When overriding this function, your override will be called while
cursor is at @var{position}.  In addition, your function will not be called
if a cached copy of the return object is found.
This function can be overloaded (see @dfn{define-mode-local-override} for details).
@end deffn


@deffn Command semantic-analyze-possible-completions context
@anchor{semantic-analyze-possible-completions}
Return a list of semantic tags which are possible completions.
@var{context} is either a position (such as point), or a precalculated
context.  Passing in a context is useful if the caller also needs
to access parts of the analysis.
Completions run through the following filters:

@itemize
@item
Elements currently in scope
@item
Constants currently in scope
@item
Elements match the @code{:prefix} in the @var{context}.
@item
Type of the completion matches the type of the context.
@end itemize

Context type matching can identify the following:

@itemize
@item
No specific type
@item
Assignment into a variable of some type.
@item
Argument to a function with type constraints.
@end itemize

When called interactively, displays the list of possible completions
in a buffer.
This function can be overloaded (see @dfn{define-mode-local-override} for details).
@end deffn

@menu
* Analysis Overview::           A description of how the analyzer works.
* Analysis Objects::            What is in the analysis object.
* Completion Overview::         How completions are calculated.
@end menu

@node Analysis Overview
@subsection Analysis Overview

The semantic analysis function @dfn{semantic-analye-current-context}
creates an Analysis Object.  See @ref{Analysis Objects}.  This object
contains many useful pieces of information needed to do any other
kind of intelligent action on the local context.

If you call this function interactively, it will popup a buffer with
a summary of the return value.  This is useful when debugging.

@example
+--------+   +----------------+   +----------------------------+
| Buffer |---| Context Parser |---| Local Context Synax Result |
+--------+   +----------------+   +----------------------------+
    |                                        |
+--------+   +-----------+                   |
| Parser |---| Tag Table |------------+      |
+--------+   +-----------+            |      |
                                      V      V
+-------------+                     +-------------------+
| Semantic DB |-------------------->| Semantic Analyzer |
+-------------+                     +-------------------+
                                             |
                                             V
                                     +-----------------+
                                     | Analysis Object |
                                     +-----------------+
@end example

@node Analysis Objects
@subsection Analysis Objects

@defindex analyze

@c First, delete text between this comment and END OF ANALYZE OBJECT text.
@c 
@c Execute the below line with C-x C-e
@c

@c (progn (require 'semantic-analyze) (eieiodoc-class semantic-analyze-context "analyze"))


@c END OF ANALZE OBJECT SECTION

@node Completion Overview
@subsection Completion Overview


@node App Debugger
@chapter Application level Data structure debugger

The data structures that Semantic provides can be complex, and
figuring out why some level of application API performs incorrectly
can be difficult.

The semantic Application debugger provides a way to look inside the
various data structures of Semantic in a structures and complete way
to help identify what a problem may be.

@section App Debugger Entry Points

There are a few basic functions that enter into the debugger:

@deffn Command semantic-adebug-bovinate
@anchor{semantic-adebug-bovinate}
The same as @dfn{bovinate}. Display the results in a debug buffer.
@end deffn

@deffn Command semantic-adebug-searchdb regex
@anchor{semantic-adebug-searchdb}
Search the semanticdb for @var{regex} for the current buffer.
Display the results as a debug list.
@end deffn

@deffn Command semantic-adebug-analyze
@anchor{semantic-adebug-analyze}
Perform @dfn{semantic-analyze-current-context}.
Display the results as a debug list.
@end deffn

@section adebug-mode

The semantic debugger mode provides a simple user facing UI for
looking into the data structures.

@deffn Command semantic-adebug-mode
@anchor{semantic-adebug-mode}
Major-mode for the Analyzer debugger.

Keybindings:
@table @kbd
@item spc
semantic-adebug-expand-or-contract
@item n
semantic-adebug-next-expando
@item p
semantic-adebug-prev-expando
@item n
semantic-adebug-next
@item p
semantic-adebug-prev
@item <mouse-2>
semantic-adebug-expand-or-contract-mouse
@end table

@end deffn

@section Create new debugger entry commands

Creating a new Application debugger entry point is easy.
First, get a datastructure you need to analyze.

The first function to call is:

@defun semantic-adebug-new-buffer name
@anchor{semantic-adebug-new-buffer}
Create a new adebug buffer with @var{name}.
@end defun

Next, you need to find the correct function for inserting your
datastructure.  All adebug insertion functions are of the form
@code{semantic-adebug-insert-THING}, where @var{thing} is whatever you
object is.  Use Emacs help to pick something out.


@node GNU Free Documentation License
@appendix GNU Free Documentation License

@include fdl.texi

@node Index
@unnumbered Index
@printindex cp

@iftex
@contents
@summarycontents
@end iftex

@bye

@c Following comments are for the benefit of ispell.