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TFC6CABWSZK2EC4MNCRQAC
/**
* Dracon - An IntelliJ-Pijul integration.
* Copyright 2021 JonathanxD <jhrldev@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.github.jonathanxd.dracon.util
import java.util.concurrent.ThreadFactory
import java.util.concurrent.atomic.AtomicInteger
class NamedThreadFactory(val name: String) : ThreadFactory {
private val group: ThreadGroup
private val threadNumber = AtomicInteger(1)
private val namePostfix: String
override fun newThread(r: Runnable): Thread {
val t = Thread(
group, r,
this.name + this.namePostfix + threadNumber.getAndIncrement(),
0
)
if (t.isDaemon) t.isDaemon = false
if (t.priority != Thread.NORM_PRIORITY) t.priority = Thread.NORM_PRIORITY
return t
}
companion object {
private val poolNumber = AtomicInteger(1)
}
init {
val s = System.getSecurityManager()
group = if (s != null) s.threadGroup else Thread.currentThread().threadGroup
namePostfix = "-namedPool-" +
poolNumber.getAndIncrement() +
"-thread-"
}
}
Files.walkFileTree(path, object : SimpleFileVisitor<Path>() {
override fun preVisitDirectory(dir: Path, attrs: BasicFileAttributes): FileVisitResult {
return if (dir != path) FileVisitResult.CONTINUE
else FileVisitResult.SKIP_SUBTREE
}
if (Files.exists(path)) {
Files.walkFileTree(path, object : SimpleFileVisitor<Path>() {
override fun preVisitDirectory(dir: Path, attrs: BasicFileAttributes): FileVisitResult {
return if (dir != path) FileVisitResult.CONTINUE
else FileVisitResult.SKIP_SUBTREE
}
override fun visitFile(file: Path, attrs: BasicFileAttributes): FileVisitResult {
Files.delete(file)
return FileVisitResult.CONTINUE
}
})
override fun visitFile(file: Path, attrs: BasicFileAttributes): FileVisitResult {
Files.delete(file)
return FileVisitResult.CONTINUE
}
})
}
it.connectAndRetrieveContent()
if (!it.connectAndRetrieveContent()) {
Notifications.Bus.notify(
Notification(
PUSH_GROUP,
DraconBundle.message("editor-server.timeout.title"),
DraconBundle.message("editor-server.timeout.text"),
NotificationType.ERROR,
),
project
)
}
if (this.rootPath.endsWith("/")) this.rootPath + this.path
else this.rootPath + "/" + this.path
when {
this.rootPath == "/" -> this.path
this.rootPath.endsWith("/") -> this.rootPath + this.path
this.rootPath.isEmpty() -> this.path
else -> this.rootPath + "/" + this.path
}
val process = ProcessBuilder()
.command(listOf(findPijul()) + args)
.directory(dir.toFile())
.start()
val process = runBlocking {
withContext(pijulProcessContext) {
val process = ProcessBuilder()
.command(listOf(findPijul()) + args)
.directory(dir.toFile())
.start()
process
}
}
val process = ProcessBuilder()
.command(listOf(findPijul()) + args)
.directory(dir.toFile())
.start()
val process = runBlocking {
withContext(pijulProcessContext) {
val process = ProcessBuilder()
.command(listOf(findPijul()) + args)
.directory(dir.toFile())
.start()
return this.cache.cache(key) {
val process = ProcessBuilder()
.command(listOf(findPijul()) + args)
.directory(dir.toFile())
.start()
return runBlocking {
withContext(pijulProcessContext) {
cache.cache(key) {
val process = ProcessBuilder()
.command(listOf(findPijul()) + args)
.directory(dir.toFile())
.start()
val input = String(process.inputStream.readAllBytes(), Charsets.UTF_8)
val error = String(process.errorStream.readAllBytes(), Charsets.UTF_8)
val input = String(process.inputStream.readAllBytes(), Charsets.UTF_8)
val error = String(process.errorStream.readAllBytes(), Charsets.UTF_8)
input.split("\n").forEach {
draconConsoleWriter(project).logCommand("pijul", args, it)
}
input.split("\n").forEach {
draconConsoleWriter(project).logCommand("pijul", args, it)
}
error.split("\n").forEach {
draconConsoleWriter(project).logCommandError("pijul", args, it)
}
error.split("\n").forEach {
draconConsoleWriter(project).logCommandError("pijul", args, it)
}
val exit = process.waitFor()
if (exit == 0) {
draconConsoleWriter(project).logCommand("pijul", args, "<Exit status> $exit")
} else {
draconConsoleWriter(project).logCommandError("pijul", args, "<Exit status> $exit")
}
val exit = process.waitFor()
if (exit == 0) {
draconConsoleWriter(project).logCommand("pijul", args, "<Exit status> $exit")
} else {
draconConsoleWriter(project).logCommandError("pijul", args, "<Exit status> $exit")
PijulExecution(
input,
error,
exit
)
}
val process = ProcessBuilder()
.apply {
when (copieMode) {
CopieMode.FROM -> environment()["COPIE_FROM"] = copiePath.toAbsolutePath().toString()
CopieMode.TO -> environment()["COPIE_TO"] = copiePath.toAbsolutePath().toString()
}
val process = runBlocking {
withContext(pijulProcessContext) {
val process = ProcessBuilder()
.apply {
when (copieMode) {
CopieMode.FROM -> environment()["COPIE_FROM"] = copiePath.toAbsolutePath().toString()
CopieMode.TO -> environment()["COPIE_TO"] = copiePath.toAbsolutePath().toString()
}
val process = ProcessBuilder()
.apply {
environment()["EDITOR_SERVER_PORT"] = freePort.toString()
environment()["VISUAL"] = editorServerPath()
environment()["EDITOR"] = editorServerPath()
val process = runBlocking {
withContext(pijulProcessContext) {
val process = ProcessBuilder()
.apply {
environment()["EDITOR_SERVER_PORT"] = freePort.toString()
environment()["VISUAL"] = editorServerPath()
environment()["EDITOR"] = editorServerPath()
}
.command(listOf(findPijul()) + args)
.directory(dir.toFile())
.start()
process
val process = ProcessBuilder()
.apply {
environment()["EDITOR_SERVER_PORT"] = freePort.toString()
environment()["VISUAL"] = editorServerPath()
environment()["EDITOR"] = editorServerPath()
val process = runBlocking {
withContext(pijulProcessContext) {
val cmd = listOf(findPijul()) + args
val terminalCmd = terminalCommand("command.execute.text", cmd.joinToString(" "))
val process = ProcessBuilder()
.apply {
environment()["EDITOR_SERVER_PORT"] = freePort.toString()
environment()["VISUAL"] = editorServerPath()
environment()["EDITOR"] = editorServerPath()
}
.command(terminalCmd)
.directory(dir.toFile())
.start()
process
it.connectAndRetrieveContent()
if(!it.connectAndRetrieveContent()) {
Notifications.Bus.notify(
Notification(
PUSH_GROUP,
DraconBundle.message("editor-server.timeout.title"),
DraconBundle.message("editor-server.timeout.text"),
NotificationType.ERROR,
),
project
)
}
it.connectAndRetrieveContent()
if (!it.connectAndRetrieveContent()) {
Notifications.Bus.notify(
Notification(
EXPERT_MODE_GROUP,
DraconBundle.message("editor-server.timeout.title"),
DraconBundle.message("editor-server.timeout.text"),
NotificationType.ERROR,
),
project
)
}
setPlugins(*properties("platformPlugins").split(',').map(String::trim).filter(String::isNotEmpty).toTypedArray())
setPlugins("org.toml.lang:0.2.144.3766-211")
setPlugins(
*properties("platformPlugins").split(',').map(String::trim).filter(String::isNotEmpty).toTypedArray(),
"org.toml.lang:0.2.144.3766-211",
"terminal"
)