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.
070808, JDK 5, Ubuntu. In a fresh userdir on a new standalone module, I add an Action, keeping to defaults except for label. I get on console: SEVERE [org.netbeans.modules.editor.indent.IndentImpl]: Not locked. Use Reformat.lock(). java.lang.Exception at org.netbeans.modules.editor.indent.IndentImpl.reformat(IndentImpl.java:217) at org.netbeans.modules.editor.indent.FormatterImpl.reformat(FormatterImpl.java:120) at org.netbeans.modules.apisupport.project.ui.wizard.BasicWizardIterator.formatFile(BasicWizardIterator.java:341) at org.netbeans.modules.apisupport.project.ui.wizard.BasicWizardIterator.getCreatedFiles(BasicWizardIterator.java:293) at org.netbeans.modules.apisupport.project.ui.wizard.action.NewActionIterator.instantiate(NewActionIterator.java:46) [....] I tried to fix as follows: int reformattedLen; try { Reformat.get(doc).lock(); reformattedLen = doc.getFormatter().reformat(doc, pos, stopPos); } finally { Reformat.get(doc).unlock(); } (add dep on editor/indent) but then I just get this instead: java.lang.AssertionError: JavaSource.runCompileControlTask called under Document write lock. at org.netbeans.api.java.source.JavaSource.runUserActionTask(JavaSource.java:511) at org.netbeans.modules.java.source.save.Reformatter$Lock.lock(Reformatter.java:398) at org.netbeans.modules.editor.indent.TaskHandler$MimeItem.lock(TaskHandler.java:310) at org.netbeans.modules.editor.indent.TaskHandler.lock(TaskHandler.java:149) at org.netbeans.modules.editor.indent.IndentImpl.reformatLock(IndentImpl.java:131) at org.netbeans.api.editor.indent.Reformat.lock(Reformat.java:89) at org.netbeans.modules.apisupport.project.ui.wizard.BasicWizardIterator.formatFile(BasicWizardIterator.java:344) [....] I'm not exactly sure what it means, but apparently the copy-pasted code to reindent the doc is not working so well any more.
*** Issue 112484 has been marked as a duplicate of this issue. ***
I'll take a look at it next week. Will have a change to ask somebody from editor for the most right way to do this.
I've just used code from the Reformatter Javadoc which seems to work nicely. src/org/netbeans/modules/apisupport/project/ui/wizard/BasicWizardIterator.java; new revision: 1.27; previous revision: 1.26 nbproject/project.xml; new revision: 1.58; previous revision: 1.57