Fix: --source-type is now honoured for stdin and for existing non-.java files#2048
Conversation
Reviewer's GuideThis PR introduces a File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey @lutzleonhardt - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟡 Testing: 1 issue found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
quintesse
left a comment
There was a problem hiding this comment.
Looks really good, just a couple of small changes and questions.
884e0ba to
2a1d492
Compare
|
@quintesse Thanks for your feedback. I have implemented your suggestions so far. Let me know if something is wrong or missing -thx. |
quintesse
left a comment
There was a problem hiding this comment.
Still some minor changes to be made, but almost there!
|
Let's iterate on it until it's satisfying :) Thanks for you input, let me know when something is missing |
6df4f37 to
4ac565d
Compare
4ac565d to
504d68f
Compare
504d68f to
1d047e4
Compare
|
@quintesse Anything missing here from my side? Thanks |
|
@lutzleonhardt if you have the time you can take a look at why the IT tests are failing. If not I'll look into it as soon as aI have some time. |
|
just testing this and at first glance it solves the reported bug (good) but it also introduce a regression and fail at handling this:
it does not save as a helloworld.java file but instead _helloworld.java which worked previously. Thats what the failed itests is about. |
|
I've added code to detect identifers so it wont add _ unless really need to. wdyt? @quintesse wiremock generated new files from foojay. expected i guess? |
…ringToResourceRef method)
004ed90 to
2a8a595
Compare
|
the pr was blocked/failing due to bad formatting. pushed update with that done. |
Closes #1975
🐞 Problem
pbpaste | jbang --source-type=java -.jshand executed via JShelljbang --source-type=java myscript.jshmyscript.jsh.java→javac“bad file name” error🔧 What changed
forceTypeparameter and always prefers it over auto-detection when caching stdin.--source-typeis supplied, we strip the original extension before adding the forced one(
myscript.jsh➜myscript.javainstead ofmyscript.jsh.java).✅ Tests
Added
TestSourceTypewith two cases:stdinHonoursForceType()– verifies that piping to-is handled as Java when requested.forceJavaOnJshFile()– verifies that forcing Java on a.jshfile succeeds and does not generate a.jsh.jar.Manual test

♻ Regression risk
Localised to two resolvers; no logic elsewhere changed. Existing behaviour for regular
.java,.jsh, remote, and gav resources stays untouched.🙌 Credits
Most of the root-cause analysis was assisted by Brokk AI.
If you’re curious, I recorded the full debugging session:
https://youtu.be/t_7MqowT638?si=QVySbqoy0mqLcljz
(24 min video – optional to watch, of course).
📋 Checklist
--enable-previewworkflow verified manuallySummary by Sourcery
Fix handling of --source-type for piped input and existing non-.java scripts by propagating the forced source type through both LiteralScriptResourceResolver and RenamingScriptResourceResolver, and add tests to verify the corrected behavior.
Bug Fixes:
Enhancements:
Tests: