-
Notifications
You must be signed in to change notification settings - Fork 453
Feature: Add method handling to mixin processing in KDL #2100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
a62a343
e3f0a20
d7e96fb
a88fbed
2fcb5b9
e6da694
37825cf
c095db7
9682083
6aa05dd
8f7ca28
0741374
7338aab
333fb26
ea16eb1
fcd4188
c5dcd9e
58e6d23
8c2aa44
03d4afe
2cfa765
bd68c2d
0693d5d
12566ec
7da25a0
c4ba8c8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Manually moved from Document | ||
// See https://github.com/w3c/csswg-drafts/issues/5886 and https://github.com/w3c/csswg-drafts/issues/556 | ||
interface-mixin DocumentOrShadowRoot { | ||
method elementFromPoint returns="Element | null" { | ||
param x type=number | ||
param y type=number | ||
} | ||
method elementsFromPoint returns="Element[]" { | ||
param x type=number | ||
param y type=number | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,5 +1,5 @@ | ||||||||||||||||||||||||||||
import { parse, type Node } from "kdljs"; | ||||||||||||||||||||||||||||
import type { Enum, Event, Property, Interface, WebIdl } from "./types"; | ||||||||||||||||||||||||||||
import type { Enum, Event, Property, Interface, WebIdl, Method } from "./types"; | ||||||||||||||||||||||||||||
import { readdir, readFile } from "fs/promises"; | ||||||||||||||||||||||||||||
import { merge } from "./helpers.js"; | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
|
@@ -76,6 +76,7 @@ function handleMixin(node: Node): DeepPartial<Interface> { | |||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
const event: Event[] = []; | ||||||||||||||||||||||||||||
const property: Record<string, Partial<Property>> = {}; | ||||||||||||||||||||||||||||
const method: Record<string, Partial<Method>> = {}; | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
for (const child of node.children) { | ||||||||||||||||||||||||||||
switch (child.name) { | ||||||||||||||||||||||||||||
|
@@ -87,6 +88,11 @@ function handleMixin(node: Node): DeepPartial<Interface> { | |||||||||||||||||||||||||||
property[propName] = handleProperty(child); | ||||||||||||||||||||||||||||
break; | ||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||
case "method": { | ||||||||||||||||||||||||||||
const methodName = child.values[0] as string; | ||||||||||||||||||||||||||||
method[methodName] = handleMethod(child); | ||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Fine for now but eventually this will need to change to support overloads) |
||||||||||||||||||||||||||||
break; | ||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||
default: | ||||||||||||||||||||||||||||
throw new Error(`Unknown node name: ${child.name}`); | ||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||
|
@@ -96,6 +102,7 @@ function handleMixin(node: Node): DeepPartial<Interface> { | |||||||||||||||||||||||||||
name, | ||||||||||||||||||||||||||||
events: { event }, | ||||||||||||||||||||||||||||
properties: { property }, | ||||||||||||||||||||||||||||
methods: { method }, | ||||||||||||||||||||||||||||
} as DeepPartial<Interface>; | ||||||||||||||||||||||||||||
if (node.properties.extends) { | ||||||||||||||||||||||||||||
result.extends = node.properties.extends as string; | ||||||||||||||||||||||||||||
|
@@ -125,6 +132,19 @@ function handleProperty(child: Node): Partial<Property> { | |||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||
* Handles a child node of type "method" and adds it to the method object. | ||||||||||||||||||||||||||||
* @param child The child node to handle. | ||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||
function handleMethod(child: Node): Partial<Method> { | ||||||||||||||||||||||||||||
const name = child.values[0] as string; | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
// Build the overrideSignatures array with the method signature string | ||||||||||||||||||||||||||||
const overrideSignatures = [ | ||||||||||||||||||||||||||||
|
} else if (member.type === "operation") { | |
const operation = convertOperation(member, result.exposed); | |
const { method } = result.methods; | |
if (!member.name) { | |
result.anonymousMethods!.method.push(operation); | |
} else if (method.hasOwnProperty(member.name)) { | |
method[member.name].signature.push(...operation.signature); | |
} else { | |
method[member.name] = operation as Browser.Method; | |
} | |
if (member.name) { | |
addComments(method[member.name], commentMap, i.name, member.name); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cssom-view.kdl