platan/idea-gradle-dependencies-formatter

Unable to paste multiple Maven dependencies at once.

mxwlsavard opened this issue · 8 comments

I can paste individual Maven dependencies just fine but if I copy and paste more than one nothing gets pasted. Here are the idea logs:
2017-12-18 11:05:59,335 [ 523444] ERROR - llij.ide.plugins.PluginManager - Wrong line separators: '...t-starter'\r\ncompile ...' at offset 52 java.lang.AssertionError: Wrong line separators: '...t-starter'\r\ncompile ...' at offset 52 at com.intellij.openapi.util.text.StringUtil.assertValidSeparators(StringUtil.java:2624) at com.intellij.openapi.editor.impl.DocumentImpl.a(DocumentImpl.java:612) at com.intellij.openapi.editor.impl.DocumentImpl.insertString(DocumentImpl.java:458) at com.intellij.openapi.editor.EditorModificationUtil.insertStringAtCaretNoScrolling(EditorModificationUtil.java:120) at com.intellij.openapi.editor.EditorModificationUtil.insertStringAtCaret(EditorModificationUtil.java:95) at com.intellij.openapi.editor.EditorModificationUtil.insertStringAtCaret(EditorModificationUtil.java:87) at com.intellij.codeInsight.editorActions.PasteHandler.a(PasteHandler.java:196) at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:1003) at com.intellij.codeInsight.editorActions.PasteHandler.a(PasteHandler.java:194) at com.intellij.codeInsight.editorActions.PasteHandler.execute(PasteHandler.java:121) at com.intellij.codeInsight.editorActions.PasteHandler.doExecute(PasteHandler.java:74) at com.intellij.openapi.editor.actionSystem.EditorActionHandler.lambda$execute$4(EditorActionHandler.java:207) at com.intellij.openapi.editor.actionSystem.EditorActionHandler.doIfEnabled(EditorActionHandler.java:110) at com.intellij.openapi.editor.actionSystem.EditorActionHandler.execute(EditorActionHandler.java:206) at com.intellij.openapi.editor.actionSystem.EditorAction.lambda$actionPerformed$0(EditorAction.java:98) at com.intellij.openapi.command.impl.CoreCommandProcessor.a(CoreCommandProcessor.java:149) at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:109) at com.intellij.openapi.editor.actionSystem.EditorAction.actionPerformed(EditorAction.java:107) at com.intellij.openapi.editor.impl.EditorImpl$MyEditable.a(EditorImpl.java:2999) at com.intellij.openapi.editor.impl.EditorImpl$MyEditable.performPaste(EditorImpl.java:2972) at com.intellij.ide.actions.PasteAction.actionPerformed(PasteAction.java:45) at com.intellij.openapi.actionSystem.ex.ActionUtil$1.run(ActionUtil.java:220) at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:237) at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.a(ActionMenuItem.java:321) at com.intellij.openapi.wm.impl.FocusManagerImpl.runOnOwnContext(FocusManagerImpl.java:911) at com.intellij.openapi.wm.impl.IdeFocusManagerImpl.runOnOwnContext(IdeFocusManagerImpl.java:136) at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.actionPerformed(ActionMenuItem.java:311) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022) at com.intellij.openapi.actionSystem.impl.ActionMenuItem.a(ActionMenuItem.java:130) at com.intellij.openapi.application.TransactionGuardImpl.a(TransactionGuardImpl.java:88) at com.intellij.openapi.application.TransactionGuardImpl.a(TransactionGuardImpl.java:111) at com.intellij.openapi.application.TransactionGuardImpl.submitTransaction(TransactionGuardImpl.java:120) at com.intellij.openapi.application.TransactionGuard.submitTransaction(TransactionGuard.java:122) at com.intellij.openapi.actionSystem.impl.ActionMenuItem.fireActionPerformed(ActionMenuItem.java:130) at com.intellij.ui.plaf.beg.BegMenuItemUI.a(BegMenuItemUI.java:521) at com.intellij.ui.plaf.beg.BegMenuItemUI.access$300(BegMenuItemUI.java:48) at com.intellij.ui.plaf.beg.BegMenuItemUI$MyMouseInputHandler.mouseReleased(BegMenuItemUI.java:541) at java.awt.Component.processMouseEvent(Component.java:6541) at javax.swing.JComponent.processMouseEvent(JComponent.java:3324) at java.awt.Component.processEvent(Component.java:6306) at java.awt.Container.processEvent(Container.java:2237) at java.awt.Component.dispatchEventImpl(Component.java:4897) at java.awt.Container.dispatchEventImpl(Container.java:2295) at java.awt.Component.dispatchEvent(Component.java:4719) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4889) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4526) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4467) at java.awt.Container.dispatchEventImpl(Container.java:2281) at java.awt.Window.dispatchEventImpl(Window.java:2746) at java.awt.Component.dispatchEvent(Component.java:4719) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:764) at java.awt.EventQueue.access$500(EventQueue.java:98) at java.awt.EventQueue$3.run(EventQueue.java:715) at java.awt.EventQueue$3.run(EventQueue.java:709) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90) at java.awt.EventQueue$4.run(EventQueue.java:737) at java.awt.EventQueue$4.run(EventQueue.java:735) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80) at java.awt.EventQueue.dispatchEvent(EventQueue.java:734) at com.intellij.ide.IdeEventQueue.j(IdeEventQueue.java:822) at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:646) at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:366) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) at java.awt.EventDispatchThread.run(EventDispatchThread.java:82) 2017-12-18 11:05:59,335 [ 523444] ERROR - llij.ide.plugins.PluginManager - IntelliJ IDEA 2017.3.1 Build #IU-173.3942.27 2017-12-18 11:05:59,335 [ 523444] ERROR - llij.ide.plugins.PluginManager - JDK: 1.8.0_152-release 2017-12-18 11:05:59,335 [ 523444] ERROR - llij.ide.plugins.PluginManager - VM: OpenJDK 64-Bit Server VM 2017-12-18 11:05:59,335 [ 523444] ERROR - llij.ide.plugins.PluginManager - Vendor: JetBrains s.r.o 2017-12-18 11:05:59,335 [ 523444] ERROR - llij.ide.plugins.PluginManager - OS: Windows 10 2017-12-18 11:05:59,335 [ 523444] ERROR - llij.ide.plugins.PluginManager - Last Action: $Paste

