Applied patch from Jan Limpens 'ReflectionBasedDictionaryAdapter needs to check if...
[castle.git] / Experiments / Attic / Rook / ASTViewer / UIErrorReport.cs
blobef2abe8467c1db2750b775d048ee76f04aa28fb3
1 // Copyright 2004-2008 Castle Project - http://www.castleproject.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.
15 namespace ASTViewer
17 using System;
18 using System.Collections;
20 using Castle.Rook.Compiler;
21 using Castle.Rook.Compiler.Services;
24 public class UIErrorReport : IErrorReport
26 int errors;
27 int warnings;
28 int disabled;
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;
39 errors++;
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;
48 errors++;
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;
57 warnings++;
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;
66 warnings++;
68 list.Add( new ErrorEntry(false, "", new LexicalPosition(), String.Format(contents, args) ) );
71 public bool HasErrors
73 get { return errors != 0; }
76 public bool HasWarnings
78 get { return warnings != 0; }
81 public void Enable()
83 disabled--;
86 public void Disable()
88 disabled++;
91 public ArrayList List
93 get { return list; }
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;
108 this.pos = pos;
109 this.contents = contents;
112 public bool IsError
114 get { return isError; }
117 public string Filename
119 get { return filename; }
122 public LexicalPosition Pos
124 get { return pos; }
127 public string Contents
129 get { return contents; }