Skip to content

ADFA-1414 Adding tooltips for java/kotlin operators#1067

Open
hal-eisen-adfa wants to merge 1 commit intostagefrom
ADFA-1414-tooltips-for-operators
Open

ADFA-1414 Adding tooltips for java/kotlin operators#1067
hal-eisen-adfa wants to merge 1 commit intostagefrom
ADFA-1414-tooltips-for-operators

Conversation

@hal-eisen-adfa
Copy link
Collaborator

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().

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 12, 2026

📝 Walkthrough

Release Notes - ADFA-1414: Adding tooltips for Java/Kotlin operators

Features

  • Operator Range Detection: New utility module OperatorSelection.kt providing operator detection for Java/Kotlin source code

    • Prioritizes longer operator matches (e.g., >>> before >> before >)
    • Top-level function getOperatorRangeAt() for raw line content analysis
    • Extension function Content.getOperatorRangeAt() for direct editor integration with bounds validation
  • Enhanced Selection Behavior: New public method selectWordOrOperatorAtCursor() in IDEEditor

    • Falls back to operator selection when no word is found at cursor position
    • Enables code-action toolbar display for operators in addition to words
  • Long-Press Improvements: Updated EmptyStateFragment.onFragmentLongPressed() to invoke selectWordOrOperatorAtCursor() instead of selectCurrentWord()

    • Extends long-press functionality to select operators in addition to words

Risks & Best Practice Violations

  • Overly Broad Operator List: The operator list includes structural/syntactic elements ((, ), [, ], {, }, ;, ,, .) that are not typically considered "operators." This may lead to unexpected selection behavior during editing operations
  • Missing Documentation: Documentation database has not been updated; requires coordination with documentation team
  • No Visible Test Coverage: Raw summary does not reference unit or integration tests for the new operator detection logic; recommend verification of edge cases (line boundaries, multi-char operators, special characters)
  • Potential UX Impact: Users may be surprised when long-pressing on punctuation/brackets triggers operator selection; recommend user testing on actual usage patterns

Walkthrough

The 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

Cohort / File(s) Summary
Fragment Long-Press Handler
app/src/main/java/com/itsaky/androidide/fragments/EmptyStateFragment.kt
Changed long-press editor action from selectCurrentWord() to selectWordOrOperatorAtCursor() to support operator selection fallback.
Editor Selection Logic
editor/src/main/java/com/itsaky/androidide/editor/ui/IDEEditor.kt
Added public method selectWordOrOperatorAtCursor() that selects the current word; if none found, computes and selects the operator range at the cursor position.
Operator Detection Utility
editor/src/main/java/com/itsaky/androidide/editor/utils/OperatorSelection.kt
New utility file providing operator range detection with two public APIs: top-level function getOperatorRangeAt(lineContent, column) and extension function Content.getOperatorRangeAt(line, column). Includes ordered operator list (by descending length) and bounds validation.

Sequence Diagram

sequenceDiagram
    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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • itsaky-adfa
  • jatezzz
  • Daniel-ADFA

Poem

🐰 A long-press now picks words with care,
But when no word floats in the air,
The clever editor finds the way—
Selecting operators at play!
Code actions shine for ops and keys,
Making long-press selection a breeze! ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title mentions adding tooltips for operators, but the changeset actually implements operator range selection functionality without adding tooltip UI components. Revise the title to reflect the actual changes, such as 'Add operator range selection at cursor' or 'Implement selectWordOrOperatorAtCursor method'.
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The description accurately documents the implementation details including the operators list ordering, the two new getOperatorRangeAt functions, selectWordOrOperatorAtCursor method, and the onFragmentLongPressed update.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ADFA-1414-tooltips-for-operators

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 26b4268 and 680cf4a.

📒 Files selected for processing (3)
  • app/src/main/java/com/itsaky/androidide/fragments/EmptyStateFragment.kt
  • editor/src/main/java/com/itsaky/androidide/editor/ui/IDEEditor.kt
  • editor/src/main/java/com/itsaky/androidide/editor/utils/OperatorSelection.kt

@hal-eisen-adfa hal-eisen-adfa requested a review from a team March 13, 2026 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant