Repository navigation
ADFA-6228: Read class lookups from the JVM symbol index instead of the classpath trie #2073
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8689a46
bb55dc8
afba1ee
4fbfab9
a59dd05
cac7cbb
7986aca
0dc8925
f126bbe
364accc
073001b
9e7c46f
e168f9a
b504911
fa003ae
7a4083b
5f86fde
4d9de2e
3aa3346
dc69407
5cee072
b5232a2
188d82c
781a4fe
0aeb760
dd38e76
7fbb593
5b66fa6
9dcc1e8
24d17c1
80289f2
7489aba
6a0702d
f7a659b
b1ee2fb
015437a
da89d3d
128c819
d3d7c2f
b0c7158
c0a8069
d33e1fd
f54bc74
01b47c9
eb2c0cf
6e0a7f9
feba9a9
8070ec6
bf78295
74260f0
f35ee80
184882f
4c47f77
7133099
ac0a12f
1ddf6b2
6eb45ea
92543f2
a0ec88a
4c67301
a499648
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,6 +41,7 @@ import kotlinx.coroutines.flow.asStateFlow | |
| import kotlinx.coroutines.flow.update | ||
| import kotlinx.coroutines.launch | ||
| import kotlinx.coroutines.withContext | ||
| import org.appdevforall.codeonthego.indexing.service.IndexingState | ||
| import java.io.File | ||
| import java.io.IOException | ||
| import java.util.Collections | ||
|
|
@@ -250,6 +251,50 @@ class EditorViewModel : ViewModel() { | |
| _statusText.value = (_statusText.value?.first ?: "") to value | ||
| } | ||
|
|
||
| /** The latest class indexing state the editor has observed. */ | ||
| var indexingState: IndexingState = IndexingState.Idle | ||
| private set | ||
|
|
||
| /** Whether class indexing is in flight, derived from [indexingState]. */ | ||
| val isIndexing: Boolean | ||
| get() = indexingState is IndexingState.Indexing | ||
|
|
||
| /** The indexing text last written to the status slot, or null if none is shown. */ | ||
| private var shownIndexingStatus: CharSequence? = null | ||
|
|
||
| /** The message the indexing text replaced in the status slot, restored when indexing ends. */ | ||
| private var replacedStatus: CharSequence? = null | ||
|
|
||
| /** Records [state], as reported by the project's indexing service manager. */ | ||
| internal fun onIndexingStateChanged(state: IndexingState) { | ||
| indexingState = state | ||
| } | ||
|
|
||
| /** | ||
| * Updates the status slot for [indexingState], formatting its progress with [formatProgress]. | ||
| * | ||
| * [isSlotOwnedElsewhere] is true while a build, project initialization or debugger start owns | ||
| * the slot; see [resolveIndexingStatus]. | ||
| */ | ||
| fun updateIndexingStatus( | ||
| isSlotOwnedElsewhere: Boolean, | ||
| formatProgress: (done: Int, total: Int) -> CharSequence, | ||
| ) { | ||
| val indexingStatus = (indexingState as? IndexingState.Indexing)?.let { formatProgress(it.done, it.total) } | ||
| val current = statusText | ||
| val next = | ||
| resolveIndexingStatus(isSlotOwnedElsewhere, indexingStatus, current, shownIndexingStatus, replacedStatus) | ||
| ?: return | ||
| if (indexingStatus != null && shownIndexingStatus?.contentEquals(current) != true) { | ||
| replacedStatus = current | ||
| } | ||
| if (indexingStatus == null) { | ||
| replacedStatus = null | ||
| } | ||
| shownIndexingStatus = indexingStatus | ||
| _statusText.value = next to CENTER | ||
| } | ||
|
|
||
| var displayedFileIndex: Int | ||
| get() = _displayedFile.value!! | ||
| set(value) { | ||
|
|
@@ -489,3 +534,27 @@ class EditorViewModel : ViewModel() { | |
| return manager.projectDir.name | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Decides what the status slot shows next for class indexing, or returns null to leave it alone. | ||
| * | ||
| * While [isSlotOwnedElsewhere] (a build, project initialization or debugger start is running) the | ||
| * slot is left to that operation. Otherwise [indexingStatus], the progress text or null when | ||
| * indexing is idle, takes it. When indexing ends the slot goes back to [replacedStatus], the message | ||
| * the indexing text replaced (a build result, say), or is cleared if there was none. It does so | ||
| * only if the slot still shows [shownIndexingStatus], the indexing text last written there, so a | ||
| * newer message survives. | ||
| */ | ||
| internal fun resolveIndexingStatus( | ||
| isSlotOwnedElsewhere: Boolean, | ||
| indexingStatus: CharSequence?, | ||
| currentStatus: CharSequence, | ||
| shownIndexingStatus: CharSequence?, | ||
| replacedStatus: CharSequence? = null, | ||
| ): CharSequence? = | ||
| when { | ||
| isSlotOwnedElsewhere -> null | ||
| indexingStatus != null -> indexingStatus.takeUnless { it.contentEquals(currentStatus) } | ||
| shownIndexingStatus?.contentEquals(currentStatus) == true -> replacedStatus ?: "" | ||
| else -> null | ||
| } | ||
|
Comment on lines
+554
to
+560
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: #!/bin/bash
rg -nP -C4 '\bisInitializing\s*=|msg_project_initialization_failed|build_status_failed|debugger_starting_failed' --type=kotlin --type=javaRepository: appdevforall/CodeOnTheGo Length of output: 13511 🏁 Script executed: #!/bin/bash
set -e
printf '%s\n' '--- current EditorViewModel ---'
sed -n '430,525p' app/src/main/java/com/itsaky/androidide/viewmodel/EditorViewModel.kt
printf '%s\n' '--- indexing update caller and status ownership ---'
rg -n -C8 'postIndexingStatusUpdate|updateIndexingStatus|resolveIndexingStatus|isSlotOwnedElsewhere|shownIndexingStatus' app/src/main/java/com/itsaky/androidide/activities/editor app/src/main/java/com/itsaky/androidide/viewmodel app/src/test
printf '%s\n' '--- initialization failure path ---'
sed -n '810,890p' app/src/main/java/com/itsaky/androidide/activities/editor/ProjectHandlerActivity.kt
printf '%s\n' '--- debugger failure path ---'
sed -n '455,495p' app/src/main/java/com/itsaky/androidide/activities/editor/BaseEditorActivity.kt
printf '%s\n' '--- build failure path ---'
sed -n '260,315p' app/src/main/java/com/itsaky/androidide/handlers/EditorBuildEventListener.kt
printf '%s\n' '--- relevant diff ---'
git diff --no-ext-diff --unified=12 ea904acb23614b3f5dc38cf3b5ffa71a1bf8c0e6 87dea06438503e0dfcc9a4d5c08fb840f9d601e1 -- app/src/main/java/com/itsaky/androidide/viewmodel/EditorViewModel.kt app/src/main/java/com/itsaky/androidide/activities/editor/BaseEditorActivity.kt app/src/main/java/com/itsaky/androidide/handlers/EditorBuildEventListener.kt app/src/main/java/com/itsaky/androidide/activities/editor/ProjectHandlerActivity.kt | sed -n '1,320p'
printf '%s\n' '--- resolver tests ---'
rg -n -C8 'anIndexingTickWhileInitializationFailureIsShown|resolveIndexingStatus|build ends|cancelled build' app/src/test app/src/androidTestRepository: appdevforall/CodeOnTheGo Length of output: 41805 🏁 Script executed: #!/bin/bash
set -e
printf '%s\n' '--- status ownership expression ---'
rg -n -C12 'isStatusOwnedElsewhere|isDebuggerStarting|isBuildInProgress|isInitializing' app/src/main/java/com/itsaky/androidide/activities/editor/BaseEditorActivity.kt app/src/main/java/com/itsaky/androidide/viewmodel/EditorViewModel.kt
printf '%s\n' '--- status setter and update implementation ---'
rg -n -C10 'fun doSetStatus|fun setStatus|var statusText|_statusText|statusText =' app/src/main/java/com/itsaky/androidide/activities/editor/BaseEditorActivity.kt app/src/main/java/com/itsaky/androidide/viewmodel/EditorViewModel.kt
printf '%s\n' '--- exact failure and deferred-update regions ---'
sed -n '395,410p' app/src/main/java/com/itsaky/androidide/activities/editor/BaseEditorActivity.kt
sed -n '470,490p' app/src/main/java/com/itsaky/androidide/activities/editor/BaseEditorActivity.kt
sed -n '1600,1635p' app/src/main/java/com/itsaky/androidide/activities/editor/BaseEditorActivity.kt
sed -n '845,880p' app/src/main/java/com/itsaky/androidide/activities/editor/ProjectHandlerActivity.ktRepository: appdevforall/CodeOnTheGo Length of output: 41793 Preserve failure messages when indexing resumes
Allow indexing to replace only an empty slot, previously shown indexing text, or explicitly approved completed-operation messages. Do not replace failure messages. 🤖 Prompt for AI Agents |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MINOR: Restoring
replacedStatuswhen indexing ends drops the replaced message's gravity and always writesCENTER.No current caller can reach this. Every status writer goes through
ProjectHandlerActivity.setStatus(status), which passesGravity.CENTER, so the replaced message was always centred. The firstsetStatus(text, Gravity.START)caller will see its message come back centred after an indexing pass.Fix: save
statusGravityalongsidereplacedStatusand restore both.