lib & contrib: update imports
[nit.git] / contrib / neo_doxygen / src / model / location.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
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
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
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.
14
15 # This module is used to model locations in source files.
16 module location
17
18 import json::static
19 import json
20
21 # A location inside a source file.
22 class Location
23 super Jsonable
24
25 # The file’s path.
26 var path: nullable String = null is writable
27
28 # The one-based index of the first line.
29 var line_start: Int = 1 is writable
30
31 # The one-based index of the last line.
32 var line_end: Int = 1 is writable
33
34 # The one-based column index of the first character.
35 var column_start: Int = 1 is writable
36
37 # The one-based column index of the last character.
38 var column_end: Int = 1 is writable
39
40 redef fun to_s do
41 var path = path
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}"
45 end
46
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
49 end