3131/**
3232 * Flattens config-bearing artifacts into {@link JConfigKey} records: pure text-in/records-out,
3333 * same idiom as {@link ManifestParsers} -- one dispatcher over per-format internals, never
34- * throwing. Mirrors codeanalyzer-python's {@code artifacts/config_keys.py}, but narrower: only
35- * {@code properties}/{@code yaml}/{@code xml}/{@code dockerfile} plus env-family basenames are
36- * handled here (python's {@code json}/{@code toml}/{@code ini} vocabulary has no Java-side
37- * artifact format to hang off, per the plan). The {@code xml} flattener is net-new -- python has
38- * none to emulate -- and is deliberately the simplest scheme that could work (see {@link
39- * #walkXml}).
34+ * throwing. Deliberately narrow: only {@code properties}/{@code yaml}/{@code xml}/{@code
35+ * dockerfile} plus env-family basenames are handled, because no other config format has a Java-side
36+ * artifact format to hang off. The {@code xml} flattener is deliberately the simplest scheme that
37+ * could work (see {@link #walkXml}).
4038 *
4139 * <p>Namespace dispatch: an env-family basename ({@code .env}, {@code .env.*}) always wins,
4240 * regardless of the artifact's declared {@code format} (matching {@code ArtifactDiscovery}, which
6361 * files are line-oriented so the parse itself knows the exact line, but {@code properties} (parsed
6462 * via {@link Properties}, which exposes no position info) and {@code yaml}/{@code xml} (tree-shaped)
6563 * carry no span at all here -- an accepted gap, matching the brief ("best-effort... null is
66- * acceptable"; python's own yaml/json/toml spans are already only a regex approximation ).
64+ * acceptable").
6765 */
6866public final class ConfigKeys {
6967
@@ -208,8 +206,8 @@ private static List<Entry> flatten(Object obj, String prefix) {
208206 }
209207
210208 // Compose's `services.<name>.environment` block only (a map of KEY: value, or a list of
211- // "KEY=value"/bare "KEY" strings) -- python's k8s `env[].name`/`.value` list- shape recognition
212- // is deliberately not ported, the brief names compose only.
209+ // "KEY=value"/bare "KEY" strings). Kubernetes' `env[].name`/`.value` list shape is deliberately
210+ // not recognized -- the brief names compose only.
213211 private static final Pattern COMPOSE_ENV = Pattern .compile ("^services\\ .[^.]+\\ .environment\\ .(.+)$" );
214212
215213 private static List <Entry > recognizeComposeEnv (List <Entry > flat ) {
@@ -246,7 +244,7 @@ private static boolean isDigits(String s) {
246244 return true ;
247245 }
248246
249- // ---- xml: net-new, python has no XML flattener to emulate. Deliberately the simplest scheme
247+ // ---- xml: deliberately the simplest scheme
250248 // that could work -- see walkXml -- not a richer one (no XPath predicates, no namespace-aware
251249 // qualified-name handling). Reuses ManifestParsers' hardened DocumentBuilderFactory rather than
252250 // building a second one: untrusted repository content gets the same XXE hardening either way. -
@@ -310,7 +308,7 @@ private static List<Element> directChildElements(Element parent) {
310308 // ---- dockerfile: `ENV`/`ARG` directives. Line-based, case-insensitive instruction keywords
311309 // (Dockerfile convention is uppercase; the spec itself is not case-sensitive).
312310 //
313- // Two known gaps, carried over from python rather than rediscovered : no BuildKit heredoc
311+ // Two known and accepted gaps : no BuildKit heredoc
314312 // awareness (a heredoc body line is just another line that doesn't match ENV/ARG and is
315313 // silently skipped, same as any other unparseable line); no multi-stage `FROM ... AS` scoping
316314 // (every ENV/ARG in the file is scanned regardless of which stage it is in). --------------
@@ -319,7 +317,7 @@ private static List<Element> directChildElements(Element parent) {
319317 private static final Pattern DOCKER_ARG = Pattern .compile ("^ARG\\ s+(.*)$" , Pattern .CASE_INSENSITIVE );
320318
321319 // Joins a possibly backslash-continued logical instruction line, starting at lines[startIdx].
322- // No separator is inserted between joined parts (matching python) -- a space survives only if
320+ // No separator is inserted between joined parts -- a space survives only if
323321 // it was already present before the continuation backslash on the physical line.
324322 private static final class Joined {
325323 final String text ;
@@ -346,8 +344,8 @@ private static Joined joinContinuations(String[] lines, int startIdx) {
346344 * Whitespace-split {@code s}, except inside a matching quote span (a quoted value may contain
347345 * spaces) or right after an unquoted {@code \} (a backslash escapes the next character). Quote
348346 * characters stay IN the returned tokens, stripped afterward by {@link #envValue} so there is
349- * one quote-stripping implementation, not two. Direct port of python 's {@code
350- * _split_ws_respecting_quotes}, for Docker's shell-style {@code ENV} splitting.
347+ * one quote-stripping implementation, not two. This is Docker 's shell-style {@code ENV}
348+ * splitting.
351349 */
352350 private static List <String > splitWsRespectingQuotes (String s ) {
353351 List <String > tokens = new ArrayList <>();
@@ -514,8 +512,8 @@ private static List<Entry> parseEnvFile(String text) {
514512 // placeholder / Maven property, e.g. `${spring.datasource.url}`), unlike a shell env var --
515513 // hence the braced identifier class allows `.` where the bare one deliberately does not (a
516514 // shell variable name never contains a dot). No `${{ ... }}` template or `%(name)s`
517- // percent-interpolation form: those are python-reference-only vocabulary the brief does not
518- // name for Java. --------------------------------------------------------------------------
515+ // percent-interpolation form: neither is Java vocabulary, and the brief does not name them.
516+ // ---------------- --------------------------------------------------------------------------
519517
520518 private static final Pattern REF_BRACED = Pattern .compile ("\\ $\\ {[A-Za-z_][A-Za-z0-9_.]*\\ }" );
521519 private static final Pattern REF_BARE = Pattern .compile ("\\ $[A-Za-z_][A-Za-z0-9_]*" );
0 commit comments