Skip to content

Enforce proper identifiers in tests#8026

Draft
greg-at-moderne wants to merge 4 commits into
mainfrom
greg-scala-identifier-validation
Draft

Enforce proper identifiers in tests#8026
greg-at-moderne wants to merge 4 commits into
mainfrom
greg-scala-identifier-validation

Conversation

@greg-at-moderne

@greg-at-moderne greg-at-moderne commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

What's changed?

Amending the test harness to add a new check. This is for enforcing that the identifiers contain only these characters which are allowed for given language.

What's your motivation?

The typical situation this check catches is when the parsing stuffs too much into a single J.Identifier. The round-trip idempotency printing test doesn't necessarily catch that.

I caught several cases like this recently in Scala. But the idea is more universal, thus the generic solution.

@greg-at-moderne greg-at-moderne self-assigned this Jun 16, 2026
@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Jun 16, 2026
@greg-at-moderne greg-at-moderne force-pushed the greg-scala-identifier-validation branch from f5e15ae to c98bdea Compare June 16, 2026 11:09
The service() overrides in G, K, JS and S resolved known services inside a
try that also held the JavaSourceFile.super.service(...) delegation for
unknown services. Their catch (Exception) then re-wrapped the
UnsupportedOperationException thrown for unsupported services in a
RuntimeException. Callers that probe for an optional service (e.g. the
test framework's identifier-name validation) catch
UnsupportedOperationException and so could not recognize the wrapped form.

Move the super.service(...) delegation outside the try so the
UnsupportedOperationException propagates unwrapped, matching the bare
behavior of the other language SourceFile implementations.
@greg-at-moderne greg-at-moderne changed the title Scala: enforce proper identifiers Scala, Groovy, Kotlin, Java: enforce proper identifiers Jun 17, 2026
@greg-at-moderne greg-at-moderne changed the title Scala, Groovy, Kotlin, Java: enforce proper identifiers Scala, Groovy, Kotlin, JavaScript: enforce proper identifiers Jun 17, 2026
@greg-at-moderne greg-at-moderne changed the title Scala, Groovy, Kotlin, JavaScript: enforce proper identifiers Enforce proper identifiers in tests Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

1 participant