module Noir::KotlinSourceMask

Overview

Character-preserving masks over Kotlin source text.

Both masks replace every masked-out character with a single space and keep every newline, so the result lines up with the original by character: masked[i] describes source[i], masked.lines[n] is exactly as long as source.lines[n], and a Regex::MatchData#end taken on the masked copy can be used to slice the raw text. Callers depend on that to gate a line scan on the masked copy while reading the real value out of the raw source.

One space per character, not per byte: Crystal's String#[] and MatchData#begin/#end are char-indexed while the scanner walks bytes, so emitting one space per byte made every offset after a non-ASCII comment (a CJK line above a route, an accented author name) drift by the number of continuation bytes and over-trimmed the raw line.

Extended Modules

Defined in:

miniparsers/kotlin_source_mask.cr

Constant Summary

BACKSLASH = '\\'.ord.to_u8
DOUBLE_QUOTE = '"'.ord.to_u8
NEWLINE = '\n'.ord.to_u8
SINGLE_QUOTE = '\''.ord.to_u8
SLASH = '/'.ord.to_u8
SPACE = ' '.ord.to_u8
STAR = '*'.ord.to_u8

Instance Method Summary

Instance Method Detail

def code_only(source : String) : String #

Comments blanked, string literals kept verbatim. Use this to run a line regex that has to read a literal value — const val PATH = "/mcp" — without also harvesting a commented-out declaration.


[View source]
def visible(source : String) : String #

Comments and string-literal contents blanked. Use this for structural work — brace counting, delimiter matching, deciding whether a call site is real code — where a { or a ( inside a string or a comment must not count.


[View source]