@@ -120,7 +120,7 @@ function isEventHandler(p: Browser.Property) {
120
120
return typeof p [ "event-handler" ] === "string" ;
121
121
}
122
122
123
- export function emitWebIDl ( webidl : Browser . WebIdl , flavor : Flavor ) {
123
+ export function emitWebIdl ( webidl : Browser . WebIdl , flavor : Flavor ) {
124
124
// Global print target
125
125
const printer = createTextWriter ( "\n" ) ;
126
126
@@ -573,21 +573,12 @@ export function emitWebIDl(webidl: Browser.WebIdl, flavor: Flavor) {
573
573
! ! iNameToEhList [ i . name ] . find ( e => e . name === p . name ) ) ;
574
574
}
575
575
576
- function emitProperty ( prefix : string , i : Browser . Interface , emitScope : EmitScope , p : Browser . Property , conflictedMembers : Set < string > ) {
577
- function printLine ( content : string ) {
578
- if ( conflictedMembers . has ( p . name ) ) {
579
- printer . printLineToStack ( content ) ;
580
- }
581
- else {
582
- printer . printLine ( content ) ;
583
- }
584
- }
585
-
586
- emitComments ( p , printLine ) ;
576
+ function emitProperty ( prefix : string , i : Browser . Interface , emitScope : EmitScope , p : Browser . Property ) {
577
+ emitComments ( p , printer . printLine ) ;
587
578
588
579
// Treat window.name specially because of https://github.com/Microsoft/TypeScript/issues/9850
589
580
if ( p . name === "name" && i . name === "Window" && emitScope === EmitScope . All ) {
590
- printLine ( "declare const name: never;" ) ;
581
+ printer . printLine ( "declare const name: never;" ) ;
591
582
}
592
583
else {
593
584
let pType : string ;
@@ -610,7 +601,7 @@ export function emitWebIDl(webidl: Browser.WebIdl, flavor: Flavor) {
610
601
const requiredModifier = p . required === undefined || p . required === 1 ? "" : "?" ;
611
602
pType = p . nullable ? makeNullable ( pType ) : pType ;
612
603
const readOnlyModifier = p [ "read-only" ] === 1 && prefix === "" ? "readonly " : "" ;
613
- printLine ( `${ prefix } ${ readOnlyModifier } ${ p . name } ${ requiredModifier } : ${ pType } ;` ) ;
604
+ printer . printLine ( `${ prefix } ${ readOnlyModifier } ${ p . name } ${ requiredModifier } : ${ pType } ;` ) ;
614
605
}
615
606
}
616
607
@@ -623,17 +614,17 @@ export function emitWebIDl(webidl: Browser.WebIdl, flavor: Flavor) {
623
614
}
624
615
}
625
616
626
- function emitProperties ( prefix : string , emitScope : EmitScope , i : Browser . Interface , conflictedMembers : Set < string > ) {
617
+ function emitProperties ( prefix : string , emitScope : EmitScope , i : Browser . Interface ) {
627
618
if ( i . properties ) {
628
619
mapToArray ( i . properties . property )
629
620
. filter ( m => matchScope ( emitScope , m ) )
630
621
. filter ( p => ! isCovariantEventHandler ( i , p ) )
631
622
. sort ( compareName )
632
- . forEach ( p => emitProperty ( prefix , i , emitScope , p , conflictedMembers ) ) ;
623
+ . forEach ( p => emitProperty ( prefix , i , emitScope , p ) ) ;
633
624
}
634
625
}
635
626
636
- function emitMethod ( prefix : string , _i : Browser . Interface , m : Browser . Method , conflictedMembers : Set < string > ) {
627
+ function emitMethod ( prefix : string , m : Browser . Method , conflictedMembers : Set < string > ) {
637
628
function printLine ( content : string ) {
638
629
if ( m . name && conflictedMembers . has ( m . name ) ) {
639
630
printer . printLineToStack ( content ) ;
@@ -682,7 +673,7 @@ export function emitWebIDl(webidl: Browser.WebIdl, flavor: Flavor) {
682
673
mapToArray ( i . methods . method )
683
674
. filter ( m => matchScope ( emitScope , m ) && ! ( prefix !== "" && ( m . name === "addEventListener" || m . name === "removeEventListener" ) ) )
684
675
. sort ( compareName )
685
- . forEach ( m => emitMethod ( prefix , i , m , conflictedMembers ) ) ;
676
+ . forEach ( m => emitMethod ( prefix , m , conflictedMembers ) ) ;
686
677
}
687
678
688
679
// The window interface inherited some methods from "Object",
@@ -708,7 +699,7 @@ export function emitWebIDl(webidl: Browser.WebIdl, flavor: Flavor) {
708
699
/// Emit the properties and methods of a given interface
709
700
function emitMembers ( prefix : string , emitScope : EmitScope , i : Browser . Interface ) {
710
701
const conflictedMembers = extendConflictsBaseTypes [ i . name ] ? extendConflictsBaseTypes [ i . name ] . memberNames : new Set ( ) ;
711
- emitProperties ( prefix , emitScope , i , conflictedMembers ) ;
702
+ emitProperties ( prefix , emitScope , i ) ;
712
703
const methodPrefix = prefix . startsWith ( "declare var" ) ? "declare function " : "" ;
713
704
emitMethods ( methodPrefix , emitScope , i , conflictedMembers ) ;
714
705
if ( emitScope === EmitScope . InstanceOnly ) {
0 commit comments