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.
Merge pull request #10 from jaksonlin/render-report-to-code
Render report to code
- Loading branch information
Showing
34 changed files
with
809 additions
and
126 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
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
30 changes: 5 additions & 25 deletions
30
src/main/kotlin/com/github/jaksonlin/pitestintellij/actions/RunPitestAction.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,36 +1,16 @@ | ||
package com.github.jaksonlin.pitestintellij.actions | ||
import com.github.jaksonlin.pitestintellij.commands.PrepareEnvironmentCommand | ||
import com.github.jaksonlin.pitestintellij.commands.BuildPitestCommandCommand | ||
import com.github.jaksonlin.pitestintellij.commands.HandlePitestResultCommand | ||
import com.github.jaksonlin.pitestintellij.commands.PitestContext | ||
import com.github.jaksonlin.pitestintellij.commands.RunPitestCommand | ||
|
||
import com.github.jaksonlin.pitestintellij.services.PitestService | ||
import com.intellij.openapi.actionSystem.AnAction | ||
import com.intellij.openapi.actionSystem.AnActionEvent | ||
import com.intellij.openapi.actionSystem.PlatformDataKeys | ||
import com.intellij.openapi.progress.ProgressIndicator | ||
import com.intellij.openapi.progress.Task | ||
import com.intellij.openapi.components.service | ||
|
||
class RunPitestAction : AnAction() { | ||
private val pitestService = service<PitestService>() | ||
override fun actionPerformed(e: AnActionEvent) { | ||
val targetProject = e.project ?: return | ||
val testVirtualFile = e.getData(PlatformDataKeys.VIRTUAL_FILE) ?: return | ||
|
||
val context = PitestContext(testVirtualFile = testVirtualFile) | ||
|
||
val commands = listOf( | ||
PrepareEnvironmentCommand(targetProject, context), | ||
BuildPitestCommandCommand(targetProject, context), | ||
RunPitestCommand(targetProject, context), | ||
HandlePitestResultCommand(targetProject, context), | ||
) | ||
|
||
object : Task.Backgroundable(targetProject, "Running pitest", true) { | ||
override fun run(indicator: ProgressIndicator) { | ||
for (command in commands) { | ||
if (indicator.isCanceled) { break } | ||
command.execute() | ||
} | ||
} | ||
}.queue() | ||
pitestService.runPitest(targetProject, testVirtualFile.path) | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
src/main/kotlin/com/github/jaksonlin/pitestintellij/commands/BuildPitestCommandCommand.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
6 changes: 6 additions & 0 deletions
6
src/main/kotlin/com/github/jaksonlin/pitestintellij/commands/CommandCancellationException.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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.github.jaksonlin.pitestintellij.commands | ||
|
||
|
||
class CommandCancellationException(message: String) : Exception(message) { | ||
|
||
} |
2 changes: 1 addition & 1 deletion
2
src/main/kotlin/com/github/jaksonlin/pitestintellij/commands/HandlePitestResultCommand.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
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
1 change: 1 addition & 0 deletions
1
src/main/kotlin/com/github/jaksonlin/pitestintellij/commands/RunPitestCommand.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
13 changes: 13 additions & 0 deletions
13
src/main/kotlin/com/github/jaksonlin/pitestintellij/commands/StoreHistoryCommand.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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.github.jaksonlin.pitestintellij.commands | ||
|
||
import PitestCommand | ||
import com.github.jaksonlin.pitestintellij.context.PitestContext | ||
import com.github.jaksonlin.pitestintellij.services.RunHistoryManager | ||
import com.intellij.openapi.project.Project | ||
|
||
class StoreHistoryCommand (project: Project, context: PitestContext) : PitestCommand(project, context) { | ||
|
||
override fun execute() { | ||
runHistoryManager.saveRunHistory(context) | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
src/main/kotlin/com/github/jaksonlin/pitestintellij/components/ObservableTree.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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package com.github.jaksonlin.pitestintellij.components | ||
import com.github.jaksonlin.pitestintellij.MyBundle | ||
import com.github.jaksonlin.pitestintellij.observers.RunHistoryObserver | ||
import com.intellij.ui.treeStructure.Tree | ||
import javax.swing.SwingUtilities | ||
import javax.swing.tree.DefaultMutableTreeNode | ||
import javax.swing.tree.DefaultTreeModel | ||
import javax.swing.tree.TreePath | ||
|
||
class ObservableTree:Tree(), RunHistoryObserver { | ||
|
||
override fun onRunHistoryChanged(eventObj:Any?) { | ||
when (eventObj) { | ||
null -> initializeMutationTree(emptyList()) | ||
is Pair<*, *> -> updateMutationTree(eventObj as? Pair<String, String> ?: return) | ||
is List<*> -> initializeMutationTree(eventObj as? List<Pair<String, String>> ?: return) | ||
else -> return | ||
} | ||
} | ||
|
||
private fun initializeMutationTree(nodeNameList: List<Pair<String, String>>) { | ||
val treeModel = buildTreeModel(nodeNameList) | ||
model = treeModel | ||
} | ||
|
||
private fun buildTreeModel(nodeNameList: List<Pair<String, String>>): DefaultTreeModel { | ||
val root = DefaultMutableTreeNode(MyBundle.message("mutation.tree.root")) | ||
|
||
nodeNameList.forEach { | ||
val packageName = it.first | ||
val packageNode = getOrCreatePackageNode(root, packageName) | ||
val newNode = DefaultMutableTreeNode(it.second) | ||
packageNode.add(newNode) | ||
} | ||
|
||
return DefaultTreeModel(root) | ||
} | ||
|
||
private fun getOrCreatePackageNode(root: DefaultMutableTreeNode, packageName: String): DefaultMutableTreeNode { | ||
var currentNode = root | ||
packageName.split('.').forEach { packagePart -> | ||
var childNode = currentNode.children().asSequence() | ||
.filterIsInstance<DefaultMutableTreeNode>() | ||
.find { it.userObject == packagePart } | ||
|
||
if (childNode == null) { | ||
childNode = DefaultMutableTreeNode(packagePart) | ||
currentNode.add(childNode) | ||
} | ||
currentNode = childNode | ||
} | ||
return currentNode | ||
} | ||
|
||
private fun updateMutationTree(pair: Pair<String, String>) { | ||
val root = model.root as DefaultMutableTreeNode | ||
val packageName = pair.first | ||
val packageNode = getOrCreatePackageNode(root, packageName) | ||
val newNode = DefaultMutableTreeNode(pair.second) | ||
packageNode.add(newNode) | ||
SwingUtilities.invokeLater { | ||
expandPath(TreePath(packageNode.path)) // expand the package node | ||
updateUI() | ||
} | ||
} | ||
} |
17 changes: 11 additions & 6 deletions
17
.../pitestintellij/commands/PitestContext.kt → ...n/pitestintellij/context/PitestContext.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
12 changes: 12 additions & 0 deletions
12
src/main/kotlin/com/github/jaksonlin/pitestintellij/mediators/MutationMediator.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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.github.jaksonlin.pitestintellij.mediators | ||
|
||
interface IMutationMediator { | ||
fun processMutationResult(mutationTargetClassFilePath:String, mutationReportFilePath: String) | ||
fun register(clientUI: IMutationReportUI) | ||
} | ||
|
||
interface IMutationReportUI { | ||
fun updateMutationResult(mutationClassFilePath:String, mutationTestResult: Map<Int, Pair<String, Boolean>>) | ||
} | ||
|
||
|
Oops, something went wrong.