Skip to content

Add @Generated annotation to PObserve generated Java classes#941

Open
ylecaillez wants to merge 1 commit intop-org:masterfrom
ylecaillez:feature/pobserve-generated-annotation
Open

Add @Generated annotation to PObserve generated Java classes#941
ylecaillez wants to merge 1 commit intop-org:masterfrom
ylecaillez:feature/pobserve-generated-annotation

Conversation

@ylecaillez
Copy link
Copy Markdown

@ylecaillez ylecaillez commented Mar 26, 2026

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

/***************************************************************************
 * This file was auto-generated on Saturday, 11 April 2026 at 05:20:27 UTC.
 * Please do not edit manually!
 **************************************************************************/
...
@Generated(value = "P Compiler", date = "2026-04-11T05:20:27Z")
public class PMachines {
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% P <-> Java Foreign Function Interface Stubs
% 
% This file was auto-generated on Saturday, 11 April 2026 at 05:20:27 UTC.
%

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.Generated on PTypes, PEvents, and PMachines generated Java classes.
  • Add javax.annotation.processing.Generated to default imports for generated Java sources.
  • Capture a single GenerationTimestamp once 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.

Comment thread Src/PCompiler/CompilerCore/Backend/PObserve/Constants.cs Outdated
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.
@ylecaillez ylecaillez force-pushed the feature/pobserve-generated-annotation branch from 112f98d to f0caf56 Compare April 11, 2026 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants