1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 # This module is used to model locations in source files.
21 # A location inside a source file.
26 var path
: nullable String = null is writable
28 # The one-based index of the first line.
29 var line_start
: Int = 1 is writable
31 # The one-based index of the last line.
32 var line_end
: Int = 1 is writable
34 # The one-based column index of the first character.
35 var column_start
: Int = 1 is writable
37 # The one-based column index of the last character.
38 var column_end
: Int = 1 is writable
42 var file_part
= "/dev/null:"
43 if path
!= null and path
.length
> 0 then file_part
= "{path}:"
44 return "{file_part}{line_start},{column_start}--{line_end},{column_end}"
47 redef fun serialize_to
(v
) do to_s
.serialize_to v
48 redef fun accept_json_serializer
(v
) do to_s
.serialize_to v