mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
C#: Do not extract comments when scaffolding.
This commit is contained in:
@@ -109,7 +109,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
/// </summary>
|
||||
protected void BindComments()
|
||||
{
|
||||
if (!Symbol.IsImplicitlyDeclared && IsSourceDeclaration && Symbol.FromSource() && !Context.OnlyScaffold)
|
||||
if (!Symbol.IsImplicitlyDeclared && IsSourceDeclaration && Symbol.FromSource())
|
||||
Context.BindComments(this, FullLocation);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,12 +10,12 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
public override void Populate(TextWriter trapFile)
|
||||
{
|
||||
trapFile.commentblock(this);
|
||||
Symbol.CommentLines.ForEach((l, child) => trapFile.commentblock_child(this, l, child));
|
||||
if (Context.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));
|
||||
}
|
||||
|
||||
@@ -31,6 +31,10 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
public void BindTo(Label entity, CommentBinding binding)
|
||||
{
|
||||
if (Context.OnlyScaffold)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Context.TrapWriter.Writer.commentblock_binding(this, entity, binding);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,11 +21,11 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
public override void Populate(TextWriter trapFile)
|
||||
{
|
||||
trapFile.commentline(this, Type == CommentLineType.MultilineContinuation ? CommentLineType.Multiline : Type, Text, RawText);
|
||||
if (Context.OnlyScaffold)
|
||||
{
|
||||
return;
|
||||
}
|
||||
trapFile.commentline(this, Type == CommentLineType.MultilineContinuation ? CommentLineType.Multiline : Type, Text, RawText);
|
||||
location = Context.CreateLocation(Location);
|
||||
WriteLocationToTrap(trapFile.commentline_location, this, location);
|
||||
|
||||
|
||||
@@ -631,6 +631,10 @@ namespace Semmle.Extraction.CSharp
|
||||
/// <param name="l">Location of the entity.</param>
|
||||
public void BindComments(Entity entity, Microsoft.CodeAnalysis.Location? l)
|
||||
{
|
||||
if (OnlyScaffold)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var duplicationGuardKey = GetCurrentTagStackKey();
|
||||
CommentGenerator.AddElement(entity.Label, duplicationGuardKey, l);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,10 @@ namespace Semmle.Extraction.CSharp.Populators
|
||||
{
|
||||
public static void ExtractCommentBlocks(Context cx, CommentProcessor gen)
|
||||
{
|
||||
if (cx.OnlyScaffold)
|
||||
{
|
||||
return;
|
||||
}
|
||||
cx.Try(null, null, () =>
|
||||
{
|
||||
gen.GenerateBindings((entity, duplicationGuardKey, block, binding) =>
|
||||
@@ -34,6 +38,10 @@ namespace Semmle.Extraction.CSharp.Populators
|
||||
|
||||
public static void ExtractComment(Context cx, SyntaxTrivia trivia)
|
||||
{
|
||||
if (cx.OnlyScaffold)
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (trivia.Kind())
|
||||
{
|
||||
case SyntaxKind.SingleLineDocumentationCommentTrivia:
|
||||
|
||||
Reference in New Issue
Block a user