On Wednesday, April 5, 2017 at 12:10:51 PM UTC-5, Edward K. Ream wrote:

​The new plan is for all callers of ic.createOutline to set up the root 
> node for the import, and then call a simper version of ic.createOutline.
>

This has been a great success.  Rev b11b62 of the "import" branch contains 
the present code.

More simplifications are coming, as described later, but first let me recap 
what has already happened.

1. All the horrible logic in ic.init_import was actually a test that 
ic.createOutline had been called from ic.scannerUnitTest(!). So the fix was 
to create a new helper, ic.compute_unit_test_kind, called only from 
ic.scannerUnitTest. Bye, bye, evil "if" statement.

2. ic.createOutline no longer creates any node.  Two callers, 
ic.scannerUnitTest and ic.importFilesCommand now create a node if 
required.  The code is straightforward.  As an additional bonus, only 
ic.importFilesCommand supports undo, which speeds up unit tests a bit.


*To do: eliminate the atAuto switch*
Last night I went to bed thinking that this would be the end of work in the 
branch.  But when I awoke I saw an opportunity to eliminate what has become 
a mysterious blemish in Leo's API, namely various atAuto switches that 
appear *unexpectedly* in Leo's code. Eliminating this "huh?" is way too 
good to ignore.

After the recent simplifications, the atAuto keyword arg to 
ic.createOutline can now be seen to have two quite different purposes:

A. The atAuto keyword arg is passed to ic.setEncoding, which uses 
c.config.default_at_auto_file_encoding as a default.

B. ic.init_import uses the atAuto and atShadow keyword args to create error 
messages. That's the *only* use for the atShadow keyword arg!

This suggests that the atAuto and atShadow keyword args should be replaced 
by args that more clearly indicate how they are used, namely "encoding" and 
"errorKind" args.

*Important*: the atAuto switch is no longer horribly confusing in the 
*direct* callers of ic.createOutline.  However, it becomes extremely 
confusing (the dreaded "huh?") when *back propagated* to the callers of 
ic.scannerUnitTest.  This ends up "infecting" all unit tests for importers 
with a mysterious atAuto keyword.

In short, the atAuto switch started life as something innocent, but became 
mysterious later as the result of being back propagated to more and more 
methods.  It became an infection. It will be worth considerable work to get 
rid of this "huh?" in the code.

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to