Skip to content

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

Merged
hal-eisen-adfa merged 6 commits intostagefrom
ADFA-1414-tooltips-for-operators
Apr 10, 2026
Merged

ADFA-1414 Adding tooltips for java/kotlin operators#1067
hal-eisen-adfa merged 6 commits intostagefrom
ADFA-1414-tooltips-for-operators

Conversation

@hal-eisen-adfa
Copy link
Copy Markdown
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
Copy Markdown
Contributor

coderabbitai bot commented Mar 12, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Replaces the long-press selection call in EmptyStateFragment to use IDEEditor.selectWordOrOperatorAtCursor; adds operator-detection utilities; and updates ShowTooltipAction to resolve operator-based tooltip tags and normalize editor-null handling. (49 words)

Changes

Cohort / File(s) Summary
Fragment Long-Press Handler
app/src/main/java/com/itsaky/androidide/fragments/EmptyStateFragment.kt
Long-press now calls IDEEditor.selectWordOrOperatorAtCursor() instead of selectCurrentWord().
Editor Selection Logic
editor/src/main/java/com/itsaky/androidide/editor/ui/IDEEditor.kt
Added public selectWordOrOperatorAtCursor() that calls selectCurrentWord() and, if no selection, falls back to Content.getOperatorRangeAt(...) to select operator ranges.
Operator Detection Utility
editor/src/main/java/com/itsaky/androidide/editor/utils/OperatorSelection.kt
New utility defining ordered operator tokens and functions: isKotlinOperatorToken, isJavaOperatorToken, getOperatorRangeAt(lineContent, column), and Content.getOperatorRangeAt(line, column) with bounds/validity checks.
Tooltip Tag Resolution
app/src/main/java/com/itsaky/androidide/actions/file/ShowTooltipAction.kt
Extracted tooltipCategoryForExtension and resolveTooltipTag; tag resolution now recognizes Kotlin/Java operator tokens via isKotlinOperatorToken/isJavaOperatorToken and returns IDE defaults when editor is null.

Sequence Diagram

sequenceDiagram
    participant User
    participant EmptyStateFragment
    participant IDEEditor
    participant OperatorSelection
    participant ShowTooltipAction

    User->>EmptyStateFragment: long-press
    EmptyStateFragment->>IDEEditor: selectWordOrOperatorAtCursor()
    IDEEditor->>IDEEditor: selectCurrentWord()
    alt word selected
        IDEEditor->>ShowTooltipAction: request tooltip for selection
        ShowTooltipAction->>ShowTooltipAction: resolveTooltipTag(..., isKotlinOperatorToken/isJavaOperatorToken)
    else no word selected
        IDEEditor->>OperatorSelection: getOperatorRangeAt(line, column)
        OperatorSelection-->>IDEEditor: range or null
        alt operator found
            IDEEditor->>ShowTooltipAction: request tooltip for operator
            ShowTooltipAction->>ShowTooltipAction: resolveTooltipTag(..., isKotlinOperatorToken/isJavaOperatorToken)
        else none
            IDEEditor-->>EmptyStateFragment: no selection
        end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • itsaky-adfa
  • jatezzz

Poem

🐇 I press and pause where the cursor hides,
I nibble words or operators at its sides.
A quick long-press hop, I find the tiny part,
I mark the symbol and summon tooltip art.
Hooray for small hops that brighten devs' heart!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 45.45% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main objective of the PR: adding tooltip support for Java/Kotlin operators.
Description check ✅ Passed The description is directly related to the changeset, providing detailed technical documentation of the new functions, their signatures, and behavior in the context of operator selection and tooltips.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • 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
Copy Markdown
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
Copy link
Copy Markdown
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: 1

🧹 Nitpick comments (1)
app/src/main/java/com/itsaky/androidide/actions/file/ShowTooltipAction.kt (1)

91-97: Consider treating .kts as Kotlin here.

File.extension is "kts" for Gradle Kotlin scripts, so those editors currently fall back to CATEGORY_IDE and won't use the Kotlin/operator tooltip path.

Suggested fix
 internal fun tooltipCategoryForExtension(extension: String?): String =
     when (extension) {
         "java" -> TooltipCategory.CATEGORY_JAVA
-        "kt" -> TooltipCategory.CATEGORY_KOTLIN
+        "kt", "kts" -> TooltipCategory.CATEGORY_KOTLIN
         "xml" -> TooltipCategory.CATEGORY_XML
         else -> TooltipCategory.CATEGORY_IDE
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/src/main/java/com/itsaky/androidide/actions/file/ShowTooltipAction.kt`
around lines 91 - 97, The tooltipCategoryForExtension function currently maps
"kt" to TooltipCategory.CATEGORY_KOTLIN but misses Kotlin script files whose
extension is "kts"; update tooltipCategoryForExtension to treat "kts" like "kt"
(e.g., add a branch for "kts" that returns TooltipCategory.CATEGORY_KOTLIN or
combine "kt", "kts" in the same when-arm) so Gradle Kotlin scripts use the
Kotlin tooltip path.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@app/src/main/java/com/itsaky/androidide/actions/file/ShowTooltipAction.kt`:
- Around line 107-110: The current branch only maps operator tokens when
category == TooltipCategory.CATEGORY_KOTLIN, so operator selections in Java
editors are left as raw symbols; change the condition to check
isOperatorToken(textToUse) regardless of category (preserving the earlier
!editorTag and CATEGORY_XML && isXmlAttribute cases) so the operator mapping
(the line producing "kotlin.operator.$textToUse") runs for Java too; update the
case that references isOperatorToken, textToUse, and
TooltipCategory.CATEGORY_KOTLIN in ShowTooltipAction.kt accordingly.

---

Nitpick comments:
In `@app/src/main/java/com/itsaky/androidide/actions/file/ShowTooltipAction.kt`:
- Around line 91-97: The tooltipCategoryForExtension function currently maps
"kt" to TooltipCategory.CATEGORY_KOTLIN but misses Kotlin script files whose
extension is "kts"; update tooltipCategoryForExtension to treat "kts" like "kt"
(e.g., add a branch for "kts" that returns TooltipCategory.CATEGORY_KOTLIN or
combine "kt", "kts" in the same when-arm) so Gradle Kotlin scripts use the
Kotlin tooltip path.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2a18a0f9-8ce2-4665-b8fb-c8204ac3a631

📥 Commits

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

📒 Files selected for processing (2)
  • app/src/main/java/com/itsaky/androidide/actions/file/ShowTooltipAction.kt
  • editor/src/main/java/com/itsaky/androidide/editor/utils/OperatorSelection.kt
🚧 Files skipped from review as they are similar to previous changes (1)
  • editor/src/main/java/com/itsaky/androidide/editor/utils/OperatorSelection.kt

Copy link
Copy Markdown
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.

♻️ Duplicate comments (1)
editor/src/main/java/com/itsaky/androidide/editor/utils/OperatorSelection.kt (1)

26-35: ⚠️ Potential issue | 🟡 Minor

Move ">>>=" before 3-char operators to keep longest-match-first behavior.

At Line 34, ">>>=" is placed after ">>>", so getOperatorRangeAt() will match ">>>" first and never return the full ">>>=" range.

Proposed fix
 private val OPERATORS: List<String> =
     listOf(
+        // 4-char
+        ">>>=",
         // 3-char (=== and !== before 2-char == and !=)
         "===",
         "!==",
         ">>>",
         "<<=",
         ">>=",
-        ">>>=",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@editor/src/main/java/com/itsaky/androidide/editor/utils/OperatorSelection.kt`
around lines 26 - 35, The OPERATORS list currently places ">>>=" after ">>>",
causing getOperatorRangeAt() to match the shorter ">>>" first; reorder the
OPERATORS list so that all longer multi-character operators come before their
shorter prefixes (specifically move ">>>=" before ">>>") to preserve
longest-match-first behavior in getOperatorRangeAt().
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In
`@editor/src/main/java/com/itsaky/androidide/editor/utils/OperatorSelection.kt`:
- Around line 26-35: The OPERATORS list currently places ">>>=" after ">>>",
causing getOperatorRangeAt() to match the shorter ">>>" first; reorder the
OPERATORS list so that all longer multi-character operators come before their
shorter prefixes (specifically move ">>>=" before ">>>") to preserve
longest-match-first behavior in getOperatorRangeAt().

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 088b144a-4a3b-4936-a7e9-b2b9901a5aa8

📥 Commits

Reviewing files that changed from the base of the PR and between ec93898 and b0ad64f.

📒 Files selected for processing (2)
  • app/src/main/java/com/itsaky/androidide/actions/file/ShowTooltipAction.kt
  • editor/src/main/java/com/itsaky/androidide/editor/utils/OperatorSelection.kt
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/src/main/java/com/itsaky/androidide/actions/file/ShowTooltipAction.kt

@hal-eisen-adfa hal-eisen-adfa merged commit f76be4e into stage Apr 10, 2026
2 checks passed
@hal-eisen-adfa hal-eisen-adfa deleted the ADFA-1414-tooltips-for-operators branch April 10, 2026 16:23
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.

2 participants