Repository navigation
Fix navigation to method calls within lambdas and static initializers - #308
Conversation
|
Ready |
|
This fixes the issue for VineFlower but not Procyon; I've created sub-issues. |
eristhea
left a comment
There was a problem hiding this comment.
i may be doing something wrong but i was unable to get this to work for lambdas. using enigma's built in :lambdaTestGui, navigating to the top call (in the top level of the method) works, but as before, the two calls inside the lambda and nested lambda do not navigate properly.

however, this does fix the issue for static init!
eristhea
left a comment
There was a problem hiding this comment.
looks great! this is a huge fix, i'm so happy to get it in.
i'd appreciate if you could add some unit testing for this, but if not i can always just open an issue and get to it when i have time. thanks for the PR!
|
I think I'll let you handle the unit tests for this one. |
|
sounds good! |
* 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
…#308) * Fix for static initializers * Bug fixes * Migrate to JavaParser * Add lambda support * Switch to RAW language level so its language level agnostic * Checkstyle * Checkstyle * Gracefully handle parsing errors * Bug fixes * Don't assume lambda method names will match JVM format * Use LineIndexer * Skip tokens that don't have a range * Checkstyle * Bug fix * Handle more edge cases * Minor code cleanup * checkstyle * Fix issue with method overloads --------- Co-authored-by: supersaiyansubtlety <supersaiyansubtlety@gmail.com>
* 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

Fixes #311
This PR uses a Java parsing library to parse the source code to obtain ranges. This means it would add an additional dependency, but this seems like the better option compared to the alternative of parsing it manually.