public void TestSkipNestedBlockComment() { var p = CommentParser.SkipNestedBlockComment(String("/*"), String("*/")).Then(End); { var comment = "/**/"; var result = p.Parse(comment); AssertSuccess(result, Unit.Value, true); } { var comment = "/*/**/*/"; var result = p.Parse(comment); AssertSuccess(result, Unit.Value, true); } { var comment = "/* here is a non-nested block comment with \n newlines in */"; var result = p.Parse(comment); AssertSuccess(result, Unit.Value, true); } { var comment = "/* here is a /* nested */ block comment with \n newlines in */"; var result = p.Parse(comment); AssertSuccess(result, Unit.Value, true); } }
public static PgDatabase LoadDatabaseSchema(TextReader reader, string charsetName, bool outputIgnoredStatements, bool ignoreSlonyTriggers) { var database = new PgDatabase(); var statement = GetWholeStatement(reader); while (statement != null) { if (PatternCreateSchema.IsMatch(statement)) { CreateSchemaParser.Parse(database, statement); } else if (PatternDefaultSchema.IsMatch(statement)) { database.SetDefaultSchema(PatternDefaultSchema.Matches(statement)[0].Groups[1].Value); } else if (PatternCreateTable.IsMatch(statement)) { CreateTableParser.Parse(database, statement); } else if (PatternAlterTable.IsMatch(statement)) { AlterTableParser.Parse(database, statement, outputIgnoredStatements); } else if (PatternCreateSequence.IsMatch(statement)) { CreateSequenceParser.Parse(database, statement); } else if (PatternAlterSequence.IsMatch(statement)) { AlterSequenceParser.Parse(database, statement, outputIgnoredStatements); } else if (PatternCreateIndex.IsMatch(statement)) { CreateIndexParser.Parse(database, statement); } else if (PatternCreateView.IsMatch(statement)) { CreateViewParser.Parse(database, statement); } else if (PatternAlterView.IsMatch(statement)) { AlterViewParser.Parse(database, statement, outputIgnoredStatements); } else if (PatternCreateTrigger.IsMatch(statement)) { CreateTriggerParser.Parse(database, statement, ignoreSlonyTriggers); } else if (PatternCreateFunction.IsMatch(statement)) { CreateFunctionParser.Parse(database, statement); } else if (PatternComment.IsMatch(statement)) { CommentParser.Parse(database, statement, outputIgnoredStatements); } else if (PatternSelect.IsMatch(statement) || PatternInsertInto.IsMatch(statement) || PatternUpdate.IsMatch(statement) || PatternDeleteFrom.IsMatch(statement)) /* we just ignore these statements*/ } {
public void IsPositionInComment() { // 012345678901234567890123456789 string source = @" /* 1 */ /* 2 */ /* 3 */ "; var comments = new CommentParser().Parse(source); Assert.AreEqual(3, comments.Count); Assert.IsFalse(comments.IsPositionInComment(0)); Assert.IsFalse(comments.IsPositionInComment(8)); Assert.IsFalse(comments.IsPositionInComment(16)); Assert.IsFalse(comments.IsPositionInComment(24)); Assert.IsTrue(comments.IsPositionInComment(9)); Assert.IsTrue(comments.IsPositionInComment(10)); Assert.IsTrue(comments.IsPositionInComment(11)); Assert.IsTrue(comments.IsPositionInComment(12)); Assert.IsTrue(comments.IsPositionInComment(13)); Assert.IsTrue(comments.IsPositionInComment(14)); Assert.IsTrue(comments.IsPositionInComment(15)); Assert.IsTrue(comments.IsPositionInComment(1)); Assert.IsTrue(comments.IsPositionInComment(2)); Assert.IsTrue(comments.IsPositionInComment(3)); Assert.IsTrue(comments.IsPositionInComment(4)); Assert.IsTrue(comments.IsPositionInComment(5)); Assert.IsTrue(comments.IsPositionInComment(6)); Assert.IsTrue(comments.IsPositionInComment(7)); }
static void FillClientMembers(Documentation doc, string typeFullName, string scriptsFolder) { var actAssembly = typeof(ToolkitResourceManager).Assembly; var type = actAssembly.GetType(typeFullName, true); if (type.IsSubclassOf(typeof(ExtenderControlBase)) || type.IsSubclassOf(typeof(ScriptControlBase)) || type == typeof(ComboBox)) { var clientScriptName = type .GetCustomAttributesData() .First(a => a.Constructor.DeclaringType == typeof(ClientScriptResourceAttribute)) .ConstructorArguments[1] .Value; var jsFileName = clientScriptName + ".js"; var jsLines = File.ReadAllLines(Path.Combine(scriptsFolder, jsFileName)); var commentParser = new CommentParser(); var clientMembers = commentParser.ParseFile(jsLines, typeFullName); doc.Add(clientMembers, ContentType.Text); } }
private void AssertCorrectlyParsed(string input, string expectedHeader) { var parser = new CommentParser("//", "/*", "*/", "#region", "#endregion"); var extractedHeader = parser.Parse(input); Assert.That(extractedHeader, Is.EqualTo(expectedHeader)); }
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 NewRevisionRangeDetectedMessageHandler(IVersionControlSystem versionControlSystem, ILocalBus bus, IActivityLogger logger) { _versionControlSystem = versionControlSystem; _bus = bus; _logger = logger; _parser = new CommentParser(); }
public void ParseCommentLine() { var output = new CommentParser().ParseLine(0, " #comment", TokenType.Table).Single(); var expectedOutput = new ParsedSpan(0, TokenType.Comment, 2, "#comment"); AreEqual(expectedOutput, output); }
public static Parser <char, T> Next <T>(Parser <char, T> parser) { return (SkipWhitespaces .Then(Try(CommentParser.SkipBlockComment(String("/*"), String("*/")) .Or(CommentParser.SkipLineComment(String("//")))).Optional() .Then(SkipWhitespaces)) .Then(parser)); }
public static IEnumerable <RawDoc> GetAnimationScriptsReferenceForType(string animationTypeName, string scriptsFolder) { var doc = new Documentation(); var commentParser = new CommentParser(); var jsLines = File.ReadAllLines(Path.Combine(scriptsFolder, "AnimationScripts.js")); var typeFullName = "AjaxControlToolkit." + animationTypeName; return(commentParser.ParseFile(jsLines, typeFullName)); }
public void StandardIssueNumberReferenceGetsParsedCorrectly() { var workItemReferences = new CommentParser().ParseWorkItemIds(Create("Fixes JRE-1234")); Assert.IsNotEmpty(workItemReferences); var reference = workItemReferences.First(); Assert.AreEqual("JRE-1234", reference); }
public void JiraIssueInBranchNameGetsParsedCorrectly(string comment, string expectedReference) { var workItemReferences = new CommentParser().ParseWorkItemIds(Create(comment)); Assert.IsNotEmpty(workItemReferences); var reference = workItemReferences.First(); Assert.AreEqual(expectedReference, reference); }
public void StandardIssueNumberWithAlphaNumericProjectIdentifierEnclosedInBracketsReferenceGetsParsedCorrectly(string comment, string expectedReference) { var workItemReferences = new CommentParser().ParseWorkItemIds(Create(comment)); Assert.IsNotEmpty(workItemReferences); var reference = workItemReferences.First(); Assert.AreEqual(expectedReference, reference); }
public void StandardIssueNumberWithAlphaNumericProjectIdentifierReferenceGetsParsedCorrectly() { var workItemReferences = new CommentParser().ParseWorkItemIds(Create("Fixes BT2-1234")); Assert.IsNotEmpty(workItemReferences); var reference = workItemReferences.First(); Assert.AreEqual("BT2-1234", reference); }
public void TheKeywordsAllWork(string keyword) { var workItemReferences = new CommentParser().ParseWorkItemReferences(Create($"{keyword} #1234")); Assert.IsNotEmpty(workItemReferences); var reference = workItemReferences.First(); Assert.AreEqual("1234", reference.IssueNumber); Assert.AreEqual("#1234", reference.LinkData); }
public void AbsoluteUrlReferenceGetsParsedCorrectly() { var workItemReferences = new CommentParser().ParseWorkItemReferences(Create("Fixes https://github.com/OrgA/RepoB/issues/1234")); Assert.IsNotEmpty(workItemReferences); var reference = workItemReferences.First(); Assert.AreEqual("1234", reference.IssueNumber); Assert.AreEqual("https://github.com/OrgA/RepoB/issues/1234", reference.LinkData); }
public void GHReferenceGetsParsedCorrectly() { var workItemReferences = new CommentParser().ParseWorkItemReferences(Create("Fixes GH-1234")); Assert.IsNotEmpty(workItemReferences); var reference = workItemReferences.First(); Assert.AreEqual("1234", reference.IssueNumber); Assert.AreEqual("GH-1234", reference.LinkData); }
public void IssueReferenceToAnotherRepoWithDashGetsParsedCorrectly() { var workItemReferences = new CommentParser().ParseWorkItemReferences(Create("Fixes OrgA/Repo-B#1234")); Assert.IsNotEmpty(workItemReferences); var reference = workItemReferences.First(); Assert.AreEqual("1234", reference.IssueNumber); Assert.AreEqual("OrgA/Repo-B#1234", reference.LinkData); }
public void ParseOneComment() { // 0123456789 string source = @" /* ok */ "; var comments = new CommentParser().Parse(source); Assert.AreEqual(1, comments.Count); Assert.AreEqual(1, comments[0].Start); Assert.AreEqual(8, comments[0].End); Assert.AreEqual(4, comments[0].Length); Assert.AreEqual(" ok ", comments[0].Text); }
public void PoswerShellParseOneComment() { // 0123456789 string source = @" <# ok #> "; var comments = new CommentParser().Parse(source, COMMENT_START, COMMENT_END); Assert.AreEqual(1, comments.Count); Assert.AreEqual(1, comments[0].Start); Assert.AreEqual(8, comments[0].End); Assert.AreEqual(4, comments[0].Length); Assert.AreEqual(" ok ", comments[0].Text); }
public void Should_Return_Null_If_Node_Cannot_Be_Parsed() { // Given var parser = new CommentParser(); var node = @"<test>Hello World</test>".CreateXmlNode(); // When var result = parser.Parse(node); // Then Assert.Null(result); }
public void NextTokenIsSameAsPassedIn() { var parser = new CommentParser(); parser.ParseLine(0, "#", TokenType.Data).Single(); Assert.AreEqual(parser.NextExpectedToken, TokenType.Data); parser.ParseLine(0, "#", TokenType.Table).Single(); Assert.AreEqual(parser.NextExpectedToken, TokenType.Table); }
public void MultipleIssueNumberWithAlphaNumericProjectIdentifierEnclosedInBracketsReferencesGetsParsedCorrectly(string comment, params string[] expectedReferences) { var workItemReferences = new CommentParser().ParseWorkItemIds(Create("Fixes Bt2-1234,Bt2-2345")); Assert.IsNotEmpty(workItemReferences); Assert.AreEqual(2, workItemReferences.Length); var reference = workItemReferences.First(); Assert.AreEqual(expectedReferences[0], reference); reference = workItemReferences.Last(); Assert.AreEqual(expectedReferences[1], reference); }
public void MultipleIssueNumberWithAlphaNumericProjectIdentifierReferencesGetsParsedCorrectly() { var workItemReferences = new CommentParser().ParseWorkItemIds(Create("Fixes Bt2-1234,Bt2-2345")); Assert.IsNotEmpty(workItemReferences); Assert.AreEqual(2, workItemReferences.Length); var reference = workItemReferences.First(); Assert.AreEqual("Bt2-1234", reference); reference = workItemReferences.Last(); Assert.AreEqual("Bt2-2345", reference); }
public void Should_Return_InlineTextComment() { // Given var commentParser = new CommentParser(); var nodeParser = new InlineTextParser(); var node = new XmlDocument().CreateTextNode("Hello World"); // When var result = nodeParser.Parse(commentParser, node); // Then Assert.Equal("Hello World", result.Text); }
public void Can_Parse_Exception_Comment() { // Given var parser = new CommentParser(); var node = @"<exception cref=""SparrowException"">Hello World</exception>".CreateXmlNode(); // When var result = parser.Parse(node); // Then Assert.NotNull(result); Assert.Equal(@"<exception cref=""SparrowException"">Hello World</exception>", XmlCommentRenderer.Render(result)); }
public void Can_Parse_InlineCode_Comment() { // Given var parser = new CommentParser(); var node = @"<c>Hello World</c>".CreateXmlNode(); // When var result = parser.Parse(node); // Then Assert.NotNull(result); Assert.Equal(@"<c>Hello World</c>", XmlCommentRenderer.Render(result)); }
public void Should_Return_CodeComment() { // Given var commentParser = new CommentParser(); var nodeParser = new CodeParser(); var node = "<code>Hello World</code>".CreateXmlNode(); // When var result = nodeParser.Parse(commentParser, node); // Then Assert.Equal("Hello World", result.Code); }
public void MultipleIssueNumberReferencesEnclosedInBracketsGetsParsedCorrectly(string comment, params string[] expectedReferences) { var workItemReferences = new CommentParser().ParseWorkItemIds(Create(comment)); Assert.IsNotEmpty(workItemReferences); Assert.AreEqual(2, workItemReferences.Length); var reference = workItemReferences.First(); Assert.AreEqual(expectedReferences[0], reference); reference = workItemReferences.Last(); Assert.AreEqual(expectedReferences[1], reference); }
public void MultipleIssueNumberReferencesGetsParsedCorrectly() { var workItemReferences = new CommentParser().ParseWorkItemIds(Create("Fixes JRE-1234,JRE-2345")); Assert.IsNotEmpty(workItemReferences); Assert.AreEqual(2, workItemReferences.Length); var reference = workItemReferences.First(); Assert.AreEqual("JRE-1234", reference); reference = workItemReferences.Last(); Assert.AreEqual("JRE-2345", reference); }
/// <summary> /// Parses the string json into a value /// </summary> /// <param name="json">A JSON string.</param> /// <returns>An ArrayList, a Hashtable, a double, a string, null, true, or false</returns> public object Validate(string json, bool supportStartComment = false, bool relaxMode = false, CommentInfos commentInfos = null) { bool success = true; this._supportStartComment = supportStartComment; if (commentInfos == null) // Optimization for the TextHighlighter extension { // So we do not have parse the comment twice if possible commentInfos = new CommentParser().Parse(json); } _supportIDWithNoQuote = (relaxMode) || (commentInfos.IsRelax); _supportTrailingComa = _supportIDWithNoQuote; _supportSlashComment = _supportIDWithNoQuote; return Compile(json, ref success); }
public void ParseJsonWithALotOfComments() { string json = DS.Resources.GetTextResource("JsonWithALotOfComments.json", Assembly.GetExecutingAssembly()); var comments = new CommentParser().Parse(json); Assert.AreEqual(20, comments.Count); Assert.AreEqual(" Template defining the caption of the object ", comments[0].Text); Assert.AreEqual(" The property to use as the identifier ", comments[1].Text); Assert.AreEqual(" The sections and the properties order. The character @ define section, the character # define an action to use as a button ", comments[2].Text); Assert.AreEqual(" The property to use to sort the objects ", comments[3].Text); Assert.AreEqual(" The property to use to group the object into sections ", comments[4].Text); Assert.AreEqual(" Properties to add the first time or each time the object is opened ", comments[5].Text); Assert.AreEqual(" Re initialize the value each time the dialog is opened ", comments[6].Text); Assert.AreEqual(" Message to display after the action failed ", comments[18].Text); Assert.AreEqual(" More info about the properties of the object ", comments[19].Text); }
public void ParseThreeCommentWithSpaces() { // 012345678901234567890123456789 string source = @" /* 1 */ /* 2 */ /* 3 */"; var comments = new CommentParser().Parse(source); Assert.AreEqual(3, comments.Count); Assert.AreEqual(1, comments[0].Start); Assert.AreEqual(7, comments[0].End); Assert.AreEqual(3, comments[0].Length); Assert.AreEqual(" 1 ", comments[0].Text); Assert.AreEqual(9, comments[1].Start); Assert.AreEqual(15, comments[1].End); Assert.AreEqual(3, comments[1].Length); Assert.AreEqual(" 2 ", comments[1].Text); Assert.AreEqual(17, comments[2].Start); Assert.AreEqual(23, comments[2].End); Assert.AreEqual(3, comments[2].Length); Assert.AreEqual(" 3 ", comments[2].Text); }