A raw text Nit source file

Introduced properties

private var _filename: String

nitc :: SourceFile :: _filename

The path of the source
private var _first_token: nullable Token

nitc :: SourceFile :: _first_token

The first token parser by the lexer
private var _last_token: nullable Token

nitc :: SourceFile :: _last_token

The first token parser by the lexer
private var _line_starts: Array[Int]

nitc :: SourceFile :: _line_starts

Offset of each line start in the content string.
private var _messages: Array[Message]

nitc :: SourceFile :: _messages

Errors and warnings associated to the whole source.
private var _mmodule: nullable MModule

nitc :: SourceFile :: _mmodule

Associated mmodule, once created
private var _stream: Reader

nitc :: SourceFile :: _stream

The original stream used to initialize string
private var _string: String

nitc :: SourceFile :: _string

The content of the source
init defaultinit(filename: String, stream: Reader)

nitc :: SourceFile :: defaultinit

fun filename: String

nitc :: SourceFile :: filename

The path of the source
protected fun filename=(filename: String)

nitc :: SourceFile :: filename=

The path of the source
fun first_token: nullable Token

nitc :: SourceFile :: first_token

The first token parser by the lexer
protected fun first_token=(first_token: nullable Token)

nitc :: SourceFile :: first_token=

The first token parser by the lexer
init from_string(filename: String, string: String)

nitc :: SourceFile :: from_string

Create a new sourcefile using a dummy filename and a given content
fun get_line(line_number: Int): String

nitc :: SourceFile :: get_line

Extract a given line excluding the line-terminators characters.
fun last_token: nullable Token

nitc :: SourceFile :: last_token

The first token parser by the lexer
protected fun last_token=(last_token: nullable Token)

nitc :: SourceFile :: last_token=

The first token parser by the lexer
fun line_starts: Array[Int]

nitc :: SourceFile :: line_starts

Offset of each line start in the content string.
protected fun line_starts=(line_starts: Array[Int])

nitc :: SourceFile :: line_starts=

Offset of each line start in the content string.
fun messages: Array[Message]

nitc :: SourceFile :: messages

Errors and warnings associated to the whole source.
protected fun messages=(messages: Array[Message])

nitc :: SourceFile :: messages=

Errors and warnings associated to the whole source.
fun mmodule: nullable MModule

nitc :: SourceFile :: mmodule

Associated mmodule, once created
protected fun mmodule=(mmodule: nullable MModule)

nitc :: SourceFile :: mmodule=

Associated mmodule, once created
fun stream: Reader

nitc :: SourceFile :: stream

The original stream used to initialize string
protected fun stream=(stream: Reader)

nitc :: SourceFile :: stream=

The original stream used to initialize string
fun string: String

nitc :: SourceFile :: string

The content of the source
protected fun string=(string: String)

nitc :: SourceFile :: string=

The content of the source

Redefined properties

redef type SELF: SourceFile

nitc $ SourceFile :: SELF

Type of this instance, automatically specialized in every class
redef init init

nitc $ SourceFile :: init

All properties

fun !=(other: nullable Object): Bool

core :: Object :: !=

Have self and other different values?
fun ==(other: nullable Object): Bool

core :: Object :: ==

Have self and other the same value?
type CLASS: Class[SELF]

core :: Object :: CLASS

The type of the class of self.
type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
private var _filename: String

nitc :: SourceFile :: _filename

The path of the source
private var _first_token: nullable Token

nitc :: SourceFile :: _first_token

The first token parser by the lexer
private var _last_token: nullable Token

nitc :: SourceFile :: _last_token

The first token parser by the lexer
private var _line_starts: Array[Int]

nitc :: SourceFile :: _line_starts

Offset of each line start in the content string.
private var _messages: Array[Message]

nitc :: SourceFile :: _messages

Errors and warnings associated to the whole source.
private var _mmodule: nullable MModule

nitc :: SourceFile :: _mmodule

Associated mmodule, once created
private var _stream: Reader

nitc :: SourceFile :: _stream

The original stream used to initialize string
private var _string: String

nitc :: SourceFile :: _string

The content of the source
protected fun class_factory(name: String): CLASS

core :: Object :: class_factory

Implementation used by get_class to create the specific class.
fun class_name: String

core :: Object :: class_name

The class name of the object.
init defaultinit(filename: String, stream: Reader)

nitc :: SourceFile :: defaultinit

fun filename: String

nitc :: SourceFile :: filename

The path of the source
protected fun filename=(filename: String)

nitc :: SourceFile :: filename=

The path of the source
fun first_token: nullable Token

nitc :: SourceFile :: first_token

The first token parser by the lexer
protected fun first_token=(first_token: nullable Token)

nitc :: SourceFile :: first_token=

