Skip to content

Conversation

@supersaiyansubtlety
Copy link
Member

@supersaiyansubtlety supersaiyansubtlety commented Sep 28, 2025

Adds #140

based on #304 rebased


Notes:

  • There's one weird issue I don't know what to make of: selecting javadoc text breaks the text rendering. They're just JTextAreas. I've tried using JEditorPanels instead, and I've tried disabling the drag-to-move feature; neither helped.
  • There's one TODO that will require a followup PR (Use dispel magic + a little polish #317): declaration snippets should include the original source's line numbers; requires line number offset implementation in syntaxpain.
  • This does not use JToolTip or ToolTipManager because I couldn't get a custom JToolTip to properly move+resize when the mouse moved to a new token. Instead it uses a custom JWindow for the tooltip and several Timers to manage it.
  • The tooltip size is limited to half the screen width/height with an additional 600px (scaled) hard cap on width. All tooltip content except the parent label is in a scroll pane which fills available space. If there's not enough room for everything, the scroll pane gets automatically scrolled to the bottom so the declaration snippet is in view. Unfortunately this means the top portion of javadocs are scrolled off the top. Ideally the javadocs and the snippet would have separate scroll panes (the snippet already has one from BaseEditorPanel), but I couldn't get two scroll panes to resize smartly in limited space (at least in a GridBagLayout, used to expand to fill width).

Improvements to RecordGetterFindingVisitor:

  • renames it RecordIndexingVisitor
  • adds map of record classes to component fields
  • adds map of record classes to component getters
  • makes its results accessible
  • fixes a bug preventing it from finding inner records' getters because it used getName() instead of getFullName()

Also:

  • makes navigating to a record component getter declaration with no explicit declaration navigate to its field instead
  • eliminates FeaturesSection by moving enableClassTreeStatIcons to StatsSection and autoSaveMappings to EditorConfig

The tooltip:

The tooltip shows the parent, javadocs, and declaration snippet of the entry under the cursor.

enigma-entry-tooltip

Clicking the parent label or tokens within the declaration snippet updates the tooltip with that entry's info; control-clicking navigates to the entry. Control-clicking a top-level class' package navigates to that package. The tooltip may be moved by dragging from anywhere that doesn't have other click functionality.


Config

Tooltips and their interact-ability can each be disabled; configs are in a new editor.toml file. This moves #304's persistent config to editor.toml.

editor.toml:

# Enables auto save functionality, which will automatically save mappings when a change is made.
# default: false
auto_save_mappings = false
# Whether editors' quick find toolbars should remain visible when they lose focus.
# default: true
persistent_quick_find = true

# Settings for editors' entry tooltips.
[entry_tooltips]
	# Whether tooltips are enabled.
	# default: true
	enable = true
	# Whether tooltips can be clicked and interacted with to navigate their content.
	# default: true
	interactable = true
enigma-entry-tooltips-config-gui

Tasks:

  • obtain entry under cursor
  • account for entry type
  • account for entry source (current class/other class)
  • show declaration of entry in source
  • de-indent trimmed declaration source
  • add javadoc if present
  • add entry parent name
  • make tooltips disablable
  • make tooltips optionally clickable
  • allow clicking entries inside tooltip to update the tooltip with that entry
  • polish
  • merge upstream once Quick find tool bar #304 is merged (both mess with EditorPanel)
  • merge upstream once Fix navigation to method calls within lambdas and static initializers #308 is merged (both add javaparser and LineIndexer)

add "bread crumbs" back button to go back to previous tooltip contents not tooltip-y

@supersaiyansubtlety
Copy link
Member Author

ready once #304 and #308 are merged

Comment on lines +219 to +222
// Put all main content in one big scroll pane.
// Ideally there'd be separate javadoc and snippet scroll panes, but multiple scroll pane children
// of a grid bag parent don't play nice when space is limited.
// The snippet has its own scroll pane, but wrapping it in this one effectively disables its resizing.
Copy link
Member Author

Choose a reason for hiding this comment

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

If anyone has ideas on how to improve this, please discuss on discord and make a followup PR.

