mirror of
https://github.com/alibaba/p3c.git
synced 2025-10-14 07:01:56 +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
|
||||
*.ear
|
||||
*.gradle
|
||||
|
||||
#hsf files
|
||||
configuration
|
||||
|
@@ -2,7 +2,7 @@
|
||||
<feature
|
||||
id="com.alibaba.smartfox.eclipse.feature"
|
||||
label="%feature.label"
|
||||
version="1.0.1.qualifier"
|
||||
version="1.0.2.qualifier"
|
||||
provider-name="%feature.provider_name"
|
||||
plugin="com.alibaba.smartfox.eclipse.plugin"
|
||||
image="smartfox.png">
|
||||
|
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.alibaba.smartfox.eclipse</groupId>
|
||||
<artifactId>smartfox-eclipse</artifactId>
|
||||
<version>1.0.1-SNAPSHOT</version>
|
||||
<version>1.0.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>com.alibaba.smartfox.eclipse.feature</artifactId>
|
||||
<packaging>eclipse-feature</packaging>
|
||||
|
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: com.alibaba.smartfox.eclipse.plugin
|
||||
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-Vendor: Alibaba
|
||||
Require-Bundle: org.eclipse.ui,
|
||||
|
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.alibaba.smartfox.eclipse</groupId>
|
||||
<artifactId>smartfox-eclipse</artifactId>
|
||||
<version>1.0.1-SNAPSHOT</version>
|
||||
<version>1.0.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>com.alibaba.smartfox.eclipse.plugin</artifactId>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
|
@@ -46,7 +46,8 @@ open class CodeAnalysisHandler : AbstractHandler(), IElementUpdater {
|
||||
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 part = HandlerUtil.getActivePart(executionEvent)
|
||||
if (part is ViewPart) {
|
||||
|
@@ -83,8 +83,13 @@ object CodeAnalysis {
|
||||
return Status.OK_STATUS
|
||||
}
|
||||
}
|
||||
job.rule = P3CMutex
|
||||
job.schedule()
|
||||
job.apply {
|
||||
isUser = true
|
||||
isSystem = false
|
||||
priority = Job.INTERACTIVE
|
||||
rule = P3cMutex
|
||||
schedule()
|
||||
}
|
||||
}
|
||||
|
||||
fun processFileToMakers(file: IFile, monitor: IProgressMonitor): List<MarkerViolation> {
|
||||
@@ -92,10 +97,9 @@ object CodeAnalysis {
|
||||
val ruleViolations = processFile(file)
|
||||
|
||||
MarkerUtil.removeAllMarkers(file)
|
||||
val markers = ruleViolations.map {
|
||||
return ruleViolations.map {
|
||||
MarkerViolation(MarkerUtil.addMarker(file, it), it)
|
||||
}
|
||||
return markers
|
||||
}
|
||||
|
||||
private fun processFile(file: IFile): List<RuleViolation> {
|
||||
|
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.alibaba.smartfox.eclipse.job
|
||||
|
||||
import org.eclipse.core.resources.IResource
|
||||
import org.eclipse.core.runtime.jobs.ISchedulingRule
|
||||
|
||||
/**
|
||||
@@ -24,12 +23,12 @@ import org.eclipse.core.runtime.jobs.ISchedulingRule
|
||||
* @author caikang
|
||||
* @date 2017/06/14
|
||||
*/
|
||||
object P3CMutex : ISchedulingRule {
|
||||
object P3cMutex : ISchedulingRule {
|
||||
override fun contains(rule: ISchedulingRule?): Boolean {
|
||||
return isConflicting(rule)
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
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 org.eclipse.core.resources.IFile
|
||||
import org.eclipse.core.resources.IMarker
|
||||
@@ -133,7 +133,7 @@ class InspectionResultView : ViewPart() {
|
||||
return Status.OK_STATUS
|
||||
}
|
||||
}
|
||||
job.rule = P3CMutex
|
||||
job.rule = P3cMutex
|
||||
job.schedule()
|
||||
}
|
||||
}
|
||||
|
@@ -27,14 +27,15 @@ import org.eclipse.core.resources.IMarker
|
||||
* @date 2017/06/13
|
||||
*/
|
||||
object InspectionResults {
|
||||
val fileViolations = linkedMapOf<IFile, List<MarkerViolation>>()
|
||||
private val fileViolations = linkedMapOf<IFile, List<MarkerViolation>>()
|
||||
|
||||
var contentDescription = ""
|
||||
|
||||
val errors: List<LevelViolations> get() = run {
|
||||
val errors: List<LevelViolations>
|
||||
get() {
|
||||
val result = toLevelViolationList(fileViolations.values.flatten())
|
||||
contentDescription = getContentDescription(result)
|
||||
result
|
||||
return result
|
||||
}
|
||||
|
||||
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.SmartfoxActivator
|
||||
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.util.CleanUps
|
||||
import com.alibaba.smartfox.eclipse.util.getResolution
|
||||
@@ -57,7 +57,7 @@ class QuickFixAction(val view: InspectionResultView) : Action("Quick Fix") {
|
||||
}
|
||||
|
||||
private fun runJob() {
|
||||
val job = object : Job("Perform Quick Fix") {
|
||||
val job = object : Job("Perform P3C Quick Fix") {
|
||||
override fun run(monitor: IProgressMonitor): IStatus {
|
||||
val subMonitor = SubMonitor.convert(monitor, markers.size)
|
||||
monitor.setTaskName("Process File")
|
||||
@@ -81,8 +81,14 @@ class QuickFixAction(val view: InspectionResultView) : Action("Quick Fix") {
|
||||
return Status.OK_STATUS
|
||||
}
|
||||
}
|
||||
job.rule = P3CMutex
|
||||
val outJob = object:Job("P3C Quick Fix Wait analysis finish"){
|
||||
override fun run(monitor: IProgressMonitor?): IStatus {
|
||||
job.schedule()
|
||||
return Status.OK_STATUS
|
||||
}
|
||||
}
|
||||
outJob.rule = P3cMutex
|
||||
outJob.schedule()
|
||||
|
||||
}
|
||||
|
||||
|
@@ -33,6 +33,17 @@ data class LevelViolations(var level: String, var rules: List<RuleViolations>,
|
||||
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>,
|
||||
@@ -42,12 +53,34 @@ data class RuleViolations(var rule: String, var files: List<FileMarkers>,
|
||||
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>) {
|
||||
fun removeMarkers() {
|
||||
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)
|
@@ -54,7 +54,6 @@ object MarkerUtil {
|
||||
|
||||
@Throws(CoreException::class)
|
||||
fun addMarker(file: IFile, violation: RuleViolation): IMarker {
|
||||
|
||||
val marker = file.createMarker(MARKER_TYPE)
|
||||
marker.setAttribute(IMarker.MESSAGE, violation.description)
|
||||
val severity = when (violation.rule.priority) {
|
||||
|
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.alibaba.smartfox.eclipse</groupId>
|
||||
<artifactId>smartfox-eclipse</artifactId>
|
||||
<version>1.0.1-SNAPSHOT</version>
|
||||
<version>1.0.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>com.alibaba.smartfox.eclipse.updatesite</artifactId>
|
||||
<packaging>eclipse-repository</packaging>
|
||||
|
@@ -5,7 +5,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.alibaba.smartfox.eclipse</groupId>
|
||||
<artifactId>smartfox-eclipse</artifactId>
|
||||
<version>1.0.1-SNAPSHOT</version>
|
||||
<version>1.0.2-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<inceptionYear>2017</inceptionYear>
|
||||
<properties>
|
||||
|
Reference in New Issue
Block a user