AssertionError: Wrong line separators

hello,
I have a problem with my plugin Eclipse code formatter   http://plugins.intellij.net/plugin/?idea&id=6546

Document#setText is  failing because sometimes there is a line separator \r\n

is there any better way how to set text to the Document or PsiFile which would handle that separator?



java.lang.AssertionError: Wrong line separators: '...skNameCode\r\n *
   ...' at offset 496
       at com.intellij.openapi.diagnostic.DefaultLogger.error(DefaultLogger.java:50)
       at com.intellij.openapi.diagnostic.Logger.error(Logger.java:54)
       at com.intellij.openapi.util.text.StringUtil.assertValidSeparators(StringUtil.java:2044)
       at com.intellij.openapi.editor.impl.DocumentImpl.assertValidSeparators(DocumentImpl.java:447)
       at com.intellij.openapi.editor.impl.DocumentImpl.replaceString(DocumentImpl.java:385)
       at com.intellij.openapi.editor.impl.DocumentImpl.access$000(DocumentImpl.java:53)
       at com.intellij.openapi.editor.impl.DocumentImpl$3.run(DocumentImpl.java:753)
       at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:105)
       at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:88)
       at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:76)
       at com.intellij.openapi.editor.impl.DocumentImpl.setText(DocumentImpl.java:760)
       at krasa.formatter.plugin.CodeFormatter.formatWhenEditorIsClosed(CodeFormatter.java:70)
       at krasa.formatter.plugin.CodeFormatter.formatWithEclipse(CodeFormatter.java:56)
       at krasa.formatter.plugin.CodeFormatter.format(CodeFormatter.java:44)
       at krasa.formatter.plugin.EclipseCodeStyleManager.reformatText(EclipseCodeStyleManager.java:74)
       at com.intellij.codeInsight.actions.ReformatCodeProcessor$1.call(ReformatCodeProcessor.java:80)
       at com.intellij.codeInsight.actions.ReformatCodeProcessor$1.call(ReformatCodeProcessor.java:74)
       at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
       at java.util.concurrent.FutureTask.run(FutureTask.java:138)
       at com.intellij.codeInsight.actions.AbstractLayoutCodeProcessor$ReformatFilesTask.iteration(AbstractLayoutCodeProcessor.java:524)
       at com.intellij.util.SequentialModalProgressTask$1.run(SequentialModalProgressTask.java:95)
       at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
       at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:641)
       at java.awt.EventQueue.access$000(EventQueue.java:84)
       at java.awt.EventQueue$1.run(EventQueue.java:602)
       at java.awt.EventQueue$1.run(EventQueue.java:600)
       at java.security.AccessController.doPrivileged(Native Method)
       at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
       at java.awt.EventQueue.dispatchEvent(EventQueue.java:611)
       at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:694)
       at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:534)

       at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:416)
       at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:374)
       at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
       at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
       at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:178)
       at java.awt.Dialog$1.run(Dialog.java:1046)
       at java.awt.Dialog$3.run(Dialog.java:1098)
       at java.security.AccessController.doPrivileged(Native Method)
       at java.awt.Dialog.show(Dialog.java:1096)
       at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl$MyDialog.show(DialogWrapperPeerImpl.java:709)
       at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl.show(DialogWrapperPeerImpl.java:416)
       at com.intellij.openapi.ui.DialogWrapper.showAndGetOk(DialogWrapper.java:1323)
       at com.intellij.openapi.ui.DialogWrapper.show(DialogWrapper.java:1308)
       at com.intellij.openapi.progress.util.ProgressWindow$MyDialog.show(ProgressWindow.java:610)
       at com.intellij.openapi.progress.util.ProgressWindow.showDialog(ProgressWindow.java:235)
       at com.intellij.openapi.progress.util.ProgressWindow$1$1.actionPerformed(ProgressWindow.java:178)
       at javax.swing.Timer.fireActionPerformed(Timer.java:291)
       at javax.swing.Timer$DoPostEvent.run(Timer.java:221)
       at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
       at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:641)
       at java.awt.EventQueue.access$000(EventQueue.java:84)
       at java.awt.EventQueue$1.run(EventQueue.java:602)
       at java.awt.EventQueue$1.run(EventQueue.java:600)
       at java.security.AccessController.doPrivileged(Native Method)
       at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
       at java.awt.EventQueue.dispatchEvent(EventQueue.java:611)
       at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:694)
       at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:534)
       at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:416)
       at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:374)
       at com.intellij.ide.IdeEventQueue.pumpEventsForHierarchy(IdeEventQueue.java:759)
       at com.intellij.openapi.progress.util.ProgressWindow.startBlocking(ProgressWindow.java:200)
       at com.intellij.openapi.application.impl.ApplicationImpl.runProcessWithProgressSynchronously(ApplicationImpl.java:652)
       at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcessWithProgressSynchronously(ProgressManagerImpl.java:273)
       at com.intellij.openapi.progress.impl.ProgressManagerImpl.run(ProgressManagerImpl.java:416)
       at com.intellij.codeInsight.actions.AbstractLayoutCodeProcessor$3.run(AbstractLayoutCodeProcessor.java:246)
       at com.intellij.codeInsight.actions.AbstractLayoutCodeProcessor$5.run(AbstractLayoutCodeProcessor.java:264)
       at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:889)
       at com.intellij.codeInsight.actions.AbstractLayoutCodeProcessor$9$1$1.run(AbstractLayoutCodeProcessor.java:459)
       at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:112)
       at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:88)
       at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:76)
       at com.intellij.codeInsight.actions.AbstractLayoutCodeProcessor$9$1.run(AbstractLayoutCodeProcessor.java:455)
       at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:333)
       at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
       at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:641)
       at java.awt.EventQueue.access$000(EventQueue.java:84)
       at java.awt.EventQueue$1.run(EventQueue.java:602)
       at java.awt.EventQueue$1.run(EventQueue.java:600)
       at java.security.AccessController.doPrivileged(Native Method)
       at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
       at java.awt.EventQueue.dispatchEvent(EventQueue.java:611)
       at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:694)
       at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:534)
       at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:416)
       at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:374)
       at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
       at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
       at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:178)
       at java.awt.Dialog$1.run(Dialog.java:1046)
       at java.awt.Dialog$3.run(Dialog.java:1098)
       at java.security.AccessController.doPrivileged(Native Method)
       at java.awt.Dialog.show(Dialog.java:1096)
       at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl$MyDialog.show(DialogWrapperPeerImpl.java:709)
       at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl.show(DialogWrapperPeerImpl.java:416)
       at com.intellij.openapi.ui.DialogWrapper.showAndGetOk(DialogWrapper.java:1323)
       at com.intellij.openapi.ui.DialogWrapper.show(DialogWrapper.java:1308)
       at com.intellij.openapi.vcs.changes.ui.CommitChangeListDialog.commit(CommitChangeListDialog.java:157)
       at com.intellij.openapi.vcs.changes.ui.CommitChangeListDialog.commitChanges(CommitChangeListDialog.java:201)
       at com.intellij.openapi.vcs.changes.ui.CommitChangeListDialog.commitChanges(CommitChangeListDialog.java:175)
       at com.intellij.openapi.vcs.changes.ui.CommitChangeListDialog.commitPaths(CommitChangeListDialog.java:169)
       at com.intellij.openapi.vcs.actions.AbstractCommonCheckinAction$1.run(AbstractCommonCheckinAction.java:65)
       at com.intellij.openapi.vcs.changes.Waiter.onSuccess(Waiter.java:79)
       at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcessWithProgressSynchronously(ProgressManagerImpl.java:289)
       at com.intellij.openapi.progress.impl.ProgressManagerImpl.run(ProgressManagerImpl.java:416)
       at com.intellij.openapi.vcs.changes.CallbackData$3.run(CallbackData.java:78)
       at com.intellij.openapi.vcs.changes.UpdateRequestsQueue.invokeAfterUpdate(UpdateRequestsQueue.java:204)
       at com.intellij.openapi.vcs.changes.ChangeListManagerImpl.invokeAfterUpdate(ChangeListManagerImpl.java:269)
       at com.intellij.openapi.vcs.actions.AbstractCommonCheckinAction.actionPerformed(AbstractCommonCheckinAction.java:53)
       at com.intellij.openapi.vcs.actions.AbstractVcsAction.actionPerformed(AbstractVcsAction.java:61)
       at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher$3.performAction(IdeKeyEventDispatcher.java:534)
       at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction(IdeKeyEventDispatcher.java:582)
       at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.inInitState(IdeKeyEventDispatcher.java:450)
       at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.java:198)
       at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:520)
       at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:416)
       at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:374)
       at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
       at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
       at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
       at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
       at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
       at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)


