Repository navigation
Feature/issue 9 cross file extension - #13
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…mports) - Replace ConcurrentHashMap/Supplier with HashMap/Factory for GWT compat - Add instanceof-based visitor dispatch for extension types - Specify import path resolution and transitive import support - Document AST changes and bootstrapping impact - OpenWorld implies NoBinary + NoXml - Expand test plan with edge cases - Add registration class naming convention Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
XML uses string-based type names like JSON, so there are no type-ID conflict issues. Only binary serialization is excluded. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Simplifies implementation by avoiding the NoInterfaces code path for OpenWorld protocols. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The generator doesn't know the target platform, so ServiceLoader logic belongs in the runtime library with graceful fallback for GWT/JS environments. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
12 tasks covering: runtime API, AST changes, parser, import resolution, OpenWorld validation, code generation (registry, visitor, registration classes), NameTable cross-package lookup, Maven plugin, and tests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add `repeated string imports` to DefinitionFile in proto.proto to support cross-file proto references. Also fix proto.proto/Java sync by moving the shared `index` field from Constant up to Part (where it already lived in the previously committed Java) and regenerate all AST classes. All 67 generator tests pass. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add IMPORT token and import parsing rule to the JavaCC grammar so that proto files can declare zero or more `import "path/to/file.proto";` statements after the package declaration and before option statements. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When resolving a QName like 'test.openworld.base.SSEEvent', the lookup now tries progressively longer package prefixes as fallback, enabling cross-file type references. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Track loaded files by canonical path to prevent duplicate loads and circular imports - Resolve import statements by searching relative to source file then configured include paths (-I flag) - Imported files participate in name resolution and specialization building but do not produce generated output - OpenWorld option implies NoBinary and is incompatible with NoInterfaces - Skip TypeIdSynthesizer for OpenWorld files Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add OpenWorld-specific code generation to MessageGenerator: - Registry (Map + register method) on abstract root types - Registry lookup in default case of polymorphic JSON reader - TypeRegistryLoader.ensureLoaded() call before deserialization switch - visitDefault() method on Visitor interface for unknown subtypes - Extension Visitor interface on cross-file extension types - instanceof-based visit dispatch for cross-file extensions Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When an extension .proto file defines types that extend an abstract type from an imported OpenWorld protocol, the generator now produces a registration class (e.g., Ext1Types) that implements TypeRegistration and registers each concrete extension type with the root OpenWorld type's factory registry. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Fix cross-file extension type extends clause using wrong package casing (camelCase was applied to all QName parts). Use resolved Definition for fully-qualified type references. Propagate NoBinary from OpenWorld base to extension files. Generate kind() returning null for cross-file extension types not in the base TypeKind enum. Make PROPERTIES and TRANSIENT_PROPERTIES protected in OpenWorld hierarchies for cross-package access. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Generate Java code from test proto files (base/SSEEvent, ext1/GraphPatchEvent, ext2/AnalyticsPatchEvent) and add TestOpenWorld with 6 test cases covering: - Base type JSON round-trip - Extension type registration and deserialization - Multiple extension types - Visitor dispatch to visitDefault for unknown extensions - Extended visitor with instanceof-based routing - Unknown type graceful handling (returns null) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The extends clause fix now uses resolved Definition objects, producing fully-qualified type names in extends clauses. This is a cosmetic change with no behavioral impact. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Instead of calling ensureLoaded() on every readXxx() invocation, trigger it once via a static initializer block in the abstract Impl class. This runs exactly once at class-loading time. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Generator writes ServiceLoader descriptor to a separate resource output directory specified via -resources CLI arg - Maven plugin passes resourceOutputDir to generator - TypeRegistryLoader.ensureLoaded() moved to static initializer in Impl class (runs once at class-loading, not per deserialization) - Test uses auto-loading via ServiceLoader instead of explicit init() Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
target/classes is the compiled output, not a source directory. Generated service descriptors must go through the normal Maven resource processing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There is no reliable Maven variable for the resource source directory. Users must configure resourceOutputDir explicitly when using OpenWorld. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Better to have a visible default that might need adjusting than to silently skip service descriptor generation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When generating code for an OpenWorld protocol, the Visitor interface, type dispatch switch, and TypeKind enum now only include specializations from the same proto file. Cross-file extensions are handled at runtime via the dynamic registry. The filtering is implemented in AbstractMessageGenerator so that all plugins (including XmlStreamingPlugin) benefit automatically. Also: - Move TypeRegistryLoader.ensureLoaded() to static initializer in Impl - Generate META-INF/services descriptor via -resources CLI arg - Add resourceOutputDir to Maven plugin - TestParser sets include paths and resource dir for OpenWorld protos - Test uses ServiceLoader auto-discovery instead of explicit init() Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Proto files packaged as resources in dependency JARs can now be imported without having the source files on disk. The generator tries file system resolution first, then falls back to classpath. Generator changes: - New setImportClassLoader() API for classpath-based resolution - New -cp CLI argument for standalone usage - resolveImports() tries file system first, then classpath - Extracted loadPlugins() as public method Maven plugin changes: - Uses Generator API directly instead of main() CLI - Automatically builds URLClassLoader from compile classpath - requiresDependencyResolution = COMPILE on @mojo Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Imports are resolved from dependency JARs automatically in Maven. For CLI usage, the -cp argument specifies JARs to search. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Fixes #9