This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 268920 - Netbeans hangs up when hitting autocomplete
Summary: Netbeans hangs up when hitting autocomplete
Status: RESOLVED FIXED
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 8.2
Hardware: All All
: P3 normal (vote)
Assignee: junichi11
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-10 07:50 UTC by malmsteenforce
Modified: 2016-11-16 02:51 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Fragment of code when Netbeans hangs up (16.14 KB, image/png)
2016-11-10 07:50 UTC, malmsteenforce
Details
Thread dump log (30.83 KB, text/plain)
2016-11-10 10:56 UTC, malmsteenforce
Details
Netbeans log (44.60 KB, application/octet-stream)
2016-11-10 10:56 UTC, malmsteenforce
Details
proposed patch (7.12 KB, patch)
2016-11-14 01:47 UTC, junichi11
Details | Diff
proposed patch v2 (9.87 KB, patch)
2016-11-14 11:42 UTC, junichi11
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description malmsteenforce 2016-11-10 07:50:20 UTC
Created attachment 162856 [details]
Fragment of code when Netbeans hangs up

To reproduce the bug:
1) Type comment next to the foreach loop: /* @var $x {class_name}
2) hit ENTER when first hint appears
3) Netbeans hangs up and doesn't respond to any key
Full 1 processor thread is taken.
Only killing netbeans process can help (you can wait forever and nothing happens).
It was reproduced at least 3 times in a row.
Comment 1 Tomas Mysik 2016-11-10 08:03:44 UTC
Please, create a thread dump [1] once this problem occurs. Also, it is always a good idea to attach the IDE log [2] (again, once the problem occurs, of course).

BTW if the IDE is just "busy" (and not frozen) it would be great if you could create and attach a profiler snapshot [3] (start profiling, reproduce problem, stop profiling).

Simply reopen this issue, thanks.
[1] http://wiki.netbeans.org/GenerateThreadDump
[2] http://wiki.netbeans.org/FaqLogMessagesFile
[3] http://wiki.netbeans.org/FaqProfileMeNow
Comment 2 malmsteenforce 2016-11-10 10:56:13 UTC
Created attachment 162862 [details]
Thread dump log
Comment 3 malmsteenforce 2016-11-10 10:56:50 UTC
Created attachment 162863 [details]
Netbeans log
Comment 4 malmsteenforce 2016-11-10 10:57:56 UTC
I've attached log files. Hope it helps resolve the issue.
Comment 5 junichi11 2016-11-11 22:58:47 UTC
(In reply to malmsteenforce from comment #4)
> I've attached log files. Hope it helps resolve the issue.

Thank you!


It's reproducible with the following code:

<?php

class Example {

}

$closure = (static function ($examples) {
    $i = 0;
    foreach ($examples as $example) { /* @var $example Exa
        $i++;
?>
<?php
    }
});
?>


It seems that if there is no closing tag for the comment, an infinite loop occurs. I'll try looking at it.

Just a workaround: First of all, please write a closing tag (*/).

You can also use a useful code template. Please try the following steps:
1. type "vdoc"
2. push the TAB key soon
3. a code template is added
4. you can move to a variable name and a class name if you push the TAB

e.g. 
    foreach ($examples as $example) { vdoc[TAB]
        $i++;

->

    foreach ($examples as $example) { /* @var $example ClassName */
        $i++;

Thanks.
Comment 6 junichi11 2016-11-14 01:47:28 UTC
Created attachment 162899 [details]
proposed patch

Tests were passed even if the fix is not applied when I created tests first.
The cause is the caret position for GSFParser. So I added the setUnitTestCaretPosition method (public static) to it.(I used the same way as TokenFormatter.)
But I'm not sure whether this is proper.

Tomas, what do you think?

Thanks.
Comment 7 Tomas Mysik 2016-11-14 06:56:09 UTC
(In reply to junichi11 from comment #6)
> Tomas, what do you think?

Seems fine to me. Perhaps remove the "public" modifier from the method, if possible.

Thanks!
Comment 8 junichi11 2016-11-14 11:42:40 UTC
Created attachment 162904 [details]
proposed patch v2

(In reply to Tomas Mysik from comment #7)
> Seems fine to me. Perhaps remove the "public" modifier from the method, if
> possible.

Thanks a lot for your answer! I was worried about that.
I improved a bit to not use it in the source package. First, removed the "public" modifier, then created a utility class(GSFPHPParserTestUtil) for the GSFPHPParser class in the unit test package.

If you are OK, I can push the fix tomorrow.

Thanks!
Comment 9 Tomas Mysik 2016-11-14 12:04:45 UTC
Patch seems fine to me. Thanks a lot!
Comment 10 junichi11 2016-11-14 12:10:43 UTC
Great to hear. Thanks!
Comment 11 junichi11 2016-11-15 03:07:39 UTC
Fixed.

http://hg.netbeans.org/web-main/rev/963ae780203c

I have changed a patch a bit because IllegalAccessError occurred in PHPFormatterQATest. (Set -1 not in tearDown() but at the end of the test method.) 

Thanks!
Comment 12 Tomas Mysik 2016-11-15 06:22:29 UTC
Thanks a lot, Junichi!
Comment 13 junichi11 2016-11-15 06:33:01 UTC
You are welcome:)
Comment 14 Quality Engineering 2016-11-16 02:51:29 UTC
Integrated into 'main-silver', will be available in build *201611160001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/963ae780203c
User: Junichi Yamamoto <junichi11@netbeans.org>
Log: #268920 - Netbeans hangs up when hitting autocomplete