using Semmle.Extraction.CommentProcessing;
using System;
namespace Semmle.Extraction.CSharp.Populators
{
///
/// Populators for comments.
///
public static class Comments
{
public static void ExtractComments(this Context cx, ICommentGenerator gen)
{
cx.Try(null, null, () =>
{
gen.GenerateBindings((entity, duplicationGuardKey, block, binding) =>
{
var commentBlock = Entities.CommentBlock.Create(cx, block);
Action a = () =>
{
commentBlock.BindTo(entity, binding);
};
// When the duplication guard key exists, it means that the entity is guarded against
// trap duplication ().
// We must therefore also guard comment construction.
if (duplicationGuardKey != null)
cx.WithDuplicationGuard(duplicationGuardKey, a);
else
a();
});
});
}
}
}