Skip to content

Commit 4f693be

Browse files
committed
Move location creation to instance method on context
1 parent 6f07230 commit 4f693be

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+85
-95
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ private Expression CreateExpressionFromArgument(TypedConstant constant, Expressi
118118

119119
private Semmle.Extraction.Entities.Location location;
120120
private Semmle.Extraction.Entities.Location Location =>
121-
location ?? (location = Semmle.Extraction.Entities.Location.Create(Context, attributeSyntax is null ? entity.ReportingLocation : attributeSyntax.Name.GetLocation()));
121+
location ?? (location = Context.CreateLocation(attributeSyntax is null ? entity.ReportingLocation : attributeSyntax.Name.GetLocation()));
122122

123123
public override bool NeedsPopulation => true;
124124

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public override void Populate(TextWriter trapFile)
1313
{
1414
trapFile.commentblock(this);
1515
var child = 0;
16-
trapFile.commentblock_location(this, Context.Create(symbol.Location));
16+
trapFile.commentblock_location(this, Context.CreateLocation(symbol.Location));
1717
foreach (var l in symbol.CommentLines)
1818
{
1919
trapFile.commentblock_child(this, (CommentLine)l, child++);
@@ -24,7 +24,7 @@ public override void Populate(TextWriter trapFile)
2424

2525
public override void WriteId(TextWriter trapFile)
2626
{
27-
trapFile.WriteSubId(Context.Create(symbol.Location));
27+
trapFile.WriteSubId(Context.CreateLocation(symbol.Location));
2828
trapFile.Write(";commentblock");
2929
}
3030

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ private CommentLine(Context cx, Microsoft.CodeAnalysis.Location loc, CommentLine
2323

2424
public override void Populate(TextWriter trapFile)
2525
{
26-
location = Context.Create(Location);
26+
location = Context.CreateLocation(Location);
2727
trapFile.commentline(this, Type == CommentLineType.MultilineContinuation ? CommentLineType.Multiline : Type, Text, RawText);
2828
trapFile.commentline_location(this, location);
2929
}
@@ -34,7 +34,7 @@ public override void Populate(TextWriter trapFile)
3434

3535
public override void WriteId(TextWriter trapFile)
3636
{
37-
trapFile.WriteSubId(Context.Create(Location));
37+
trapFile.WriteSubId(Context.CreateLocation(Location));
3838
trapFile.Write(";commentline");
3939
}
4040

csharp/extractor/Semmle.Extraction.CSharp/Entities/Compilations/Diagnostic.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public Diagnostic(Context cx, Microsoft.CodeAnalysis.Diagnostic diag) : base(cx)
1717
protected override void Populate(TextWriter trapFile)
1818
{
1919
trapFile.diagnostics(this, (int)diagnostic.Severity, diagnostic.Id, diagnostic.Descriptor.Title.ToString(),
20-
diagnostic.GetMessage(), Extraction.Entities.Location.Create(cx, diagnostic.Location));
20+
diagnostic.GetMessage(), cx.CreateLocation(diagnostic.Location));
2121
}
2222
}
2323
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ protected override void ExtractInitializers(TextWriter trapFile)
6060

6161
var initInfo = new ExpressionInfo(Context,
6262
AnnotatedTypeSymbol.CreateNotAnnotated(initializerType),
63-
Context.Create(initializer.ThisOrBaseKeyword.GetLocation()),
63+
Context.CreateLocation(initializer.ThisOrBaseKeyword.GetLocation()),
6464
Kinds.ExprKind.CONSTRUCTOR_INIT,
6565
this,
6666
-1,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public Extraction.Entities.Location Location
118118
get
119119
{
120120
if (cachedLocation == null)
121-
cachedLocation = Context.Create(CodeAnalysisLocation);
121+
cachedLocation = Context.CreateLocation(CodeAnalysisLocation);
122122
return cachedLocation;
123123
}
124124

csharp/extractor/Semmle.Extraction.CSharp/Entities/Expressions/Discard.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public Discard(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.DISCARD))
1212
}
1313

1414
private Discard(Context cx, CSharpSyntaxNode syntax, IExpressionParentEntity parent, int child) :
15-
base(new ExpressionInfo(cx, cx.GetType(syntax), cx.Create(syntax.GetLocation()), ExprKind.DISCARD, parent, child, false, null))
15+
base(new ExpressionInfo(cx, cx.GetType(syntax), cx.CreateLocation(syntax.GetLocation()), ExprKind.DISCARD, parent, child, false, null))
1616
{
1717
}
1818

csharp/extractor/Semmle.Extraction.CSharp/Entities/Expressions/Initializer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ protected override void PopulateExpression(TextWriter trapFile)
137137
var addMethod = Method.Create(cx, collectionInfo.Symbol as IMethodSymbol);
138138
var voidType = AnnotatedTypeSymbol.CreateNotAnnotated(cx.Compilation.GetSpecialType(SpecialType.System_Void));
139139

140-
var invocation = new Expression(new ExpressionInfo(cx, voidType, cx.Create(i.GetLocation()), ExprKind.METHOD_INVOCATION, this, child++, false, null));
140+
var invocation = new Expression(new ExpressionInfo(cx, voidType, cx.CreateLocation(i.GetLocation()), ExprKind.METHOD_INVOCATION, this, child++, false, null));
141141

142142
if (addMethod != null)
143143
trapFile.expr_call(invocation, addMethod);

csharp/extractor/Semmle.Extraction.CSharp/Entities/Expressions/InterpolatedString.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ protected override void PopulateExpression(TextWriter trapFile)
2727
case SyntaxKind.InterpolatedStringText:
2828
// Create a string literal
2929
var interpolatedText = (InterpolatedStringTextSyntax)c;
30-
new Expression(new ExpressionInfo(cx, Type, cx.Create(c.GetLocation()), ExprKind.STRING_LITERAL, this, child++, false, interpolatedText.TextToken.Text));
30+
new Expression(new ExpressionInfo(cx, Type, cx.CreateLocation(c.GetLocation()), ExprKind.STRING_LITERAL, this, child++, false, interpolatedText.TextToken.Text));
3131
break;
3232
default:
3333
throw new InternalError(c, $"Unhandled interpolation kind {c.Kind()}");

csharp/extractor/Semmle.Extraction.CSharp/Entities/Expressions/ObjectCreation/AnonymousObjectCreation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ protected override void PopulateExpression(TextWriter trapFile)
3636
var property = cx.GetModel(init).GetDeclaredSymbol(init);
3737
var propEntity = Property.Create(cx, property);
3838
var type = property.GetAnnotatedType();
39-
var loc = cx.Create(init.GetLocation());
39+
var loc = cx.CreateLocation(init.GetLocation());
4040

4141
var assignment = new Expression(new ExpressionInfo(cx, type, loc, ExprKind.SIMPLE_ASSIGN, objectInitializer, child++, false, null));
4242
Create(cx, init.Expression, assignment, 0);

0 commit comments

Comments
 (0)