chore: fix kotlin compiler warnings
This commit is contained in:
parent
ab5948a51b
commit
6c14ad7113
5 changed files with 34 additions and 37 deletions
|
@ -119,10 +119,10 @@ data class ZigProjectConfigurationData(
|
||||||
if (git) {
|
if (git) {
|
||||||
project.zigCoroutineScope.launch {
|
project.zigCoroutineScope.launch {
|
||||||
GitRepositoryInitializer.getInstance()?.initRepository(project, baseDir)
|
GitRepositoryInitializer.getInstance()?.initRepository(project, baseDir)
|
||||||
createGitIgnoreFile(project, baseDir, requestor)
|
createGitIgnoreFile(baseDir, requestor)
|
||||||
}
|
}
|
||||||
} else if (forceGitignore) {
|
} else if (forceGitignore) {
|
||||||
createGitIgnoreFile(project, baseDir, requestor)
|
createGitIgnoreFile(baseDir, requestor)
|
||||||
}
|
}
|
||||||
|
|
||||||
return@reportProgress true
|
return@reportProgress true
|
||||||
|
@ -131,7 +131,7 @@ data class ZigProjectConfigurationData(
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun createGitIgnoreFile(project: Project, projectDir: VirtualFile, requestor: Any) {
|
private suspend fun createGitIgnoreFile(projectDir: VirtualFile, requestor: Any) {
|
||||||
if (projectDir.findChild(".gitignore") != null) {
|
if (projectDir.findChild(".gitignore") != null) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,6 @@ import com.intellij.openapi.application.ModalityState
|
||||||
|
|
||||||
class ZigRegularRunner: ZigProgramRunner<ZigProfileState<*>>(DefaultRunExecutor.EXECUTOR_ID) {
|
class ZigRegularRunner: ZigProgramRunner<ZigProfileState<*>>(DefaultRunExecutor.EXECUTOR_ID) {
|
||||||
override suspend fun execute(state: ZigProfileState<*>, toolchain: AbstractZigToolchain, environment: ExecutionEnvironment): RunContentDescriptor? {
|
override suspend fun execute(state: ZigProfileState<*>, toolchain: AbstractZigToolchain, environment: ExecutionEnvironment): RunContentDescriptor? {
|
||||||
val cli = state.getCommandLine(toolchain, false)
|
|
||||||
val exec = state.execute(environment.executor, this)
|
val exec = state.execute(environment.executor, this)
|
||||||
return withEDTContext(ModalityState.any()) {
|
return withEDTContext(ModalityState.any()) {
|
||||||
val runContentBuilder = RunContentBuilder(exec, environment)
|
val runContentBuilder = RunContentBuilder(exec, environment)
|
||||||
|
|
|
@ -90,7 +90,7 @@ class ZigStepDiscoveryService(private val project: Project) {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
{}
|
|
||||||
} else if (result.checkSuccess(LOG)) {
|
} else if (result.checkSuccess(LOG)) {
|
||||||
currentTimeoutSec = DEFAULT_TIMEOUT_SEC
|
currentTimeoutSec = DEFAULT_TIMEOUT_SEC
|
||||||
val lines = result.stdoutLines
|
val lines = result.stdoutLines
|
||||||
|
|
|
@ -81,18 +81,18 @@ class BuildToolWindowContext(private val project: Project): Disposable {
|
||||||
val tree = Tree(model).also { it.isRootVisible = false }
|
val tree = Tree(model).also { it.isRootVisible = false }
|
||||||
}
|
}
|
||||||
private val viewPanel = JPanel(VerticalLayout(0))
|
private val viewPanel = JPanel(VerticalLayout(0))
|
||||||
private val steps = TreeBox()
|
private val stepsBox = TreeBox()
|
||||||
private val build = if (IPCUtil.haveIPC) TreeBox() else null
|
private val buildBox = if (IPCUtil.haveIPC) TreeBox() else null
|
||||||
private var live = AtomicBoolean(true)
|
private var live = AtomicBoolean(true)
|
||||||
init {
|
init {
|
||||||
viewPanel.add(JBLabel(ZigBrainsBundle.message("build.tool.window.tree.steps.label")))
|
viewPanel.add(JBLabel(ZigBrainsBundle.message("build.tool.window.tree.steps.label")))
|
||||||
viewPanel.add(steps.panel)
|
viewPanel.add(stepsBox.panel)
|
||||||
steps.panel.setNotScanned()
|
stepsBox.panel.setNotScanned()
|
||||||
|
|
||||||
steps.tree.addMouseListener(object : MouseAdapter() {
|
stepsBox.tree.addMouseListener(object : MouseAdapter() {
|
||||||
override fun mouseClicked(e: MouseEvent) {
|
override fun mouseClicked(e: MouseEvent) {
|
||||||
if (e.clickCount == 2) {
|
if (e.clickCount == 2) {
|
||||||
val node = steps.tree.lastSelectedPathComponent as? DefaultMutableTreeNode ?: return
|
val node = stepsBox.tree.lastSelectedPathComponent as? DefaultMutableTreeNode ?: return
|
||||||
val step = node.userObject as? StepNodeDescriptor ?: return
|
val step = node.userObject as? StepNodeDescriptor ?: return
|
||||||
|
|
||||||
val stepName = step.element?.name ?: return
|
val stepName = step.element?.name ?: return
|
||||||
|
@ -112,10 +112,10 @@ class BuildToolWindowContext(private val project: Project): Disposable {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
if (build != null) {
|
if (buildBox != null) {
|
||||||
viewPanel.add(JBLabel(ZigBrainsBundle.message("build.tool.window.tree.build.label")))
|
viewPanel.add(JBLabel(ZigBrainsBundle.message("build.tool.window.tree.build.label")))
|
||||||
viewPanel.add(build.panel)
|
viewPanel.add(buildBox.panel)
|
||||||
build.panel.setNoBuilds()
|
buildBox.panel.setNoBuilds()
|
||||||
|
|
||||||
project.zigCoroutineScope.launch {
|
project.zigCoroutineScope.launch {
|
||||||
while (!project.isDisposed && live.get()) {
|
while (!project.isDisposed && live.get()) {
|
||||||
|
@ -126,14 +126,14 @@ class BuildToolWindowContext(private val project: Project): Disposable {
|
||||||
ipc.mutex.withLock {
|
ipc.mutex.withLock {
|
||||||
withEDTContext(ModalityState.any()) {
|
withEDTContext(ModalityState.any()) {
|
||||||
if (ipc.nodes.isEmpty()) {
|
if (ipc.nodes.isEmpty()) {
|
||||||
build.root.removeAllChildren()
|
buildBox.root.removeAllChildren()
|
||||||
build.panel.setNoBuilds()
|
buildBox.panel.setNoBuilds()
|
||||||
return@withEDTContext
|
return@withEDTContext
|
||||||
}
|
}
|
||||||
val allNodes = ArrayList(ipc.nodes)
|
val allNodes = ArrayList(ipc.nodes)
|
||||||
val existingNodes = ArrayList<ZigIPCService.IPCTreeNode>()
|
val existingNodes = ArrayList<ZigIPCService.IPCTreeNode>()
|
||||||
val removedNodes = ArrayList<ZigIPCService.IPCTreeNode>()
|
val removedNodes = ArrayList<ZigIPCService.IPCTreeNode>()
|
||||||
build.root.children().iterator().forEach { child ->
|
buildBox.root.children().iterator().forEach { child ->
|
||||||
if (child !is ZigIPCService.IPCTreeNode) {
|
if (child !is ZigIPCService.IPCTreeNode) {
|
||||||
return@forEach
|
return@forEach
|
||||||
}
|
}
|
||||||
|
@ -145,18 +145,18 @@ class BuildToolWindowContext(private val project: Project): Disposable {
|
||||||
}
|
}
|
||||||
val newNodes = ArrayList<MutableTreeNode>(allNodes)
|
val newNodes = ArrayList<MutableTreeNode>(allNodes)
|
||||||
newNodes.removeAll(existingNodes)
|
newNodes.removeAll(existingNodes)
|
||||||
removedNodes.forEach { build.root.remove(it) }
|
removedNodes.forEach { buildBox.root.remove(it) }
|
||||||
newNodes.forEach { build.root.add(it) }
|
newNodes.forEach { buildBox.root.add(it) }
|
||||||
if (removedNodes.isNotEmpty() || newNodes.isNotEmpty()) {
|
if (removedNodes.isNotEmpty() || newNodes.isNotEmpty()) {
|
||||||
build.model.reload(build.root)
|
buildBox.model.reload(buildBox.root)
|
||||||
}
|
}
|
||||||
if (build.root.childCount == 0) {
|
if (buildBox.root.childCount == 0) {
|
||||||
build.panel.setNoBuilds()
|
buildBox.panel.setNoBuilds()
|
||||||
} else {
|
} else {
|
||||||
build.panel.setViewportBody(build.tree)
|
buildBox.panel.setViewportBody(buildBox.tree)
|
||||||
}
|
}
|
||||||
for (bn in allNodes) {
|
for (bn in allNodes) {
|
||||||
expandRecursively(build, bn)
|
expandRecursively(buildBox, bn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -220,28 +220,28 @@ class BuildToolWindowContext(private val project: Project): Disposable {
|
||||||
|
|
||||||
inner class BuildReloadListener: ZigStepDiscoveryListener {
|
inner class BuildReloadListener: ZigStepDiscoveryListener {
|
||||||
override suspend fun preReload() {
|
override suspend fun preReload() {
|
||||||
steps.panel.setRunningZigBuild()
|
stepsBox.panel.setRunningZigBuild()
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun postReload(stepInfo: List<Pair<String, String?>>) {
|
override suspend fun postReload(steps: List<Pair<String, String?>>) {
|
||||||
steps.root.removeAllChildren()
|
stepsBox.root.removeAllChildren()
|
||||||
for ((task, description) in stepInfo) {
|
for ((task, description) in steps) {
|
||||||
val icon = when(task) {
|
val icon = when(task) {
|
||||||
"install" -> AllIcons.Actions.Install
|
"install" -> AllIcons.Actions.Install
|
||||||
"uninstall" -> AllIcons.Actions.Uninstall
|
"uninstall" -> AllIcons.Actions.Uninstall
|
||||||
else -> AllIcons.RunConfigurations.TestState.Run
|
else -> AllIcons.RunConfigurations.TestState.Run
|
||||||
}
|
}
|
||||||
steps.root.add(DefaultMutableTreeNode(StepNodeDescriptor(project, task, icon, description)))
|
stepsBox.root.add(DefaultMutableTreeNode(StepNodeDescriptor(project, task, icon, description)))
|
||||||
}
|
}
|
||||||
withEDTContext(ModalityState.any()) {
|
withEDTContext(ModalityState.any()) {
|
||||||
steps.model.reload(steps.root)
|
stepsBox.model.reload(stepsBox.root)
|
||||||
steps.panel.setViewportBody(steps.tree)
|
stepsBox.panel.setViewportBody(stepsBox.tree)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun errorReload(type: ZigStepDiscoveryListener.ErrorType, details: String?) {
|
override suspend fun errorReload(type: ZigStepDiscoveryListener.ErrorType, details: String?) {
|
||||||
withEDTContext(ModalityState.any()) {
|
withEDTContext(ModalityState.any()) {
|
||||||
steps.panel.setViewportError(ZigBrainsBundle.message(when(type) {
|
stepsBox.panel.setViewportError(ZigBrainsBundle.message(when(type) {
|
||||||
ZigStepDiscoveryListener.ErrorType.MissingToolchain -> "build.tool.window.status.error.missing-toolchain"
|
ZigStepDiscoveryListener.ErrorType.MissingToolchain -> "build.tool.window.status.error.missing-toolchain"
|
||||||
ZigStepDiscoveryListener.ErrorType.MissingZigExe -> "build.tool.window.status.error.missing-zig-exe"
|
ZigStepDiscoveryListener.ErrorType.MissingZigExe -> "build.tool.window.status.error.missing-zig-exe"
|
||||||
ZigStepDiscoveryListener.ErrorType.MissingBuildZig -> "build.tool.window.status.error.missing-build-zig"
|
ZigStepDiscoveryListener.ErrorType.MissingBuildZig -> "build.tool.window.status.error.missing-build-zig"
|
||||||
|
@ -252,7 +252,7 @@ class BuildToolWindowContext(private val project: Project): Disposable {
|
||||||
|
|
||||||
override suspend fun timeoutReload(seconds: Int) {
|
override suspend fun timeoutReload(seconds: Int) {
|
||||||
withEDTContext(ModalityState.any()) {
|
withEDTContext(ModalityState.any()) {
|
||||||
steps.panel.setViewportError(ZigBrainsBundle.message("build.tool.window.status.timeout", seconds), null)
|
stepsBox.panel.setViewportError(ZigBrainsBundle.message("build.tool.window.status.timeout", seconds), null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,18 +55,16 @@ class ZonBlock(
|
||||||
|
|
||||||
override fun getChildIndent(): Indent {
|
override fun getChildIndent(): Indent {
|
||||||
val node = this.node
|
val node = this.node
|
||||||
return getIndentBasedOnParentType(node, null, node.elementType, PLACEHOLDER)
|
return getIndentBasedOnParentType(node.elementType, PLACEHOLDER)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getIndent(): Indent {
|
override fun getIndent(): Indent {
|
||||||
val node = this.node
|
val node = this.node
|
||||||
val parent = node.treeParent ?: return noneIndent
|
val parent = node.treeParent ?: return noneIndent
|
||||||
return getIndentBasedOnParentType(parent, node, parent.elementType, node.elementType)
|
return getIndentBasedOnParentType(parent.elementType, node.elementType)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private fun getIndentBasedOnParentType(
|
private fun getIndentBasedOnParentType(
|
||||||
parent: ASTNode,
|
|
||||||
child: ASTNode?,
|
|
||||||
parentType: IElementType,
|
parentType: IElementType,
|
||||||
childType: IElementType
|
childType: IElementType
|
||||||
): Indent {
|
): Indent {
|
||||||
|
|
Loading…
Add table
Reference in a new issue