The first token parser by the lexer
init from_string(filename: String, string: String)

nitc :: SourceFile :: from_string

Create a new sourcefile using a dummy filename and a given content
fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of self.
fun get_line(line_number: Int): String

nitc :: SourceFile :: get_line

Extract a given line excluding the line-terminators characters.
fun hash: Int

core :: Object :: hash

The hash code of the object.
init init

core :: Object :: init

fun inspect: String

core :: Object :: inspect

Developer readable representation of self.
protected fun inspect_head: String

core :: Object :: inspect_head

Return "CLASSNAME:#OBJECTID".
intern fun is_same_instance(other: nullable Object): Bool

core :: Object :: is_same_instance

Return true if self and other are the same instance (i.e. same identity).
fun is_same_serialized(other: nullable Object): Bool

core :: Object :: is_same_serialized

Is self the same as other in a serialization context?
intern fun is_same_type(other: Object): Bool

core :: Object :: is_same_type

Return true if self and other have the same dynamic type.
fun last_token: nullable Token

nitc :: SourceFile :: last_token

The first token parser by the lexer
protected fun last_token=(last_token: nullable Token)

nitc :: SourceFile :: last_token=

The first token parser by the lexer
fun line_starts: Array[Int]

nitc :: SourceFile :: line_starts

Offset of each line start in the content string.
protected fun line_starts=(line_starts: Array[Int])

nitc :: SourceFile :: line_starts=

Offset of each line start in the content string.
fun messages: Array[Message]

nitc :: SourceFile :: messages

Errors and warnings associated to the whole source.
protected fun messages=(messages: Array[Message])

nitc :: SourceFile :: messages=

Errors and warnings associated to the whole source.
fun mmodule: nullable MModule

nitc :: SourceFile :: mmodule

Associated mmodule, once created
protected fun mmodule=(mmodule: nullable MModule)

nitc :: SourceFile :: mmodule=

Associated mmodule, once created
private intern fun native_class_name: CString

core :: Object :: native_class_name

The class name of the object in CString format.
intern fun object_id: Int

core :: Object :: object_id

An internal hash code for the object based on its identity.
fun output

core :: Object :: output

Display self on stdout (debug only).
intern fun output_class_name

core :: Object :: output_class_name

Display class name on stdout (debug only).
fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
fun stream: Reader

nitc :: SourceFile :: stream

The original stream used to initialize string
protected fun stream=(stream: Reader)

nitc :: SourceFile :: stream=

The original stream used to initialize string
fun string: String

nitc :: SourceFile :: string

The content of the source
protected fun string=(string: String)

nitc :: SourceFile :: string=

The content of the source
intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

fun to_s: String

core :: Object :: to_s

User readable representation of self.
package_diagram nitc::SourceFile SourceFile core::Object Object nitc::SourceFile->core::Object

Parents

interface Object

core :: Object

The root of the class hierarchy.

Class definitions

nitc $ SourceFile
# A raw text Nit source file
class SourceFile
	# The path of the source
	var filename: String

	# The content of the source
	var string: String is noinit

	# The original stream used to initialize `string`
	var stream: Reader

	init
	do
		string = stream.read_all
		line_starts[0] = 0
	end

	# Create a new sourcefile using a dummy filename and a given content
	init from_string(filename: String, string: String) is
		nosuper
	do
		self.filename = filename
		self.string = string
		line_starts[0] = 0
	end

	# Offset of each line start in the content `string`.
	#
	# Used for fast access to each line when rendering parts of the `string`.
	var line_starts = new Array[Int]

	# Extract a given line excluding the line-terminators characters.
	#
	# `line_number` starts at 1 for the first line.
	fun get_line(line_number: Int): String do
		if line_number > line_starts.length then return ""
		var line_start = line_starts[line_number-1]
		var line_end = line_start
		var string = self.string
		while line_end+1 < string.length and string.chars[line_end+1] != '\n' and string.chars[line_end+1] != '\r' do
			line_end += 1
		end
		return string.substring(line_start, line_end-line_start+1)
	end
end
src/location.nit:20,1--64,3

nitc :: parser_nodes $ SourceFile
redef class SourceFile
	# The first token parser by the lexer
	# May have disappeared in the final AST
	var first_token: nullable Token = null

	# The first token parser by the lexer
	# May have disappeared in the final AST
	var last_token: nullable Token = null
end
src/parser/parser_nodes.nit:414,1--422,3

nitc :: toolcontext $ SourceFile
redef class SourceFile
	# Errors and warnings associated to the whole source.
	var messages = new Array[Message]
end
src/toolcontext.nit:138,1--141,3

nitc :: loader $ SourceFile
redef class SourceFile
	# Associated mmodule, once created
	var mmodule: nullable MModule = null
end
src/loader.nit:1272,1--1275,3