refactor(dedup): second pass at src/ duplication — clear 10 of 13 remaining blocks #21

Merged
bermudalamb merged 4 commits from chore/sonarqube-src-dedup-pass2 into main 2026-05-27 17:14:01 -05:00
Showing only changes of commit 4b6b3edc87 - Show all commits
@@ -104,76 +104,39 @@ public class StatementReader : SqlServerStatementReader
if (CurrentCharacter == '=')
{
// Handle => operator (used in PostgreSQL for hstore and other operations)
// =, => (PostgreSQL hstore + other operations)
MovePosition();
if (CurrentCharacter == '>')
{
MovePosition();
_currentToken = new Token(TokenType.Operator, "=>");
return true;
}
// Single = is handled as regular operator
if (TryMatchTwoCharOperator('>', "=>")) return true;
_currentToken = new Token(TokenType.Operator, "=");
return true;
}
if (CurrentCharacter == '|')
{
// Handle || concatenation operator
// |, ||
MovePosition();
if (CurrentCharacter == '|')
{
MovePosition();
_currentToken = new Token(TokenType.Operator, "||");
return true;
}
// Single | is also an operator
if (TryMatchTwoCharOperator('|', "||")) return true;
_currentToken = new Token(TokenType.Operator, "|");
return true;
}
if (CurrentCharacter == '<')
{
// Handle <, <=, <>, << operators
// <, <=, <>, <<
MovePosition();
if (CurrentCharacter == '=')
{
MovePosition();
_currentToken = new Token(TokenType.Operator, "<=");
return true;
}
if (CurrentCharacter == '>')
{
MovePosition();
_currentToken = new Token(TokenType.Operator, "<>");
return true;
}
if (CurrentCharacter == '<')
{
MovePosition();
_currentToken = new Token(TokenType.Operator, "<<");
return true;
}
if (TryMatchTwoCharOperator('=', "<=")) return true;
if (TryMatchTwoCharOperator('>', "<>")) return true;
if (TryMatchTwoCharOperator('<', "<<")) return true;
_currentToken = new Token(TokenType.Operator, "<");
return true;
}
if (CurrentCharacter == '>')
{
// Handle >, >=, >> operators
// >, >=, >>
MovePosition();
if (CurrentCharacter == '=')
{
MovePosition();
_currentToken = new Token(TokenType.Operator, ">=");
return true;
}
if (CurrentCharacter == '>')
{
MovePosition();
_currentToken = new Token(TokenType.Operator, ">>");
return true;
}
if (TryMatchTwoCharOperator('=', ">=")) return true;
if (TryMatchTwoCharOperator('>', ">>")) return true;
_currentToken = new Token(TokenType.Operator, ">");
return true;
}
@@ -244,6 +207,23 @@ public class StatementReader : SqlServerStatementReader
return stringValue.ToString();
}
/// <summary>
/// If the position is currently sitting on <paramref name="nextChar"/>, advances past it,
/// emits <paramref name="twoCharOperator"/> as the current Operator token, and returns
/// <c>true</c>. Otherwise leaves position untouched and returns <c>false</c>. Used by the
/// multi-character operator dispatch (e.g. <c>&lt;</c>/<c>&lt;=</c>/<c>&lt;&gt;</c>/<c>&lt;&lt;</c>).
/// </summary>
private bool TryMatchTwoCharOperator(char nextChar, string twoCharOperator)
{
if (CurrentCharacter != nextChar)
{
return false;
}
MovePosition();
_currentToken = new Token(TokenType.Operator, twoCharOperator);
return true;
}
}