Skip to content

Commit 7effe10

Browse files
committed
navigation discovery
1 parent c8e49f4 commit 7effe10

File tree

5 files changed

+37
-1
lines changed

5 files changed

+37
-1
lines changed

ide-common/src/main/kotlin/org/digma/intellij/plugin/discovery/model/EndpointLocation.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,11 @@ import com.intellij.openapi.vfs.VirtualFile
44

55
class EndpointLocation(val file: VirtualFile, val endpointId: String, val offset: Int, val methodCodeObjectId: String) {
66
fun isAlive(): Boolean = file.isValid
7+
8+
9+
10+
override fun toString(): String {
11+
return "EndpointLocation(file=$file, endpointId='$endpointId', offset=$offset, methodCodeObjectId='$methodCodeObjectId')"
12+
}
13+
714
}

ide-common/src/main/kotlin/org/digma/intellij/plugin/discovery/model/SpanLocation.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,10 @@ import com.intellij.openapi.vfs.VirtualFile
44

55
class SpanLocation(val file: VirtualFile, val offset: Int, val methodCodeObjectId: String) {
66
fun isAlive(): Boolean = file.isValid
7+
8+
override fun toString(): String {
9+
return "SpanLocation(file=$file, offset=$offset, methodCodeObjectId='$methodCodeObjectId')"
10+
}
11+
12+
713
}

jvm-common/src/main/kotlin/org/digma/intellij/plugin/idea/navigation/JvmEndpointNavigationProvider.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,21 @@ internal class JvmEndpointNavigationProvider(private val project: Project) {
6060

6161

6262
suspend fun maintenance() {
63+
64+
if(logger.isTraceEnabled){
65+
Log.trace(logger, "starting maintenance, current endpoint location count ${endpointsMap.size}")
66+
endpointsMap.forEach { (endpointId, endpointLocations) ->
67+
Log.trace(logger, "endpoint location for endpoint {}: [{}]", endpointId, endpointLocations)
68+
}
69+
}
70+
6371
maintenanceLock.withLock {
6472
val toRemove = endpointsMap.filter { (_, endpointLocations) ->
6573
!endpointLocations.any { it.isAlive() } || !endpointLocations.any { hasIndex(project, it.file) }
6674
}.keys
75+
if (toRemove.isEmpty()) {
76+
return@withLock
77+
}
6778
Log.trace(logger, "maintenance removing endpoints {}", toRemove)
6879
endpointsMap.entries.removeIf { toRemove.contains(it.key) }
6980
}

jvm-common/src/main/kotlin/org/digma/intellij/plugin/idea/navigation/JvmNavigationDiscoveryManager.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,8 @@ class JvmNavigationDiscoveryManager(private val project: Project, private val cs
219219

220220

221221
private fun launchMaintenanceJob() {
222-
cs.launchWhileActiveWithErrorReporting(1.minutes, 30.seconds, "${this::class.java.simpleName}.MaintenanceTask", logger) {
222+
cs.launchWhileActiveWithErrorReporting(1.minutes, 1.minutes, "${this::class.java.simpleName}.MaintenanceTask", logger) {
223+
DumbService.getInstance(project).waitForSmartMode()
223224
JvmSpanNavigationProvider.getInstance(project).maintenance()
224225
JvmEndpointNavigationProvider.getInstance(project).maintenance()
225226
}

jvm-common/src/main/kotlin/org/digma/intellij/plugin/idea/navigation/JvmSpanNavigationProvider.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,19 @@ internal class JvmSpanNavigationProvider(private val project: Project) {
7070
}
7171

7272
suspend fun maintenance() {
73+
74+
if(logger.isTraceEnabled){
75+
Log.trace(logger, "starting maintenance, current span location count ${spanLocations.size}")
76+
spanLocations.forEach { (spanId, spanLocation) ->
77+
Log.trace(logger, "span location for span {} [{}]", spanId, spanLocation)
78+
}
79+
}
80+
7381
maintenanceLock.withLock {
7482
val toRemove = spanLocations.filter { (_, spanLocation) -> !spanLocation.isAlive() || !hasIndex(project, spanLocation.file) }.keys
83+
if (toRemove.isEmpty()) {
84+
return@withLock
85+
}
7586
Log.trace(logger, "maintenance removing spans {}", toRemove)
7687
spanLocations.entries.removeIf { toRemove.contains(it.key) }
7788
}

0 commit comments

Comments
 (0)