865257751772f8b912d3677312796a2659ac505d
[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 var path: nullable String = null is writable
25 var line_start: Int = 1 is writable
26 var line_end: Int = 1 is writable
27 var column_start: Int = 1 is writable
28 var column_end: Int = 1 is writable
29
30 redef fun to_s: String do
31 var file_part = "/dev/null:"
32 if path != null and path.length > 0 then file_part = "{path.as(not null)}:"
33 return "{file_part}{line_start},{column_start}--{line_end},{column_end}"
34 end
35
36 redef fun to_json do return to_s.to_json
37 end