Skip to content

Commit

Permalink
Merge pull request #178 from SeanCai/master
Browse files Browse the repository at this point in the history
fix #157 #102 #77 performance issue
  • Loading branch information
SeanCai authored Nov 23, 2017
2 parents 71bdcde + 3044543 commit 59eb16b
Show file tree
Hide file tree
Showing 15 changed files with 74 additions and 30 deletions.
1 change: 1 addition & 0 deletions eclipse-plugin/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ testdata/

*.war
*.ear
*.gradle

#hsf files
configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,23 @@ 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> {
file.refreshLocal(IResource.DEPTH_ZERO, monitor)
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> {
Expand Down Expand Up @@ -126,4 +130,4 @@ object CodeAnalysis {
}
return report.toList()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package com.alibaba.smartfox.eclipse.job

import org.eclipse.core.resources.IResource
import org.eclipse.core.runtime.jobs.ISchedulingRule

/**
Expand All @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -133,7 +133,7 @@ class InspectionResultView : ViewPart() {
return Status.OK_STATUS
}
}
job.rule = P3CMutex
job.rule = P3cMutex
job.schedule()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,16 @@ 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 result = toLevelViolationList(fileViolations.values.flatten())
contentDescription = getContentDescription(result)
result
}
val errors: List<LevelViolations>
get() {
val result = toLevelViolationList(fileViolations.values.flatten())
contentDescription = getContentDescription(result)
return result
}

lateinit var view: InspectionResultView

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand All @@ -81,8 +81,14 @@ class QuickFixAction(val view: InspectionResultView) : Action("Quick Fix") {
return Status.OK_STATUS
}
}
job.rule = P3CMutex
job.schedule()
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()

}

Expand All @@ -105,4 +111,4 @@ class QuickFixAction(val view: InspectionResultView) : Action("Quick Fix") {
return ruleName == MissingOverrideAnnotationRule::class.java.simpleName
|| ruleName == NeedBraceRule::class.java.simpleName
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand All @@ -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)
data class MarkerViolation(val marker: IMarker, val violation: RuleViolation)
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion eclipse-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit 59eb16b

Please sign in to comment.