[Feature]Variable loc info PR3: Add frontend UI support for location alias visualization #188
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds frontend visualization support for location aliases in the web interface. It extends the TypeScript interfaces to include alias metadata, updates all three code viewer components to detect and highlight location definition lines, and creates a new CSS file with styling for visual distinction.
Changes
TypeScript Interface Updates (
website/src/utils/dataLoader.ts)Extended
SourceMappinginterface with new optional fields:type?: "code" | "loc_def"- Distinguishes code lines from loc definition linesloc_id?: string- The #loc identifier (e.g., "13" for #loc13, "" for bare #loc)alias_name?: string- Name from alias definition (e.g., "x_ptr", "pid")alias_of?: string- Target #loc that this alias referenceskind?: string- Deprecated alias fortype, kept for backward compatibilityCode Viewer Enhancements (
website/src/components/CodeViewer.tsx)All three viewer components updated:
BasicCodeViewer- For extremely large files (plain text rendering)LargeFileViewer- For large files (virtualized with syntax highlighting)StandardCodeViewer- For normal files (full syntax highlighting)New functionality:
CodeViewer.cssfor loc definition stylingsourceMappingprop to all viewer component signaturesmapping.type === "loc_def" || mapping.kind === "loc_def".loc-definition-lineCSS class for visual markingTooltip format:
"Alias: x_ptr (#loc13) → #loc → file.py:308:0""Location definition: #loc13 → file.py:308:0"Data attributes added:
data-loc-id: The location identifierdata-alias-name: The alias name if presentdata-loc-def: Set to "true" for definition linesStyling (
website/src/components/CodeViewer.css- NEW FILE)Loc definition line styles:
rgba(255, 215, 0, 0.15)) for subtle highlighting#DAA520) for clear visual marker0.25) for better visibilityAdditional styles prepared:
.alias-badge: Inline badge styling (prepared for future inline display).alias-name-indicator: For potential future enhancementsUser Experience
Visual Indicators
Location definition lines are now clearly marked with:
Interactive Tooltips
Hovering over location definition lines shows:
Example Screenshots
Benefits
Backward Compatibility
Dependencies
Implementation Details
Tooltip Construction Logic
CSS Class Application
Files Changed
website/src/utils/dataLoader.ts: +6 lines (interface extension)website/src/components/CodeViewer.tsx: +68 lines (viewer updates)website/src/components/CodeViewer.css: +43 lines (NEW FILE - styling)Total: 117 lines added across 3 files
Testing
Manual Testing
Browser Compatibility
Future Enhancements
This PR lays the groundwork for:
Screenshot
Related PRs