Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bd1b001

Browse files
committed
C#: Rename some methods.
1 parent 58e6d23 commit bd1b001

22 files changed

Lines changed: 56 additions & 54 deletions

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ public ExpressionNodeInfo(Context cx, ExpressionSyntax node, IExpressionParentEn
384384
Parent = parent;
385385
Child = child;
386386
TypeInfo = typeInfo;
387-
Conversion = cx.Model(node).GetConversion(node);
387+
Conversion = cx.GetModel(node).GetConversion(node);
388388
}
389389

390390
public Context Context { get; }
@@ -443,7 +443,7 @@ public Microsoft.CodeAnalysis.Location CodeAnalysisLocation
443443
}
444444
}
445445

446-
public SemanticModel Model => Context.Model(Node);
446+
public SemanticModel Model => Context.GetModel(Node);
447447

448448
public string ExprValue
449449
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ protected override void Populate()
103103
var child = 0;
104104
foreach (var i in Syntax.Expressions)
105105
{
106-
var collectionInfo = cx.Model(Syntax).GetCollectionInitializerSymbolInfo(i);
106+
var collectionInfo = cx.GetModel(Syntax).GetCollectionInitializerSymbolInfo(i);
107107
var addMethod = Method.Create(cx, collectionInfo.Symbol as IMethodSymbol);
108108
var voidType = Entities.Type.Create(cx, new AnnotatedTypeSymbol(cx.Compilation.GetSpecialType(SpecialType.System_Void), NullableAnnotation.NotApplicable));
109109

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ protected override void Populate()
5252
if (target != null && !target.IsStatic)
5353
{
5454
// Implicit `this` qualifier; add explicitly
55-
var callingMethod = cx.Model(Syntax).GetEnclosingSymbol(Location.symbol.SourceSpan.Start) as IMethodSymbol;
55+
var callingMethod = cx.GetModel(Syntax).GetEnclosingSymbol(Location.symbol.SourceSpan.Start) as IMethodSymbol;
5656

5757
if (callingMethod == null)
5858
cx.ModelError(Syntax, "Couldn't determine implicit this type");

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public static Expression CreatePattern(this Context cx, PatternSyntax syntax, IE
2020
{
2121
if (declPattern.Designation is VariableDesignationSyntax designation)
2222
{
23-
if (cx.Model(syntax).GetDeclaredSymbol(designation) is ILocalSymbol symbol)
23+
if (cx.GetModel(syntax).GetDeclaredSymbol(designation) is ILocalSymbol symbol)
2424
{
2525
var type = Type.Create(cx, symbol.GetAnnotatedType());
2626
return VariableDeclaration.Create(cx, symbol, type, declPattern.Type, cx.Create(syntax.GetLocation()), cx.Create(designation.GetLocation()), false, parent, child);
@@ -43,7 +43,7 @@ public static Expression CreatePattern(this Context cx, PatternSyntax syntax, IE
4343
case ParenthesizedVariableDesignationSyntax parDesignation:
4444
return VariableDeclaration.CreateParenthesized(cx, varPattern, parDesignation, parent, child);
4545
case SingleVariableDesignationSyntax varDesignation:
46-
if (cx.Model(syntax).GetDeclaredSymbol(varDesignation) is ILocalSymbol symbol)
46+
if (cx.GetModel(syntax).GetDeclaredSymbol(varDesignation) is ILocalSymbol symbol)
4747
{
4848
var type = Type.Create(cx, symbol.GetAnnotatedType());
4949

@@ -111,7 +111,7 @@ public RecursivePattern(Context cx, RecursivePatternSyntax syntax, IExpressionPa
111111
Expressions.TypeAccess.Create(cx, t, this, 1);
112112

113113
// Extract the local variable declaration
114-
if (syntax.Designation is VariableDesignationSyntax designation && cx.Model(syntax).GetDeclaredSymbol(designation) is ILocalSymbol symbol)
114+
if (syntax.Designation is VariableDesignationSyntax designation && cx.GetModel(syntax).GetDeclaredSymbol(designation) is ILocalSymbol symbol)
115115
{
116116
var type = Entities.Type.Create(cx, symbol.GetAnnotatedType());
117117

@@ -139,7 +139,7 @@ private IsPattern(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.IS))
139139
private void PopulatePattern(PatternSyntax pattern, TypeSyntax optionalType, SyntaxToken varKeyword, VariableDesignationSyntax designation)
140140
{
141141
var isVar = optionalType is null;
142-
if (!(designation is null) && cx.Model(pattern).GetDeclaredSymbol(designation) is ILocalSymbol symbol)
142+
if (!(designation is null) && cx.GetModel(pattern).GetDeclaredSymbol(designation) is ILocalSymbol symbol)
143143
{
144144
var type = Entities.Type.Create(cx, symbol.GetAnnotatedType());
145145
VariableDeclaration.Create(cx, symbol, type, optionalType, cx.Create(pattern.GetLocation()), cx.Create(designation.GetLocation()), isVar, this, 1);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ protected override void Populate() { }
1616

1717
void VisitParameter(ParameterSyntax p)
1818
{
19-
var symbol = cx.Model(p).GetDeclaredSymbol(p);
19+
var symbol = cx.GetModel(p).GetDeclaredSymbol(p);
2020
Parameter.Create(cx, symbol, this);
2121
}
2222

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ static bool IsDynamicObjectCreation(Context cx, ObjectCreationExpressionSyntax n
2424

2525
static ExprKind GetKind(Context cx, ObjectCreationExpressionSyntax node)
2626
{
27-
var si = cx.Model(node).GetSymbolInfo(node.Type);
27+
var si = cx.GetModel(node).GetSymbolInfo(node.Type);
2828
return Entities.Type.IsDelegate(si.Symbol as INamedTypeSymbol) ? ExprKind.EXPLICIT_DELEGATE_CREATION : ExprKind.OBJECT_CREATION;
2929
}
3030

@@ -40,7 +40,7 @@ protected override void Populate()
4040
PopulateArguments(Syntax.ArgumentList, 0);
4141
}
4242

43-
var target = cx.Model(Syntax).GetSymbolInfo(Syntax);
43+
var target = cx.GetModel(Syntax).GetSymbolInfo(Syntax);
4444
var method = (IMethodSymbol)target.Symbol;
4545

4646
if (method != null)
@@ -119,7 +119,7 @@ protected override void Populate()
119119
foreach (var init in Syntax.Initializers)
120120
{
121121
// Create an "assignment"
122-
var property = cx.Model(init).GetDeclaredSymbol(init);
122+
var property = cx.GetModel(init).GetDeclaredSymbol(init);
123123
var propEntity = Property.Create(cx, property);
124124
var type = Entities.Type.Create(cx, property.GetAnnotatedType());
125125
var loc = cx.Create(init.GetLocation());

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -197,14 +197,14 @@ public override Expression Populate(Context cx, IExpressionParentEntity parent,
197197
/// <returns>A "syntax tree" of the query.</returns>
198198
static Clause ConstructQueryExpression(Context cx, QueryExpressionSyntax node)
199199
{
200-
var info = cx.Model(node).GetQueryClauseInfo(node.FromClause);
200+
var info = cx.GetModel(node).GetQueryClauseInfo(node.FromClause);
201201
var method = info.OperationInfo.Symbol as IMethodSymbol;
202202

203-
Clause clauseExpr = new RangeClause(method, node.FromClause, cx.Model(node).GetDeclaredSymbol(node.FromClause), node.FromClause.Identifier).AddArgument(node.FromClause.Expression);
203+
Clause clauseExpr = new RangeClause(method, node.FromClause, cx.GetModel(node).GetDeclaredSymbol(node.FromClause), node.FromClause.Identifier).AddArgument(node.FromClause.Expression);
204204

205205
foreach (var qc in node.Body.Clauses)
206206
{
207-
info = cx.Model(node).GetQueryClauseInfo(qc);
207+
info = cx.GetModel(node).GetQueryClauseInfo(qc);
208208

209209
method = info.OperationInfo.Symbol as IMethodSymbol;
210210

@@ -214,7 +214,7 @@ static Clause ConstructQueryExpression(Context cx, QueryExpressionSyntax node)
214214
var orderByClause = (OrderByClauseSyntax)qc;
215215
foreach (var ordering in orderByClause.Orderings)
216216
{
217-
method = cx.Model(node).GetSymbolInfo(ordering).Symbol as IMethodSymbol;
217+
method = cx.GetModel(node).GetSymbolInfo(ordering).Symbol as IMethodSymbol;
218218

219219
clauseExpr = clauseExpr.WithCallClause(method, orderByClause).AddArgument(ordering.Expression);
220220

@@ -229,25 +229,25 @@ static Clause ConstructQueryExpression(Context cx, QueryExpressionSyntax node)
229229
case SyntaxKind.FromClause:
230230
var fromClause = (FromClauseSyntax)qc;
231231
clauseExpr = clauseExpr.
232-
WithLetClause(method, fromClause, cx.Model(node).GetDeclaredSymbol(fromClause), fromClause.Identifier).
232+
WithLetClause(method, fromClause, cx.GetModel(node).GetDeclaredSymbol(fromClause), fromClause.Identifier).
233233
AddArgument(fromClause.Expression);
234234
break;
235235
case SyntaxKind.LetClause:
236236
var letClause = (LetClauseSyntax)qc;
237-
clauseExpr = clauseExpr.WithLetClause(method, letClause, cx.Model(node).GetDeclaredSymbol(letClause), letClause.Identifier).
237+
clauseExpr = clauseExpr.WithLetClause(method, letClause, cx.GetModel(node).GetDeclaredSymbol(letClause), letClause.Identifier).
238238
AddArgument(letClause.Expression);
239239
break;
240240
case SyntaxKind.JoinClause:
241241
var joinClause = (JoinClauseSyntax)qc;
242242

243-
clauseExpr = clauseExpr.WithLetClause(method, joinClause, cx.Model(node).GetDeclaredSymbol(joinClause), joinClause.Identifier).
243+
clauseExpr = clauseExpr.WithLetClause(method, joinClause, cx.GetModel(node).GetDeclaredSymbol(joinClause), joinClause.Identifier).
244244
AddArgument(joinClause.InExpression).
245245
AddArgument(joinClause.LeftExpression).
246246
AddArgument(joinClause.RightExpression);
247247

248248
if (joinClause.Into != null)
249249
{
250-
var into = cx.Model(node).GetDeclaredSymbol(joinClause.Into);
250+
var into = cx.GetModel(node).GetDeclaredSymbol(joinClause.Into);
251251
((LetClause)clauseExpr).WithInto(into);
252252
}
253253

@@ -257,7 +257,7 @@ static Clause ConstructQueryExpression(Context cx, QueryExpressionSyntax node)
257257
}
258258
}
259259

260-
method = cx.Model(node).GetSymbolInfo(node.Body.SelectOrGroup).Symbol as IMethodSymbol;
260+
method = cx.GetModel(node).GetSymbolInfo(node.Body.SelectOrGroup).Symbol as IMethodSymbol;
261261

262262
clauseExpr = new CallClause(clauseExpr, method, node.Body.SelectOrGroup);
263263

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ static VariableDeclaration CreateSingle(Context cx, DeclarationExpressionSyntax
2727
{
2828
bool isVar = node.Type.IsVar;
2929

30-
var variableSymbol = cx.Model(designation).GetDeclaredSymbol(designation) as ILocalSymbol;
30+
var variableSymbol = cx.GetModel(designation).GetDeclaredSymbol(designation) as ILocalSymbol;
3131
if (variableSymbol == null)
3232
{
3333
cx.ModelError(node, "Failed to determine local variable");
@@ -76,7 +76,7 @@ public static Expression CreateParenthesized(Context cx, VarPatternSyntax varPat
7676
CreateParenthesized(cx, varPattern, paren, tuple, child0++);
7777
break;
7878
case SingleVariableDesignationSyntax single:
79-
if (cx.Model(variable).GetDeclaredSymbol(single) is ILocalSymbol local)
79+
if (cx.GetModel(variable).GetDeclaredSymbol(single) is ILocalSymbol local)
8080
{
8181
var decl = Create(cx, variable, Entities.Type.Create(cx, local.GetAnnotatedType()), true, tuple, child0++);
8282
var id = single.Identifier;
@@ -126,13 +126,13 @@ public static VariableDeclaration Create(Context cx, CSharpSyntaxNode c, Annotat
126126

127127
public static VariableDeclaration Create(Context cx, CatchDeclarationSyntax d, bool isVar, IExpressionParentEntity parent, int child)
128128
{
129-
var symbol = cx.Model(d).GetDeclaredSymbol(d);
129+
var symbol = cx.GetModel(d).GetDeclaredSymbol(d);
130130
var type = Entities.Type.Create(cx, symbol.GetAnnotatedType());
131131
var ret = Create(cx, d, type, isVar, parent, child);
132132
cx.Try(d, null, () =>
133133
{
134134
var id = d.Identifier;
135-
var declSymbol = cx.Model(d).GetDeclaredSymbol(d);
135+
var declSymbol = cx.GetModel(d).GetDeclaredSymbol(d);
136136
var location = cx.Create(id.GetLocation());
137137
LocalVariable.Create(cx, declSymbol, ret, isVar, location);
138138
TypeMention.Create(cx, d.Type, ret, type);
@@ -146,7 +146,7 @@ public static VariableDeclaration CreateDeclarator(Context cx, VariableDeclarato
146146
cx.Try(d, null, () =>
147147
{
148148
var id = d.Identifier;
149-
var declSymbol = cx.Model(d).GetDeclaredSymbol(d);
149+
var declSymbol = cx.GetModel(d).GetDeclaredSymbol(d);
150150
var location = cx.Create(id.GetLocation());
151151
var localVar = LocalVariable.Create(cx, declSymbol, ret, isVar, location);
152152

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class NamespaceDeclaration : FreshEntity
1212
public NamespaceDeclaration(Context cx, NamespaceDeclarationSyntax node, NamespaceDeclaration parent)
1313
: base(cx)
1414
{
15-
var ns = Namespace.Create(cx, (INamespaceSymbol)cx.Model(node).GetSymbolInfo(node.Name).Symbol);
15+
var ns = Namespace.Create(cx, (INamespaceSymbol)cx.GetModel(node).GetSymbolInfo(node.Name).Symbol);
1616
cx.Emit(Tuples.namespace_declarations(this, ns));
1717
cx.Emit(Tuples.namespace_declaration_location(this, cx.Create(node.Name.GetLocation())));
1818

csharp/extractor/Semmle.Extraction.CSharp/Entities/Statements/Case.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ protected override void Populate()
3636
{
3737
var value = Stmt.Value;
3838
Expression.Create(cx, value, this, 0);
39-
Switch.LabelForValue(cx.Model(Stmt).GetConstantValue(value).Value);
39+
Switch.LabelForValue(cx.GetModel(Stmt).GetConstantValue(value).Value);
4040
}
4141

4242
public static CaseLabel Create(Context cx, CaseSwitchLabelSyntax node, Switch parent, int child)
@@ -73,7 +73,7 @@ private void PopulatePattern(PatternSyntax pattern, TypeSyntax optionalType, Var
7373
switch (designation)
7474
{
7575
case SingleVariableDesignationSyntax _:
76-
if (cx.Model(pattern).GetDeclaredSymbol(designation) is ILocalSymbol symbol)
76+
if (cx.GetModel(pattern).GetDeclaredSymbol(designation) is ILocalSymbol symbol)
7777
{
7878
var type = Type.Create(cx, symbol.GetAnnotatedType());
7979
Expressions.VariableDeclaration.Create(cx, symbol, type, optionalType, cx.Create(pattern.GetLocation()), cx.Create(designation.GetLocation()), isVar, this, 0);

0 commit comments

Comments
 (0)