java.lang.AssertionError: Wrong line separators: '/**\r\n * \r\n
*/...' at offset 3
       at com.intellij.openapi.diagnostic.DefaultLogger.error(DefaultLogger.java:50)
       at com.intellij.openapi.diagnostic.Logger.error(Logger.java:54)
       at com.intellij.openapi.util.text.StringUtil.assertValidSeparators(StringUtil.java:2044)
       at com.intellij.openapi.editor.impl.DocumentImpl.assertValidSeparators(DocumentImpl.java:447)
       at com.intellij.openapi.editor.impl.DocumentImpl.replaceString(DocumentImpl.java:385)
       at com.intellij.openapi.editor.impl.DocumentImpl.access$000(DocumentImpl.java:53)
       at com.intellij.openapi.editor.impl.DocumentImpl$3.run(DocumentImpl.java:753)
       at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:105)
       at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:88)
       at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:76)
       at com.intellij.openapi.editor.impl.DocumentImpl.setText(DocumentImpl.java:760)
       at krasa.formatter.plugin.CodeFormatter.formatWhenEditorIsClosed(CodeFormatter.java:70)
       at krasa.formatter.plugin.CodeFormatter.formatWithEclipse(CodeFormatter.java:56)
       at krasa.formatter.plugin.CodeFormatter.format(CodeFormatter.java:44)
       at krasa.formatter.plugin.EclipseCodeStyleManager.reformatText(EclipseCodeStyleManager.java:74)
       at com.intellij.codeInsight.actions.ReformatCodeProcessor$1.call(ReformatCodeProcessor.java:80)
       at com.intellij.codeInsight.actions.ReformatCodeProcessor$1.call(ReformatCodeProcessor.java:74)
       at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
       at java.util.concurrent.FutureTask.run(FutureTask.java:138)
       at com.intellij.codeInsight.actions.AbstractLayoutCodeProcessor$ReformatFilesTask.iteration(AbstractLayoutCodeProcessor.java:524)
       at com.intellij.util.SequentialModalProgressTask$1.run(SequentialModalProgressTask.java:95)
       at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
       at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:641)
       at java.awt.EventQueue.access$000(EventQueue.java:84)
       at java.awt.EventQueue$1.run(EventQueue.java:602)
       at java.awt.EventQueue$1.run(EventQueue.java:600)
       at java.security.AccessController.doPrivileged(Native Method)
       at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
       at java.awt.EventQueue.dispatchEvent(EventQueue.java:611)
       at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:694)
       at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:534)
       at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:416)
       at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:374)
       at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
       at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
       at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:178)
       at java.awt.Dialog$1.run(Dialog.java:1046)
       at java.awt.Dialog$3.run(Dialog.java:1098)
       at java.security.AccessController.doPrivileged(Native Method)
       at java.awt.Dialog.show(Dialog.java:1096)
       at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl$MyDialog.show(DialogWrapperPeerImpl.java:709)
       at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl.show(DialogWrapperPeerImpl.java:416)
       at com.intellij.openapi.ui.DialogWrapper.showAndGetOk(DialogWrapper.java:1323)
       at com.intellij.openapi.ui.DialogWrapper.show(DialogWrapper.java:1308)
       at com.intellij.openapi.progress.util.ProgressWindow$MyDialog.show(ProgressWindow.java:610)
       at com.intellij.openapi.progress.util.ProgressWindow.showDialog(ProgressWindow.java:235)
       at com.intellij.openapi.progress.util.ProgressWindow$1$1.actionPerformed(ProgressWindow.java:178)
       at javax.swing.Timer.fireActionPerformed(Timer.java:291)
       at javax.swing.Timer$DoPostEvent.run(Timer.java:221)
       at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
       at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:641)
       at java.awt.EventQueue.access$000(EventQueue.java:84)
       at java.awt.EventQueue$1.run(EventQueue.java:602)
       at java.awt.EventQueue$1.run(EventQueue.java:600)
       at java.security.AccessController.doPrivileged(Native Method)
       at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
       at java.awt.EventQueue.dispatchEvent(EventQueue.java:611)
       at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:694)
       at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:534)
       at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:416)
       at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:374)
       at com.intellij.ide.IdeEventQueue.pumpEventsForHierarchy(IdeEventQueue.java:759)
       at com.intellij.openapi.progress.util.ProgressWindow.startBlocking(ProgressWindow.java:200)
       at com.intellij.openapi.application.impl.ApplicationImpl.runProcessWithProgressSynchronously(ApplicationImpl.java:652)
       at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcessWithProgressSynchronously(ProgressManagerImpl.java:273)
       at com.intellij.openapi.progress.impl.ProgressManagerImpl.run(ProgressManagerImpl.java:416)
       at com.intellij.codeInsight.actions.AbstractLayoutCodeProcessor$3.run(AbstractLayoutCodeProcessor.java:246)
       at com.intellij.codeInsight.actions.AbstractLayoutCodeProcessor$5.run(AbstractLayoutCodeProcessor.java:264)
       at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:889)
       at com.intellij.codeInsight.actions.AbstractLayoutCodeProcessor$9$1$1.run(AbstractLayoutCodeProcessor.java:459)
       at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:112)
       at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:88)
       at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:76)
       at com.intellij.codeInsight.actions.AbstractLayoutCodeProcessor$9$1.run(AbstractLayoutCodeProcessor.java:455)
       at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:333)
       at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
       at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:641)
       at java.awt.EventQueue.access$000(EventQueue.java:84)
       at java.awt.EventQueue$1.run(EventQueue.java:602)
       at java.awt.EventQueue$1.run(EventQueue.java:600)
       at java.security.AccessController.doPrivileged(Native Method)
       at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
       at java.awt.EventQueue.dispatchEvent(EventQueue.java:611)
       at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:694)
       at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:534)
       at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:416)
       at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:374)
       at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
       at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
       at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:178)
       at java.awt.Dialog$1.run(Dialog.java:1046)
       at java.awt.Dialog$3.run(Dialog.java:1098)
       at java.security.AccessController.doPrivileged(Native Method)
       at java.awt.Dialog.show(Dialog.java:1096)
       at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl$MyDialog.show(DialogWrapperPeerImpl.java:709)
       at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl.show(DialogWrapperPeerImpl.java:416)
       at com.intellij.openapi.ui.DialogWrapper.showAndGetOk(DialogWrapper.java:1323)
       at com.intellij.openapi.ui.DialogWrapper.show(DialogWrapper.java:1308)
       at com.intellij.openapi.vcs.changes.ui.CommitChangeListDialog.commit(CommitChangeListDialog.java:157)
       at com.intellij.openapi.vcs.changes.ui.CommitChangeListDialog.commitChanges(CommitChangeListDialog.java:201)
       at com.intellij.openapi.vcs.changes.ui.CommitChangeListDialog.commitChanges(CommitChangeListDialog.java:175)
       at com.intellij.openapi.vcs.changes.ui.CommitChangeListDialog.commitPaths(CommitChangeListDialog.java:169)
       at com.intellij.openapi.vcs.actions.AbstractCommonCheckinAction$1.run(AbstractCommonCheckinAction.java:65)
       at com.intellij.openapi.vcs.changes.Waiter.onSuccess(Waiter.java:79)
       at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcessWithProgressSynchronously(ProgressManagerImpl.java:289)
       at com.intellij.openapi.progress.impl.ProgressManagerImpl.run(ProgressManagerImpl.java:416)
       at com.intellij.openapi.vcs.changes.CallbackData$3.run(CallbackData.java:78)
       at com.intellij.openapi.vcs.changes.UpdateRequestsQueue.invokeAfterUpdate(UpdateRequestsQueue.java:204)
       at com.intellij.openapi.vcs.changes.ChangeListManagerImpl.invokeAfterUpdate(ChangeListManagerImpl.java:269)
       at com.intellij.openapi.vcs.actions.AbstractCommonCheckinAction.actionPerformed(AbstractCommonCheckinAction.java:53)
       at com.intellij.openapi.vcs.actions.AbstractVcsAction.actionPerformed(AbstractVcsAction.java:61)
       at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher$3.performAction(IdeKeyEventDispatcher.java:534)
       at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction(IdeKeyEventDispatcher.java:582)
       at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.inInitState(IdeKeyEventDispatcher.java:450)
       at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.java:198)
       at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:520)
       at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:416)
       at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:374)
       at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
       at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
       at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
       at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
       at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
       at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)


