generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
revert "simpleframework" (line endings are parsed wrongly from xml)
- Loading branch information
1 parent
e6c380e
commit 21944ce
Showing
4 changed files
with
37 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 22 additions & 13 deletions
35
src/main/kotlin/com/github/aarcangeli/ideaclangformat/services/ClangFormatResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,39 @@ | ||
package com.github.aarcangeli.ideaclangformat.services | ||
|
||
import org.simpleframework.xml.Attribute | ||
import org.simpleframework.xml.ElementList | ||
import org.simpleframework.xml.Root | ||
import org.simpleframework.xml.Text | ||
import org.simpleframework.xml.core.Persister | ||
import java.io.StringReader | ||
import javax.xml.bind.JAXBContext | ||
import javax.xml.bind.JAXBException | ||
import javax.xml.bind.annotation.XmlAttribute | ||
import javax.xml.bind.annotation.XmlElement | ||
import javax.xml.bind.annotation.XmlRootElement | ||
import javax.xml.bind.annotation.XmlValue | ||
|
||
fun parseClangFormatResponse(stdout: String): ClangFormatResponse { | ||
val serializer = Persister() | ||
return serializer.read(ClangFormatResponse::class.java, stdout) | ||
val ctx: JAXBContext? | ||
try { | ||
ctx = JAXBContext.newInstance(ClangFormatResponse::class.java) | ||
} | ||
catch (e: JAXBException) { | ||
throw RuntimeException("Failed to load JAXB context", e) | ||
} | ||
|
||
val result = ctx.createUnmarshaller().unmarshal(StringReader(stdout)) | ||
return result as ClangFormatResponse | ||
} | ||
|
||
@Root(name = "replacements", strict = false) | ||
@XmlRootElement(name = "replacements") | ||
class ClangFormatResponse { | ||
@field:ElementList(name = "replacement", required = false, inline = true) | ||
@set:XmlElement(name = "replacement") | ||
var replacements: List<ClangFormatReplacement> = ArrayList() | ||
} | ||
|
||
@Root(strict = false, name = "replacement") | ||
class ClangFormatReplacement { | ||
@field:Attribute(required = true) | ||
@set:XmlAttribute | ||
var offset: Int = 0 | ||
|
||
@field:Attribute(required = true) | ||
@set:XmlAttribute | ||
var length: Int = 0 | ||
|
||
@field:Text(required = false) | ||
@set:XmlValue | ||
var value: String = "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters