(content: string, filename: string)
| 139 | * Uses the main properties parser for error detection. |
| 140 | */ |
| 141 | export function parsePropertiesFileRaw(content: string, filename: string): ParsedPropertiesFile { |
| 142 | const properties: ParsedProperty[] = []; |
| 143 | const disabledIds = new Set<string>(); |
| 144 | const parseErrors: ValidationIssue[] = []; |
| 145 | |
| 146 | // Use the main parser to collect format errors via callback |
| 147 | parseProperties(content, filename, { |
| 148 | onError: error => parseErrors.push({line: error.line, text: error.text}), |
| 149 | }); |
| 150 | |
| 151 | // Also collect our own structured properties with line numbers |
| 152 | const lines = content.split('\n'); |
| 153 | for (let i = 0; i < lines.length; i++) { |
| 154 | const lineNumber = i + 1; |
| 155 | const text = lines[i].trim(); |
| 156 | |
| 157 | if (!text) continue; |
| 158 | |
| 159 | // Check for Disabled: comments |
| 160 | const disabledMatch = text.match(PATTERNS.disabled); |
| 161 | if (disabledMatch) { |
| 162 | const ids = disabledMatch[1].split(/\s+/).filter(id => id.trim() !== ''); |
| 163 | for (const id of ids) { |
| 164 | disabledIds.add(id); |
| 165 | } |
| 166 | continue; |
| 167 | } |
| 168 | |
| 169 | // Skip other comments |
| 170 | if (text.startsWith('#')) continue; |
| 171 | |
| 172 | // Parse property line |
| 173 | const match = text.match(PATTERNS.property); |
| 174 | if (match) { |
| 175 | properties.push({ |
| 176 | key: match[1].trim(), |
| 177 | value: match[2].trim(), |
| 178 | line: lineNumber, |
| 179 | }); |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | return {filename, properties, disabledIds, parseErrors}; |
| 184 | } |
| 185 | |
| 186 | /** |
| 187 | * Validate a parsed properties file for various issues. |
no test coverage detected