neo_doxygen: Document `Location`.
[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 neo4j
19
20 # A location inside a source file.
21 class Location
22 super Jsonable
23
24 # The file’s path.
25 var path: nullable String = null is writable
26
27 # The one-based index of the first line.
28 var line_start: Int = 1 is writable
29
30 # The one-based index of the last line.
31 var line_end: Int = 1 is writable
32
33 # The one-based column index of the first character.
34 var column_start: Int = 1 is writable
35
36 # The one-based column index of the last character.
37 var column_end: Int = 1 is writable
38
39 redef fun to_s: String do
40 var file_part = "/dev/null:"
41 if path != null and path.length > 0 then file_part = "{path.as(not null)}:"
42 return "{file_part}{line_start},{column_start}--{line_end},{column_end}"
43 end
44
45 redef fun to_json do return to_s.to_json
46 end