News for hackers. Stuff that matters.
Re:Pure Java Typesetting System by thangalin on Monday January 23, 2023 @01:38PM (#34493025)
> but the workaround is trivial.

If you have a trivial solution to rename hundreds of Java classes and their references en masse without breaking the build and without renaming each file one-at-a-time, do tell. You can find more details about potential solutions I've tried here:

https://stackoverflow.com/questions/75154524/bulk-rename-of-...

Re:Pure Java Typesetting System by playingalong on Monday January 23, 2023 @01:47PM (#34493131)
I bet Open Rewrite can handle that quite easily: https://docs.openrewrite.org/
Re:Pure Java Typesetting System by thangalin on Monday January 23, 2023 @02:03PM (#34493367)
I wasn't able to find a recipe that performs a regular expression rename. That is, there doesn't seem to be anything like:

    ---
    type: specs.openrewrite.org/v1beta/recipe
    name: com.yourorg.ChangeTypeExample
    displayName: Change type example
    recipeList:
      - org.openrewrite.java.ChangeType:
          oldFullyQualifiedTypeName: (.+)
          newFullyQualifiedTypeName: Kt$1
Re:Pure Java Typesetting System by Someone on Monday January 23, 2023 @02:17PM (#34493544)
I would do that the hacker way:

- build the current TeX.jar

- jar tf TeX.jar | grep whatever to get a list of to-be-renamed classes

- use sed or manual editing to generate a large list of recipes

- run those recipes

Instead of jar tf, grep for “^package foo.bar.baz” and “class (complex regex)” in the source code to get a list of package and class names, or use the directory structure. Maybe do all of them, and compare the results for robustness.

That list will be large and it may not go perfect in one go, but it’s a one-off job, and you‘ll get there.

Re:Pure Java Typesetting System by dangerlibrary on Monday January 23, 2023 @01:50PM (#34493176)
This feels like something where the right solution is to drop down to the terminal and use the old standbys - sed/grep/find, etc. Could probably wrap it all up in `make` or `just` if this is something you do regularly.
Re:Pure Java Typesetting System by thangalin on Monday January 23, 2023 @02:05PM (#34493398)
It's not trivial. Some class names are substrings of other classes. I'm pretty sure this requires loading and parsing the source code's AST to accomplish without breaking the build. The SO thread goes into more gnarly details.
Re:Pure Java Typesetting System by dangerlibrary on Tuesday January 24, 2023 @01:03PM (#34507381)
Sorry, I didn't mean to imply it was trivial, by any means. Just that there are powerful tools for "manipulating many line-delimited text files at once" and those tools seem likely to fit your goal.

It's possible you do in fact need to parse the AST for your goals - I haven't spent the requisite time to deeply understand the problem.

Re:Pure Java Typesetting System by dcminter on Monday January 23, 2023 @02:08PM (#34493438)
Edit: Never mind, whartung enlightened me in a sibling comment. Leaving the egg on my face for posterity below.

---

Why do you want to change all the files? The license only says you have to change the names of files that you modify. It's a pretty weird term.

If for some reason you were determined to change the names of all files then you ought to be able to create a plugin that walks the tree of classes and invokes the refactoring capabilities of the IDE to make the change. It's a strange use-case though so I'm not really surprised there isn't a ready tool for it.

Re:Pure Java Typesetting System by thangalin on Monday January 23, 2023 @02:27PM (#34493679)
> Why do you want to change all the files?

Ever pull on a thread to unravel an entire sweater?

Imagine wanting to add an SVG typesetter. To do this, the interface implemented by the DVI typesetter needs to be extracted and generalized so that it works for both SVG and DVI (to maintain existing behaviour). The `Typesetter` interface is used by, for example, `BaseNode`, so any changes to that interface could touch `BaseNode`. Changes to `BaseNode` can affect all `*Node` classes, which then cascade over to `*Noad` and `*Prim` classes, and from there the rest of the source base.

Re:Pure Java Typesetting System by counttheforks on Monday January 23, 2023 @02:43PM (#34493890)
Posted a solution on your other comment: https://news.ycombinator.com/item?id=34493760