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.
Summary: | org.netbeans.editor.GuardedException: Attempt to remove from guarded block at position 1 | ||
---|---|---|---|
Product: | java | Reporter: | cezariusz <cezariusz> |
Component: | Source | Assignee: | Ralph Ruijs <ralphbenjamin> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | cezariusz, ralphbenjamin, sdedic, vikas_netbeans |
Priority: | P3 | ||
Version: | 8.0 | ||
Hardware: | All | ||
OS: | All | ||
Issue Type: | DEFECT | Exception Reporter: | 204535 |
Attachments: |
stacktrace
proposed patch |
Description
cezariusz
2015-03-07 17:59:17 UTC
Created attachment 152467 [details]
stacktrace
I have created a dialog using New -> Swing GUI Forms -> JDialog Form. I was created with a main function, which I didn't want. So I clicked on it in the Members navigator, right click -> Refactor -> Safely Delete. The exception has been reported and the function wasn't removed. SafeDelete uses TreeMaker.removeClassMember(), reassigning to java.source. The culprit is the CasualDiff / WorkingCopy; this time, because it attached a comment to a Java element (main method) across a guarded block boundary. There's another subtle issue: Suppose you add some Label to the dialog - then try to delete the method. The refactoring module insists that the part of text is readonly. I believe there's a "+- 1" error in RefactoringElementsBag.java:222 - the condition should read like if (section.contains(elementStart, true) || (section.contains(elementEnd, true) && section.getStartPosition().getOffset() != elementEnd.getOffset())) { return true; } The element's end is actually a position right after the element text, so it may share offset with guarded block begin, as the character on that offset will not be actually deleted. Created attachment 152888 [details]
proposed patch
Part of the bug is being fixed as jet-main#e30db8faa778.
Proposed changes to refactoring API attached.
Integrated into 'main-silver', will be available in build *201504030001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/e30db8faa778 User: Svata Dedic <sdedic@netbeans.org> Log: #250995: member pos estimator respects Guarded boundaries when accummulating surrounding whitespaces and comments Thanks you for the patch, integrated as a24a65e0e399 |