In the month and a half since my last [unanswered] post, I have devised a partial answer to my own question, but I still have a problem. In the following I describe my objective, show [some of] my working code so far, and then as my real question.
OBJECTIVE: Using SYNTAX_UPDATER_VISITOR as a model, I want to process a class, inserting some code after a qualified call that is not: 1) in the condition of an "if" or "elseif" statement, 2) not in an assertion, 3) not in an assignment statement, 4) not in a loop condition, 5) not an argument to another call, and 6) in other constructs I have not thought about yet.
object.qualified_call -- visitor should insert code after this line
call (object.qualified_call) -- BUT NOT AFTER THIS LINE (case 5)
object.encode -- New text inserted by visitor
WORKING CODE: The code below shows some of what I do so far. Feature `process_access_id_as' sets `target_text' whenever an identifier is encountered; `target_text' is used in `process_access_feature_as' to generate the string to be inserted. In order to handle case number 5 (result of qualified call used as argument to a call), `process_parameter_list_as' sets `is_processing_parameter_list' to true and then when then `process_access_feature_as' can check `is_processing_parameter_list'. (The if statement checks other cases as well, which are handled similarly.)
process_access_id_as (l_as: ACCESS_ID_AS)
-- Redefined to capture the `target' of a feature call for use
-- in `process_access_feat_as'.
-- This could be in a feature call or in an assignment statement
target_text := l_as.access_name_8
-- Is a parameter list being processed?
process_parameter_list_as (l_as: PARAMETER_LIST_AS)
is_processing_parameter_list := true
is_processing_parameter_list := false
process_access_feat_as (l_as: ACCESS_FEAT_AS)
-- Redefined to add code after a qualified feature call
if not is_in_condition and
not is_loop_condition and
not is_processing_assignment and
not is_processing_check and
not is_processing_parameter_list and
l_as.is_qualified and attached target then
s := target.access_name_8
if s.as_lower /~ "result" then
context.add_string (s + ".on_encode")
target := Void
QUESTION: How do I make this work for a qualified call on Current?
Current.call -- Visitor should insert code after this line
process_keyword_as (l_as: KEYWORD_AS)
-- Redefined to capture the `target' of a qualified feature call when
-- the target is "Current"; for use in `process_access_feature_as'.
-- (e.g. Current.do_something)
if l_as.is_note_keyword then
target_text := "note"
if l_as.is_current_keyword then
target_text := "Current"
In the above the "note" keyword, as an example, is processed but the "Current" keyword is not (ie. the if statement, "if l_as.is_current_keyword" is always false). Why?
Jimmy J. Johnson