@ix0rai ix0rai moved this to Ready in enigma 2.7 Nov 4, 2025
@ix0rai ix0rai added this to enigma 2.7 Nov 4, 2025
@ix0rai ix0rai moved this from Ready to In review in enigma 2.7 Nov 4, 2025
move FeaturesSection.autoSaveMappings to EditorConfig
eliminate FeaturesSection
@supersaiyansubtlety supersaiyansubtlety mentioned this pull request Nov 9, 2025
8 tasks
@ix0rai ix0rai self-requested a review November 9, 2025 17:47
Copy link
Member

@ix0rai ix0rai left a comment

Choose a reason for hiding this comment

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

this is amazing! just a couple last nitpicks before we merge

@ix0rai ix0rai merged commit b3bd7b1 into QuiltMC:develop/2.7 Nov 9, 2025
2 checks passed
@github-project-automation github-project-automation bot moved this from In review to Done in enigma 2.7 Nov 9, 2025
@ix0rai ix0rai mentioned this pull request Nov 12, 2025
5 tasks
ix0rai pushed a commit that referenced this pull request Nov 16, 2025
* add POC tooltip to EditorPanel editor that shows full name of entry under cursor

* update tooltip content when mouse moves, but can't get JToolTip to resize+move

* replace EditorPanel's use of JToolTip and TooltipManager with JWindow and timers, respectively

* check if same token instead of same entry when updating tooltip

* replace complex Optional composition with consumer methods

* extract BaseEditorPanel without tooltip, navigator, or listeners

* display entries' entire outer source class in their tooltips

* always set tooltipEditor classhandle instead of setting source when it's the same class (editor bounds were 0x0 when setting source)
navigate to tooltip target entry declaration when showing tooltip

* add javaparser dep matching #308

* implement source trimming for classes using javaparser

* minor improvements

* minor cleanup

* make trimFactor a param instead of a field

* implement source trimming for methods

* match declarations only by range and extract findDeclaration

* inline variable

* implement field source trimming
stop excluding curly braces from method and class sources

* fix tooltip source trimming for static record fields
add "No source available" label when there's no classhandle

* update TODOs
centralize target name reporting

* extract TooltipEditorPanel

* trim param tooltip target source to parent method
refine error messages

* fail early when target declaration token is missing
add local source trimming

* fix tooltip source trimming for constructors

* minor refactor

* show record component parent instead of just component; matches param showing parent method

* when excluding implements from record component parent, find token instead of assuming offset

* close and destroy tooltip when source changes

