Ccodemod

codemod/spring7-requestcontext-jstl-present

Rename Java references to Spring Web MVC RequestContext.jstPresent so they use RequestContext.JSTL_PRESENT for Spring Framework 7.

upgradebreaking-changejavaspring-frameworkv6-to-v7
Public
1 executions

Run locally

npx codemod @codemod/spring7-requestcontext-jstl-present

@codemod/spring7-requestcontext-jstl-present

Rename Java references to Spring Web MVC RequestContext.jstPresent so they use RequestContext.JSTL_PRESENT for Spring Framework 7.

Installation

bash

Usage

This codemod targets Java source files and renames only AST-backed member references that can be confidently matched to Spring's org.springframework.web.servlet.support.RequestContext.jstPresent field.

It rewrites:

  • RequestContext.jstPresent when RequestContext is imported from Spring Web MVC
  • org.springframework.web.servlet.support.RequestContext.jstPresent
  • SomeSubclass.jstPresent when SomeSubclass is a uniquely resolvable in-file subclass of Spring's RequestContext
  • inherited bare accesses like jstPresent, this.jstPresent, and super.jstPresent inside confidently resolvable subclasses, including nested, local, and anonymous classes
  • exact static imports of org.springframework.web.servlet.support.RequestContext.jstPresent and matching bare usages

It does not rewrite:

  • string literals, comments, Javadoc, or reflection strings like "jstPresent"
  • unrelated classes or user-defined fields named jstPresent
  • ambiguous bare identifiers when the enclosing class hierarchy or symbol target cannot be resolved conservatively from the current file
  • non-Java files

By default the workflow excludes common generated-source directories. To include them, run the workflow with --param includeGeneratedSources=true.

Examples:

java

becomes:

java
java

becomes:

java

Development

bash

License

MIT

Ready to contribute?

Build your own codemod and share it with the community.