Ejemplo n.º 1
0
		private static string GetErrorMessage(MissingTokenType missingTokenType) {
			switch (missingTokenType) {
				case MissingTokenType.BlockEnd: return "Missing block end";
				case MissingTokenType.DirectiveName: return "Missing directive name";
				case MissingTokenType.AttributeName: return "Missing attribute name";
				case MissingTokenType.AttributeNameAndEqualSign: return "Missing attribute name and equal sign";
				case MissingTokenType.EqualSign: return "Missing equal sign";
				case MissingTokenType.AttributeValue: return "Missing attribute value";
				case MissingTokenType.EqualSignAndAttributeValue: return "Missing equal sign and attribute value";
				case MissingTokenType.Quote: return "Missing quote";
				default: return missingTokenType.ToString();
			}
		}
Ejemplo n.º 2
0
        private static string GetFixText(MissingTokenType missingTokenType)
        {
            switch (missingTokenType)
            {
            case MissingTokenType.BlockEnd: return("Add block end");

            case MissingTokenType.DirectiveName: return("Add directive name");

            case MissingTokenType.AttributeName: return("Add attribute name");

            case MissingTokenType.AttributeNameAndEqualSign: return("Add attribute name and equal sign");

            case MissingTokenType.EqualSign: return("Add equal sign");

            case MissingTokenType.AttributeValue: return("Add attribute value");

            case MissingTokenType.EqualSignAndAttributeValue: return("Add equal sign and attribute value");

            case MissingTokenType.Quote: return("Add quote");

            default: throw new ArgumentOutOfRangeException("missingTokenType");
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets the text of the token to add.
        /// </summary>
        /// <param name="missingTokenType">The associated missing token type.</param>
        /// <returns>A <see cref="TextInfo"/> containing the text to add with spacing.</returns>
        private static TextInfo GetMissingTextInfo(MissingTokenType missingTokenType)
        {
            switch (missingTokenType)
            {
            case MissingTokenType.BlockEnd: return(new TextInfo("#>", true, false, TextRange.InvalidRange));

            case MissingTokenType.DirectiveName: return(new TextInfo("name", true, true, new TextRange(0, 4)));

            case MissingTokenType.AttributeName: return(new TextInfo("name", true, false, new TextRange(0, 4)));

            case MissingTokenType.AttributeNameAndEqualSign: return(new TextInfo("name=", true, false, new TextRange(0, 4)));

            case MissingTokenType.EqualSign: return(new TextInfo("=", false, false, TextRange.InvalidRange));

            case MissingTokenType.AttributeValue: return(new TextInfo("\"value\"", false, true, new TextRange(1, 6)));

            case MissingTokenType.EqualSignAndAttributeValue: return(new TextInfo("=\"value\"", false, true, new TextRange(2, 7)));

            case MissingTokenType.Quote: return(new TextInfo("\"", false, true, TextRange.InvalidRange));

            default: throw new ArgumentOutOfRangeException("missingTokenType");
            }
        }
Ejemplo n.º 4
0
        private static string GetErrorMessage(MissingTokenType missingTokenType)
        {
            switch (missingTokenType)
            {
            case MissingTokenType.BlockEnd: return("Missing block end");

            case MissingTokenType.DirectiveName: return("Missing directive name");

            case MissingTokenType.AttributeName: return("Missing attribute name");

            case MissingTokenType.AttributeNameAndEqualSign: return("Missing attribute name and equal sign");

            case MissingTokenType.EqualSign: return("Missing equal sign");

            case MissingTokenType.AttributeValue: return("Missing attribute value");

            case MissingTokenType.EqualSignAndAttributeValue: return("Missing equal sign and attribute value");

            case MissingTokenType.Quote: return("Missing quote");

            default: return(missingTokenType.ToString());
            }
        }
Ejemplo n.º 5
0
		/// <summary>
		/// Initializes a new instance of the <see cref="MissingTokenErrorElement"/> class.
		/// </summary>
		public MissingTokenErrorElement(MissingTokenType missingTokenType)
			: base(GetErrorMessage(missingTokenType)) {
			_missingTokenType = missingTokenType;
		}
Ejemplo n.º 6
0
 /// <summary>
 /// Appends an error element where a token of a given type was expected.
 /// </summary>
 /// <param name="parentElement">The parent element.</param>
 /// <param name="missingTokenType">The missing token type.</param>
 private void AppendMissingToken([NotNull] CompositeElement parentElement, MissingTokenType missingTokenType)
 {
     AppendNewChild(parentElement, new MissingTokenErrorElement(missingTokenType));
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Appends an error element where a token of a given type was expected.
 /// </summary>
 /// <param name="parentElement">The parent element.</param>
 /// <param name="missingTokenType">The missing token type.</param>
 private void AppendMissingToken([NotNull] CompositeElement parentElement, MissingTokenType missingTokenType)
 {
     AppendNewChild(parentElement, new MissingTokenErrorElement(missingTokenType));
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Gets the text of the token to add.
 /// </summary>
 /// <param name="missingTokenType">The associated missing token type.</param>
 /// <returns>A <see cref="TextInfo"/> containing the text to add with spacing.</returns>
 private static TextInfo GetMissingTextInfo(MissingTokenType missingTokenType)
 {
     switch (missingTokenType) {
         case MissingTokenType.BlockEnd: return new TextInfo("#>", true, false, TextRange.InvalidRange);
         case MissingTokenType.DirectiveName: return new TextInfo("name", true, true, new TextRange(0, 4));
         case MissingTokenType.AttributeName: return new TextInfo("name", true, false, new TextRange(0, 4));
         case MissingTokenType.AttributeNameAndEqualSign: return new TextInfo("name=", true, false, new TextRange(0, 4));
         case MissingTokenType.EqualSign: return new TextInfo("=", false, false, TextRange.InvalidRange);
         case MissingTokenType.AttributeValue: return new TextInfo("\"value\"", false, true, new TextRange(1, 6));
         case MissingTokenType.EqualSignAndAttributeValue: return new TextInfo("=\"value\"", false, true, new TextRange(2, 7));
         case MissingTokenType.Quote: return new TextInfo("\"", false, true, TextRange.InvalidRange);
         default: throw new ArgumentOutOfRangeException("missingTokenType");
     }
 }
Ejemplo n.º 9
0
 private static string GetFixText(MissingTokenType missingTokenType)
 {
     switch (missingTokenType) {
         case MissingTokenType.BlockEnd: return "Add block end";
         case MissingTokenType.DirectiveName: return "Add directive name";
         case MissingTokenType.AttributeName: return "Add attribute name";
         case MissingTokenType.AttributeNameAndEqualSign: return "Add attribute name and equal sign";
         case MissingTokenType.EqualSign: return "Add equal sign";
         case MissingTokenType.AttributeValue: return "Add attribute value";
         case MissingTokenType.EqualSignAndAttributeValue: return "Add equal sign and attribute value";
         case MissingTokenType.Quote: return "Add quote";
         default: throw new ArgumentOutOfRangeException("missingTokenType");
     }
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MissingTokenErrorElement"/> class.
 /// </summary>
 public MissingTokenErrorElement(MissingTokenType missingTokenType)
     : base(GetErrorMessage(missingTokenType))
 {
     _missingTokenType = missingTokenType;
 }