Skip to content

Commit 2fa9037

Browse files
authored
Merge pull request github#4738 from tamasvajk/feature/revert-relational-pattern
C#: Revert "Merge pull request github#4653 from tamasvajk/feature/csharp9-relational-pattern"
2 parents a94f244 + 998e2de commit 2fa9037

File tree

14 files changed

+2
-3962
lines changed

14 files changed

+2
-3962
lines changed

csharp/change-notes/2020-11-19-Relational-pattern.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

csharp/extractor/Semmle.Extraction.CSharp/Entities/Expressions/Patterns/Pattern.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ internal static Expression Create(Context cx, PatternSyntax syntax, IExpressionP
4242
case RecursivePatternSyntax recPattern:
4343
return new RecursivePattern(cx, recPattern, parent, child);
4444

45-
case RelationalPatternSyntax relPattern:
46-
return new RelationalPattern(cx, relPattern, parent, child);
47-
4845
case VarPatternSyntax varPattern:
4946
switch (varPattern.Designation)
5047
{

csharp/extractor/Semmle.Extraction.CSharp/Entities/Expressions/Patterns/RecursivePattern.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ internal class RecursivePattern : Expression
1515
/// <param name="syntax">The syntax node of the recursive pattern.</param>
1616
/// <param name="parent">The parent pattern/expression.</param>
1717
/// <param name="child">The child index of this pattern.</param>
18+
/// <param name="isTopLevel">If this pattern is in the top level of a case/is. In that case, the variable and type access are populated elsewhere.</param>
1819
public RecursivePattern(Context cx, RecursivePatternSyntax syntax, IExpressionParentEntity parent, int child) :
1920
base(new ExpressionInfo(cx, Entities.NullType.Create(cx), cx.Create(syntax.GetLocation()), ExprKind.RECURSIVE_PATTERN, parent, child, false, null))
2021
{

csharp/extractor/Semmle.Extraction.CSharp/Entities/Expressions/Patterns/RelationalPattern.cs

Lines changed: 0 additions & 29 deletions
This file was deleted.

csharp/extractor/Semmle.Extraction.CSharp/Kinds/ExprKind.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,6 @@ public enum ExprKind
115115
SWITCH_CASE = 118,
116116
ASSIGN_COALESCE = 119,
117117
SUPPRESS_NULLABLE_WARNING = 120,
118-
NAMESPACE_ACCESS = 121,
119-
LT_PATTERN = 122,
120-
GT_PATTERN = 123,
121-
LE_PATTERN = 124,
122-
GE_PATTERN = 125,
118+
NAMESPACE_ACCESS = 121
123119
}
124120
}

csharp/ql/src/semmle/code/csharp/exprs/Expr.qll

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -342,45 +342,6 @@ class ConstantPatternExpr extends PatternExpr {
342342
override string getAPrimaryQlClass() { result = "ConstantPatternExpr" }
343343
}
344344

345-
/** A relational pattern, for example `>1` in `x is >1`. */
346-
class RelationalPatternExpr extends PatternExpr, @relational_pattern_expr {
347-
/** Gets the name of the operator in this pattern. */
348-
string getOperator() { none() }
349-
350-
/** Gets the expression of this relational pattern. */
351-
Expr getExpr() { result = this.getChild(0) }
352-
353-
override string toString() { result = getOperator() + " ..." }
354-
}
355-
356-
/** A less-than pattern, for example `< 10` in `x is < 10`. */
357-
class LTPattern extends RelationalPatternExpr, @lt_pattern_expr {
358-
override string getOperator() { result = "<" }
359-
360-
override string getAPrimaryQlClass() { result = "LTPattern" }
361-
}
362-
363-
/** A greater-than pattern, for example `> 10` in `x is > 10`. */
364-
class GTPattern extends RelationalPatternExpr, @gt_pattern_expr {
365-
override string getOperator() { result = ">" }
366-
367-
override string getAPrimaryQlClass() { result = "GTPattern" }
368-
}
369-
370-
/** A less-than or equals pattern, for example `<= 10` in `x is <= 10`. */
371-
class LEPattern extends RelationalPatternExpr, @le_pattern_expr {
372-
override string getOperator() { result = "<=" }
373-
374-
override string getAPrimaryQlClass() { result = "LEPattern" }
375-
}
376-
377-
/** A greater-than or equals pattern, for example `>= 10` in `x is >= 10` */
378-
class GEPattern extends RelationalPatternExpr, @ge_pattern_expr {
379-
override string getOperator() { result = ">=" }
380-
381-
override string getAPrimaryQlClass() { result = "GEPattern" }
382-
}
383-
384345
/**
385346
* A type pattern, for example `string` in `x is string`, `string s` in
386347
* `x is string s`, or `string _` in `x is string _`.

csharp/ql/src/semmlecode.csharp.dbscheme

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -998,17 +998,11 @@ case @expr.kind of
998998
| 119 = @assign_coalesce_expr
999999
| 120 = @suppress_nullable_warning_expr
10001000
| 121 = @namespace_access_expr
1001-
/* C# 9.0 */
1002-
| 122 = @lt_pattern_expr
1003-
| 123 = @gt_pattern_expr
1004-
| 124 = @le_pattern_expr
1005-
| 125 = @ge_pattern_expr
10061001
;
10071002

10081003
@switch = @switch_stmt | @switch_expr;
10091004
@case = @case_stmt | @switch_case_expr;
10101005
@pattern_match = @case | @is_expr;
1011-
@relational_pattern_expr = @gt_pattern_expr | @lt_pattern_expr | @ge_pattern_expr | @le_pattern_expr;
10121006

10131007
@integer_literal_expr = @int_literal_expr | @long_literal_expr | @uint_literal_expr | @ulong_literal_expr;
10141008
@real_literal_expr = @float_literal_expr | @double_literal_expr | @decimal_literal_expr;

csharp/ql/test/library-tests/csharp9/PrintAst.expected

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -335,63 +335,6 @@ ParenthesizedPattern.cs:
335335
# 27| 0: [TypeAccessPatternExpr] access to type String
336336
# 27| 0: [TypeMention] string
337337
# 27| 2: [IntLiteral] 5
338-
RelationalPattern.cs:
339-
# 3| [Class] RelationalPattern
340-
# 5| 5: [Method] M1
341-
# 5| -1: [TypeMention] bool
342-
#-----| 2: (Parameters)
343-
# 5| 0: [Parameter] c
344-
# 5| -1: [TypeMention] char
345-
# 6| 4: [IsExpr] ... is ...
346-
# 6| 0: [ParameterAccess] access to parameter c
347-
# 6| 1: [GEPattern] >= ...
348-
# 6| 0: [CharLiteral] a
349-
# 7| 6: [Method] M2
350-
# 7| -1: [TypeMention] bool
351-
#-----| 2: (Parameters)
352-
# 7| 0: [Parameter] c
353-
# 7| -1: [TypeMention] char
354-
# 8| 4: [IsExpr] ... is ...
355-
# 8| 0: [ParameterAccess] access to parameter c
356-
# 8| 1: [GTPattern] > ...
357-
# 8| 0: [CharLiteral] a
358-
# 9| 7: [Method] M3
359-
# 9| -1: [TypeMention] bool
360-
#-----| 2: (Parameters)
361-
# 9| 0: [Parameter] c
362-
# 9| -1: [TypeMention] char
363-
# 10| 4: [IsExpr] ... is ...
364-
# 10| 0: [ParameterAccess] access to parameter c
365-
# 10| 1: [LEPattern] <= ...
366-
# 10| 0: [CharLiteral] a
367-
# 11| 8: [Method] M4
368-
# 11| -1: [TypeMention] bool
369-
#-----| 2: (Parameters)
370-
# 11| 0: [Parameter] c
371-
# 11| -1: [TypeMention] char
372-
# 12| 4: [IsExpr] ... is ...
373-
# 12| 0: [ParameterAccess] access to parameter c
374-
# 12| 1: [LTPattern] < ...
375-
# 12| 0: [CharLiteral] a
376-
# 14| 9: [Method] M5
377-
# 14| -1: [TypeMention] string
378-
#-----| 2: (Parameters)
379-
# 14| 0: [Parameter] i
380-
# 14| -1: [TypeMention] int
381-
# 15| 4: [BlockStmt] {...}
382-
# 16| 0: [ReturnStmt] return ...;
383-
# 16| 0: [SwitchExpr] ... switch { ... }
384-
# 16| -1: [ParameterAccess] access to parameter i
385-
# 18| 0: [SwitchCaseExpr] ... => ...
386-
# 18| 0: [ConstantPatternExpr,IntLiteral] 1
387-
# 18| 2: [StringLiteral] "1"
388-
# 19| 1: [SwitchCaseExpr] ... => ...
389-
# 19| 0: [GTPattern] > ...
390-
# 19| 0: [IntLiteral] 1
391-
# 19| 2: [StringLiteral] ">1"
392-
# 20| 2: [SwitchCaseExpr] ... => ...
393-
# 20| 0: [DiscardPatternExpr] _
394-
# 20| 2: [StringLiteral] "other"
395338
TargetType.cs:
396339
# 5| [Class] TargetType
397340
# 7| 5: [Method] M2

csharp/ql/test/library-tests/csharp9/RelationalPattern.cs

Lines changed: 0 additions & 23 deletions
This file was deleted.

csharp/ql/test/library-tests/csharp9/relationalPattern.expected

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)