* silently ignore missing declaration tokens (until #252 is fixed)

* restore quickFindToolbar to ui
stop closing tooltip's class handles as tabs may still need them; remove ClassHandleListener instead
rename TooltipEditorPanel -> DeclarationSnippetPanel
extract EditorTooltip
add test input for easier manual tooltip testing

* restore EditorPanel popupMenu functionality

* improve caret pos logic in BaseEditorPanel::setSource

* replace source with message if the declaration token could be found

* implement source snippet unindenting

* replace entry simple name label with formatted parent name label

* add 'From: ' prefix to parent label
left-align tooltip rows

* add javadocs to tooltip

* allow disabling tooltip

* make tooltip optionally interactable
implement dragging to move tooltip

* prevent hiding tooltip when cursor is over a token or the tooltip

* fix parent label for top-level classes and add missing dot separator for package
format labels
use GridBagLayout for param javadocs (currently takes up extra space)

* allow clicking entries withing tooltip to populate tooltip with that entry's information

* fix calculation for offsetting multiline snippet pos to un-trimmed pos
allow clicking parent entries in tooltips to populate tooltip
when ctrl+clicking entries in tooltips, open entry tab

* minor improvements, add TODOs

* resolve references when finding tooltip targets

* customize tooltip target highlighting

* update TODOs regarding records

* polish tooltip positioning
fix exception when consumeMousePosition... methods where passed a component that wasn't showing
fix several cases where the tooltip would hide when it shouldn't or hiden't when it should

* increase padding at outer edges of tooltip rows
add tooltip border

* use a JPanel with a GridBagLayout instead of a Box as the content pane for EditorTooltip; allows elements to expand to fill their space
double-pack in EditorTooltip's declarationSnippet source set listener to eliminate extra space, because swing </3

* reject some TODOs

* ctrl+click on parent package label to naviage to package

* fix tooltip separators
improve "No source available" message formatting

* respect tooltip ineractable config for parent package clicking
add z_ prefix to tooltip test input to avoid changing SearchMappingsTest

* use global focus listener to ensure tooltip is closed when neither it nor its editor has focus

* move consumeMousePosition... methods to GuiUtil

* rename EditorTooltip -> EntryTooltip
use GridBagConstraintsBuilder in EntryTooltip
respect scale config in EntryTooltip

* use GridBagConstraintsBuilder in initEditorPane

* make tooltip focusable; enables copying tooltip content

* fix hiding tooltip immediately after re-populating it
simplify tooltip focus and hiding logic

* remove tooltip to editor click forward as it didn't work consistently
remove unecessary insteractable tooltip click listener

* add EntryTooltip.repopulated field for workaround

* deobfuscate parent package

* focus class selector when navigating to parent package from tooltip

* scroll to class selector path when navigating from entry tooltip parent

* move Config.persistentEditorQuickFind to EditorConfig.persistentQuickFind

* rename config getter methods to match their ids and update Config javadoc

* fix another tooltip focus issue

* fix bug preventing RecordGetterFindingVisitor from finding inner records' getters
make RecordGetterFindingVisitor's getter map accessible
fix DeclarationSnippetPanel for record component getters

* rename RecordGetterFindingVisitor -> RecordIndexingVisitor
expand RecordGetterFindingVisitor to provide maps of record classes to their fields and methods
make EntryTooltip show record field javadocs for record classes
make EntryTooltip show record field javadocs for record getters if they don't have their own javadocs

* clear things in visitEnd instead of visit
clear fields and methods

* fix for java 17

* tighten RecordIndexingVisitor encapsulation

* make navigating to a record component getter with no explicit declaration navigate to its field instead

* add nullable annotation

* only set BaseEditorPanel.editor text once

* fix typo

* tweak moveMaintainingAnchor

* close entry tooltip on key press

* close tooltip on KEY_TYPED instead of KEY_PRESSED so ctrl+c can copy

* add javaparser to lib list in README

* cleanup createSnippet

* fix swapped un/bounded names

* make LineIndexer::getIndex return -1 for out-of-bounds positions, add LineIndexerTest

* rename EditorTooltipSection -> EntryTooltipSection

* limit EntryTooltip size

* put main tooltip content in a scroll pane

* focus snippet editor ui on source set
remove main content scroll pane border

* checkstyle

* replace AtomicInteger gridY's with primitive ints

* hard cap tooltip width at 600px (scaled)

* expand parent package path when navigating from tooltip

* explicitly check if source is bounded when setting 'Unable to locate declaration' message
show <init> for constructor simple names

* improve constructor name check

* use 'inherited from' label for tooltip labels for entries that resolved to a parent

* dispatch key events that close the entry tooltip to the previously focused component

* close entry tooltip with global mouse listener

* add gui for entry tooltip config

* deduplicate check box sync logic

* javadoc createSyncedCheckBox

* javadoc syncStateWithConfig override

* move tooltip management to EnitorPanel.TooltipManager
add/remove EntryTooltip's global listeners on open/close
reset TooltipManager on key presses

* minor refactor

* make 'tooltips' consistently plural in user-facing strings

* dispatch KEY_PRESSED events that close entry tooltips (with exception for ctrl+c)

* rework moveMaintainingAnchor when tooltip shrunk

* move FeaturesSection.enableClassTreeStatIcons to StatsSection
move FeaturesSection.autoSaveMappings to EditorConfig
eliminate FeaturesSection

* ensure RecordIndexingVisitor is cleared in visitEnd

* make several tooltip string translatable

* make a snippet string translatable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request user interface affects the enigma ui

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

Show javadocs/other information on hover

2 participants