Thanks for reporting this! Last lines of logs contains IntelliJ IDEA version and OS name, which is great. Currently I can confirm that problem occurs on Windows (on Linux it works correctly). Please stay tuned!

I've created a CI with Windows https://ci.appveyor.com/project/platan/idea-gradle-dependencies-formatter/build/master%205 and it some tests for maven to gradle conversion are failing.

Problem is pretty common. Here I found an explanation roana0229/android-xml-sorter#12

The new version with fix (0.5.3) is pending for JetBrains approval: https://plugins.jetbrains.com/plugin/7937-gradle-dependencies-formatter

Wow thanks a lot! I tried to understand that other issue, is it that the plugin is only expecting ‘nix line endings and bombing when there’s Windows line endings?

Exactly. This is my fix 51181c2. Here you have Intellij platform documentation about this requirement http://www.jetbrains.org/intellij/sdk/docs/basics/architectural_overview/documents.html

I just tested the updated plugin and it is working! Thanks for fixing this, I was starting to tear my hair out copying dependencies one at a time. I did notice one more issue, hyphens in Maven variable names get pasted with spaces surrounding them in the Gradle dependency, ie:

<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-jdbc</artifactId>
	<version>${spring-boot-version}</version>
</dependency>

becomes
compile "org.springframework.boot:spring-boot-starter-jdbc:${spring - boot - version}"

I'm not personally bothered by it because I can work around it easily enough but I can create an issue for it if you want.

I'm happy to see that the fix works for you.
The issue with pasting a variable looks interesting. I will take a closer look at this case.