Re: ENB: possible improvements to javascript importer

2018-02-15 Thread Edward K. Ream


On Thursday, February 15, 2018 at 6:57:28 AM UTC-6, Edward K. Ream wrote:
 
> 1. As Vitalije points out, headlines for functions are too cluttered...

> 2. The js importer botches leovue/src/components/viewgrid.js.

The newly-created #723  
addresses these two problems.

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.


Re: ENB: possible improvements to javascript importer

2018-02-15 Thread Edward K. Ream
On Thursday, February 8, 2018 at 12:01:27 PM UTC-6, Edward K. Ream wrote:
>
> Vitalije has rightly complained about the present javascript importer.
>

And now I'm complaining ;-)

1. As Vitalije points out, headlines for functions are too cluttered.  This 
will be relatively easy to fix

2. The js importer botches leovue/src/components/viewgrid.js. This will be 
significantly harder to fix.

I have refactored this code into the following four nodes:

1. app.config

app.config([
  'formioComponentsProvider',
  function(formioComponentsProvider) {
<< provider >>
  }
]);

2. app.directive

app.directive('viewgridBuilder', function($parse, FormioUtils) {
  // [snip: a long function]
});

3. app.run

app.run([
  '$templateCache',
  function($templateCache) {
// [snip: another long function]
);
  }
]);

4. // The View Template
app.run([
  '$templateCache',
  function($templateCache) {
// [snip: a shorter function]
  }
]);

Yes, 1 through 4 are calls containing function definitions.  And yes, 3 and 
4 are calls to the same function.

And, big sigh, #639  
says that the js importer should *not* generate section references.

At present, I have no great ideas about how to continue.  At present, the 
js importer does not consider square brackets when "allocating" lines to 
nodes.  Perhaps it should.

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.


Re: ENB: possible improvements to javascript importer

2018-02-09 Thread Edward K. Ream
On Friday, February 9, 2018 at 8:43:43 AM UTC-6, Edward K. Ream wrote:

Rev e3d9636 improves js_i.starts_block as follows.  It appears to work well.

func_patterns = [
re.compile(r'\)\s*=>\s*\{'),
re.compile(r'\bclass\b'),
re.compile(r'\bfunction\b'),
]

def starts_block(self, i, lines, new_state, prev_state):
'''True if the new state starts a block.'''
if new_state.level() <= prev_state.level():
return False
line = lines[i]
for pattern in self.func_patterns:
if pattern.search(line) is not None:
return True
return False

Let me know if other patterns should be included.

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.


Re: ENB: possible improvements to javascript importer

2018-02-09 Thread Edward K. Ream
On Thursday, February 8, 2018 at 12:01:27 PM UTC-6, Edward K. Ream wrote:

We can see the problem in the electron "hello world" javascript code.  The 
> importer fails to recognize these two event handlers:
>
> app.on('window-all-closed', () => {
>   // whatever
> })
>
> app.on('activate', () => {
>   // whatever
> })
>
> The fault lies in js_i.starts_block.  It only recognizes the start of a 
> function if a line that increases the { level *also* contains the word 
> "function".  Clearly, it should use a more sophisticated pattern matcher.
>

> In general, recognizing js functions is hard because there are many ways 
> to start functions/methods in javascript. 
>

Well, it's no good whinging about javascript syntax. Invention is required.

js_i.starts_block return True if the line should start a new node.  It 
might more profitably look for lines that *don't/can't* start a function.  
But this seems like a dubious idea now that I look into it.

In the example given above, looking for '=>' would work...

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.


ENB: possible improvements to javascript importer

2018-02-08 Thread Edward K. Ream
Vitalije has rightly complained about the present javascript importer.

We can see the problem in the electron "hello world" javascript code.  The 
importer fails to recognize these two event handlers:

app.on('window-all-closed', () => {
  // whatever
})

app.on('activate', () => {
  // whatever
})

The fault lies in js_i.starts_block.  It only recognizes the start of a 
function if a line that increases the { level *also* contains the word 
"function".  Clearly, it should use a more sophisticated pattern matcher.

In general, recognizing js functions is hard because there are many ways to 
start functions/methods in javascript. Please let me know if there are 
other patterns that the js importer should recognize.

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.