Skip to content

SQL Syntax highlighter support (oracle dialect) for q-quoted string literals#295

Merged
romankassebaum merged 1 commit intoTurboPack:masterfrom
csm101:oracle_q_quote_string_literals
Apr 3, 2026
Merged

SQL Syntax highlighter support (oracle dialect) for q-quoted string literals#295
romankassebaum merged 1 commit intoTurboPack:masterfrom
csm101:oracle_q_quote_string_literals

Conversation

@csm101
Copy link
Copy Markdown
Contributor

@csm101 csm101 commented Apr 2, 2026

This is a screenshot of TSynEdit with TSynSQLSyn (with Dialect=sqlOracle) displaying the correct string literals highlighting for q-quoted string literals after having applied my fix

image

this fixes issue #294 I just reported: in the issue report there is a screenshot of the current behavior of the highlighter without my fix and a detailed description of the oracle syntax being supported

Thank you and have a nice day

…iterals (introduced since Oracle 10 R2). Fixes issue TurboPack#294
Copilot AI review requested due to automatic review settings April 2, 2026 15:40
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Oracle q-quoted (alternative quoting mechanism) string literal recognition to the SQL highlighter when SQLDialect = sqlOracle, fixing incorrect tokenization/highlighting for this syntax.

Changes:

  • Introduces a dedicated range state (rsOracleQQuoteString) and scanner (OracleQQuoteProc) to tokenize q'<delim>...<closing-delim>' as a single string token.
  • Detects q/Q quote starts in the identifier dispatch path and switches into the new q-quote parsing mode.
  • Persists the q-quote closing delimiter across line ranges by encoding it into GetRange/SetRange.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 2028 to 2031
function TSynSQLSyn.GetRange: Pointer;
begin
Result := Pointer(fRange);
Result := Pointer((Ord(fRange) and $FF) or (Ord(FOracleQQuoteClosingDelimiter) shl 8));
end;
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The range state is being bit-packed into a Pointer using hard-coded masks/shifts ($FF and shl 8). Please introduce named constants (e.g., RangeMask/DelimiterShift) and add a brief comment documenting the encoding layout, so future range-state additions don’t accidentally break persistence across lines.

Copilot uses AI. Check for mistakes.
Comment on lines 2077 to +2083
procedure TSynSQLSyn.SetRange(Value: Pointer);
var
EncodedRange: NativeUInt;
begin
fRange := TRangeState(Value);
EncodedRange := NativeUInt(Value);
fRange := TRangeState(EncodedRange and $FF);
FOracleQQuoteClosingDelimiter := WideChar((EncodedRange shr 8) and $FFFF);
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SetRange decodes the packed range using magic numbers ($FF, shr 8, $FFFF). Consider centralizing this encode/decode logic (shared constants or small helpers) and documenting the expected bit widths; otherwise expanding TRangeState beyond 0..255 would silently corrupt the restored range.

Copilot uses AI. Check for mistakes.
@romankassebaum romankassebaum merged commit e0388ee into TurboPack:master Apr 3, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants