1 /* valasourcereference.vala
3 * Copyright (C) 2006-2009 Jürg Billeter
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 * Jürg Billeter <j@bitron.ch>
26 * Represents a reference to a location in a source file.
28 public class Vala
.SourceReference
{
30 * The source file to be referenced.
32 public weak SourceFile file
{ get; set; }
35 * The first line number of the referenced source code.
37 public int first_line
{ get; set; }
40 * The first column number of the referenced source code.
42 public int first_column
{ get; set; }
45 * The last line number of the referenced source code.
47 public int last_line
{ get; set; }
50 * The last column number of the referenced source code.
52 public int last_column
{ get; set; }
54 public List
<UsingDirective
> using_directives
{ get; private set; }
57 * Creates a new source reference.
59 * @param file a source file
60 * @param first_line first line number
61 * @param first_column first column number
62 * @param last_line last line number
63 * @param last_column last column number
64 * @return newly created source reference
66 public SourceReference (SourceFile _file
, int _first_line
= 0, int _first_column
= 0, int _last_line
= 0, int _last_column
= 0) {
68 first_line
= _first_line
;
69 first_column
= _first_column
;
70 last_line
= _last_line
;
71 last_column
= _last_column
;
72 using_directives
= file
.current_using_directives
;
76 * Returns a string representation of this source reference.
78 * @return human-readable string
80 public string to_string () {
81 return ("%s:%d.%d-%d.%d".printf (file
.get_relative_filename (), first_line
, first_column
, last_line
, last_column
));