Skip to content

Fix location tracking and remove static caching to prevent parallel test failures#24

Open
nawforce wants to merge 2 commits intomainfrom
add-location-tracking-to-modifier-and-annotation
Open

Fix location tracking and remove static caching to prevent parallel test failures#24
nawforce wants to merge 2 commits intomainfrom
add-location-tracking-to-modifier-and-annotation

Conversation

@nawforce
Copy link
Contributor

Fixes #19

Summary

This PR implements proper location tracking for Modifier and Annotation types and fixes parallel test failures caused by static caching.

Changes

Location Tracking

  • Changed lineOffset from 1-based to 0-based indexing to match ANTLR conventions
  • Made end positions exclusive ([start, end) half-open interval) for both columns and byte offsets
  • Enabled location validation in tests by comparing ANTLR vs outline parser locations

Caching Bug Fix

  • Removed intern() methods and static caches from Annotation and Modifier companion objects
  • Removed all intern() calls from factory methods in Types.scala
  • The static caches were causing parallel test failures because ArrayInternCache uses equality that ignores location field, returning cached instances with wrong locations

Test Infrastructure

  • Added syncNodeModules task to ensure node_modules are available for ScalaJS tests
  • Optimized ANTLR location extraction by skipping byte offset calculation (too expensive)
  • Updated Compare.scala to ignore byte offsets when comparing locations
  • Added UndefOr[Token] handling for ScalaJS where context.stop might be undefined

Dependency Updates

  • Upgraded apex-ls to 6.0.2 to fix lexer errors with malformed files
  • Upgraded Scala.js to 1.18.2 for compatibility with apex-ls 6.0.2

Testing

All 6,303 tests pass successfully with location tracking fully enabled.

Related Issues

Changes:
- Added optional location field to Modifier case class
- Added optional location field to Annotation case class
- Updated tokenToModifier() to preserve token locations
- Updated parseModifiersAndAnnotations() to create spanned locations for
  compound modifiers (e.g., 'with sharing')
- Updated parseAnnotation() to capture full annotation span from @ through
  parameters

Both location fields default to None for backward compatibility and exclude
location from equality/hash checks to preserve existing semantics.

All 6,302 tests pass with these changes.

Resolves #19
@nawforce nawforce requested a review from kjonescertinia March 15, 2026 22:56
@nawforce nawforce force-pushed the add-location-tracking-to-modifier-and-annotation branch from 01ad5b8 to 8efc3ca Compare March 15, 2026 22:58
…est failures

This commit completes issue #19 by implementing proper location tracking for
Modifier and Annotation types and fixing several related issues:

**Location Tracking:**
- Changed lineOffset from 1-based to 0-based indexing to match ANTLR conventions
- Made end positions exclusive ([start, end) half-open interval) for both columns and byte offsets
- Enabled location validation in tests by comparing ANTLR vs outline parser locations

**Caching Bug Fix:**
- Removed intern() methods and static caches from Annotation and Modifier companion objects
- Removed all intern() calls from factory methods in Types.scala
- The static caches were causing parallel test failures because ArrayInternCache uses
  equality that ignores location field, returning cached instances with wrong locations

**Test Infrastructure:**
- Added syncNodeModules task to ensure node_modules are available for ScalaJS tests
- Optimized ANTLR location extraction by skipping byte offset calculation (too expensive)
- Updated Compare.scala to ignore byte offsets when comparing locations
- Added UndefOr[Token] handling for ScalaJS where context.stop might be undefined

**Dependency Updates:**
- Upgraded apex-ls to 6.0.2 to fix lexer errors with malformed files
- Upgraded Scala.js to 1.18.2 for compatibility with apex-ls 6.0.2

All 6,303 tests pass successfully with location tracking fully enabled.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@nawforce nawforce force-pushed the add-location-tracking-to-modifier-and-annotation branch from 8efc3ca to 86530c7 Compare March 15, 2026 23:05
@@ -1,4 +1,4 @@
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.12.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.18.2")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.2.0")
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we update the other dependencies here

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.

Add location tracking to Modifier and Annotation types Outline parser diagnostic positions inconsistent with ANTLR parser

2 participants