java.lang.AssertionError: Wrong line separators: '/**\r\n * \r\n
*/...' at offset 3
       at com.intellij.openapi.diagnostic.DefaultLogger.error(DefaultLogger.java:50)
       at com.intellij.openapi.diagnostic.Logger.error(Logger.java:54)
       at com.intellij.openapi.util.text.StringUtil.assertValidSeparators(StringUtil.java:2044)
       at com.intellij.openapi.editor.impl.DocumentImpl.assertValidSeparators(DocumentImpl.java:447)
       at com.intellij.openapi.editor.impl.DocumentImpl.replaceString(DocumentImpl.java:385)
       at com.intellij.openapi.editor.impl.DocumentImpl.access$000(DocumentImpl.java:53)
       at com.intellij.openapi.editor.impl.DocumentImpl$3.run(DocumentImpl.java:753)
       at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:105)
       at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:88)
       at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:76)
       at com.intellij.openapi.editor.impl.DocumentImpl.setText(DocumentImpl.java:760)
       at krasa.formatter.plugin.CodeFormatter.formatWhenEditorIsClosed(CodeFormatter.java:70)
       at krasa.formatter.plugin.CodeFormatter.formatWithEclipse(CodeFormatter.java:56)
       at krasa.formatter.plugin.CodeFormatter.format(CodeFormatter.java:44)
       at krasa.formatter.plugin.EclipseCodeStyleManager.reformatText(EclipseCodeStyleManager.java:74)
       at com.intellij.codeInsight.actions.ReformatCodeProcessor$1.call(ReformatCodeProcessor.java:80)
       at com.intellij.codeInsight.actions.ReformatCodeProcessor$1.call(ReformatCodeProcessor.java:74)
       at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
       at java.util.concurrent.FutureTask.run(FutureTask.java:138)
       at com.intellij.codeInsight.actions.AbstractLayoutCodeProcessor$ReformatFilesTask.iteration(AbstractLayoutCodeProcessor.java:524)
       at com.intellij.util.SequentialModalProgressTask$1.run(SequentialModalProgressTask.java:95)
       at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
       at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:641)
       at java.awt.EventQueue.access$000(EventQueue.java:84)
       at java.awt.EventQueue$1.run(EventQueue.java:602)
       at java.awt.EventQueue$1.run(EventQueue.java:600)
       at java.security.AccessController.doPrivileged(Native Method)
       at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
       at java.awt.EventQueue.dispatchEvent(EventQueue.java:611)
       at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:694)
       at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:534)
       at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:416)
       at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:374)
       at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
       at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
       at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:178)
       at java.awt.Dialog$1.run(Dialog.java:1046)
       at java.awt.Dialog$3.run(Dialog.java:1098)
       at java.security.AccessController.doPrivileged(Native Method)
       at java.awt.Dialog.show(Dialog.java:1096)
       at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl$MyDialog.show(DialogWrapperPeerImpl.java:709)
       at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl.show(DialogWrapperPeerImpl.java:416)
       at com.intellij.openapi.ui.DialogWrapper.showAndGetOk(DialogWrapper.java:1323)
       at com.intellij.openapi.ui.DialogWrapper.show(DialogWrapper.java:1308)
       at com.intellij.openapi.progress.util.ProgressWindow$MyDialog.show(ProgressWindow.java:610)
       at com.intellij.openapi.progress.util.ProgressWindow.showDialog(ProgressWindow.java:235)
       at com.intellij.openapi.progress.util.ProgressWindow$1$1.actionPerformed(ProgressWindow.java:178)
       at javax.swing.Timer.fireActionPerformed(Timer.java:291)
       at javax.swing.Timer$DoPostEvent.run(Timer.java:221)
       at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
       at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:641)
       at java.awt.EventQueue.access$000(EventQueue.java:84)
       at java.awt.EventQueue$1.run(EventQueue.java:602)
       at java.awt.EventQueue$1.run(EventQueue.java:600)
       at java.security.AccessController.doPrivileged(Native Method)
       at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
       at java.awt.EventQueue.dispatchEvent(EventQueue.java:611)
       at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:694)
       at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:534)
       at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:416)
       at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:374)
       at com.intellij.ide.IdeEventQueue.pumpEventsForHierarchy(IdeEventQueue.java:759)
       at com.intellij.openapi.progress.util.ProgressWindow.startBlocking(ProgressWindow.java:200)
       at com.intellij.openapi.application.impl.ApplicationImpl.runProcessWithProgressSynchronously(ApplicationImpl.java:652)
       at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcessWithProgressSynchronously(ProgressManagerImpl.java:273)
       at com.intellij.openapi.progress.impl.ProgressManagerImpl.run(ProgressManagerImpl.java:416)
       at com.intellij.codeInsight.actions.AbstractLayoutCodeProcessor$3.run(AbstractLayoutCodeProcessor.java:246)
       at com.intellij.codeInsight.actions.AbstractLayoutCodeProcessor$5.run(AbstractLayoutCodeProcessor.java:264)
       at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:889)
       at com.intellij.codeInsight.actions.AbstractLayoutCodeProcessor$9$1$1.run(AbstractLayoutCodeProcessor.java:459)
       at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:112)
       at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:88)
       at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:76)
       at com.intellij.codeInsight.actions.AbstractLayoutCodeProcessor$9$1.run(AbstractLayoutCodeProcessor.java:455)
       at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:333)
       at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
       at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:641)
       at java.awt.EventQueue.access$000(EventQueue.java:84)
       at java.awt.EventQueue$1.run(EventQueue.java:602)
       at java.awt.EventQueue$1.run(EventQueue.java:600)
       at java.security.AccessController.doPrivileged(Native Method)
       at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
       at java.awt.EventQueue.dispatchEvent(EventQueue.java:611)
       at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:694)
       at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:534)
       at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:416)
       at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:374)
       at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
       at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
       at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:178)
       at java.awt.Dialog$1.run(Dialog.java:1046)
       at java.awt.Dialog$3.run(Dialog.java:1098)
       at java.security.AccessController.doPrivileged(Native Method)
       at java.awt.Dialog.show(Dialog.java:1096)
       at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl$MyDialog.show(DialogWrapperPeerImpl.java:709)
       at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl.show(DialogWrapperPeerImpl.java:416)
       at com.intellij.openapi.ui.DialogWrapper.showAndGetOk(DialogWrapper.java:1323)
       at com.intellij.openapi.ui.DialogWrapper.show(DialogWrapper.java:1308)
       at com.intellij.openapi.vcs.changes.ui.CommitChangeListDialog.commit(CommitChangeListDialog.java:157)
       at com.intellij.openapi.vcs.changes.ui.CommitChangeListDialog.commitChanges(CommitChangeListDialog.java:201)
       at com.intellij.openapi.vcs.changes.ui.CommitChangeListDialog.commitChanges(CommitChangeListDialog.java:175)
       at com.intellij.openapi.vcs.changes.ui.CommitChangeListDialog.commitPaths(CommitChangeListDialog.java:169)
       at com.intellij.openapi.vcs.actions.AbstractCommonCheckinAction$1.run(AbstractCommonCheckinAction.java:65)
       at com.intellij.openapi.vcs.changes.Waiter.onSuccess(Waiter.java:79)
       at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcessWithProgressSynchronously(ProgressManagerImpl.java:289)
       at com.intellij.openapi.progress.impl.ProgressManagerImpl.run(ProgressManagerImpl.java:416)
       at com.intellij.openapi.vcs.changes.CallbackData$3.run(CallbackData.java:78)
       at com.intellij.openapi.vcs.changes.UpdateRequestsQueue.invokeAfterUpdate(UpdateRequestsQueue.java:204)
       at com.intellij.openapi.vcs.changes.ChangeListManagerImpl.invokeAfterUpdate(ChangeListManagerImpl.java:269)
       at com.intellij.openapi.vcs.actions.AbstractCommonCheckinAction.actionPerformed(AbstractCommonCheckinAction.java:53)
       at com.intellij.openapi.vcs.actions.AbstractVcsAction.actionPerformed(AbstractVcsAction.java:61)
       at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher$3.performAction(IdeKeyEventDispatcher.java:534)
       at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction(IdeKeyEventDispatcher.java:582)
       at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.inInitState(IdeKeyEventDispatcher.java:450)
       at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.java:198)
       at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:520)
       at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:416)
       at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:374)
       at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
       at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
       at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
       at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
       at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
       at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
3 comments
Comment actions Permalink

All documents inside IntelliJ IDEA always use the \n line separator. The correct line separator is put in when saving the files.
Please see http://confluence.jetbrains.net/display/IDEADEV/IntelliJ+IDEA+Architectural+Overview for more information.

0
Comment actions Permalink

well, I do not know where those \r\n comes from, because I send \n as a separator to the eclipse formatter.
following code is used:

        VirtualFile virtualFile = psiFile.getVirtualFile();
        FileDocumentManager fileDocumentManager = FileDocumentManager.getInstance();
        Document document = fileDocumentManager.getDocument(virtualFile);
        fileDocumentManager.saveDocument(document); //when file is edited and editor is closed, it is needed to save the text
        document.setText(reformat(virtualFile));
        importOptimization.appendBlankLinesBetweenGroups(document, true);
        fileDocumentManager.saveDocument(document);

0
Comment actions Permalink

omg, content of the file is loaded manually by  FileInputStream.
so now I know where is the problem.... Thanks

0

Please sign in to leave a comment.