PageRenderTime 47ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/ILSpy/NRefactory/ICSharpCode.NRefactory/TypeSystem/Error.cs

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