Skip to content

Commit 21db59b

Browse files
committed
C#: Sprinkle uses of OnlyScaffold to extract less when in overlay mode.
1 parent 7a57474 commit 21db59b

File tree

17 files changed

+43
-18
lines changed

17 files changed

+43
-18
lines changed

csharp/extractor/Semmle.Extraction.CSharp/Entities/Attribute.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ public override void Populate(TextWriter trapFile)
5959
{
6060
var type = Type.Create(Context, Symbol.AttributeClass);
6161
trapFile.attributes(this, kind, type.TypeRef, entity);
62+
63+
if (Context.OnlyScaffold)
64+
{
65+
return;
66+
}
67+
6268
WriteLocationToTrap(trapFile.attribute_location, this, Location);
6369

6470
if (attributeSyntax is not null)

csharp/extractor/Semmle.Extraction.CSharp/Entities/Base/CachedSymbol.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public virtual IEnumerable<Location> Locations
109109
/// </summary>
110110
protected void BindComments()
111111
{
112-
if (!Symbol.IsImplicitlyDeclared && IsSourceDeclaration && Symbol.FromSource())
112+
if (!Symbol.IsImplicitlyDeclared && IsSourceDeclaration && Symbol.FromSource() && !Context.OnlyScaffold)
113113
Context.BindComments(this, FullLocation);
114114
}
115115

csharp/extractor/Semmle.Extraction.CSharp/Entities/CommentBlock.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ private CommentBlock(Context cx, Comments.CommentBlock init)
1111
public override void Populate(TextWriter trapFile)
1212
{
1313
trapFile.commentblock(this);
14-
WriteLocationToTrap(trapFile.commentblock_location, this, Context.CreateLocation(Symbol.Location));
14+
if (!Context.OnlyScaffold)
15+
{
16+
WriteLocationToTrap(trapFile.commentblock_location, this, Context.CreateLocation(Symbol.Location));
17+
}
1518
Symbol.CommentLines.ForEach((l, child) => trapFile.commentblock_child(this, l, child));
1619
}
1720

csharp/extractor/Semmle.Extraction.CSharp/Entities/CommentLine.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ public override void Populate(TextWriter trapFile)
2323
{
2424
location = Context.CreateLocation(Location);
2525
trapFile.commentline(this, Type == CommentLineType.MultilineContinuation ? CommentLineType.Multiline : Type, Text, RawText);
26-
WriteLocationToTrap(trapFile.commentline_location, this, location);
26+
if (!Context.OnlyScaffold)
27+
{
28+
WriteLocationToTrap(trapFile.commentline_location, this, location);
29+
}
2730
}
2831

2932
public override Microsoft.CodeAnalysis.Location? ReportingLocation => location?.Symbol;

csharp/extractor/Semmle.Extraction.CSharp/Entities/Constructor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ Symbol.ContainingType.TypeKind is TypeKind.Class or TypeKind.Struct &&
179179
/// </summary>
180180
private bool IsBestSourceLocation => ReportingLocation is not null && Context.IsLocationInContext(ReportingLocation);
181181

182-
private bool MakeSynthetic => IsPrimary || (IsDefault && IsBestSourceLocation);
182+
private bool MakeSynthetic => (IsPrimary || (IsDefault && IsBestSourceLocation)) && !Context.OnlyScaffold;
183183

184184
[return: NotNullIfNotNull(nameof(constructor))]
185185
public static new Constructor? Create(Context cx, IMethodSymbol? constructor)

csharp/extractor/Semmle.Extraction.CSharp/Entities/Field.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public override void Populate(TextWriter trapFile)
5454
WriteLocationsToTrap(trapFile.field_location, this, Locations);
5555
}
5656

57-
if (!IsSourceDeclaration || !Symbol.FromSource())
57+
if (!IsSourceDeclaration || !Symbol.FromSource() || Context.OnlyScaffold)
5858
return;
5959

6060
Context.BindComments(this, Location.Symbol);

csharp/extractor/Semmle.Extraction.CSharp/Entities/Indexer.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public override void Populate(TextWriter trapFile)
4242
Parameter.Create(Context, Symbol.Parameters[i], this, original);
4343
}
4444

45-
if (IsSourceDeclaration)
45+
if (IsSourceDeclaration && !Context.OnlyScaffold)
4646
{
4747
var expressionBody = ExpressionBody;
4848
if (expressionBody is not null)
@@ -55,6 +55,12 @@ public override void Populate(TextWriter trapFile)
5555

5656
PopulateAttributes();
5757
PopulateModifiers(trapFile);
58+
59+
if (Context.OnlyScaffold)
60+
{
61+
return;
62+
}
63+
5864
BindComments();
5965

6066
var declSyntaxReferences = IsSourceDeclaration

csharp/extractor/Semmle.Extraction.CSharp/Entities/Method.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ protected virtual void ExtractInitializers(TextWriter trapFile)
4848

4949
protected virtual void PopulateMethodBody(TextWriter trapFile)
5050
{
51-
if (!IsSourceDeclaration)
51+
if (!IsSourceDeclaration || Context.OnlyScaffold)
5252
return;
5353

5454
var block = Block;
@@ -94,7 +94,7 @@ public void Overrides(TextWriter trapFile)
9494
{
9595
trapFile.explicitly_implements(this, explicitInterface.TypeRef);
9696

97-
if (IsSourceDeclaration)
97+
if (IsSourceDeclaration && !Context.OnlyScaffold)
9898
{
9999
foreach (var syntax in Symbol.DeclaringSyntaxReferences.Select(d => d.GetSyntax()).OfType<MethodDeclarationSyntax>())
100100
TypeMention.Create(Context, syntax.ExplicitInterfaceSpecifier!.Name, this, explicitInterface);

csharp/extractor/Semmle.Extraction.CSharp/Entities/OrdinaryMethod.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public override void Populate(TextWriter trapFile)
3434
var returnType = Type.Create(Context, Symbol.ReturnType);
3535
trapFile.methods(this, Name, ContainingType, returnType.TypeRef, OriginalDefinition);
3636

37-
if (IsSourceDeclaration)
37+
if (IsSourceDeclaration && !Context.OnlyScaffold)
3838
{
3939
foreach (var declaration in Symbol.DeclaringSyntaxReferences.Select(s => s.GetSyntax()).OfType<MethodDeclarationSyntax>())
4040
{

csharp/extractor/Semmle.Extraction.CSharp/Entities/Parameter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ Symbol.ContainingSymbol is IMethodSymbol ms &&
140140
Context.PopulateLater(defaultValueExpressionCreation);
141141
}
142142

143-
if (!IsSourceDeclaration || !Symbol.FromSource())
143+
if (!IsSourceDeclaration || !Symbol.FromSource() || Context.OnlyScaffold)
144144
return;
145145

146146
BindComments();

0 commit comments

Comments
 (0)