Extract shared boundary_common utilities from duplicated frontend code#2
Merged
Merged
Conversation
Seven boundary language frontends (Clojure, Crystal, D, Hare, Nim, Odin, VB) plus the ECMAScript boundary all duplicated the same scaffolding: read a file, parse source, extract inline boundary JSON from the first-line comment, combine semantic + boundary into a CompileArtifact, and inject a default main function. New module compiler::boundary_common provides: - parse_file_with: generic file-read + parse dispatch - parse_artifact_with: file-read + parse + boundary extraction - artifact_from_source: semantic + boundary -> CompileArtifact - extract_boundary_from_comment: first-line JSON extraction with configurable comment prefixes - ensure_main: append default main if none present Each frontend now delegates to these helpers and only retains its language- specific declaration parsing logic. Eliminates ~250 lines of duplicated code across 8 files while preserving identical behavior (all existing tests pass). Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Latest stable rustfmt (1.96.0) reformats several long lines that were previously accepted. This is a whole-crate format pass. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Replace or_else(|| match ...) with or(match ...) where the closure captures no state (unnecessary_lazy_evaluations), and collapse nested if into if-let chain (collapsible_if). Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.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.
Summary
Seven boundary language frontends (Clojure, Crystal, D, Hare, Nim, Odin, VB) plus ECMAScript all duplicated identical scaffolding for file I/O, artifact assembly, boundary JSON extraction, and main-function injection. This PR factors that boilerplate into a new
compiler::boundary_commonmodule, eliminating ~250 lines of repetition across 8 files.New shared helpers in
boundary_common:Each frontend now declares only a
BOUNDARY_PREFIXESconst and its language-specific parsing logic, delegating everything else to the shared module. Behavior is unchanged—all existing boundary tests pass.Link to Devin session: https://app.devin.ai/sessions/044d1730fc5f41e2ae796230b73a3482
Requested by: @undivisible