jruby-prism-parser 0.23.0.pre.SNAPSHOT-java → 0.24.0-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -452,17 +452,19 @@ module Prism
452
452
 
453
453
  # This represents a token from the Ruby source.
454
454
  class Token
455
+ # The Source object that represents the source this token came from.
456
+ attr_reader :source
457
+ private :source
458
+
455
459
  # The type of token that this token is.
456
460
  attr_reader :type
457
461
 
458
462
  # A byteslice of the source that this token represents.
459
463
  attr_reader :value
460
464
 
461
- # A Location object representing the location of this token in the source.
462
- attr_reader :location
463
-
464
465
  # Create a new token object with the given type, value, and location.
465
- def initialize(type, value, location)
466
+ def initialize(source, type, value, location)
467
+ @source = source
466
468
  @type = type
467
469
  @value = value
468
470
  @location = location
@@ -473,6 +475,12 @@ module Prism
473
475
  { type: type, value: value, location: location }
474
476
  end
475
477
 
478
+ # A Location object representing the location of this token in the source.
479
+ def location
480
+ return @location if @location.is_a?(Location)
481
+ @location = Location.new(source, @location >> 32, @location & 0xFFFFFFFF)
482
+ end
483
+
476
484
  # Implement the pretty print interface for Token.
477
485
  def pretty_print(q)
478
486
  q.group do