Partially completed code is messing with...autocomplete?

Issue #694 resolved
Derek Wiers created an issue

I swear this is an issue I've run into a number of times, but now that I'm trying to reproduce it it's tough (I'll share a screenshot when I do). The gist of it is this: I'm writing some code, and in referencing a class or object, I want to know what my options are. I type it in, type "." and want to see the drop down menu for that - however the fact that the line I'm currently editing isn't complete yet appears to confuse the editor, and all code below the line in question is un-highlighted, and no drop down appears. I'm putting this issue in just in case yourself or another user can chime in with more details and/or screenshot - otherwise, I'll be posting one once I see the issue again. It's possible it might be related to the Fluent Interface bug where symbols aren't recognized properly, but more on that when I find it.

Comments (13)

  1. Scott Wells repo owner

    Derek, please let me know if you're still seeing this with the changes I made in 1.8.0.0. I think it's as likely that 1.8.0.0 won't have fixed as that it will, but because I fixed the fluent API issue (at least the remaining instance that was reported), I'm hoping that it will have helped here as well.

  2. Willem Mulder

    Just to confirm: I'm seeing the same thing now and then. Not a big thing for me though; I love Illuminated Cloud regardless :-) Would still be great if it could be fixed!

  3. Willem Mulder

    Ah the coincidence. It just happened to me right now that I completely lost my autocomplete (and deploy using control+s didn't work either), although I don't know the exact cause of the loss. Also, the CPU is eating about 30% of my heavy machine. After restart everything is fine again.

  4. Scott Wells repo owner

    That's almost certainly the same issue as #669. I'm burning in a prospective fix for that issue this week and will include it in next week's release assuming no issues detected with the fix between now and then.

  5. Derek Wiers reporter
    somevar = somemethod(arg1, someMethodThatReturnsSomething(....... // <-- it is here that I can't autocomplete someMethodThatReturnsSomething() or its arguments, because this is not a finished line.
    
    private String someMethodThatReturnsSomething(args) {
        return mangledArgs;
    }
    
  6. Derek Wiers reporter

    The issue for this ticket is not typically associated with high cpu usage. In the case of #669, most IDE functionality is lost during the bout of high CPU usage and I just need to restart the IDE for that, since even deploying doesn't work then. No, for this ticket, the CPU is not significantly affected and is simply some sort of logic issue.

  7. Scott Wells repo owner

    Sorry for the confusion, Derek. That was in response to Willem's last comment which seems to be the same issue as #669. I agree that the main issue in this ticket is just a completion issue, and I appreciate you providing a simple example of how to reproduce it. Hopefully I'll be able to produce a fix based on that quickly.

  8. Scott Wells repo owner

    Derek, is this still happening to you on recent builds that seem to help with #669 (which may or may not have contributed to this issue) plus a number of other completion/expression type evaluation issues that I've fixed? If so, do you happen to have any thoughts on reproducible scenarios?

  9. Derek Wiers reporter

    Yes, this is happening. It mostly happens because my development habits are non-linear in nature. I don't code from top-down; rather, I pre-structure the code to break the problem down, so I'll create methods and fill them in later once I've fine-tuned what the logic needs to do. Which means I'm working on code that's not on the bottom. So if I have a method:

    private void foo(String bar, Integer foobar, Id someRandomId) {...}
    

    at the bottom of a class, and I am in the middle of filling in a method above it in the class, and I want to reference foo():

    private void someEarlierMethod() {
        foo('Test',         // Example of how far I might get before pausing to think or see my arglist (Control+J on my mac, or just "," between args)
    

    When I get as far as the above, the syntax highlighting on the rest of the class is wonky because everything is thrown off by the ill-terminated line that I'm in the middle of typing, and no autocomplete or syntax help from anything below the current line is available (Also true if I'm trying to autocomplete the method name foo - it won't even recognize it as a method and color it as such until I'm done with the line)

  10. Scott Wells repo owner

    Gotcha. That may be more difficult to address. As you can hopefully appreciate, writing/maintaining a parser that is forgiving of syntax errors and recovers well enough so that the whole file doesn't go red is challenging. My current Apex/SOQL/SOSL parser handles those situations well about 95% of the time, but there are situations like this where it falls down. I've found that sometimes what seems like a simple tweak to the parser to try to make it more forgiving in one case can tank it in another, so I'm VERY conservative about making changes. It's not fragile...just tricky to get right, especially given the fact that Apex doesn't really have a regular grammar so there are some tricks required to make it work well.

    So that's likely more than you ever wanted to know. I'll keep this on my list and use your example above as a way to try to corner this, but if it looks like getting it working might end up pulling the proverbial loose thread out of the sweater, I'll let you know that as well. Thanks again!

  11. Derek Wiers reporter

    Screen Shot 2017-09-25 at 11.17.10 AM.png Here's an example. I defined convertToContactList() in the above code, then I went back up and called it and assigned it to scopeList in the method above it. However, convertToContactList () isn't highlighted right (should be green) and the call to it should be yellow (according to my ever-changing-because-I-am-always-tinkering highlighting rules). When typing the invocation of the method, no suggestions popped up, and no suggestions popped up for the argument(s) either. It wasn't recognized until I finished the line with a ; .

    I definitely understand the difficulty of writing a parser that forgiving is certainly a challenge - however I figured as I had just seen the issue again now, I'd give you a more concrete example.

  12. Scott Wells repo owner

    Oh, absolutely keep the reproducible examples coming! I'll definitely take a look at each and see what changes are required to accommodate it. Some of them will absolutely be used to strengthen the parser's recovery model. My ultimate goal is a parser that's as tolerant of incomplete/invalid code as IntelliJ's own Java parser, though my guess is that in reality I'll never get 100% the way there. Still, the only way to make progress is to know what real-world scenarios aren't handled well today.

  13. Scott Wells repo owner

    Issue tracker grooming. If this is still an issue, please feel free to reopen, ideally with a concrete reproduction scenario.

  14. Log in to comment