PageRenderTime 48ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/Error.cs

http://github.com/mono/monodevelop
C# | 218 lines | 71 code | 17 blank | 130 comment | 0 complexity | 159c779e7d38cb24afcefc810926e8d2 MD5 | raw file
Possible License(s): LGPL-2.0, GPL-2.0, CC-BY-SA-3.0, MIT, LGPL-2.1, Apache-2.0, BSD-3-Clause
  1. //
  2. // Error.cs
  3. //
  4. // Author:
  5. // Mike Krüger <mkrueger@xamarin.com>
  6. //
  7. // Copyright (c) 2015 mkrueger
  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. using System;
  27. using MonoDevelop.Core.Text;
  28. using MonoDevelop.Ide.Editor;
  29. namespace MonoDevelop.Ide.TypeSystem
  30. {
  31. /// <summary>
  32. /// Enum that describes the type of an error.
  33. /// </summary>
  34. [Obsolete("Use Visual Studio Editor APIs")]
  35. public enum ErrorType
  36. {
  37. Unknown,
  38. Error,
  39. Warning
  40. }
  41. /// <summary>
  42. /// Descibes an error during parsing.
  43. /// </summary>
  44. [Serializable]
  45. [Obsolete("Use Visual Studio Editor APIs")]
  46. public class Error
  47. {
  48. readonly ErrorType errorType;
  49. readonly string message;
  50. readonly DocumentRegion region;
  51. /// <summary>
  52. /// The type of the error.
  53. /// </summary>
  54. public ErrorType ErrorType { get { return errorType; } }
  55. /// <summary>
  56. /// The error description.
  57. /// </summary>
  58. public string Message { get { return message; } }
  59. /// <summary>
  60. /// The id of the error.
  61. /// </summary>
  62. public string Id { get; private set; }
  63. /// <summary>
  64. /// The region of the error.
  65. /// </summary>
  66. public DocumentRegion Region { get { return region; } }
  67. /// <summary>
  68. /// Gets or sets the tag.
  69. /// </summary>
  70. public object Tag { get; set; }
  71. /// <summary>
  72. /// Initializes a new instance of the <see cref="ICSharpCode.NRefactory.TypeSystem.Error"/> class.
  73. /// </summary>
  74. /// <param name='errorType'>
  75. /// The error type.
  76. /// </param>
  77. /// <param name='message'>
  78. /// The description of the error.
  79. /// </param>
  80. /// <param name='region'>
  81. /// The region of the error.
  82. /// </param>
  83. public Error (ErrorType errorType, string message, DocumentRegion region)
  84. {
  85. this.errorType = errorType;
  86. this.message = message;
  87. this.region = region;
  88. }
  89. /// <summary>
  90. /// Initializes a new instance of the <see cref="ICSharpCode.NRefactory.TypeSystem.Error"/> class.
  91. /// </summary>
  92. /// <param name='errorType'>
  93. /// The error type.
  94. /// </param>
  95. /// <param name='message'>
  96. /// The description of the error.
  97. /// </param>
  98. /// <param name='location'>
  99. /// The location of the error.
  100. /// </param>
  101. public Error (ErrorType errorType, string message, DocumentLocation location)
  102. {
  103. this.errorType = errorType;
  104. this.message = message;
  105. this.region = new DocumentRegion (location, location);
  106. }
  107. /// <summary>
  108. /// Initializes a new instance of the <see cref="ICSharpCode.NRefactory.TypeSystem.Error"/> class.
  109. /// </summary>
  110. /// <param name='errorType'>
  111. /// The error type.
  112. /// </param>
  113. /// <param name='message'>
  114. /// The description of the error.
  115. /// </param>
  116. public Error (ErrorType errorType, string message, int line, int column) : this (errorType, message, new DocumentLocation (line, column))
  117. {
  118. }
  119. /// <summary>
  120. /// Initializes a new instance of the <see cref="ICSharpCode.NRefactory.TypeSystem.Error"/> class.
  121. /// </summary>
  122. /// <param name='errorType'>
  123. /// The error type.
  124. /// </param>
  125. /// <param name='message'>
  126. /// The description of the error.
  127. /// </param>
  128. public Error (ErrorType errorType, string message)
  129. {
  130. this.errorType = errorType;
  131. this.message = message;
  132. this.region = DocumentRegion.Empty;
  133. }
  134. /// <summary>
  135. /// Initializes a new instance of the <see cref="ICSharpCode.NRefactory.TypeSystem.Error"/> class.
  136. /// </summary>
  137. /// <param name='errorType'>
  138. /// The error type.
  139. /// </param>
  140. /// <param name='message'>
  141. /// The description of the error.
  142. /// </param>
  143. /// <param name='region'>
  144. /// The region of the error.
  145. /// </param>
  146. public Error (ErrorType errorType, string id, string message, DocumentRegion region)
  147. {
  148. this.errorType = errorType;
  149. this.Id = id;
  150. this.message = message;
  151. this.region = region;
  152. }
  153. /// <summary>
  154. /// Initializes a new instance of the <see cref="ICSharpCode.NRefactory.TypeSystem.Error"/> class.
  155. /// </summary>
  156. /// <param name='errorType'>
  157. /// The error type.
  158. /// </param>
  159. /// <param name='message'>
  160. /// The description of the error.
  161. /// </param>
  162. /// <param name='location'>
  163. /// The location of the error.
  164. /// </param>
  165. public Error (ErrorType errorType, string id, string message, DocumentLocation location)
  166. {
  167. this.errorType = errorType;
  168. this.Id = id;
  169. this.message = message;
  170. this.region = new DocumentRegion (location, location);
  171. }
  172. /// <summary>
  173. /// Initializes a new instance of the <see cref="ICSharpCode.NRefactory.TypeSystem.Error"/> class.
  174. /// </summary>
  175. /// <param name='errorType'>
  176. /// The error type.
  177. /// </param>
  178. /// <param name='message'>
  179. /// The description of the error.
  180. /// </param>
  181. public Error (ErrorType errorType, string id, string message, int line, int column) : this (errorType, id, message, new DocumentLocation (line, column))
  182. {
  183. }
  184. /// <summary>
  185. /// Initializes a new instance of the <see cref="ICSharpCode.NRefactory.TypeSystem.Error"/> class.
  186. /// </summary>
  187. /// <param name='errorType'>
  188. /// The error type.
  189. /// </param>
  190. /// <param name='message'>
  191. /// The description of the error.
  192. /// </param>
  193. public Error (ErrorType errorType, string id, string message)
  194. {
  195. this.errorType = errorType;
  196. this.Id = id;
  197. this.message = message;
  198. this.region = DocumentRegion.Empty;
  199. }
  200. }
  201. }