Skip to content

Commit 5ce5a96

Browse files
committed
Remove 'ContextExtensions'
1 parent 9ddeff8 commit 5ce5a96

File tree

1 file changed

+14
-22
lines changed

1 file changed

+14
-22
lines changed

csharp/extractor/Semmle.Extraction/Context.cs

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -457,54 +457,47 @@ public void ExtractionError(Message msg)
457457
new Entities.ExtractionMessage(this, msg);
458458
Extractor.Message(msg);
459459
}
460-
}
461460

462-
public static class ContextExtensions
463-
{
464461
/// <summary>
465462
/// Signal an error in the program model.
466463
/// </summary>
467-
/// <param name="cx">The context.</param>
468464
/// <param name="node">The syntax node causing the failure.</param>
469465
/// <param name="msg">The error message.</param>
470-
public static void ModelError(this Context cx, SyntaxNode node, string msg)
466+
public void ModelError(SyntaxNode node, string msg)
471467
{
472-
if (!cx.Extractor.Standalone)
468+
if (!Extractor.Standalone)
473469
throw new InternalError(node, msg);
474470
}
475471

476472
/// <summary>
477473
/// Signal an error in the program model.
478474
/// </summary>
479-
/// <param name="context">The context.</param>
480475
/// <param name="node">Symbol causing the error.</param>
481476
/// <param name="msg">The error message.</param>
482-
public static void ModelError(this Context cx, ISymbol symbol, string msg)
477+
public void ModelError(ISymbol symbol, string msg)
483478
{
484-
if (!cx.Extractor.Standalone)
479+
if (!Extractor.Standalone)
485480
throw new InternalError(symbol, msg);
486481
}
487482

488483
/// <summary>
489484
/// Signal an error in the program model.
490485
/// </summary>
491-
/// <param name="context">The context.</param>
492486
/// <param name="msg">The error message.</param>
493-
public static void ModelError(this Context cx, string msg)
487+
public void ModelError(string msg)
494488
{
495-
if (!cx.Extractor.Standalone)
489+
if (!Extractor.Standalone)
496490
throw new InternalError(msg);
497491
}
498492

499493
/// <summary>
500494
/// Tries the supplied action <paramref name="a"/>, and logs an uncaught
501495
/// exception error if the action fails.
502496
/// </summary>
503-
/// <param name="context">The context.</param>
504497
/// <param name="node">Optional syntax node for error reporting.</param>
505498
/// <param name="symbol">Optional symbol for error reporting.</param>
506499
/// <param name="a">The action to perform.</param>
507-
public static void Try(this Context context, SyntaxNode? node, ISymbol? symbol, Action a)
500+
public void Try(SyntaxNode? node, ISymbol? symbol, Action a)
508501
{
509502
try
510503
{
@@ -516,33 +509,32 @@ public static void Try(this Context context, SyntaxNode? node, ISymbol? symbol,
516509

517510
if (node != null)
518511
{
519-
message = Message.Create(context, ex.Message, node, ex.StackTrace);
512+
message = Message.Create(this, ex.Message, node, ex.StackTrace);
520513
}
521514
else if (symbol != null)
522515
{
523-
message = Message.Create(context, ex.Message, symbol, ex.StackTrace);
516+
message = Message.Create(this, ex.Message, symbol, ex.StackTrace);
524517
}
525518
else if (ex is InternalError ie)
526519
{
527-
message = new Message(ie.Text, ie.EntityText, Entities.Location.Create(context, ie.Location), ex.StackTrace);
520+
message = new Message(ie.Text, ie.EntityText, Entities.Location.Create(this, ie.Location), ex.StackTrace);
528521
}
529522
else
530523
{
531-
message = new Message($"Uncaught exception. {ex.Message}", null, Entities.Location.Create(context), ex.StackTrace);
524+
message = new Message($"Uncaught exception. {ex.Message}", null, Entities.Location.Create(this), ex.StackTrace);
532525
}
533526

534-
context.ExtractionError(message);
527+
ExtractionError(message);
535528
}
536529
}
537530

538531
/// <summary>
539532
/// Write the given tuple to the trap file.
540533
/// </summary>
541-
/// <param name="cx">Extractor context.</param>
542534
/// <param name="tuple">Tuple to write.</param>
543-
public static void Emit(this Context cx, Tuple tuple)
535+
public void Emit(Tuple tuple)
544536
{
545-
cx.TrapWriter.Emit(tuple);
537+
TrapWriter.Emit(tuple);
546538
}
547539
}
548540
}

0 commit comments

Comments
 (0)