-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathCommentBlock.cs
More file actions
50 lines (41 loc) · 1.73 KB
/
CommentBlock.cs
File metadata and controls
50 lines (41 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System.IO;
using Semmle.Util;
namespace Semmle.Extraction.CSharp.Entities
{
internal class CommentBlock : CachedEntity<Comments.CommentBlock>
{
private CommentBlock(Context cx, Comments.CommentBlock init)
: base(cx, init) { }
public override void Populate(TextWriter trapFile)
{
if (OnlyScaffold)
{
return;
}
trapFile.commentblock(this);
Symbol.CommentLines.ForEach((l, child) => trapFile.commentblock_child(this, l, child));
WriteLocationToTrap(trapFile.commentblock_location, this, Context.CreateLocation(Symbol.Location));
}
public override bool NeedsPopulation => true;
public override void WriteId(EscapingTextWriter trapFile)
{
trapFile.WriteSubId(Context.CreateLocation(Symbol.Location));
trapFile.Write(";commentblock");
}
public override Microsoft.CodeAnalysis.Location ReportingLocation => Symbol.Location;
public void BindTo(Label entity, CommentBinding binding)
{
if (OnlyScaffold)
{
return;
}
Context.TrapWriter.Writer.commentblock_binding(this, entity, binding);
}
public static CommentBlock Create(Context cx, Comments.CommentBlock block) => CommentBlockFactory.Instance.CreateEntity(cx, block, block);
private class CommentBlockFactory : CachedEntityFactory<Comments.CommentBlock, CommentBlock>
{
public static CommentBlockFactory Instance { get; } = new CommentBlockFactory();
public override CommentBlock Create(Context cx, Comments.CommentBlock init) => new CommentBlock(cx, init);
}
}
}