private void Test(string[] header, string[] text)
    {
      string headerString = string.Join (Environment.NewLine, header);
      string textString = string.Join(Environment.NewLine, text);
      
      if (header.Length > 0 && text.Length > 0)
        headerString += Environment.NewLine;

      var parser = new CommentParser ("//", "/*", "*/", "#region", "#endregion");
      Assert.AreEqual (headerString, parser.Parse (headerString + textString));
    }
Example #2
0
 public static bool Validate(string header, CommentParser commentParser)
 {
     try
     {
         var result = commentParser.Parse(header);
         return(result == header);
     }
     catch (ParseException)
     {
         return(false);
     }
 }
        public Document(TextDocument document, Language language, string[] lines, ProjectItem projectItem, IEnumerable<string> keywords = null)
        {
            _document = document;

              _lineEndingInDocument = NewLineManager.DetectMostFrequentLineEnd (GetText ());

              string inputText = CreateInputText(lines);
              _header = new DocumentHeader (document, inputText, new DocumentHeaderProperties (projectItem));
              _keywords = keywords;

              _language = language;

              _commentParser = new CommentParser (language.LineComment, language.BeginComment, language.EndComment, language.BeginRegion, language.EndRegion);
        }
Example #4
0
        public Document(TextDocument document, Language language, string[] lines, ProjectItem projectItem, IEnumerable <string> keywords = null)
        {
            _document = document;

            _lineEndingInDocument = NewLineManager.DetectMostFrequentLineEnd(GetText());


            string inputText = CreateInputText(lines);

            _header   = new DocumentHeader(document, inputText, new DocumentHeaderProperties(projectItem));
            _keywords = keywords;

            _language = language;

            _commentParser = new CommentParser(language.LineComment, language.BeginComment, language.EndComment, language.BeginRegion, language.EndRegion);
        }
 public static bool Validate(string header, CommentParser commentParser)
 {
     try
       {
     var result = commentParser.Parse (header);
     return result == header;
       }
       catch (ParseException)
       {
     return false;
       }
 }
 private void TestError(string[] text)
 {
     string textString = string.Join (Environment.NewLine, text);
       var parser = new CommentParser ("//", "/*", "*/", "#region", "#endregion");
       Assert.Throws<ParseException>(() => parser.Parse (textString));
 }
    public void TestEndRegionWithSpace()
    {
      var header = new[]
      {
        "#Region ",
        "//This is a comment.",
        "#End Region"
      };

      string headerString = string.Join (Environment.NewLine, header);
      
      headerString += Environment.NewLine;

      var parser = new CommentParser ("//", "/*", "*/", "#Region", "#End Region");
      Assert.AreEqual (headerString, parser.Parse (headerString));
      
    }