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.
No code formatting is happening anywhere: C or C++ source or header file I have tried to format via keyboard shortcut and with the context-menu.
Investigation: Method org.netbeans.editor.BaseAction.actionPerformed(final ActionEvent evt) detect wrong target component. Code: -------------------8<---------------------- public final void actionPerformed(final ActionEvent evt) { final JTextComponent target = getTextComponent(evt); // #146657 - Only perform the action if the document is BaseDocument's instance // #147899 - NPE if (target == null || !(target.getDocument() instanceof BaseDocument)) { return; } -------------------8<---------------------- Target is: org.openide.awt.QuickSearch$SearchTextField[,26,2,84x19,invalid,layout=javax.swing.plaf.basic.BasicTextUI$UpdateHandler,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.BorderUIResource$CompoundBorderUIResource@1782656,flags=296,maximumSize=java.awt.Dimension[width=84,height=19],minimumSize=,preferredSize=,caretColor=sun.swing.PrintColorUIResource[r=51,g=51,b=51],disabledTextColor=javax.swing.plaf.ColorUIResource[r=184,g=207,b=229],editable=true,margin=javax.swing.plaf.InsetsUIResource[top=0,left=0,bottom=0,right=0],selectedTextColor=sun.swing.PrintColorUIResource[r=51,g=51,b=51],selectionColor=javax.swing.plaf.ColorUIResource[r=184,g=207,b=229],columns=10,columnWidth=8,command=,horizontalAlignment=LEADING] As result the action is not performed. Stack: org.netbeans.editor.BaseAction.actionPerformed(BaseAction.java:297) org.netbeans.spi.editor.AbstractEditorAction.actionPerformed(AbstractEditorAction.java:444) javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995) javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318) javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387) javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242) javax.swing.AbstractButton.doClick(AbstractButton.java:357) javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:809) javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:850) java.awt.Component.processMouseEvent(Component.java:6297) javax.swing.JComponent.processMouseEvent(JComponent.java:3275) java.awt.Component.processEvent(Component.java:6062) java.awt.Container.processEvent(Container.java:2039) java.awt.Component.dispatchEventImpl(Component.java:4660) java.awt.Container.dispatchEventImpl(Container.java:2097) java.awt.Component.dispatchEvent(Component.java:4488) java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4575) java.awt.LightweightDispatcher.processMouseEvent(Container.java:4236) java.awt.LightweightDispatcher.dispatchEvent(Container.java:4166) java.awt.Container.dispatchEventImpl(Container.java:2083) java.awt.Window.dispatchEventImpl(Window.java:2489) java.awt.Component.dispatchEvent(Component.java:4488) java.awt.EventQueue.dispatchEventImpl(EventQueue.java:668) java.awt.EventQueue.access$400(EventQueue.java:81) java.awt.EventQueue$2.run(EventQueue.java:627) java.awt.EventQueue$2.run(EventQueue.java:625) java.security.AccessController.doPrivileged(AccessController.java) java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87) java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98) java.awt.EventQueue$3.run(EventQueue.java:641) java.awt.EventQueue$3.run(EventQueue.java:639) java.security.AccessController.doPrivileged(AccessController.java) java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87) java.awt.EventQueue.dispatchEvent(EventQueue.java:638) org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:158) java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269) java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184) java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174) java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169) java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161) java.awt.EventDispatchThread.run(EventDispatchThread.java:122) Reassign to evaluation.
I just found out that it actually working for some other files. But I have a file on which it simply refuses to do any formatting. Since you mentioned, yes, there is a bug when the cursor is positioned on the quick search edit box and you try to do Cmd+Click on a symbol. Is not going to the declaration/definition. You have to hide the quick search and than do the cmd+click Best regards, Andrei
(In reply to comment #2) > I just found out that it actually working for some other files. But I have a > file on which it simply refuses to do any formatting. Does IDE log contain errors?
Where are those IDE logs?
(In reply to comment #4) > Where are those IDE logs? View->IDE log
Here is the log: Reformatting failed. Reformatter try to delete important symbol: "// Treat no TERM key as an "OPEN" type license" in changeset:"" Reformatting failed. Reformatter try to delete important symbol: "// Treat no TERM key as an "OPEN" type license" in changeset:"" and the code to reproduce it: if(0){ int a=0; }//sample comment else int b = 1; For that, I get: Reformatting failed. Reformatter try to delete important symbol: "//sample comment" in changeset:""
I have to agree, the sample code that I gave you and the situation that I had in my file were in the gray zone for code "correctness". However, a message with the line number where the problem is would be nice. After properly positioned the comments, the file was formatted just fine
Having this "IDE logs" trick is not always working. The IDE logs window is not updating when I try to reformat. The reformat simply fails with no messages o that window. I have to close the IDE logs than open it again to force the IDE to flush the messages on the window
Sorry, I'm confused. What is actually wrong? If you have a focus inside search field then the Reformat action would reformat the field which likely does nothing (it's as designed). If the focus is inside the editor then the reformat works fine for me at least in C and java files.
I'm sorry, I kind of highjacked the original issue (code formatting) with a new report of a new bug (code navigation not working with focus is on the search box) To summarise, here are the 2 distinct problems: 1. formatting is not happening when we have that special code situation (I already gave a small piece of C/C++ code to reproduce it) 2. A completely different problem (nothing to do with formatting) which I put it in here just because I saw your stack trace and I just remembered another bug which is search box related (org.openide.awt.QuickSearch$SearchTextField): when the focus is on the quick search edit box, cmd+click is not working. IMO, it should because I'm clicking in a different place and the focus should change and the operation performed. The operation is navigating to the declaration/definition of the symbol that we just cmd+clicked. It should not matter that the cursor is on the quick search box
ad 2) Tested daily build 20121119 on Ubuntu 12.04 64bit + JDK1.6.0_30 and it works for me in C++ and java. I do Cmd+Click inside the code editor (focus is inside quick search field) and the cursor jumps to the declaration place and the code editor gets focused. Could you attach the messages.log of the IDE to this issue? ad 1) Reassigning back to cnd for evaluation. Thanks.
(In reply to comment #11) > ad 2) > Tested daily build 20121119 on Ubuntu 12.04 64bit + JDK1.6.0_30 and it works > for me in C++ and java. I do Cmd+Click inside the code editor (focus is inside > quick search field) and the cursor jumps to the declaration place and the code > editor gets focused. Could you attach the messages.log of the IDE to this > issue? > > ad 1) > Reassigning back to cnd for evaluation. Thanks. Extracted separate bug #222396 reassign buck to editor
Created attachment 128066 [details] IDE log
Steps to reproduce: - create Fractal C/C++ sample - open fractal.cc file - put cursor on 52 line - select in project tree "Source Files" folder - Tools->Options->Formatting->C++ - Select another style (for example "OpenSolaris") - OK - right click on line 52 and select format Expected behavior: - format action is performed Actual behavior: - format action is not performed I can reproduce this behavior on Ubuntu and Solaris. We have a lot of customer complains that format action does not work on the first attempt.
Created attachment 128069 [details] IDE log line
Created attachment 128070 [details] ScreenShoot
OS: Mac OS X 1.8.2 (Mountain Lion) NetBeans: Product Version: NetBeans IDE 7.3 Beta 2 (Build 201211062253) Java: 1.6.0_37; Java HotSpot(TM) 64-Bit Server VM 20.12-b01-434 Runtime: Java(TM) SE Runtime Environment 1.6.0_37-b06-434-11M3909 System: Mac OS X version 10.8.2 running on x86_64; MacRoman; en_US (nb) User directory: /Users/shiretu/Library/Application Support/NetBeans/7.3beta2 Cache directory: /Users/shiretu/Library/Caches/NetBeans/7.3beta2
I cannot reproduce on my machine but I'll consult with our QE whether they can reproduce with the given steps. Btw is the step "- select in project tree "Source Files" folder" crucial or it would fail without it as well? Thanks.
(In reply to comment #18) > I cannot reproduce on my machine but I'll consult with our QE whether they can > reproduce with the given steps. > Btw is the step "- select in project tree "Source Files" folder" crucial or it > would fail without it as well? Thanks. No. Bug can be reproduced without "select in project tree "Source Files" folder".
(In reply to comment #19) > No. Bug can be reproduced without "select in project tree "Source Files" > folder". Well I still don't understand why the active text component is a Quick search text field when you've never interacted that component during the steps-to-reproduce. Do you have any special focus policy e.g. focus-follows-mouse or don't you know about any hint that would possibly clarify this? Thanks.
(In reply to comment #20) > Well I still don't understand why the active text component is a Quick search > text field when you've never interacted that component during the > steps-to-reproduce. > Do you have any special focus policy e.g. focus-follows-mouse or don't you > know about any hint that would possibly clarify this? Thanks. I do not exactly understand what you mean. Platform: #uname -a SunOS asimon 5.10 Generic_127112-10 i86pc i386 i86pc Desktop system: GNOME I do not change focus policy. As I said, the bug is reproduced on Ubuntu 12.4.
Mila was referring to the fact that the target component of your format action was QuickSearch$SearchTextField which is something outside of the (big) editor.
(In reply to comment #22) > Mila was referring to the fact that the target component of your format action > was QuickSearch$SearchTextField which is something outside of the (big) editor. Yes it is a problem. Why target component is QuickSearch$SearchTextField while popup menu is invoked inside editor?
I've added a focus request for the editor component in case there's a context menu invoked for it. Hopefully that will resolve the problem. If not please reopen the issue. http://hg.netbeans.org/jet-main/rev/a1d96b192098
Integrated into 'main-golden', will be available in build *201211240959* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-golden/rev/a1d96b192098 User: Miloslav Metelka <mmetelka@netbeans.org> Log: #222337 - Code formatting not working.