public CommentBlock(CommentLine firstLine) { lines = new List <CommentLine> { firstLine }; Location = firstLine.Location; }
public async Task <IActionResult> PutCommentLine(int id, CommentLine commentLine) { if (id != commentLine.CommentLineId) { return(BadRequest()); } _context.Entry(commentLine).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CommentLineExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <CommentLine> > PostCommentLine(CommentLine commentLine) { _context.CommentLines.Add(commentLine); await _context.SaveChangesAsync(); return(CreatedAtAction("GetCommentLine", new { id = commentLine.CommentLineId }, commentLine)); }
public Line InsertCommentLine(string comment) { var line = new CommentLine(comment) { LineType = LineType.Excluded, IsExcluded = true }; _lines.Add(line); return(line); }
public Line InsertEmptyLine() { var line = new CommentLine() { LineType = LineType.Excluded, IsExcluded = true }; _lines.Add(line); return(line); }
/// <summary> /// Adds a comment line to the this comment block. /// </summary> /// <param name="line">The line to add.</param> public void AddCommentLine(CommentLine line) { Location = !lines.Any() ? line.Location : Location.Create( line.Location.SourceTree !, new TextSpan(Location.SourceSpan.Start, line.Location.SourceSpan.End - Location.SourceSpan.Start)); lines.Add(line); }
/// <summary> /// Creates a new <see cref="IIniDocument"/> using data from a <see cref="TextReader"/>. /// </summary> /// <param name='reader'> /// A <see cref="TextReader"/> that will supply the input data. /// </param> public static IIniDocument Read(TextReader reader) { IIniDocument output = new IniDocument(); IIniSection currentSection = output; bool endOfStream = false; int lineNumber = 0; while (!endOfStream) { string currentLine = reader.ReadLine(); Match currentMatch; lineNumber++; // If we get a null response then we are at the end of the stream and can exit if (currentLine == null) { endOfStream = true; continue; } // We silently skip over empty lines if (EmptyLine.Match(currentLine).Success || CommentLine.Match(currentLine).Success) { continue; } // If we find a 'new section' line then we create a new section and begin dealing with it currentMatch = SectionLine.Match(currentLine); if (currentMatch.Success) { string sectionName = currentMatch.Groups[1].Value.Trim(); currentSection = new IniSection(); output.Sections.Add(sectionName, currentSection); continue; } // If we find a value line then we store it within the current section. currentMatch = ValueLine.Match(currentLine); if (currentMatch.Success) { string key = currentMatch.Groups[1].Value.Trim(); string value = currentMatch.Groups[2].Value.Trim(); currentSection[key] = value; continue; } throw new FormatException(String.Format("Invalid INI data at line {0}.", lineNumber)); } return(output); }
public void ValidateLines() { // Arrange and Act var codeLine = new CodeLine("var foo = 123;"); var commentLine = new CommentLine("This is a comment"); var todoLine = new TodoLine("Add code for this implementation: '{0}'", "Create database"); var warningLine = new PreprocessorDirectiveLine("#warning"); // Assert Assert.True(commentLine is ILine); Assert.True(todoLine is ILine); Assert.True(todoLine.Content == "Add code for this implementation: 'Create database'"); Assert.True(warningLine is ILine); }
/// <summary> /// Determine whether commentlines should be merged. /// </summary> /// <param name="newLine">A comment line to be appended to this comment block.</param> /// <returns>Whether the new line should be appended to this block.</returns> public bool CombinesWith(CommentLine newLine) { if (!CommentLines.Any()) { return(true); } var sameFile = Location.SourceTree == newLine.Location.SourceTree; var sameRow = Location.EndLine() == newLine.Location.StartLine(); var sameColumn = Location.EndLine() + 1 == newLine.Location.StartLine(); var nextRow = Location.StartColumn() == newLine.Location.StartColumn(); var adjacent = sameFile && (sameRow || (sameColumn && nextRow)); return (newLine.Type == CommentLineType.MultilineContinuation || adjacent); }
private static void AddCommentsInsideLine(string line, CodeLine codeLine) { CommentLine commentLine = null; for (var index = 0; index < line.Length; index++) { var character = line[index]; if (codeLine.StringLines.Any(x => index > x.Start && index < x.End)) { continue; } if (character == '/' && index + 1 < line.Length && (line[index + 1] == '/' || line[index + 1] == '*') && commentLine == null) { commentLine = new CommentLine { Start = index }; if (line[index + 1] == '/') { commentLine.End = line.Length; codeLine.CommentLines.Add(commentLine); break; } continue; } if (character == '*' && index + 1 < line.Length && line[index + 1] == '/') { if (commentLine != null) { commentLine.End = index; codeLine.CommentLines.Add(commentLine); } } } }
public override void VisitCompilationUnit(CompilationUnitSyntax compilationUnit) { foreach (var m in compilationUnit.ChildNodes()) { cx.Try(m, null, () => ((CSharpSyntaxNode)m).Accept(this)); } // Gather comments: foreach (SyntaxTrivia trivia in compilationUnit.DescendantTrivia(compilationUnit.Span)) { CommentLine.Extract(cx, trivia); } foreach (var trivia in compilationUnit.GetLeadingTrivia()) { CommentLine.Extract(cx, trivia); } foreach (var trivia in compilationUnit.GetTrailingTrivia()) { CommentLine.Extract(cx, trivia); } }
public void AddComment(CommentLine comment) { comments[comment.Location] = comment; }
public void Visit(CommentLine line) { return; }
internal static void commentline_location(this TextWriter trapFile, CommentLine commentLine, Location location) { trapFile.WriteTuple("commentline_location", commentLine, location); }
internal static void commentline(this TextWriter trapFile, CommentLine commentLine, CommentLineType type, string text, string rawtext) { trapFile.WriteTuple("commentline", commentLine, (int)type, text, rawtext); }
internal static void commentblock_child(this TextWriter trapFile, CommentBlock commentBlock, CommentLine commentLine, int child) { trapFile.WriteTuple("commentblock_child", commentBlock, commentLine, child); }
internal static Tuple commentline_location(CommentLine commentLine, Location location) => new Tuple("commentline_location", commentLine, location);
internal static Tuple commentline(CommentLine commentLine, CommentType type, string text, string rawtext) => new Tuple("commentline", commentLine, type, text, rawtext);
internal static Tuple commentblock_child(CommentBlock commentBlock, CommentLine commentLine, int child) => new Tuple("commentblock_child", commentBlock, commentLine, child);
protected void Page_Load(object sender, EventArgs e) { //登陆成功判定模块 string[] pp = Request.Url.ToString().Split('?'); string[] p1 = pp[1].Split('='); string[] p11; string p2; if (p1.Length > 2) { p11 = p1[1].Split('&'); p2 = p1[2]; } else { p11 = new string[1]; p11[0] = p1[1]; p2 = null; } if (p1 != null) { var Find = from temp in db.User where temp.UserID == p11[0] select temp; int i = 0; foreach (User c in Find) { i++; } if (i == 1) { i = 0; foreach (User c in Find) { useronline = c; i++; } } else { Response.Redirect("~/Login.aspx"); } } //接收feed var feeddata = from c in db.Feed where c.FeedID == int.Parse(p2) select c; foreach (Feed f in feeddata) { currentfeed = f; } Label4.Text = currentfeed.Title; var tempsearch = from u in db.User where u.UserID == currentfeed.PosterID select u; foreach (User u in tempsearch) { Label5.Text = u.UserName; } Label6.Text = currentfeed.PostTime.ToString(); if (currentfeed.FeedStatus == true) { Label7.Text = "已发布"; Button1.Text = "删除"; } else { Label7.Text = "已删除"; Button1.Text = "发布"; } if (currentfeed.ImageStatus == true) { Image2.Visible = true; Image2.ImageUrl = currentfeed.ImageID; Label8.Text = "已发布"; Button2.Text = "删除"; } else { Image2.Visible = false; Label8.Text = "已删除"; Button2.Text = "发布"; } TextBox1.Text = currentfeed.FeedText; TextBox1.ReadOnly = true; //根据用户身份展示不同页面 if (useronline.Identification == true) { Label7.Visible = true; Button1.Visible = true; if (Image2.Visible == true) { Label8.Visible = true; Button2.Visible = true; } var commentdata = from c in db.Comment where c.FeedID == currentfeed.FeedID orderby c.CommentTime select c; allcommentamount = 0; foreach (Comment c in commentdata) { allcommentamount++; } comment = new Comment[allcommentamount]; int j = 0; foreach (Comment c in commentdata) { comment[j] = c; j++; } TableRow[] row = new TableRow[allcommentamount * 2 + 2]; TableCell[] cell = new TableCell[allcommentamount * 4]; CommentLine[] commentline = new CommentLine[allcommentamount]; for (int k = 0; k < allcommentamount; k++) { commentline[k] = new CommentLine(comment[k]); } for (int k = 0; k < allcommentamount; k++) { cell[k * 4] = new TableCell(); cell[k * 4 + 1] = new TableCell(); cell[k * 4 + 2] = new TableCell(); cell[k * 4 + 3] = new TableCell(); row[k * 2] = new TableRow(); row[k * 2 + 1] = new TableRow(); cell[k * 4].Controls.Add(commentline[k].text); row[k * 2].Cells.Add(cell[k * 4]); cell[k * 4 + 1].Controls.Add(commentline[k].commentor); cell[k * 4 + 2].Controls.Add(commentline[k].commenttime); cell[k * 4 + 3].Controls.Add(commentline[k].commentstatus); cell[k * 4 + 3].Controls.Add(commentline[k].delete); row[k * 2 + 1].Cells.Add(cell[k * 4 + 1]); row[k * 2 + 1].Cells.Add(cell[k * 4 + 2]); row[k * 2 + 1].Cells.Add(cell[k * 4 + 3]); CommentListTable.Rows.Add(row[k * 2]); CommentListTable.Rows.Add(row[k * 2 + 1]); } newcomment.TextMode = TextBoxMode.MultiLine; submit.Text = "评论"; TableCell[] lastcell = new TableCell[2]; lastcell[0] = new TableCell(); lastcell[0].Controls.Add(newcomment); lastcell[1] = new TableCell(); lastcell[1].Controls.Add(submit); row[allcommentamount * 2] = new TableRow(); row[allcommentamount * 2 + 1] = new TableRow(); row[allcommentamount * 2].Cells.Add(lastcell[0]); row[allcommentamount * 2 + 1].Cells.Add(lastcell[1]); CommentListTable.Rows.Add(row[allcommentamount * 2]); CommentListTable.Rows.Add(row[allcommentamount * 2 + 1]); } else { var commentdata = from c in db.Comment where c.FeedID == currentfeed.FeedID && c.CommentStatus == true orderby c.CommentTime select c; allcommentamount = 0; foreach (Comment c in commentdata) { allcommentamount++; } comment = new Comment[allcommentamount]; int j = 0; foreach (Comment c in commentdata) { comment[j] = c; j++; } TableRow[] row = new TableRow[allcommentamount * 2 + 2]; TableCell[] cell = new TableCell[allcommentamount * 3]; CommentLine[] commentline = new CommentLine[allcommentamount]; for (int k = 0; k < allcommentamount; k++) { commentline[k] = new CommentLine(comment[k]); } for (int k = 0; k < allcommentamount; k++) { cell[k * 3] = new TableCell(); cell[k * 3 + 1] = new TableCell(); cell[k * 3 + 2] = new TableCell(); row[k * 2] = new TableRow(); row[k * 2 + 1] = new TableRow(); cell[k * 3].Controls.Add(commentline[k].text); row[k * 2].Cells.Add(cell[k * 4]); cell[k * 3 + 1].Controls.Add(commentline[k].commentor); cell[k * 3 + 2].Controls.Add(commentline[k].commenttime); row[k * 2 + 1].Cells.Add(cell[k * 4 + 1]); row[k * 2 + 1].Cells.Add(cell[k * 4 + 2]); CommentListTable.Rows.Add(row[k * 2]); CommentListTable.Rows.Add(row[k * 2 + 1]); } newcomment.TextMode = TextBoxMode.MultiLine; submit.Text = "评论"; TableCell[] lastcell = new TableCell[2]; lastcell[0] = new TableCell(); lastcell[0].Controls.Add(newcomment); lastcell[1] = new TableCell(); lastcell[1].Controls.Add(submit); row[allcommentamount * 2] = new TableRow(); row[allcommentamount * 2 + 1] = new TableRow(); row[allcommentamount * 2].Cells.Add(lastcell[0]); row[allcommentamount * 2 + 1].Cells.Add(lastcell[1]); CommentListTable.Rows.Add(row[allcommentamount * 2]); CommentListTable.Rows.Add(row[allcommentamount * 2 + 1]); } submit.Click += new EventHandler(submit_Click); }
public static void ExtractComment(Context cx, SyntaxTrivia trivia) { switch (trivia.Kind()) { case SyntaxKind.SingleLineDocumentationCommentTrivia: /* * This is actually a multi-line comment consisting of /// lines. * So split it up. */ var text = trivia.ToFullString(); var split = text.Split('\n'); var currentLocation = trivia.GetLocation().SourceSpan.Start - 3; for (var line = 0; line < split.Length - 1; ++line) { var fullLine = split[line]; var nextLineLocation = currentLocation + fullLine.Length + 1; fullLine = fullLine.TrimEnd('\r'); var trimmedLine = fullLine; var leadingSpaces = trimmedLine.IndexOf('/'); if (leadingSpaces != -1) { fullLine = fullLine.Substring(leadingSpaces); currentLocation += leadingSpaces; trimmedLine = trimmedLine.Substring(leadingSpaces + 3); // Remove leading spaces and the "///" trimmedLine = trimmedLine.Trim(); var span = Microsoft.CodeAnalysis.Text.TextSpan.FromBounds(currentLocation, currentLocation + fullLine.Length); var location = Microsoft.CodeAnalysis.Location.Create(trivia.SyntaxTree !, span); var commentType = CommentLineType.XmlDoc; cx.CommentGenerator.AddComment(CommentLine.Create(cx, location, commentType, trimmedLine, fullLine)); } else { cx.ModelError("Unexpected comment format"); } currentLocation = nextLineLocation; } break; case SyntaxKind.SingleLineCommentTrivia: { var contents = trivia.ToString().Substring(2); var commentType = CommentLineType.Singleline; if (contents.Length > 0 && contents[0] == '/') { commentType = CommentLineType.XmlDoc; contents = contents.Substring(1); // An XML comment. } cx.CommentGenerator.AddComment(CommentLine.Create(cx, trivia.GetLocation(), commentType, contents.Trim(), trivia.ToFullString())); } break; case SyntaxKind.MultiLineDocumentationCommentTrivia: case SyntaxKind.MultiLineCommentTrivia: /* We receive a single SyntaxTrivia for a multiline block spanning several lines. * So we split it into separate lines */ text = trivia.ToFullString(); split = text.Split('\n'); currentLocation = trivia.GetLocation().SourceSpan.Start; for (var line = 0; line < split.Length; ++line) { var fullLine = split[line]; var nextLineLocation = currentLocation + fullLine.Length + 1; fullLine = fullLine.TrimEnd('\r'); var trimmedLine = fullLine; if (line == 0) { trimmedLine = trimmedLine.Substring(2); } if (line == split.Length - 1) { trimmedLine = trimmedLine.Substring(0, trimmedLine.Length - 2); } trimmedLine = trimmedLine.Trim(); var span = Microsoft.CodeAnalysis.Text.TextSpan.FromBounds(currentLocation, currentLocation + fullLine.Length); var location = Microsoft.CodeAnalysis.Location.Create(trivia.SyntaxTree !, span); var commentType = line == 0 ? CommentLineType.Multiline : CommentLineType.MultilineContinuation; cx.CommentGenerator.AddComment(CommentLine.Create(cx, location, commentType, trimmedLine, fullLine)); currentLocation = nextLineLocation; } break; } }
// TODO: void ProcessCommentLine(CommentLine l) { }
public void ProcessLine(string line) { ILine l = null; try { if (line.StartsWith("PokerStars")) { StartNewHand(); l = ProcessInitializationLine(line); } else if (line.StartsWith("***")) { l = ProcessRoundLine(line); } else if (line.Contains("said, ") || line.Contains("joins the table") || line.Contains("leaves the table") || line.Contains(" is connected ")) { l = new CommentLine(line); } else if (line.Contains("collected") && (line.Contains("from pot") || line.Contains("from side pot") || line.Contains("from main pot"))) { l = ProcessGameActionLine(line); } else if (line.Contains("finished the tournament")) { l = ProcessGameActionLine(line); } else if (line.Contains("wins the tournament")) { l = new CommentLine(line); } else if (line.Contains("has timed out")) { l = new TimedOutLine(line); } else { switch (current.Round) { case HandRound.Initialization: { l = ProcessInitializationLine(line); break; } case HandRound.HoleCards: { l = ProcessHoleCardsLine(line); break; } case HandRound.Flop: { l = ProcessFlopLine(line); break; } case HandRound.Turn: { l = ProcessTurnLine(line); break; } case HandRound.River: { l = ProcessRiverLine(line); break; } case HandRound.Showdown: { l = ProcessShowdownLine(line); break; } case HandRound.Summary: { l = ProcessSummaryLine(line); break; } default: { ErrorMessage("Unrecognized Hand Round " + current.Round.ToString()); break; } } } if (l != null) { ProcessLineData(l); } else { if (!String.IsNullOrEmpty(line)) { UnparsedLine(lineIdx + ": " + "Unparsed Line in ProcessGameActionLine: " + line); } } } catch (Exception ex) { ErrorMessage(lineIdx + ": " + line + " " + ex.ToString()); } }