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 242868 - Close bracket hint doesn't show code if open bracket starts its own line
Summary: Close bracket hint doesn't show code if open bracket starts its own line
Status: RESOLVED FIXED
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.3
Hardware: All All
: P4 normal (vote)
Assignee: Tomas Mysik
URL:
Keywords:
: 218218 230904 255296 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-03-13 15:13 UTC by Netrilix
Modified: 2016-02-16 05:03 UTC (History)
7 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
Sample of bad hinting (37.33 KB, image/png)
2014-03-13 19:13 UTC, Netrilix
Details
screenshot for prototype (14.08 KB, image/png)
2015-11-07 13:07 UTC, junichi11
Details
patch for prototype (56.20 KB, patch)
2015-11-09 14:47 UTC, junichi11
Details | Diff
patch v2 for prototype (73.49 KB, patch)
2015-12-03 03:43 UTC, junichi11
Details | Diff
patch v2 for prototype (82.65 KB, patch)
2015-12-03 05:38 UTC, junichi11
Details | Diff
patch v2 for prototype (83.88 KB, patch)
2015-12-03 06:18 UTC, junichi11
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Netrilix 2014-03-13 15:13:13 UTC
With code formatted as:

function test(){

**SNIP**

}

If the start of the declaration is scrolled off the page, and you put your cursor on the close bracket, it would hint as to what the open bracket was ( a little pop-up would should "function test(){" ).


But consider this code:

function test()
{

**SNIP**

}

Placing the cursor on the closing bracket in this case will only show "{" in the pop-up, which offers no information. Ideally, if the opening bracket is alone on the line, the hint would also show the previous line.


Have a great day,
Mike




Product Version = NetBeans IDE 7.3 (Build 201306052037)
Operating System = Windows 8 version 6.2 running on amd64
Java; VM; Vendor = 1.7.0_21
Runtime = Java HotSpot(TM) 64-Bit Server VM 23.21-b01
Comment 1 Jiri Prox 2014-03-13 16:08:24 UTC
This issue is already fixed in 8.0
Comment 2 Netrilix 2014-03-13 19:13:29 UTC
Created attachment 146009 [details]
Sample of bad hinting
Comment 3 Netrilix 2014-03-13 19:16:25 UTC
I've just downloaded 8.0 RC1 and Nightly 201403130001, and neither of them shows that the issue has already been fixed.

In case I explained the issue poorly, I've attached a screenshot. As you can see, the hint only shows "{" from line 3, not the function itself from line 2 ( "function test()" ).
Comment 4 junichi11 2015-11-01 04:02:47 UTC
Is this the editor area? (I'm sorry if I'm wrong.) Thanks.
Comment 5 junichi11 2015-11-05 04:22:27 UTC
I'm Sorry. I was wrong.
Comment 6 junichi11 2015-11-05 04:29:12 UTC
*** Bug 255296 has been marked as a duplicate of this bug. ***
Comment 7 junichi11 2015-11-07 13:07:33 UTC
Created attachment 157205 [details]
screenshot for prototype

I'm implementing it now...
Comment 8 junichi11 2015-11-07 13:29:17 UTC
Tomas, I'll attach a patch for prototype after I was able to add unit tests. Unfortunately, there are two problems now.

1. Probably, a problem of spi side [1]
2. I got many same WARNINGs[2] (My implementation may have some problems)


[1] https://netbeans.org/bugzilla/show_bug.cgi?id=256427
[2] WARNING [org.openide.util.WeakListenerImpl]: Can't remove java.beans.PropertyChangeListener using method org.netbeans.modules.csl.core.GsfDocument.removePropertyChangeListener from org.netbeans.modules.csl.core.GsfDocument

Thanks.
Comment 9 Tomas Mysik 2015-11-09 08:29:27 UTC
Will look at it, soon. Thanks!
Comment 10 junichi11 2015-11-09 14:47:21 UTC
Created attachment 157232 [details]
patch for prototype

I've created a patch for prototype(There are the above problems yet). Could you please review it?

Thanks!
Comment 11 Tomas Mysik 2015-11-20 08:46:36 UTC
Ondro, could you please review this patch? Thanks!
Comment 12 Tomas Mysik 2015-11-20 08:59:26 UTC
Maybe also Petr could have a look at the patch, whether it is OK or not. Thanks!
Comment 13 Petr Pisl 2015-11-30 13:10:47 UTC
I have went through the patch. Formally it's ok, anyway I have one note. The method ParserManger.parse () shouldn't be called from AWT, which in this case is ok, because BraceMatcher should not be. But the ParseManager.parse() can be very expensive. 

If the source is already parsed in the parsing cycle, then it's ok, the latest parse result is returned without the parsing. Parsing cycle is usually started a timeout (2s) after latest change. Using this in BraceMatcher has big chance to require parsing before the parsing cycle. It's mean that the parsing will be done completely and BraceMatcher will wait for the parsing result, which can take some time. So it's better to avoid to require parsing if it's necessary. And I think this is the case. The position could be find via lexer (Token Sequence).
Comment 14 junichi11 2015-12-01 01:00:22 UTC
@Petr Thanks a lot for reviewing it!

I'll try using only lexer.
Comment 15 junichi11 2015-12-03 03:43:04 UTC
Created attachment 157631 [details]
patch v2 for prototype

I've created the second prototype using only lexer. Also fixed tests.

Thanks.
Comment 16 junichi11 2015-12-03 05:10:01 UTC
Sorry, test cases are missing yet (try statement). Please wait a while since I'll add them later.
Comment 17 junichi11 2015-12-03 05:38:30 UTC
Created attachment 157633 [details]
patch v2 for prototype

Fixed. Thanks.
Comment 18 junichi11 2015-12-03 06:18:04 UTC
Created attachment 157634 [details]
patch v2 for prototype

Sorry, again...
Comment 19 Tomas Mysik 2015-12-03 07:23:45 UTC
Junichi, thanks a lot for your work! Will look at it soon.

Thanks!
Comment 20 Petr Pisl 2015-12-03 10:12:07 UTC
@junichi11: Nice work. Thanks.
Comment 21 Tomas Mysik 2015-12-04 08:09:26 UTC
Patch applied, thanks a lot for it Junichi!

One note: instead of Exceptions class, Logger is preferred. I made this change and log BadLocationException with WARNING level. Let me know if this is incorrect (and e.g. INFO level should be used).

Thanks.

http://hg.netbeans.org/web-main/rev/99ade2827779
Comment 22 junichi11 2015-12-04 10:51:43 UTC
You are welcome :)

Thanks a lot for applying it and fixing the Exception class!
Comment 23 Quality Engineering 2015-12-05 02:43:23 UTC
Integrated into 'main-silver', will be available in build *201512050002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/99ade2827779
User: Tomas Mysik <tmysik@netbeans.org>
Log: #242868 - Close bracket hint doesn't show code if open bracket starts its own line

Patch contributed by junichi11@netbeans.org.
Comment 24 junichi11 2015-12-15 13:55:42 UTC
*** Bug 218218 has been marked as a duplicate of this bug. ***
Comment 25 junichi11 2016-02-16 05:03:39 UTC
*** Bug 230904 has been marked as a duplicate of this bug. ***