Conclusion of opening / closing parades?

It seems that someone must have done the work of figuring out how to output or suggest where to put the closing parentheses. I mean, the allocation of relevant partners is great, but the proposal will be even better. Is this a specific issue? If so, what is its name (for example, what do I need for Google Scholar?). If not, why not? Is this a question of an unexplained / poorly posed question?

To do this, suppose I have an incorrect ruby ​​code:

foo.all.map { |i| i.bar }).uniq.compact.reject { |j| j.match /baz/i } 

Please note that I am missing the initial bracket. The problem I'm talking about is this: "How do I suggest inserting a finger at the beginning when I move the cursor over an unpaired guy?"

If this is not a poorly posed question, why hasn't anyone else done this?

+4
source share
1 answer

You can track "balanced" and "unbalanced" parsers by user type. Then offer steam as soon as the paranas become unbalanced.

For example, text input (something)) will offer the initial finger before s . Correct placement of the fix-it patch can be difficult. For example, if the user enters something(else)) choice: insert the start fix-it groove after g or at the beginning of the line?

Tracking balanced pares will be relatively simple:

 int parenCount = 0 event keyUp(char c){ if(c is close-paren){ parenCount--; }else if(c is open-paren){ parenCount++; } if(parenCount < 0){ // missing an open-paren somewhere } } // handle missing close-parens when user finished typing the string... // for example if user types "myObject.something(" and hits enter 

You may also need to search for unnecessary partners, as in a.doSomethingWith((aNumber))

0
source

Source: https://habr.com/ru/post/1386170/


All Articles