mirror of
https://github.com/alibaba/p3c.git
synced 2025-10-15 15:40:26 +00:00
fix https://github.com/alibaba/p3c/issues/157 https://github.com/alibaba/p3c/issues/102 https://github.com/alibaba/p3c/issues/77
treeview keep expand state while update result data
This commit is contained in:
1
eclipse-plugin/.gitignore
vendored
1
eclipse-plugin/.gitignore
vendored
@@ -11,6 +11,7 @@ testdata/
|
|||||||
|
|
||||||
*.war
|
*.war
|
||||||
*.ear
|
*.ear
|
||||||
|
*.gradle
|
||||||
|
|
||||||
#hsf files
|
#hsf files
|
||||||
configuration
|
configuration
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
<feature
|
<feature
|
||||||
id="com.alibaba.smartfox.eclipse.feature"
|
id="com.alibaba.smartfox.eclipse.feature"
|
||||||
label="%feature.label"
|
label="%feature.label"
|
||||||
version="1.0.1.qualifier"
|
version="1.0.2.qualifier"
|
||||||
provider-name="%feature.provider_name"
|
provider-name="%feature.provider_name"
|
||||||
plugin="com.alibaba.smartfox.eclipse.plugin"
|
plugin="com.alibaba.smartfox.eclipse.plugin"
|
||||||
image="smartfox.png">
|
image="smartfox.png">
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.alibaba.smartfox.eclipse</groupId>
|
<groupId>com.alibaba.smartfox.eclipse</groupId>
|
||||||
<artifactId>smartfox-eclipse</artifactId>
|
<artifactId>smartfox-eclipse</artifactId>
|
||||||
<version>1.0.1-SNAPSHOT</version>
|
<version>1.0.2-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>com.alibaba.smartfox.eclipse.feature</artifactId>
|
<artifactId>com.alibaba.smartfox.eclipse.feature</artifactId>
|
||||||
<packaging>eclipse-feature</packaging>
|
<packaging>eclipse-feature</packaging>
|
||||||
|
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
|||||||
Bundle-ManifestVersion: 2
|
Bundle-ManifestVersion: 2
|
||||||
Bundle-Name: com.alibaba.smartfox.eclipse.plugin
|
Bundle-Name: com.alibaba.smartfox.eclipse.plugin
|
||||||
Bundle-SymbolicName: com.alibaba.smartfox.eclipse.plugin;singleton:=true
|
Bundle-SymbolicName: com.alibaba.smartfox.eclipse.plugin;singleton:=true
|
||||||
Bundle-Version: 1.0.1.qualifier
|
Bundle-Version: 1.0.2.qualifier
|
||||||
Bundle-Activator: com.alibaba.smartfox.eclipse.SmartfoxActivator
|
Bundle-Activator: com.alibaba.smartfox.eclipse.SmartfoxActivator
|
||||||
Bundle-Vendor: Alibaba
|
Bundle-Vendor: Alibaba
|
||||||
Require-Bundle: org.eclipse.ui,
|
Require-Bundle: org.eclipse.ui,
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.alibaba.smartfox.eclipse</groupId>
|
<groupId>com.alibaba.smartfox.eclipse</groupId>
|
||||||
<artifactId>smartfox-eclipse</artifactId>
|
<artifactId>smartfox-eclipse</artifactId>
|
||||||
<version>1.0.1-SNAPSHOT</version>
|
<version>1.0.2-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>com.alibaba.smartfox.eclipse.plugin</artifactId>
|
<artifactId>com.alibaba.smartfox.eclipse.plugin</artifactId>
|
||||||
<packaging>eclipse-plugin</packaging>
|
<packaging>eclipse-plugin</packaging>
|
||||||
|
@@ -46,7 +46,8 @@ open class CodeAnalysisHandler : AbstractHandler(), IElementUpdater {
|
|||||||
element.setTooltip(text)
|
element.setTooltip(text)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Throws(ExecutionException::class) override fun execute(executionEvent: ExecutionEvent): Any? {
|
@Throws(ExecutionException::class)
|
||||||
|
override fun execute(executionEvent: ExecutionEvent): Any? {
|
||||||
val selection = HandlerUtil.getCurrentSelectionChecked(executionEvent)
|
val selection = HandlerUtil.getCurrentSelectionChecked(executionEvent)
|
||||||
val part = HandlerUtil.getActivePart(executionEvent)
|
val part = HandlerUtil.getActivePart(executionEvent)
|
||||||
if (part is ViewPart) {
|
if (part is ViewPart) {
|
||||||
|
@@ -83,8 +83,13 @@ object CodeAnalysis {
|
|||||||
return Status.OK_STATUS
|
return Status.OK_STATUS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
job.rule = P3CMutex
|
job.apply {
|
||||||
job.schedule()
|
isUser = true
|
||||||
|
isSystem = false
|
||||||
|
priority = Job.INTERACTIVE
|
||||||
|
rule = P3cMutex
|
||||||
|
schedule()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun processFileToMakers(file: IFile, monitor: IProgressMonitor): List<MarkerViolation> {
|
fun processFileToMakers(file: IFile, monitor: IProgressMonitor): List<MarkerViolation> {
|
||||||
@@ -92,10 +97,9 @@ object CodeAnalysis {
|
|||||||
val ruleViolations = processFile(file)
|
val ruleViolations = processFile(file)
|
||||||
|
|
||||||
MarkerUtil.removeAllMarkers(file)
|
MarkerUtil.removeAllMarkers(file)
|
||||||
val markers = ruleViolations.map {
|
return ruleViolations.map {
|
||||||
MarkerViolation(MarkerUtil.addMarker(file, it), it)
|
MarkerViolation(MarkerUtil.addMarker(file, it), it)
|
||||||
}
|
}
|
||||||
return markers
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun processFile(file: IFile): List<RuleViolation> {
|
private fun processFile(file: IFile): List<RuleViolation> {
|
||||||
@@ -126,4 +130,4 @@ object CodeAnalysis {
|
|||||||
}
|
}
|
||||||
return report.toList()
|
return report.toList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -15,7 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.alibaba.smartfox.eclipse.job
|
package com.alibaba.smartfox.eclipse.job
|
||||||
|
|
||||||
import org.eclipse.core.resources.IResource
|
|
||||||
import org.eclipse.core.runtime.jobs.ISchedulingRule
|
import org.eclipse.core.runtime.jobs.ISchedulingRule
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -24,12 +23,12 @@ import org.eclipse.core.runtime.jobs.ISchedulingRule
|
|||||||
* @author caikang
|
* @author caikang
|
||||||
* @date 2017/06/14
|
* @date 2017/06/14
|
||||||
*/
|
*/
|
||||||
object P3CMutex : ISchedulingRule {
|
object P3cMutex : ISchedulingRule {
|
||||||
override fun contains(rule: ISchedulingRule?): Boolean {
|
override fun contains(rule: ISchedulingRule?): Boolean {
|
||||||
return isConflicting(rule)
|
return isConflicting(rule)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isConflicting(rule: ISchedulingRule?): Boolean {
|
override fun isConflicting(rule: ISchedulingRule?): Boolean {
|
||||||
return rule == this || rule is IResource
|
return rule == this
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -16,7 +16,7 @@
|
|||||||
package com.alibaba.smartfox.eclipse.ui
|
package com.alibaba.smartfox.eclipse.ui
|
||||||
|
|
||||||
import com.alibaba.smartfox.eclipse.SmartfoxActivator
|
import com.alibaba.smartfox.eclipse.SmartfoxActivator
|
||||||
import com.alibaba.smartfox.eclipse.job.P3CMutex
|
import com.alibaba.smartfox.eclipse.job.P3cMutex
|
||||||
import com.alibaba.smartfox.eclipse.util.MarkerUtil
|
import com.alibaba.smartfox.eclipse.util.MarkerUtil
|
||||||
import org.eclipse.core.resources.IFile
|
import org.eclipse.core.resources.IFile
|
||||||
import org.eclipse.core.resources.IMarker
|
import org.eclipse.core.resources.IMarker
|
||||||
@@ -133,7 +133,7 @@ class InspectionResultView : ViewPart() {
|
|||||||
return Status.OK_STATUS
|
return Status.OK_STATUS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
job.rule = P3CMutex
|
job.rule = P3cMutex
|
||||||
job.schedule()
|
job.schedule()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -27,15 +27,16 @@ import org.eclipse.core.resources.IMarker
|
|||||||
* @date 2017/06/13
|
* @date 2017/06/13
|
||||||
*/
|
*/
|
||||||
object InspectionResults {
|
object InspectionResults {
|
||||||
val fileViolations = linkedMapOf<IFile, List<MarkerViolation>>()
|
private val fileViolations = linkedMapOf<IFile, List<MarkerViolation>>()
|
||||||
|
|
||||||
var contentDescription = ""
|
var contentDescription = ""
|
||||||
|
|
||||||
val errors: List<LevelViolations> get() = run {
|
val errors: List<LevelViolations>
|
||||||
val result = toLevelViolationList(fileViolations.values.flatten())
|
get() {
|
||||||
contentDescription = getContentDescription(result)
|
val result = toLevelViolationList(fileViolations.values.flatten())
|
||||||
result
|
contentDescription = getContentDescription(result)
|
||||||
}
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
lateinit var view: InspectionResultView
|
lateinit var view: InspectionResultView
|
||||||
|
|
||||||
|
@@ -19,7 +19,7 @@ import com.alibaba.p3c.pmd.lang.java.rule.flowcontrol.NeedBraceRule
|
|||||||
import com.alibaba.smartfox.eclipse.RunWithoutViewRefresh
|
import com.alibaba.smartfox.eclipse.RunWithoutViewRefresh
|
||||||
import com.alibaba.smartfox.eclipse.SmartfoxActivator
|
import com.alibaba.smartfox.eclipse.SmartfoxActivator
|
||||||
import com.alibaba.smartfox.eclipse.job.CodeAnalysis
|
import com.alibaba.smartfox.eclipse.job.CodeAnalysis
|
||||||
import com.alibaba.smartfox.eclipse.job.P3CMutex
|
import com.alibaba.smartfox.eclipse.job.P3cMutex
|
||||||
import com.alibaba.smartfox.eclipse.pmd.rule.MissingOverrideAnnotationRule
|
import com.alibaba.smartfox.eclipse.pmd.rule.MissingOverrideAnnotationRule
|
||||||
import com.alibaba.smartfox.eclipse.util.CleanUps
|
import com.alibaba.smartfox.eclipse.util.CleanUps
|
||||||
import com.alibaba.smartfox.eclipse.util.getResolution
|
import com.alibaba.smartfox.eclipse.util.getResolution
|
||||||
@@ -57,7 +57,7 @@ class QuickFixAction(val view: InspectionResultView) : Action("Quick Fix") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun runJob() {
|
private fun runJob() {
|
||||||
val job = object : Job("Perform Quick Fix") {
|
val job = object : Job("Perform P3C Quick Fix") {
|
||||||
override fun run(monitor: IProgressMonitor): IStatus {
|
override fun run(monitor: IProgressMonitor): IStatus {
|
||||||
val subMonitor = SubMonitor.convert(monitor, markers.size)
|
val subMonitor = SubMonitor.convert(monitor, markers.size)
|
||||||
monitor.setTaskName("Process File")
|
monitor.setTaskName("Process File")
|
||||||
@@ -81,8 +81,14 @@ class QuickFixAction(val view: InspectionResultView) : Action("Quick Fix") {
|
|||||||
return Status.OK_STATUS
|
return Status.OK_STATUS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
job.rule = P3CMutex
|
val outJob = object:Job("P3C Quick Fix Wait analysis finish"){
|
||||||
job.schedule()
|
override fun run(monitor: IProgressMonitor?): IStatus {
|
||||||
|
job.schedule()
|
||||||
|
return Status.OK_STATUS
|
||||||
|
}
|
||||||
|
}
|
||||||
|
outJob.rule = P3cMutex
|
||||||
|
outJob.schedule()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,4 +111,4 @@ class QuickFixAction(val view: InspectionResultView) : Action("Quick Fix") {
|
|||||||
return ruleName == MissingOverrideAnnotationRule::class.java.simpleName
|
return ruleName == MissingOverrideAnnotationRule::class.java.simpleName
|
||||||
|| ruleName == NeedBraceRule::class.java.simpleName
|
|| ruleName == NeedBraceRule::class.java.simpleName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -33,6 +33,17 @@ data class LevelViolations(var level: String, var rules: List<RuleViolations>,
|
|||||||
it.removeMarkers()
|
it.removeMarkers()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (other !is LevelViolations) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return level == other.level
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun hashCode(): Int {
|
||||||
|
return level.hashCode()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data class RuleViolations(var rule: String, var files: List<FileMarkers>,
|
data class RuleViolations(var rule: String, var files: List<FileMarkers>,
|
||||||
@@ -42,12 +53,34 @@ data class RuleViolations(var rule: String, var files: List<FileMarkers>,
|
|||||||
it.removeMarkers()
|
it.removeMarkers()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (other !is RuleViolations) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return rule == other.rule
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun hashCode(): Int {
|
||||||
|
return rule.hashCode()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data class FileMarkers(var file: IFile, var markers: List<MarkerViolation>) {
|
data class FileMarkers(var file: IFile, var markers: List<MarkerViolation>) {
|
||||||
fun removeMarkers() {
|
fun removeMarkers() {
|
||||||
MarkerUtil.removeAllMarkers(file)
|
MarkerUtil.removeAllMarkers(file)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (other !is FileMarkers) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return file == other.file
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun hashCode(): Int {
|
||||||
|
return file.hashCode()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data class MarkerViolation(val marker: IMarker, val violation: RuleViolation)
|
data class MarkerViolation(val marker: IMarker, val violation: RuleViolation)
|
||||||
|
@@ -54,7 +54,6 @@ object MarkerUtil {
|
|||||||
|
|
||||||
@Throws(CoreException::class)
|
@Throws(CoreException::class)
|
||||||
fun addMarker(file: IFile, violation: RuleViolation): IMarker {
|
fun addMarker(file: IFile, violation: RuleViolation): IMarker {
|
||||||
|
|
||||||
val marker = file.createMarker(MARKER_TYPE)
|
val marker = file.createMarker(MARKER_TYPE)
|
||||||
marker.setAttribute(IMarker.MESSAGE, violation.description)
|
marker.setAttribute(IMarker.MESSAGE, violation.description)
|
||||||
val severity = when (violation.rule.priority) {
|
val severity = when (violation.rule.priority) {
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.alibaba.smartfox.eclipse</groupId>
|
<groupId>com.alibaba.smartfox.eclipse</groupId>
|
||||||
<artifactId>smartfox-eclipse</artifactId>
|
<artifactId>smartfox-eclipse</artifactId>
|
||||||
<version>1.0.1-SNAPSHOT</version>
|
<version>1.0.2-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>com.alibaba.smartfox.eclipse.updatesite</artifactId>
|
<artifactId>com.alibaba.smartfox.eclipse.updatesite</artifactId>
|
||||||
<packaging>eclipse-repository</packaging>
|
<packaging>eclipse-repository</packaging>
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.alibaba.smartfox.eclipse</groupId>
|
<groupId>com.alibaba.smartfox.eclipse</groupId>
|
||||||
<artifactId>smartfox-eclipse</artifactId>
|
<artifactId>smartfox-eclipse</artifactId>
|
||||||
<version>1.0.1-SNAPSHOT</version>
|
<version>1.0.2-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<inceptionYear>2017</inceptionYear>
|
<inceptionYear>2017</inceptionYear>
|
||||||
<properties>
|
<properties>
|
||||||
|
Reference in New Issue
Block a user