On Wed, Jan 17, 2018 at 5:30 AM, vitalije <[email protected]> wrote:

Well, obviously we don't agree on what "reasonably" imported code look
> like. I have had encountered dozens of js files that *are* imported
> correctly in terms that they can be written again with the file content
> unchanged, but they all suffered from creating too many or too few nodes
> and I had to import them by hand.
>

​There are many styles of writing javascript, including many styles of
writing javascript classes.  So your comment about needing​ AI to do the
import makes sense.

Imo this is not such a big deal, because the initial import can always be
massaged.  Indeed, the import code is used only in the these cases:

1. The explicit import commands.
2. When reading @auto nodes.
3. When executing the parse-body command.
4. When executing c.recursiveImport.

After the import, no matter how good or bad, you can always convert the
tree to @file or @clean, and make any desired change *permanently.*

Attached to this message are two files one Leo file trying to import the
> other js file. Put them in the same folder and try import. It fails,
>

​I'll open a new issue for this.
​

> it leaves a lot of created nodes with arguably ugly names. No developer
> would ever name those nodes like importer does,
>

​This can be fixed by changing js_i.clean_headline.  In fact, changing "if
1:" to "if 0:" will probably result in something more to your liking.
Perhaps a way of personalizing this method would be good.​

nor he would structure the tree like that if he were creating that file
> using Leo from the beginning.  For me, reasonably imported file must be
> something close to what a developer would have if he wrote the same source
> file directly in Leo.
>

​That may be true, but now we are in the realm of true javascript
expertise, something that *on purpose* I did not build into the js importer.

All of Leo's importers (with one or two exceptions) now use a pipeline
architecture.  See importers/linescanner.py, the node "i.The pipeline".
There are 5 stages in this pipeline, stages 0 through 4.  Stage 2 is a post
pass, executed after all nodes have been created.

Again, it might be good to allow per-user extensions to the per-language
post pass.  In the meantime, you could write your own AI-inspired postpass
after, say, calling c.recursiveImport.

So, I can partially agree that current implementation of js importer can
> import some of the source files, but I personally find those imports
> useless most of the time. I have to reshape the tree so much that it turned
> to be more efficient to import whole file in one node and then to extract
> pieces by hand.
>

​Are you sure your own post-pass wouldn't be able to clean things up to
your liking?

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 [email protected].
To post to this group, send email to [email protected].
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