PageRenderTime 49ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/main/contrib/ICSharpCode.NRefactory/TypeSystem/Error.cs

http://github.com/mono/monodevelop
C# | 135 lines | 38 code | 9 blank | 88 comment | 0 complexity | 83dcfcadadea55b4c6d809695b2ebfc3 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 <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. using System;
  27. using ICSharpCode.NRefactory.CSharp;
  28. namespace ICSharpCode.NRefactory.TypeSystem
  29. {
  30. /// <summary>
  31. /// Enum that describes the type of an error.
  32. /// </summary>
  33. public enum ErrorType
  34. {
  35. Unknown,
  36. Error,
  37. Warning
  38. }
  39. /// <summary>
  40. /// Descibes an error during parsing.
  41. /// </summary>
  42. public class Error
  43. {
  44. /// <summary>
  45. /// The type of the error.
  46. /// </summary>
  47. public ErrorType ErrorType { get; private set; }
  48. /// <summary>
  49. /// The error description.
  50. /// </summary>
  51. public string Message { get; private set; }
  52. /// <summary>
  53. /// The region of the error.
  54. /// </summary>
  55. public DomRegion Region { get; private set; }
  56. /// <summary>
  57. /// Initializes a new instance of the <see cref="ICSharpCode.NRefactory.TypeSystem.Error"/> class.
  58. /// </summary>
  59. /// <param name='errorType'>
  60. /// The error type.
  61. /// </param>
  62. /// <param name='message'>
  63. /// The description of the error.
  64. /// </param>
  65. /// <param name='region'>
  66. /// The region of the error.
  67. /// </param>
  68. public Error (ErrorType errorType, string message, DomRegion region)
  69. {
  70. this.ErrorType = errorType;
  71. this.Message = message;
  72. this.Region = region;
  73. }
  74. /// <summary>
  75. /// Initializes a new instance of the <see cref="ICSharpCode.NRefactory.TypeSystem.Error"/> class.
  76. /// </summary>
  77. /// <param name='errorType'>
  78. /// The error type.
  79. /// </param>
  80. /// <param name='message'>
  81. /// The description of the error.
  82. /// </param>
  83. /// <param name='location'>
  84. /// The location of the error.
  85. /// </param>
  86. public Error (ErrorType errorType, string message, AstLocation location)
  87. {
  88. this.ErrorType = errorType;
  89. this.Message = message;
  90. this.Region = new DomRegion (location, location);
  91. }
  92. /// <summary>
  93. /// Initializes a new instance of the <see cref="ICSharpCode.NRefactory.TypeSystem.Error"/> class.
  94. /// </summary>
  95. /// <param name='errorType'>
  96. /// The error type.
  97. /// </param>
  98. /// <param name='message'>
  99. /// The description of the error.
  100. /// </param>
  101. /// <param name='line'>
  102. /// The line of the error.
  103. /// </param>
  104. /// <param name='col'>
  105. /// The column of the error.
  106. /// </param>
  107. public Error (ErrorType errorType, string message, int line, int col) : this (errorType, message, new AstLocation (line, col))
  108. {
  109. }
  110. /// <summary>
  111. /// Initializes a new instance of the <see cref="ICSharpCode.NRefactory.TypeSystem.Error"/> class.
  112. /// </summary>
  113. /// <param name='errorType'>
  114. /// The error type.
  115. /// </param>
  116. /// <param name='message'>
  117. /// The description of the error.
  118. /// </param>
  119. public Error (ErrorType errorType, string message)
  120. {
  121. this.ErrorType = errorType;
  122. this.Message = message;
  123. this.Region = DomRegion.Empty;
  124. }
  125. }
  126. }