aboutsummaryrefslogtreecommitdiff
path: root/gdb/parser-defs.h
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2021-03-08 07:27:57 -0700
committerTom Tromey <tom@tromey.com>2021-03-08 07:28:37 -0700
commit4933522da0d59823d2bfef3706e2252203365e9c (patch)
tree6d388690c17f9c42a69005c8a59d5dcb7bf23516 /gdb/parser-defs.h
parent413403fc34156cf695b09553fca91e0990520787 (diff)
downloadgdb-4933522da0d59823d2bfef3706e2252203365e9c.zip
gdb-4933522da0d59823d2bfef3706e2252203365e9c.tar.gz
gdb-4933522da0d59823d2bfef3706e2252203365e9c.tar.bz2
Add completion for operations
This patch adds the necessary support for field name completion for expressions using class operation. This patch takes an approach similar to what is done today. It might be good, in the future, to change completion to be a method on the base class, to enable context-sensitive completion in more areas. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * parser-defs.h (struct expr_completion_state) <expout_last_op>: New member. (struct parser_state) <mark_struct_expression>: New method. * parse.c (parser_state::mark_struct_expression): Update assert. (parser_state::mark_struct_expression): New method. (parser_state::mark_completion_tag): Update assert. (parse_expression_for_completion): Handle expout_last_op.
Diffstat (limited to 'gdb/parser-defs.h')
-rw-r--r--gdb/parser-defs.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h
index a9ae198..9f70ff9 100644
--- a/gdb/parser-defs.h
+++ b/gdb/parser-defs.h
@@ -25,6 +25,7 @@
#include "expression.h"
#include "symtab.h"
+#include "expop.h"
struct block;
struct language_defn;
@@ -93,6 +94,11 @@ struct expr_completion_state
field name. It is -1 if no dereference operation was found. */
int expout_last_struct = -1;
+ /* The last struct expression directly before a '.' or '->'. This
+ is set when parsing and is only used when completing a field
+ name. It is nullptr if no dereference operation was found. */
+ expr::structop_base_operation *expout_last_op = nullptr;
+
/* If we are completing a tagged type name, this will be nonzero. */
enum type_code expout_tag_completion_type = TYPE_CODE_UNDEF;
@@ -156,6 +162,11 @@ struct parser_state : public expr_builder
void mark_struct_expression ();
+ /* Mark the given operation as the starting location of a structure
+ expression. This is used when completing on field names. */
+
+ void mark_struct_expression (expr::structop_base_operation *op);
+
/* Indicate that the current parser invocation is completing a tag.
TAG is the type code of the tag, and PTR and LENGTH represent the
start of the tag name. */