Skip to content

class Crystal::Location
inherits Reference

A location of an ASTnode, including its filename, line number and column number.

Included modules

Comparable

Class methods

.new(filename : String | VirtualFile | Nil, line_number : Int32, column_number : Int32)

View source

Methods

#<=>(other)

View source

#between?(min, max)

View source

#column_number : Int32

View source

#dirname : String?

Returns the directory name of this location's filename. If the filename is a VirtualFile, this is invoked on its expanded location.

View source

#expanded_location

Returns the Location whose filename is a String, not a VirtualFile, traversing virtual file expanded locations.

View source

#inspect(io : IO) : Nil

Appends a String representation of this object which includes its class name, its object address and the values of all instance variables.

class Person
  def initialize(@name : String, @age : Int32)
  end
end

Person.new("John", 32).inspect # => #<Person:0x10fd31f20 @name="John", @age=32>
View source

#line_number : Int32

View source

#macro_location

Returns the Location whose filename is a String, not a VirtualFile, traversing virtual file expanded locations leading to the original user source code

View source

#original_filename

Returns the filename of the expanded_location

View source

#pretty_print(pp)

View source

#to_s(io : IO) : Nil

Appends a short String representation of this object which includes its class name and its object address.

class Person
  def initialize(@name : String, @age : Int32)
  end
end

Person.new("John", 32).to_s # => #<Person:0x10a199f20>
View source