1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 using System
.Collections
;
20 using Castle
.Rook
.Compiler
;
21 using Castle
.Rook
.Compiler
.Services
;
24 public class UIErrorReport
: IErrorReport
29 ArrayList list
= new ArrayList();
31 public UIErrorReport()
35 public void Error(String filename
, LexicalPosition pos
, String contents
, params object[] args
)
37 if (disabled
!= 0) return;
41 list
.Add( new ErrorEntry(true, filename
, pos
, String
.Format(contents
, args
) ) );
44 public void Error(String contents
, params object[] args
)
46 if (disabled
!= 0) return;
50 list
.Add( new ErrorEntry(true, "", new LexicalPosition(), String
.Format(contents
, args
) ) );
53 public void Warning(String filename
, LexicalPosition pos
, Severity severity
, String contents
, params object[] args
)
55 if (disabled
!= 0) return;
59 list
.Add( new ErrorEntry(false, "", new LexicalPosition(), String
.Format(contents
, args
) ) );
62 public void Warning(String contents
, params object[] args
)
64 if (disabled
!= 0) return;
68 list
.Add( new ErrorEntry(false, "", new LexicalPosition(), String
.Format(contents
, args
) ) );
73 get { return errors != 0; }
76 public bool HasWarnings
78 get { return warnings != 0; }
97 public class ErrorEntry
99 private readonly string filename
;
100 private readonly bool isError
;
101 private readonly LexicalPosition pos
;
102 private readonly string contents
;
104 public ErrorEntry(bool error
, string filename
, LexicalPosition pos
, string contents
)
106 this.filename
= filename
;
107 this.isError
= error
;
109 this.contents
= contents
;
114 get { return isError; }
117 public string Filename
119 get { return filename; }
122 public LexicalPosition Pos
127 public string Contents
129 get { return contents; }