remove html report
This commit is contained in:
parent
098a72d209
commit
09d5bda15e
|
|
@ -0,0 +1,24 @@
|
|||
# User-specific stuff:
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/dictionaries
|
||||
|
||||
# Sensitive or high-churn files:
|
||||
.idea/**/dataSources/
|
||||
.idea/**/dataSources.ids
|
||||
.idea/**/dataSources.local.xml
|
||||
.idea/**/sqlDataSources.xml
|
||||
.idea/**/dynamic.xml
|
||||
.idea/**/uiDesigner.xml
|
||||
|
||||
# Gradle:
|
||||
.idea/**/gradle.xml
|
||||
.idea/**/libraries
|
||||
|
||||
## File-based project format:
|
||||
*.iws
|
||||
|
||||
## Plugin-specific files:
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" project-jdk-name="IntelliJ IDEA Community Edition IC-173.4548.28" project-jdk-type="IDEA JDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/StAnalysisKotlin.iml" filepath="$PROJECT_DIR$/StAnalysisKotlin.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PLUGIN_MODULE" version="4">
|
||||
<component name="DevKit.ModuleBuildProperties" url="file://$MODULE_DIR$/resources/META-INF/plugin.xml" />
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
Binary file not shown.
|
|
@ -0,0 +1,46 @@
|
|||
<idea-plugin>
|
||||
<id>ru.touchin.staticanalysis</id>
|
||||
<name>Static analysis runner</name>
|
||||
<version>2.0</version>
|
||||
<vendor email="arseniy.borisov@touchin.ru" url="http://www.touchin.ru">Touch Instinct</vendor>
|
||||
|
||||
<description><![CDATA[
|
||||
Helper plugin for static analysis in Touch Instinct
|
||||
]]></description>
|
||||
|
||||
<change-notes><![CDATA[
|
||||
1.0 First version
|
||||
]]>
|
||||
</change-notes>
|
||||
|
||||
<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html for description -->
|
||||
<idea-version since-build="145.0"/>
|
||||
|
||||
<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html
|
||||
on how to target different products -->
|
||||
<!-- uncomment to enable plugin in all products
|
||||
<depends>com.intellij.modules.lang</depends>
|
||||
-->
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<!-- Add your extensions here -->
|
||||
</extensions>
|
||||
|
||||
<actions>
|
||||
<action id="AnalysisRunner.Run"
|
||||
class="ru.touchin.staticanalysis.actions.RunStaticAnalysis"
|
||||
icon="PluginIcons.PLUGIN_ICON"
|
||||
text="Touchin static analysis"
|
||||
description="Touchin static analysis">
|
||||
<add-to-group group-id="ToolbarRunGroup" anchor="last"/>
|
||||
<keyboard-shortcut first-keystroke="control shift S" keymap="$default"/>
|
||||
</action>
|
||||
</actions>
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<toolWindow id="Static Analysis Log" icon="PluginIcons.PLUGIN_ICON" anchor="bottom"
|
||||
factoryClass="ru.touchin.staticanalysis.notifications.LogToolWindowFactory"/>
|
||||
<projectService id="ConsoleView" serviceImplementation="ru.touchin.staticanalysis.notifications.ConsoleService"/>
|
||||
</extensions>
|
||||
|
||||
</idea-plugin>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 446 B |
Binary file not shown.
|
After Width: | Height: | Size: 924 B |
|
|
@ -0,0 +1,11 @@
|
|||
package icons;
|
||||
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public interface PluginIcons {
|
||||
|
||||
Icon PLUGIN_ICON = IconLoader.getIcon("/icons/logo.png");
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package ru.touchin.staticanalysis.actions
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnAction
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys
|
||||
import ru.touchin.staticanalysis.tasks.AnalysisTask
|
||||
|
||||
class RunStaticAnalysis : AnAction("Touchin static analysis") {
|
||||
|
||||
private lateinit var analysisTask: AnalysisTask
|
||||
|
||||
override fun actionPerformed(actionEvent: AnActionEvent) {
|
||||
val project = actionEvent.getData(PlatformDataKeys.PROJECT)!!
|
||||
analysisTask = AnalysisTask(project)
|
||||
analysisTask.queue()
|
||||
}
|
||||
|
||||
override fun update(actionEvent: AnActionEvent) {
|
||||
actionEvent.presentation.isEnabled = !::analysisTask.isInitialized || !analysisTask.isRunning
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package ru.touchin.staticanalysis.notifications
|
||||
|
||||
import com.intellij.execution.filters.TextConsoleBuilderFactory
|
||||
import com.intellij.execution.ui.ConsoleView
|
||||
import com.intellij.openapi.project.Project
|
||||
|
||||
class ConsoleService(project: Project) {
|
||||
|
||||
val consoleView: ConsoleView = TextConsoleBuilderFactory.getInstance().createBuilder(project).console
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package ru.touchin.staticanalysis.notifications
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.wm.ToolWindow
|
||||
import com.intellij.openapi.wm.ToolWindowFactory
|
||||
|
||||
class LogToolWindowFactory : ToolWindowFactory {
|
||||
|
||||
override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) {
|
||||
val consoleView = ServiceManager.getService(project, ConsoleService::class.java).consoleView
|
||||
val content = toolWindow.contentManager.factory.createContent(consoleView.component, "", true)
|
||||
toolWindow.contentManager.addContent(content)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package ru.touchin.staticanalysis.notifications
|
||||
|
||||
import com.intellij.notification.*
|
||||
import com.intellij.openapi.project.Project
|
||||
import icons.PluginIcons
|
||||
|
||||
class PluginNotificationManager(private val project: Project) {
|
||||
|
||||
fun showErrorNotification(message: String) {
|
||||
hideOldNotifications()
|
||||
NotificationGroup(NOTIFICATION_TITLE, NotificationDisplayType.STICKY_BALLOON, true)
|
||||
.createNotification(NOTIFICATION_TITLE, message, NotificationType.ERROR, null)
|
||||
.notify(project)
|
||||
}
|
||||
|
||||
fun showInfoNotification(message: String) {
|
||||
hideOldNotifications()
|
||||
NotificationGroup(NOTIFICATION_TITLE, NotificationDisplayType.STICKY_BALLOON, true, null, PluginIcons.PLUGIN_ICON)
|
||||
Notification(NOTIFICATION_TITLE, PluginIcons.PLUGIN_ICON, NOTIFICATION_TITLE, null, message, NotificationType.INFORMATION, null)
|
||||
.notify(project)
|
||||
}
|
||||
|
||||
private fun hideOldNotifications() {
|
||||
val logModel = EventLog.getLogModel(project)
|
||||
for (notification in logModel.notifications) {
|
||||
if (notification.groupId == NOTIFICATION_TITLE) {
|
||||
logModel.removeNotification(notification)
|
||||
notification.expire()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val NOTIFICATION_TITLE = "Static Analysis"
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,116 @@
|
|||
package ru.touchin.staticanalysis.tasks
|
||||
|
||||
import com.intellij.execution.ui.ConsoleViewContentType
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.components.ServiceManager
|
||||
import com.intellij.openapi.progress.ProcessCanceledException
|
||||
import com.intellij.openapi.progress.ProgressIndicator
|
||||
import com.intellij.openapi.progress.Task.Backgroundable
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.wm.IdeFrame
|
||||
import com.intellij.openapi.wm.ToolWindowManager
|
||||
import com.intellij.openapi.wm.WindowManager
|
||||
import com.intellij.ui.AppIcon
|
||||
import ru.touchin.staticanalysis.notifications.ConsoleService
|
||||
import ru.touchin.staticanalysis.notifications.PluginNotificationManager
|
||||
import java.io.BufferedReader
|
||||
import java.io.File
|
||||
import java.io.InputStreamReader
|
||||
import java.util.regex.Pattern
|
||||
|
||||
|
||||
class AnalysisTask(project: Project) : Backgroundable(project, "StaticAnalysis", true) {
|
||||
|
||||
var isRunning: Boolean = false
|
||||
private val notificationsManager = PluginNotificationManager(project)
|
||||
|
||||
private val gradlewCommand = if (System.getProperty("os.name").startsWith("Windows"))
|
||||
listOf("cmd", "/c", "gradlew.bat", "staticAnalys")
|
||||
else
|
||||
listOf("./gradlew", "staticAnalys")
|
||||
|
||||
private val gradlewProcess: Process by lazy {
|
||||
ProcessBuilder(gradlewCommand)
|
||||
.directory(File(project.basePath))
|
||||
.redirectErrorStream(true)
|
||||
.start()
|
||||
}
|
||||
|
||||
override fun run(progressIndicator: ProgressIndicator) {
|
||||
isRunning = true
|
||||
progressIndicator.isIndeterminate = true
|
||||
try {
|
||||
runAnalysis(progressIndicator)
|
||||
} catch (canceledException: ProcessCanceledException) {
|
||||
progressIndicator.cancel()
|
||||
} catch (exception: Exception) {
|
||||
notificationsManager.showErrorNotification("Exception: " + exception.message)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCancel() {
|
||||
gradlewProcess.destroy()
|
||||
}
|
||||
|
||||
override fun onFinished() {
|
||||
isRunning = false
|
||||
}
|
||||
|
||||
@Throws(Exception::class)
|
||||
private fun runAnalysis(progressIndicator: ProgressIndicator) {
|
||||
val analysisOutput: String = getAnalysisOutput(progressIndicator)
|
||||
if (!analysisOutput.startsWith("Error") && !analysisOutput.startsWith("FAILURE")) {
|
||||
if (Pattern.compile("Overall: PASSED").matcher(analysisOutput).find()) {
|
||||
notificationsManager.showInfoNotification("Overall: PASSED!")
|
||||
requestIdeFocus()
|
||||
} else if (!Pattern.compile("Overall: FAILED").matcher(analysisOutput).find()) {
|
||||
notificationsManager.showErrorNotification("Can't detect analysis result. Try to run it manually.")
|
||||
} else {
|
||||
val errorsCountPattern = Pattern.compile("Overall: FAILED \\((.+)\\)")
|
||||
val errorsCountMatcher = errorsCountPattern.matcher(analysisOutput)
|
||||
if (errorsCountMatcher.find()) {
|
||||
notificationsManager.showErrorNotification(String.format("Analysis failed: %s", errorsCountMatcher.group(1)))
|
||||
ApplicationManager.getApplication().invokeLater {
|
||||
ToolWindowManager.getInstance(project).getToolWindow("Static Analysis Log").show(null)
|
||||
}
|
||||
} else {
|
||||
notificationsManager.showErrorNotification("Can't detect analysis result. Try to run it manually.")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
notificationsManager.showErrorNotification(analysisOutput)
|
||||
}
|
||||
}
|
||||
|
||||
@Throws(Exception::class)
|
||||
private fun getAnalysisOutput(progressIndicator: ProgressIndicator): String {
|
||||
val bufferedReader = BufferedReader(InputStreamReader(gradlewProcess.inputStream))
|
||||
val analysisOutputBuilder = StringBuilder()
|
||||
|
||||
val consoleView = ServiceManager.getService(project, ConsoleService::class.java).consoleView
|
||||
var outputLine: String? = bufferedReader.readLine()
|
||||
while (outputLine != null) {
|
||||
|
||||
consoleView.print(outputLine + '\n', ConsoleViewContentType.NORMAL_OUTPUT)
|
||||
progressIndicator.text2 = outputLine
|
||||
progressIndicator.checkCanceled()
|
||||
analysisOutputBuilder.append(outputLine)
|
||||
analysisOutputBuilder.append('\n')
|
||||
outputLine = bufferedReader.readLine()
|
||||
}
|
||||
|
||||
return analysisOutputBuilder.toString()
|
||||
}
|
||||
|
||||
private fun requestIdeFocus() {
|
||||
ApplicationManager.getApplication().invokeLater {
|
||||
val frame = WindowManager.getInstance().getFrame(project)
|
||||
if (frame is IdeFrame) {
|
||||
AppIcon.getInstance().requestFocus(frame)
|
||||
AppIcon.getInstance().requestAttention(project, true)
|
||||
AppIcon.getInstance().setOkBadge(project, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue