Skip to content

Add slots and replace/rename functionality. - #40

Open
bterlson wants to merge 15 commits into
alloy-framework:mainfrom
bterlson:slots
Open

Add slots and replace/rename functionality.#40
bterlson wants to merge 15 commits into
alloy-framework:mainfrom
bterlson:slots

Conversation

@bterlson

Copy link
Copy Markdown
Contributor

No description provided.

@github-actions

github-actions Bot commented Oct 29, 2024

Copy link
Copy Markdown
Contributor

❌ There is undocummented changes. Run chronus add to add a changeset or click here.

The following packages have changes but are not documented.

  • @alloy-js/core
  • @alloy-js/java
  • @alloy-js/typescript
Show changes

@pkg-pr-new

pkg-pr-new Bot commented Oct 29, 2024

Copy link
Copy Markdown

Open in Stackblitz

@alloy-js/babel-plugin

pnpm add https://pkg.pr.new/alloy-framework/alloy/@alloy-js/babel-plugin@40

@alloy-js/babel-preset

pnpm add https://pkg.pr.new/alloy-framework/alloy/@alloy-js/babel-preset@40

@alloy-js/babel-plugin-jsx-dom-expressions

pnpm add https://pkg.pr.new/alloy-framework/alloy/@alloy-js/babel-plugin-jsx-dom-expressions@40

@alloy-js/core

pnpm add https://pkg.pr.new/alloy-framework/alloy/@alloy-js/core@40

@alloy-js/csharp

pnpm add https://pkg.pr.new/alloy-framework/alloy/@alloy-js/csharp@40

@alloy-js/java

pnpm add https://pkg.pr.new/alloy-framework/alloy/@alloy-js/java@40

@alloy-js/prettier-plugin-alloy

pnpm add https://pkg.pr.new/alloy-framework/alloy/@alloy-js/prettier-plugin-alloy@40

@alloy-js/typescript

pnpm add https://pkg.pr.new/alloy-framework/alloy/@alloy-js/typescript@40

commit: 7443b42

@jongio jongio left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

A few issues to address:

javaslots.ts has a debug console.log that should be removed before merge, and transformJavaFqn has dead code (the if (index < parts.length) condition is always true in a .map() callback).

binder.ts has a minor inconsistency where a computed key variable is defined but then name.replace(...) is used directly on the next line instead.

Tests: The rename tests log output to the console but don't assert on it. These tests will pass regardless of actual behavior.

Also noting: this PR currently has merge conflicts and is missing a changeset (per the chronus bot).

isStatic ? "_" + memberName
: "." + memberName
: "");
console.log("Resolved Java FQN", fqn);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This console.log looks like debug output that shouldn't ship. Remove it before merge.

return parts
.map((part, index) => {
if (index < parts.length) {
return parts.slice(0, index + 1).join("_");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The condition if (index < parts.length) is always true when iterating with .map() (index goes from 0 to length-1). The else branch is unreachable dead code. You can remove the conditional and just return the parts.slice(0, index + 1).join("_") directly.

Also worth adding a doc comment explaining what this function produces. For input "com.example.service" it outputs "com.com_example.com_example_service" (cumulative underscore-joined prefixes). That behavior isn't obvious from reading the code.

return waiting.get(key) as Ref<TScope | undefined>;
}

const scopeRef = shallowRef<OutputScope | undefined>(undefined);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Line 873 defines const key = name.replace(/\./g, "_") but this line uses name.replace(/\./g, "_") again instead of reusing key. Minor inconsistency.

console.log(tree.contents[0].contents);
});

it("can rename the same thing, last wins", () => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This test (and the "can rename the same thing, last wins" test below it) ends with console.log(...) but has no expect() assertions. The test will always pass regardless of actual output. Consider adding assertions that verify the rename actually took effect in the rendered tree.

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.

3 participants