MCPcopy Index your code
hub / github.com/compiler-explorer/compiler-explorer / parsePropertiesFileRaw

Function parsePropertiesFileRaw

lib/properties-validator.ts:141–184  ·  view source on GitHub ↗
(content: string, filename: string)

Source from the content-addressed store, hash-verified

139 * Uses the main properties parser for error detection.
140 */
141export 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.

Callers 2

validateFunction · 0.85

Calls 4

parsePropertiesFunction · 0.85
pushMethod · 0.80
matchMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected