2 * Copyright (C) 2008-2009 Abderrahim Kitouni
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 /* A Vala.Report subclass for reporting errors in Anjuta UI */
19 public class AnjutaReport
: Vala
.Report
{
21 public Vala
.SourceReference source
;
23 public string message
;
25 public IAnjuta
.DocumentManager docman
{ get; set; }
26 Vala
.List
<Error?
> errors_list
= new Vala
.ArrayList
<Error?
>();
27 bool general_error
= false;
29 public void update_errors (IAnjuta
.Editor editor
) {
30 var ind
= editor as IAnjuta
.Indicable
;
31 var mark
= editor as IAnjuta
.Markable
;
32 if (ind
== null && mark
== null)
38 mark
.delete_all_markers (IAnjuta
.MarkableMarker
.MESSAGE
);
40 foreach (var e
in errors_list
) {
41 if (e
.source
.file
.filename
.has_suffix (((IAnjuta
.Document
)editor
).get_filename ())) {
43 /* begin_iter should be one cell before to select the first character */
44 var begin_iter
= editor
.get_line_begin_position (e
.source
.begin
.line
);
45 for (var i
= 1; i
< e
.source
.begin
.column
; i
++)
47 var end_iter
= editor
.get_line_begin_position (e
.source
.end
.line
);
48 for (var i
= 0; i
< e
.source
.end
.column
; i
++)
50 ind
.set(begin_iter
, end_iter
, e
.error ? IAnjuta
.IndicableIndicator
.CRITICAL
:
51 IAnjuta
.IndicableIndicator
.WARNING
);
53 if (editor is IAnjuta
.Markable
) {
54 mark
.mark(e
.source
.begin
.line
, IAnjuta
.MarkableMarker
.MESSAGE
, e
.message
);
60 public void clear_error_indicators (Vala
.SourceFile? file
= null) {
62 errors_list
= new Vala
.ArrayList
<Error?
>();
65 for (var i
= 0; i
< errors_list
.size
; i
++) {
66 if (errors_list
[i
].source
.file
== file
) {
67 if (errors_list
[i
].error
)
72 errors_list
.remove_at (i
);
76 assert (errors_list
.size
<= errors
+ warnings
);
79 foreach (var doc
in docman
.get_doc_widgets ()) {
80 if (doc is IAnjuta
.Indicable
)
81 ((IAnjuta
.Indicable
)doc
).clear ();
82 if (doc is IAnjuta
.Markable
)
83 ((IAnjuta
.Markable
)doc
).delete_all_markers (IAnjuta
.MarkableMarker
.MESSAGE
);
86 public override void warn (Vala
.SourceReference? source
, string message
) {
93 errors_list
.add(Error () {source
= source
, message
= message
, error
= false});
96 public override void err (Vala
.SourceReference? source
, string message
) {
100 general_error
= true;
105 errors_list
.add(Error () {source
= source
, message
= message
, error
= true});