Add @Generated annotation to PObserve generated Java classes#941
Add @Generated annotation to PObserve generated Java classes#941ylecaillez wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the PObserve Java backend code generator to embed a Java @Generated annotation directly into the generated top-level Java classes (types, events, machines), and centralizes timestamp generation so file headers/annotations can share a single generation timestamp.
Changes:
- Emit
@javax.annotation.processing.GeneratedonPTypes,PEvents, andPMachinesgenerated Java classes. - Add
javax.annotation.processing.Generatedto default imports for generated Java sources. - Capture a single
GenerationTimestamponce and reuse it for the “do not edit” banner and FFI banner strings.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| Src/PCompiler/CompilerCore/Backend/PObserve/TypesGenerator.cs | Emits Constants.GeneratedAnnotation before the PTypes class declaration. |
| Src/PCompiler/CompilerCore/Backend/PObserve/MachineGenerator.cs | Emits Constants.GeneratedAnnotation before the PMachines class declaration. |
| Src/PCompiler/CompilerCore/Backend/PObserve/EventGenerator.cs | Emits Constants.GeneratedAnnotation before the PEvents class declaration. |
| Src/PCompiler/CompilerCore/Backend/PObserve/Constants.cs | Adds a shared GenerationTimestamp, the generated-annotation string, and the required Java import; reuses the timestamp in existing banners. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Emit @generated(value="P Compiler", date=...) from javax.annotation.processing.Generated on the top-level PTypes, PEvents, and PMachines classes so that tools and IDEs can identify generated code. Also unify the three separate DateTime.Now calls (DoNotEditWarning, FFI banner, and the new annotation) into a single GenerationTimestamp captured once at class-load time, ensuring all output files carry the same timestamp.
112f98d to
f0caf56
Compare
|
Thanks for the PR! One suggestion: I'd vote to drop the timestamp entirely — both the Reasoning: embedding If keeping the banners' human-readable "this is generated" message is desirable, the wording works fine without a timestamp: just Concretely this would simplify the diff a lot — the whole Bonus: if you'd ever want a timestamp back later, the reproducible-builds convention is to honor a (Separately, the Copilot review comment about UTC vs local-time mismatch looks stale — the current diff uses UTC consistently for both the annotation and the banners. Worth dismissing.) |
NOTE: we do have a post compile script which add these @generated annotation at build time but maybe you'll be interested to have this embedded directly in the compiler.
Emit @generated(value="P Compiler", date=...) from javax.annotation.processing.Generated on the top-level PTypes, PEvents, and PMachines classes so that tools and IDEs can identify generated code.
Also unify the three separate DateTime.Now calls (DoNotEditWarning, FFI banner, and the new annotation) into a single GenerationTimestamp captured once at class-load time, ensuring all output files carry the same timestamp.
Example