Skip to content

Commit dee7789

Browse files
committed
C#: Sprinkle uses of OnlyScaffold to extract less when in overlay mode.
1 parent 97e30bc commit dee7789

File tree

10 files changed

+17
-11
lines changed

10 files changed

+17
-11
lines changed

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/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();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public override void Populate(TextWriter trapFile)
7474
WriteLocationsToTrap(trapFile.property_location, this, Locations);
7575
}
7676

77-
if (IsSourceDeclaration && Symbol.FromSource())
77+
if (IsSourceDeclaration && Symbol.FromSource() && !Context.OnlyScaffold)
7878
{
7979
var expressionBody = ExpressionBody;
8080
if (expressionBody is not null)

csharp/extractor/Semmle.Extraction.CSharp/Entities/Types/Type.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ protected void PopulateType(TextWriter trapFile, bool constructUnderlyingTupleTy
222222

223223
private IEnumerable<BaseTypeSyntax> GetBaseTypeDeclarations()
224224
{
225-
if (!IsSourceDeclaration || !Symbol.FromSource())
225+
if (!IsSourceDeclaration || !Symbol.FromSource() || Context.OnlyScaffold)
226226
{
227227
return Enumerable.Empty<BaseTypeSyntax>();
228228
}

csharp/extractor/Semmle.Extraction.CSharp/Entities/Types/TypeParameter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public override void Populate(TextWriter trapFile)
3232
WriteLocationsToTrap(trapFile.type_location, this, locations);
3333
}
3434

35-
if (IsSourceDeclaration)
35+
if (IsSourceDeclaration && !Context.OnlyScaffold)
3636
{
3737
var declSyntaxReferences = Symbol.DeclaringSyntaxReferences
3838
.Select(d => d.GetSyntax())

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public override void Populate(TextWriter trapFile)
3131
WriteLocationsToTrap(trapFile.operator_location, this, Locations);
3232
}
3333

34-
if (IsSourceDeclaration)
34+
if (IsSourceDeclaration && !Context.OnlyScaffold)
3535
{
3636
var declSyntaxReferences = Symbol.DeclaringSyntaxReferences.Select(s => s.GetSyntax()).ToArray();
3737
foreach (var declaration in declSyntaxReferences.OfType<OperatorDeclarationSyntax>())

0 commit comments

Comments
 (0)