ADFA-1414 Adding tooltips for java/kotlin operators#1067
ADFA-1414 Adding tooltips for java/kotlin operators#1067hal-eisen-adfa wants to merge 1 commit intostagefrom
Conversation
📝 WalkthroughRelease Notes - ADFA-1414: Adding tooltips for Java/Kotlin operatorsFeatures
Risks & Best Practice Violations
WalkthroughThe PR adds operator-aware text selection functionality to the editor. When a user long-presses, the system attempts to select the word at the cursor; if no word exists, it falls back to selecting the operator at that position, enabling code actions on operators. Changes
Sequence DiagramsequenceDiagram
actor User
participant EmptyStateFragment
participant IDEEditor
participant OperatorSelection
User->>EmptyStateFragment: Long-press on editor
EmptyStateFragment->>IDEEditor: selectWordOrOperatorAtCursor()
IDEEditor->>IDEEditor: selectCurrentWord()
alt Word selected
IDEEditor->>IDEEditor: Update selection region
else No word found
IDEEditor->>OperatorSelection: getOperatorRangeAt(line, column)
OperatorSelection->>OperatorSelection: Find operator at cursor
OperatorSelection-->>IDEEditor: Return operator range (start, end)
IDEEditor->>IDEEditor: Select operator range
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@editor/src/main/java/com/itsaky/androidide/editor/utils/OperatorSelection.kt`:
- Around line 26-84: The OPERATORS list orders tokens by length for
longest-match-first but contains the 4-char operator ">>>=" placed under the //
3-char section, preventing correct matching; move the string ">>>=" to precede
the 3-char operators (i.e., place it before ">>>", "<<=", ">>=") in the
OPERATORS list so the longest operators are listed first and the matching logic
using OPERATORS works as intended.
- Around line 94-103: The operator-detection fails because suffix.subSequence(0,
op.length) == op compares a CharSequence (possibly ContentLine) to a String
using reference equality; in getOperatorRangeAt change the comparison to a
content-based check such as suffix.subSequence(0, op.length).contentEquals(op)
or compare suffix.subSequence(0, op.length).toString() with op, ensuring the
check uses contentEquals or String equality so OPERATORS are detected correctly
(use the local variables suffix, op and the function getOperatorRangeAt to
locate the change).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 388846b4-8344-495d-83db-ef63c3764d29
📒 Files selected for processing (3)
app/src/main/java/com/itsaky/androidide/fragments/EmptyStateFragment.kteditor/src/main/java/com/itsaky/androidide/editor/ui/IDEEditor.kteditor/src/main/java/com/itsaky/androidide/editor/utils/OperatorSelection.kt
I'm not seeing anything in the documentation db yet, but I need to check in with Elissa.
OPERATORS list: 3‑char, 2‑char, then 1‑char (so e.g. >>> is matched before >> and >).
getOperatorRangeAt(lineContent, column): Pair<Int, Int>?
Returns (startColumn, endColumnExclusive) for the operator at that column, or null. Uses 0‑based columns; end is exclusive.
Content.getOperatorRangeAt(line, column): Pair<Int, Int>?
Same semantics for a Sora Content, with bounds checks for line and column.
selectWordOrOperatorAtCursor()
Calls selectCurrentWord(); if the cursor still has no selection, gets the operator range at cursor.leftLine / cursor.leftColumn and, if present, calls setSelectionRegion(line, startCol, line, endCol).
onFragmentLongPressed()
Now calls currentEditor.selectWordOrOperatorAtCursor() instead of currentEditor.selectCurrentWord().