Add @Generated annotation to PObserve generated Java classes#941
Open
ylecaillez wants to merge 1 commit intop-org:masterfrom
Open
Add @Generated annotation to PObserve generated Java classes#941ylecaillez wants to merge 1 commit intop-org:masterfrom
ylecaillez wants to merge 1 commit intop-org:masterfrom
Conversation
Contributor
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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