1 | // |
---|
2 | // Error.cs |
---|
3 | // |
---|
4 | // Author: |
---|
5 | // Mike Krüger <mike@icsharpcode.net> |
---|
6 | // |
---|
7 | // Copyright (c) 2011 Mike Krüger <mike@icsharpcode.net> |
---|
8 | // |
---|
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy |
---|
10 | // of this software and associated documentation files (the "Software"), to deal |
---|
11 | // in the Software without restriction, including without limitation the rights |
---|
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
---|
13 | // copies of the Software, and to permit persons to whom the Software is |
---|
14 | // furnished to do so, subject to the following conditions: |
---|
15 | // |
---|
16 | // The above copyright notice and this permission notice shall be included in |
---|
17 | // all copies or substantial portions of the Software. |
---|
18 | // |
---|
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
---|
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
---|
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
---|
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
---|
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
---|
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
---|
25 | // THE SOFTWARE. |
---|
26 | |
---|
27 | using System; |
---|
28 | |
---|
29 | namespace ICSharpCode.NRefactory.TypeSystem |
---|
30 | { |
---|
31 | /// <summary> |
---|
32 | /// Enum that describes the type of an error. |
---|
33 | /// </summary> |
---|
34 | public enum ErrorType |
---|
35 | { |
---|
36 | Unknown, |
---|
37 | Error, |
---|
38 | Warning |
---|
39 | } |
---|
40 | |
---|
41 | /// <summary> |
---|
42 | /// Descibes an error during parsing. |
---|
43 | /// </summary> |
---|
44 | [Serializable] |
---|
45 | public class Error |
---|
46 | { |
---|
47 | readonly ErrorType errorType; |
---|
48 | readonly string message; |
---|
49 | readonly DomRegion region; |
---|
50 | |
---|
51 | /// <summary> |
---|
52 | /// The type of the error. |
---|
53 | /// </summary> |
---|
54 | public ErrorType ErrorType { get { return errorType; } } |
---|
55 | |
---|
56 | /// <summary> |
---|
57 | /// The error description. |
---|
58 | /// </summary> |
---|
59 | public string Message { get { return message; } } |
---|
60 | |
---|
61 | /// <summary> |
---|
62 | /// The region of the error. |
---|
63 | /// </summary> |
---|
64 | public DomRegion Region { get { return region; } } |
---|
65 | |
---|
66 | /// <summary> |
---|
67 | /// Initializes a new instance of the <see cref="ICSharpCode.NRefactory.TypeSystem.Error"/> class. |
---|
68 | /// </summary> |
---|
69 | /// <param name='errorType'> |
---|
70 | /// The error type. |
---|
71 | /// </param> |
---|
72 | /// <param name='message'> |
---|
73 | /// The description of the error. |
---|
74 | /// </param> |
---|
75 | /// <param name='region'> |
---|
76 | /// The region of the error. |
---|
77 | /// </param> |
---|
78 | public Error (ErrorType errorType, string message, DomRegion region) |
---|
79 | { |
---|
80 | this.errorType = errorType; |
---|
81 | this.message = message; |
---|
82 | this.region = region; |
---|
83 | } |
---|
84 | |
---|
85 | /// <summary> |
---|
86 | /// Initializes a new instance of the <see cref="ICSharpCode.NRefactory.TypeSystem.Error"/> class. |
---|
87 | /// </summary> |
---|
88 | /// <param name='errorType'> |
---|
89 | /// The error type. |
---|
90 | /// </param> |
---|
91 | /// <param name='message'> |
---|
92 | /// The description of the error. |
---|
93 | /// </param> |
---|
94 | /// <param name='location'> |
---|
95 | /// The location of the error. |
---|
96 | /// </param> |
---|
97 | public Error (ErrorType errorType, string message, TextLocation location) |
---|
98 | { |
---|
99 | this.errorType = errorType; |
---|
100 | this.message = message; |
---|
101 | this.region = new DomRegion (location, location); |
---|
102 | } |
---|
103 | |
---|
104 | /// <summary> |
---|
105 | /// Initializes a new instance of the <see cref="ICSharpCode.NRefactory.TypeSystem.Error"/> class. |
---|
106 | /// </summary> |
---|
107 | /// <param name='errorType'> |
---|
108 | /// The error type. |
---|
109 | /// </param> |
---|
110 | /// <param name='message'> |
---|
111 | /// The description of the error. |
---|
112 | /// </param> |
---|
113 | /// <param name='line'> |
---|
114 | /// The line of the error. |
---|
115 | /// </param> |
---|
116 | /// <param name='col'> |
---|
117 | /// The column of the error. |
---|
118 | /// </param> |
---|
119 | public Error (ErrorType errorType, string message, int line, int col) : this (errorType, message, new TextLocation (line, col)) |
---|
120 | { |
---|
121 | } |
---|
122 | |
---|
123 | /// <summary> |
---|
124 | /// Initializes a new instance of the <see cref="ICSharpCode.NRefactory.TypeSystem.Error"/> class. |
---|
125 | /// </summary> |
---|
126 | /// <param name='errorType'> |
---|
127 | /// The error type. |
---|
128 | /// </param> |
---|
129 | /// <param name='message'> |
---|
130 | /// The description of the error. |
---|
131 | /// </param> |
---|
132 | public Error (ErrorType errorType, string message) |
---|
133 | { |
---|
134 | this.errorType = errorType; |
---|
135 | this.message = message; |
---|
136 | this.region = DomRegion.Empty; |
---|
137 | } |
---|
138 | } |
---|
139 | } |
---|