Skip to content

Commit

Permalink
🚧 Remove attributed type in favor of attributes array on all types (S…
Browse files Browse the repository at this point in the history
  • Loading branch information
NeunEinser authored May 23, 2024
1 parent d99eeb6 commit 6439d5f
Show file tree
Hide file tree
Showing 10 changed files with 541 additions and 334 deletions.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions packages/java-edition/src/json/checker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ export function fieldValue(type: mcdoc.McdocType): core.SyncChecker<JsonNode> {
type.kind !== 'literal' &&
type.kind !== 'reference' &&
type.kind !== 'union' &&
type.kind !== 'attributed' &&
type.kind !== 'unsafe' &&
type.kind !== 'concrete' &&
type.kind !== 'indexed' &&
Expand Down Expand Up @@ -340,10 +339,6 @@ export function fieldValue(type: mcdoc.McdocType): core.SyncChecker<JsonNode> {
)(node, ctx)
}
break
case 'attributed':
// TODO: don't just ignore the attribute
fieldValue(type.child)(node, ctx)
break
}
}
}
Expand Down
26 changes: 12 additions & 14 deletions packages/mcdoc/src/binder/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,7 @@ function hoist(node: ModuleNode, ctx: McdocBinderContext): void {
if (typeParams) {
bindTypeParamBlock(node, typeParams, ans, ctx)
}
ans.typeDef = attributeType(ans.typeDef, attributes, ctx)

appendAttributes(ans.typeDef, attributes, ctx)
return ans
})
}
Expand Down Expand Up @@ -397,7 +396,7 @@ async function bindDispatchStatement(
if (typeParams) {
bindTypeParamBlock(node, typeParams, data, ctx)
}
data.typeDef = attributeType(data.typeDef, attributes, ctx)
appendAttributes(data.typeDef, attributes, ctx)

for (const key of parallelIndices) {
if (DynamicIndexNode.is(key)) {
Expand Down Expand Up @@ -848,25 +847,24 @@ function wrapType(
}
}
}
ans = attributeType(ans, attributes, ctx)
ans.attributes = convertAttributes(attributes, ctx)
return ans
}

function attributeType(
type: McdocType,
function appendAttributes(
typeDef: McdocType,
attributes: AttributeNode[],
ctx: McdocBinderContext,
): McdocType {
for (const attribute of attributes) {
type = {
kind: 'attributed',
attribute: convertAttribute(attribute, ctx),
child: type,
) {
const convertedAttributes = convertAttributes(attributes, ctx)
if (convertedAttributes) {
if (typeDef.attributes) {
typeDef.attributes = [...typeDef.attributes, ...convertedAttributes]
} else {
typeDef.attributes = convertedAttributes
}
}
return type
}

function convertAttributes(
nodes: AttributeNode[],
ctx: McdocBinderContext,
Expand Down
Loading

0 comments on commit 6439d5f

Please sign in to comment.