aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorChong Yidong2009-11-28 21:09:00 +0000
committerChong Yidong2009-11-28 21:09:00 +0000
commitfd1cefda5892e57f9d2c9dd264e24a9f878346d0 (patch)
tree5a91f1289767735d85167c9e61217ca2dad244cf /doc
parent26224fafa0c504defeff50909e887ea48b06353b (diff)
downloademacs-fd1cefda5892e57f9d2c9dd264e24a9f878346d0.tar.gz
emacs-fd1cefda5892e57f9d2c9dd264e24a9f878346d0.zip
* semantic.texi (Analyzer Internals): Rename from Analyzer.
* sem-user.texi (Semantic mode user commands): Fix key syntax. Document semantic-complete-analyze-inline. (Semanticdb search debugging commands): Minor clarification. (Analyzer, Smart Completion, Smart Summary, Smart Jump) (Analyzer Debug) New nodes, adapted from the upstream Semantic user manual.
Diffstat (limited to 'doc')
-rw-r--r--doc/misc/ChangeLog11
-rw-r--r--doc/misc/sem-user.texi385
-rw-r--r--doc/misc/semantic.texi12
3 files changed, 380 insertions, 28 deletions
diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog
index 261a0daeb8f..ee85ec2a2ec 100644
--- a/doc/misc/ChangeLog
+++ b/doc/misc/ChangeLog
@@ -1,3 +1,14 @@
12009-11-28 Chong Yidong <cyd@stupidchicken.com>
2
3 * semantic.texi (Analyzer Internals): Rename from Analyzer.
4
5 * sem-user.texi (Semantic mode user commands): Fix key syntax.
6 Document semantic-complete-analyze-inline.
7 (Semanticdb search debugging commands): Minor clarification.
8 (Analyzer, Smart Completion, Smart Summary, Smart Jump)
9 (Analyzer Debug) New nodes, adapted from the upstream Semantic user
10 manual.
11
12009-11-28 Kevin Ryde <user42@zip.com.au> 122009-11-28 Kevin Ryde <user42@zip.com.au>
2 13
3 * cl.texi (Porting Common Lisp): Update EIEIO dead ftp link to a 14 * cl.texi (Porting Common Lisp): Update EIEIO dead ftp link to a
diff --git a/doc/misc/sem-user.texi b/doc/misc/sem-user.texi
index dfca1a09295..582ffb9103b 100644
--- a/doc/misc/sem-user.texi
+++ b/doc/misc/sem-user.texi
@@ -28,6 +28,7 @@ File,,,emacs,Emacs manual}.
28* Semantic mode:: Global minor mode for @semantic{}. 28* Semantic mode:: Global minor mode for @semantic{}.
29* SemanticDB:: Caching parsed buffers between sessions. 29* SemanticDB:: Caching parsed buffers between sessions.
30* Idle Scheduler:: Performing @semantic{} operations when idle. 30* Idle Scheduler:: Performing @semantic{} operations when idle.
31* Analyzer:: Semantic tools for analyzing code.
31@end menu 32@end menu
32 33
33@node Semantic mode 34@node Semantic mode
@@ -107,64 +108,70 @@ Others act on the @dfn{current tag}, meaning the tag at (or around)
107point. 108point.
108 109
109@table @kbd 110@table @kbd
110@item \C-c , j 111@item C-c , j
111Prompt for a tag defined in the current file, and move point to it 112Prompt for a tag defined in the current file, and move point to it
112(@code{semantic-complete-jump-local}). 113(@code{semantic-complete-jump-local}).
113 114
114@item \C-c , J 115@item C-c , J
115Prompt for a tag defined in any file that Emacs has parsed, and move 116Prompt for a tag defined in any file that Emacs has parsed, and move
116point to it (@code{semantic-complete-jump}). 117point to it (@code{semantic-complete-jump}).
117 118
118@item \C-c , l 119@item C-c , l
119Display a list of the possible completions of the current tag 120Display a list of the possible completions of the current tag
120(@code{semantic-analyze-possible-completions}). 121(@code{semantic-analyze-possible-completions}).
121 122
122@item \C-c , g 123@item C-c , g
123Prompt for a tag, and display a list of tags that call it 124Prompt for a tag, and display a list of tags that call it
124(@code{semantic-symref-symbol}). 125(@code{semantic-symref-symbol}).
125 126
126@item \C-c , G 127@item C-c , G
127Display a list of tags that call the current tag 128Display a list of tags that call the current tag
128(@code{semantic-symref}). 129(@code{semantic-symref}).
129 130
130@item \C-c , p 131@item C-c , p
131Move point to the previous tag (@code{senator-previous-tag}). 132Move point to the previous tag (@code{senator-previous-tag}).
132 133
133@item \C-c , n 134@item C-c , n
134Move point to the next tag (@code{senator-next-tag}). 135Move point to the next tag (@code{senator-next-tag}).
135 136
136@item \C-c , u 137@item C-c , u
137Move point ``up'' one reference (@code{senator-go-to-up-reference}). 138Move point ``up'' one reference (@code{senator-go-to-up-reference}).
138The meaning of ``up'' is language-dependent; in C++, for instance, 139The meaning of ``up'' is language-dependent; in C++, for instance,
139this means moving to the parent of the current tag. 140this means moving to the parent of the current tag.
140 141
141@item \C-c, @key{SPC} 142@item C-c, @key{SPC}
142(@code{semantic-complete-analyze-inline}) 143Display a list of possible completions for the symbol at point
144(@code{semantic-complete-analyze-inline}). This also activates a
145special set of keybindings for choosing a completion: @key{RET}
146accepts the current completion, @kbd{M-n} and @kbd{M-p} cycle through
147possible completions, @key{TAB} completes as far as possible and then
148cycles, and @kbd{C-g} or any other key aborts the completion.
149@xref{Smart Completion}.
143 150
144@item \C-c,\C-w 151@item C-c , C-w
145Kill the current tag (@code{senator-kill-tag}). This removes the text 152Kill the current tag (@code{senator-kill-tag}). This removes the text
146for that tag, placing it in the kill ring. You can retrieve the text 153for that tag, placing it in the kill ring. You can retrieve the text
147with @kbd{C-y}. This also places the tag in the @dfn{tag ring}, so 154with @kbd{C-y}. This also places the tag in the @dfn{tag ring}, so
148that you can yank it with @kbd{\C-c,\C-y}, below. 155that you can yank it with @kbd{\C-c,\C-y}, below.
149 156
150@item \C-c,\M-w 157@item C-c , M-w
151Copy the current tag into the kill ring as well as the tag ring 158Copy the current tag into the kill ring as well as the tag ring
152(@code{senator-copy-tag}). 159(@code{senator-copy-tag}).
153 160
154@item \C-c,\C-y 161@item C-c , C-y
155Yank a tag from the tag ring (@code{senator-yank-tag}). 162Yank a tag from the tag ring (@code{senator-yank-tag}).
156 163
157@item \C-c,r 164@item C-c , r
158Copy the current tag into a register 165Copy the current tag into a register
159(@code{senator-copy-tag-to-register}). With an optional argument, 166(@code{senator-copy-tag-to-register}). With an optional argument,
160kill it as well. This allows you to insert or jump to that tag with 167kill it as well. This allows you to insert or jump to that tag with
161the usual register commands. @xref{Registers,,,emacs,Emacs manual}. 168the usual register commands. @xref{Registers,,,emacs,Emacs manual}.
162 169
163@item ?\C-c , @kbd{up} 170@item \C-c , @kbd{up}
164Transpose the current tag with the previous one 171Transpose the current tag with the previous one
165(@code{senator-transpose-tags-up}). 172(@code{senator-transpose-tags-up}).
166 173
167@item ?\C-c ?, @kbd{down} 174@item C-c , @kbd{down}
168Transpose the current tag with the next one 175Transpose the current tag with the next one
169(@code{senator-transpose-tags-down}). 176(@code{senator-transpose-tags-down}).
170@end table 177@end table
@@ -433,7 +440,6 @@ You can use @kbd{M-x semanticdb-dump-all-table-summary} to see the
433list of databases that will be searched from a given buffer. You can 440list of databases that will be searched from a given buffer. You can
434follow up with @kbd{M-x semanticdb-find-test-translate-path} to then 441follow up with @kbd{M-x semanticdb-find-test-translate-path} to then
435make sure specific tables from the path are discovered correctly. 442make sure specific tables from the path are discovered correctly.
436
437Alternately, you can get a list of include files @semantic{} 443Alternately, you can get a list of include files @semantic{}
438encountered, but could not find on disk using @kbd{M-x 444encountered, but could not find on disk using @kbd{M-x
439semanticdb-find-adebug-lost-includes}. 445semanticdb-find-adebug-lost-includes}.
@@ -443,10 +449,11 @@ semanticdb-find-adebug-lost-includes}.
443Dump a list of all databases in Emacs memory. 449Dump a list of all databases in Emacs memory.
444@end deffn 450@end deffn
445 451
446@deffn Command semanticdb-find-test-translate-path &optional arg
447@anchor{semanticdb-find-test-translate-path} 452@anchor{semanticdb-find-test-translate-path}
448Call and output results of @dfn{semanticdb-find-translate-path} 453@deffn Command semanticdb-find-test-translate-path &optional arg
449With @var{arg} non-@code{nil}, specify a @var{brutish} translation. 454Call and output results of @dfn{semanticdb-find-translate-path}. In
455the displayed buffer, you can type @key{SPC} to expand items. With
456@var{arg} non-@code{nil}, specify a @var{brutish} translation.
450@end deffn 457@end deffn
451 458
452@deffn Command semanticdb-find-adebug-lost-includes 459@deffn Command semanticdb-find-adebug-lost-includes
@@ -681,8 +688,8 @@ Semantic Idle Completions mode is a minor mode for performing
681displayed inline, with keybindings that allow you to cycle through 688displayed inline, with keybindings that allow you to cycle through
682different alternatives. 689different alternatives.
683 690
684@c @xref{Analyzer}, for information about code 691Semantic Idle Completions mode performs completion based on the
685@c completion. 692Semantic Analyzer (@pxref{Analyzer}).
686 693
687@anchor{global-semantic-idle-completions-mode} 694@anchor{global-semantic-idle-completions-mode}
688@anchor{semantic-idle-completions-mode} 695@anchor{semantic-idle-completions-mode}
@@ -761,3 +768,337 @@ Display completions in a tooltip.
761Display completions in a separate window. 768Display completions in a separate window.
762@end table 769@end table
763@end deffn 770@end deffn
771
772@node Analyzer
773@section Analyzer
774@cindex Analyzer
775
776The Semantic Analyzer is a library for performing context analysis on
777source code. It provides user commands for displaying, completing,
778and navigating through source code.
779
780@menu
781* Smart Completion:: Performing code completion.
782* Smart Summary:: Displaying help on a symbol.
783* Smart Jump:: Jumping to the definition of a tag.
784* Analyzer Debug:: Debugging problems with the analyzer.
785@end menu
786
787@node Smart Completion
788@subsection Smart Completion
789
790The Semantic Analyzer can be used to perform code completion in a
791manner that takes the local context into account.
792
793In addition to the user commands documented in this section, the
794completions performed by Semantic Idle Completions mode also uses the
795Semantic Analyzer. @xref{Idle Completions Mode}.
796
797@deffn Command semantic-analyze-possible-completions context
798This is the most basic command for Semantic Analyzer-based completion.
799Called interactively, it displays in another window a list of the
800possible completions for the symbol at point.
801
802When called from a Lisp program,
803@code{semantic-analyze-possible-completions} does not display a
804completions list. The argument @var{context} should be either a
805buffer position, or a context object. The return value is a list of
806@semantic{} tag objects that complete the symbol for @var{context},
807based on the following criteria:
808
809@itemize
810@item Elements currently in scope.
811@item Constants currently in scope.
812@item Elements matching the context's @code{:prefix}.
813@item Type of the completion matching the type of the context.
814@end itemize
815
816Most of the other commands documented in this section call
817@code{semantic-analyze-possible-completions} internally.
818@end deffn
819
820@anchor{semantic-complete-analyze-inline}
821@deffn Command semantic-complete-analyze-inline
822This command is bound to @kbd{C-c , @key{SPC}} when Semantic mode is
823enabled (@pxref{Semantic mode user commands}). It displays a list of
824possible completions for the symbol at point, and activates a special
825set of keybindings for choosing a completion.
826
827You can type @key{RET} to accept the current completion, @kbd{M-n} and
828@kbd{M-p} to cycle through the possible completions, @key{TAB} to
829complete as far as possible and then cycle through completions, and
830either @kbd{C-g} or any other key to abort the completion.
831
832This command is similar to the completion performed by Semantic Idle
833Completions mode. The main difference is that it is called
834explicitly, whereas Semantic Idle Completions mode completes during
835idle time (@pxref{Idle Completions Mode}).
836@end deffn
837
838@anchor{semantic-complete-inline-analyzer-displayor-class}
839@deffn Option semantic-complete-inline-analyzer-idle-displayor-class
840The value of this variable determines how
841@code{semantic-complete-analyze-inline} shows its completions.
842Possible values include:
843
844@table @code
845@item semantic-displayor-traditional
846Display completions in a separate window. This is the default value.
847
848@item semantic-displayor-ghost
849Display completions ``inline'' with the buffer text, similar to the
850default behavior of Semantic Idle Completions mode (@pxref{Idle
851Completions Mode}).
852
853@item semantic-displayor-tooltip
854Display completions in a tooltip.
855@end table
856@end deffn
857
858In addition to @code{semantic-complete-analyze-inline}, you can use
859the simpler command @code{semantic-ia-complete-symbol point}. This
860behaves like the usual @kbd{M-@key{TAB}} (@code{complete-symbol})
861command (@pxref{Symbol Completion,,,emacs,Emacs manual}), except it
862uses Semantic Analyzer.
863
864@anchor{semantic-ia-complete-symbol}
865@deffn Command semantic-ia-complete-symbol point
866Complete the current symbol at @var{point}.
867@end deffn
868
869@node Smart Summary
870@subsection Smart Summary
871
872You can use the commands in this section to find information about the
873code at point:
874
875@anchor{semantic-ia-show-summary}
876@deffn Command semantic-ia-show-summary pos
877Display a summary for the symbol at @var{pos}. Called interactively,
878@var{pos} defaults to point.
879@end deffn
880
881@anchor{semantic-ia-show-doc}
882@deffn Command semantic-ia-show-doc pos
883Display the code-level documentation for the symbol at @var{pos}.
884Called interactively, @var{pos} defaults to point.
885@end deffn
886
887@anchor{semantic-ia-describe-class}
888@deffn Command semantic-ia-describe-class typename
889Prompt for the name of a data type, @var{typename}, and display its
890components. For instance, if the type in question is a class, this
891displays the methods and member variables.
892@end deffn
893
894You can also use Semantic Idle Summary mode to show information about
895the current symbol in the echo area during idle time. @xref{Idle
896Summary Mode}.
897
898@node Smart Jump
899@subsection Smart Jump
900
901The Semantic Analyzer can be used to jump directly to the definition
902for a code symbol. Because it is based on code analysis, its behavior
903is often more accurate than than the @code{find-tag} command
904(@pxref{Tags,,,emacs,Emacs manual}).
905
906@anchor{semantic-ia-fast-jump}
907@deffn Command semantic-ia-fast-jump pos
908Jump to the definition for the symbol at @var{pos}. Called
909interactively, @var{pos} defaults to point.
910@end deffn
911
912@anchor{semantic-ia-fast-mouse-jump}
913@defun semantic-ia-fast-mouse-jump event
914Jump to the definition for the symbol at the position of the mouse
915event @var{event}. This command is meant to be bound to a mouse
916command, like this:
917
918@example
919(global-set-key '[(S-mouse-1)] semantic-ia-fast-mouse-jump)
920@end example
921@end defun
922
923You can also use @kbd{C-c , j} (@code{semantic-complete-jump-local})
924and @kbd{C-c , J} (@code{semantic-complete-jump}) to navigate tags.
925@xref{Semantic mode user commands}. Those commands do not make use of
926the Semantic Analyzer.
927
928@node Analyzer Debug
929@subsection Debugging the Semantic Analyzer
930
931In the event that the Semantic Analyzer does not analyze your code
932properly, you can take steps to identify and solve the problem. This
933section was written with C/C++ in mind, but should be relevant for any
934typed language.
935
936@subsubsection Step 1: Check the context
937
938The first thing to do is check the current context. You can do this
939with @kbd{M-x semantic-analyze-current-context}.
940
941@deffn Command semantic-analyze-current-context pos
942Analyze the context at @var{pos}. This function is used by most of
943the other Semantic Analyzer commands to obtain the context of the code
944at a given buffer position. The return value is an EIEIO object
945describing the context at @var{pos} (@pxref{Top,,,eieio,EIEIO
946manual}).
947
948When called interactively, this displays a @samp{*Semantic Context
949Analysis*} buffer in a separate window. This buffer contains a
950summary of the context at point.
951@end deffn
952
953The Prefix section of the @samp{*Semantic Context Analysis*} buffer
954lists the tags based on the text at point. If it shows only a simple
955string, the Semantic was unable to identify what the data type was.
956
957The first item in the list of the prefix is the first lookup failure
958in the chain, and that is the item to focus debugging effort on. For
959example:
960
961@example
962Context Type: #<semantic-analyze-context context>
963Bounds: (182 . 185)
964Prefix: Foo* bar
965 int bbb (const char* y)
966Prefix Types: class Foo @{@}
967--------
968-> Local Vars: int argc
969 char** argv
970@end example
971
972In this example you can see that the prefix has two fully found tags.
973In the following example, the symbol ``bbb'' is incomplete, and could
974not be found:
975
976@example
977Context Type: #<semantic-analyze-context context>
978Bounds: (182 . 184)
979Prefix: Foo* bar
980 "bb"
981Prefix Classes: 'function
982 'variable
983Prefix Types: class Foo @{@}
984--------
985-> Local Vars: int argc
986 char** argv
987@end example
988
989@subsubsection Step 2 : Check your include path
990
991Once you know what symbol can't be found, the next thing to check is
992your include path. Is the header or include file that has the
993definitions you need actually in the list of headers @semantic{} is
994searching through? To get a basic list, you can use @kbd{M-x
995semanticdb-find-test-translate-path}. @xref{Semanticdb search
996debugging commands}.
997
998For C++, check to make sure that your project level include files are
999in quotes, and not angle brackets. Items in angle brackets are system
1000includes.
1001
1002If items should be loaded but aren't, you may need to update the
1003search throttle. @xref{Search Throttle}. If you see some tables that
1004have 0 tags in them, then you you may have an incorrectly set
1005throttle. For example,
1006
1007@example
1008*#<semanticdb-table main.cpp (4 tags DIRTY)>
1009*#<semanticdb-table foo.hh (0 tags DIRTY)>
1010@end example
1011
1012Here, @semantic{} found @file{foo.hh}, but there are 0 tags. This may
1013be because the throttle was set to not read in and parse files that
1014Emacs has not yet loaded in. To fix this case, visit the file, and
1015let @semantic{} parse and save the tags table.
1016
1017@subsubsection Step 3: Check the local scope
1018
1019If your data type is somehow abbreviated based on scope, such as from
1020a @code{using} statement, you should make sure that the symbol you
1021want is in the local scope. Examine the scope with @kbd{M-x
1022semantic-calculate-scope}. The scope structure is displayed in ADEBUG
1023mode, so use @kbd{SPC} to expand different elements and looking for
1024your symbol.
1025
1026If your symbol should be in the scope, but you cannot find it, then
1027you may have found a language support bug in the local-variable
1028parser, or using statement parser.
1029
1030Calling @kbd{M-x bovinte} should force a reset on the scope in case
1031there is merely some bad state.
1032
1033@example
1034 ] Name: Cache
1035 ] Class: #'semantic-scope-cache
1036 ] :table #<semanticdb-table testsubclass.cpp (13 tags DIRTY)>
1037 ] tag createMoose : class moose
1038 ] scopetypes 'nil
1039 ] parents #<TAG LIST: 1 entries>
1040 ] scope #<TAG LIST: 22 entries>
1041 ] fullscope #<TAG LIST: 23 entries>
1042 ] localvar #<TAG LIST: 6 entries>
1043@end example
1044
1045In the above sample output, the @code{tag} slot specifies where within
1046you source this scope is relevant. @code{Parents} should contain any
1047in scope parents, such as the class a method belongs to.
1048@code{Localvar} should contain your local variables. @code{Scope}
1049should contain datatypes in scope due to a @code{using} statement or
1050the like.
1051
1052@subsubsection Step 4: Check the typecache
1053
1054For complex typed languages like C++, @semantic{} creates a typecache,
1055or an optimized search table with all the various data types in it.
1056Elements in the typecache do not obey local scope. It only contains
1057fully qualified names. You can examine the typecache with
1058@kbd{M-x semanticdb-typecache-dump}.
1059
1060If your data types are not in the typecache, there may be some parsing
1061error or other bug. Calling @kbd{M-x bovinte} should force a reset on
1062the typecache in case there is merely some bad state.
1063
1064@example
1065]#<semanticdb-typecache /home/zappo/cedet/semantic/tests/testsubclass.cpp>
1066 ] Name: /home/zappo/cedet/semantic/tests/testsubclass.cpp
1067 ] Class: #'semanticdb-typecache
1068 ] filestream 'nil
1069 ] includestream #<TAG LIST: 84 entries>
1070 ] stream 'nil
1071 ] dependants 'nil
1072@end example
1073
1074In the above example, the output of @kbd{M-x semanticdb-typecache-dump}
1075was expanded one level. The @code{filestream} slot should contain
1076datatypes in the current file. The @code{includestream} should
1077contain all the datatypes in all included header files.
1078
1079The @code{dependants} slot will specify other files that depend on
1080this one.
1081
1082@section Step 5: Check the parser
1083
1084Go to the location where your unfound tag should be. You can call
1085@kbd{M-x bovinate}, and see a dump of the raw tag structure. To see a
1086navigable tree, use @kbd{M-x semantic-adebug-bovinate} instead. You
1087can then look to make sure your tag has been properly parsed.
1088
1089If it has not, then you may have found a parser bug. To get a feel
1090how @semantic{} treats your file, type @kbd{M-x
1091global-semantic-show-unmatched-syntax-mode}. This causes any syntax
1092it cannot parse to be underlined in red.
1093
1094If your type is not parsable, it could be for a couple of reasons:
1095
1096@enumerate
1097@item
1098If there is a MACRO keyword used in the definition of the type, you
1099may need to update the @code{semantic-lex-c-preprocessor-symbol-map}
1100to account for it.
1101
1102@item
1103Or perhaps the parser needs to be fixed.
1104@end enumerate
diff --git a/doc/misc/semantic.texi b/doc/misc/semantic.texi
index 064f1a6e3ae..b880f1a20fc 100644
--- a/doc/misc/semantic.texi
+++ b/doc/misc/semantic.texi
@@ -240,8 +240,8 @@ more about how @semantic{} works.
240@menu 240@menu
241* Parser code :: Code used for the parsers 241* Parser code :: Code used for the parsers
242* Tag handling :: Code used for manipulating tags 242* Tag handling :: Code used for manipulating tags
243* Semanticdb internals :: Code used in the semantic database 243* Semanticdb Internals :: Code used in the semantic database
244* Analyzer :: Code used in the code analyzer 244* Analyzer Internals :: Code used in the code analyzer
245* Tools :: Code used in user tools 245* Tools :: Code used in user tools
246* Tests :: Code used for testing 246* Tests :: Code used for testing
247@end menu 247@end menu
@@ -349,8 +349,8 @@ Capture documentation comments from near a tag.
349 349
350@end table 350@end table
351 351
352@node Semanticdb internals 352@node Semanticdb Internals
353@section Semanticdb internals 353@section Semanticdb Internals
354 354
355@acronym{Semanticdb} complexity is certainly an issue. It is a rather 355@acronym{Semanticdb} complexity is certainly an issue. It is a rather
356hairy problem to try and solve. 356hairy problem to try and solve.
@@ -400,8 +400,8 @@ need to be flushed. References are in the form of include files.
400 400
401@end table 401@end table
402 402
403@node Analyzer 403@node Analyzer Internals
404@section Analyzer 404@section Analyzer Internals
405 405
406The @semantic{} analyzer is a complex engine which has been broken 406The @semantic{} analyzer is a complex engine which has been broken
407down across several modules. When the @semantic{} analyzer fails, 407down across several modules. When the @semantic{} analyzer fails,