Skip to content

Commit 3830c31

Browse files
committed
Added ApiProtectedMixin and associated test cases
1 parent 7fab7e6 commit 3830c31

File tree

53 files changed

+322
-82
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+322
-82
lines changed

apps/api-extractor/src/generators/ApiModelGenerator.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,10 +334,12 @@ export class ApiModelGenerator {
334334
const apiItemMetadata: ApiItemMetadata = this._collector.fetchApiItemMetadata(astDeclaration);
335335
const docComment: tsdoc.DocComment | undefined = apiItemMetadata.tsdocComment;
336336
const releaseTag: ReleaseTag = apiItemMetadata.effectiveReleaseTag;
337+
const isProtected: boolean = (astDeclaration.modifierFlags & ts.ModifierFlags.Protected) !== 0;
337338

338339
apiConstructor = new ApiConstructor({
339340
docComment,
340341
releaseTag,
342+
isProtected,
341343
parameters,
342344
overloadIndex,
343345
excerptTokens
@@ -709,11 +711,13 @@ export class ApiModelGenerator {
709711
}
710712
const isOptional: boolean =
711713
(astDeclaration.astSymbol.followedSymbol.flags & ts.SymbolFlags.Optional) !== 0;
714+
const isProtected: boolean = (astDeclaration.modifierFlags & ts.ModifierFlags.Protected) !== 0;
712715

713716
apiMethod = new ApiMethod({
714717
name,
715718
docComment,
716719
releaseTag,
720+
isProtected,
717721
isStatic,
718722
isOptional,
719723
typeParameters,
@@ -846,11 +850,13 @@ export class ApiModelGenerator {
846850
const releaseTag: ReleaseTag = apiItemMetadata.effectiveReleaseTag;
847851
const isOptional: boolean =
848852
(astDeclaration.astSymbol.followedSymbol.flags & ts.SymbolFlags.Optional) !== 0;
853+
const isProtected: boolean = (astDeclaration.modifierFlags & ts.ModifierFlags.Protected) !== 0;
849854

850855
apiProperty = new ApiProperty({
851856
name,
852857
docComment,
853858
releaseTag,
859+
isProtected,
854860
isStatic,
855861
isOptional,
856862
excerptTokens,

build-tests/api-documenter-test/etc/api-documenter-test.api.json

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"metadata": {
33
"toolPackage": "@microsoft/api-extractor",
44
"toolVersion": "[test mode]",
5-
"schemaVersion": 1005,
5+
"schemaVersion": 1006,
66
"oldestForwardsCompatibleVersion": 1001,
77
"tsdocConfig": {
88
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
@@ -255,7 +255,8 @@
255255
"startIndex": 1,
256256
"endIndex": 2
257257
},
258-
"isStatic": false
258+
"isStatic": false,
259+
"isProtected": false
259260
}
260261
],
261262
"implementsTokenRanges": []
@@ -298,6 +299,7 @@
298299
"text": "constructor();"
299300
}
300301
],
302+
"isProtected": false,
301303
"releaseTag": "Public",
302304
"overloadIndex": 1,
303305
"parameters": []
@@ -320,6 +322,7 @@
320322
"text": ");"
321323
}
322324
],
325+
"isProtected": false,
323326
"releaseTag": "Public",
324327
"overloadIndex": 2,
325328
"parameters": [
@@ -400,6 +403,7 @@
400403
],
401404
"isOptional": false,
402405
"isStatic": false,
406+
"isProtected": false,
403407
"returnTypeTokenRange": {
404408
"startIndex": 1,
405409
"endIndex": 2
@@ -445,6 +449,7 @@
445449
],
446450
"isOptional": false,
447451
"isStatic": false,
452+
"isProtected": false,
448453
"returnTypeTokenRange": {
449454
"startIndex": 5,
450455
"endIndex": 6
@@ -499,6 +504,7 @@
499504
],
500505
"isOptional": false,
501506
"isStatic": false,
507+
"isProtected": false,
502508
"returnTypeTokenRange": {
503509
"startIndex": 3,
504510
"endIndex": 4
@@ -567,6 +573,7 @@
567573
],
568574
"isOptional": false,
569575
"isStatic": false,
576+
"isProtected": false,
570577
"returnTypeTokenRange": {
571578
"startIndex": 8,
572579
"endIndex": 9
@@ -618,6 +625,7 @@
618625
],
619626
"isOptional": false,
620627
"isStatic": false,
628+
"isProtected": false,
621629
"returnTypeTokenRange": {
622630
"startIndex": 1,
623631
"endIndex": 2
@@ -653,7 +661,8 @@
653661
"startIndex": 1,
654662
"endIndex": 2
655663
},
656-
"isStatic": false
664+
"isStatic": false,
665+
"isProtected": false
657666
},
658667
{
659668
"kind": "Property",
@@ -681,7 +690,8 @@
681690
"startIndex": 1,
682691
"endIndex": 2
683692
},
684-
"isStatic": false
693+
"isStatic": false,
694+
"isProtected": false
685695
},
686696
{
687697
"kind": "Method",
@@ -711,6 +721,7 @@
711721
],
712722
"isOptional": false,
713723
"isStatic": false,
724+
"isProtected": false,
714725
"returnTypeTokenRange": {
715726
"startIndex": 3,
716727
"endIndex": 4
@@ -754,7 +765,8 @@
754765
"startIndex": 1,
755766
"endIndex": 2
756767
},
757-
"isStatic": false
768+
"isStatic": false,
769+
"isProtected": false
758770
},
759771
{
760772
"kind": "Property",
@@ -782,7 +794,8 @@
782794
"startIndex": 1,
783795
"endIndex": 2
784796
},
785-
"isStatic": false
797+
"isStatic": false,
798+
"isProtected": false
786799
},
787800
{
788801
"kind": "Method",
@@ -820,6 +833,7 @@
820833
],
821834
"isOptional": false,
822835
"isStatic": true,
836+
"isProtected": false,
823837
"returnTypeTokenRange": {
824838
"startIndex": 5,
825839
"endIndex": 6
@@ -866,6 +880,7 @@
866880
],
867881
"isOptional": false,
868882
"isStatic": false,
883+
"isProtected": false,
869884
"returnTypeTokenRange": {
870885
"startIndex": 1,
871886
"endIndex": 2
@@ -904,7 +919,8 @@
904919
"startIndex": 1,
905920
"endIndex": 2
906921
},
907-
"isStatic": false
922+
"isStatic": false,
923+
"isProtected": false
908924
},
909925
{
910926
"kind": "Property",
@@ -931,7 +947,8 @@
931947
"startIndex": 1,
932948
"endIndex": 2
933949
},
934-
"isStatic": false
950+
"isStatic": false,
951+
"isProtected": false
935952
}
936953
],
937954
"extendsTokenRange": {
@@ -2449,6 +2466,7 @@
24492466
],
24502467
"isOptional": false,
24512468
"isStatic": false,
2469+
"isProtected": false,
24522470
"returnTypeTokenRange": {
24532471
"startIndex": 3,
24542472
"endIndex": 4

build-tests/api-extractor-scenarios/etc/test-outputs/ambientNameConflict/api-extractor-scenarios.api.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"metadata": {
33
"toolPackage": "@microsoft/api-extractor",
44
"toolVersion": "[test mode]",
5-
"schemaVersion": 1005,
5+
"schemaVersion": 1006,
66
"oldestForwardsCompatibleVersion": 1001,
77
"tsdocConfig": {
88
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",

build-tests/api-extractor-scenarios/etc/test-outputs/ambientNameConflict2/api-extractor-scenarios.api.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"metadata": {
33
"toolPackage": "@microsoft/api-extractor",
44
"toolVersion": "[test mode]",
5-
"schemaVersion": 1005,
5+
"schemaVersion": 1006,
66
"oldestForwardsCompatibleVersion": 1001,
77
"tsdocConfig": {
88
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",

build-tests/api-extractor-scenarios/etc/test-outputs/ancillaryDeclarations/api-extractor-scenarios.api.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"metadata": {
33
"toolPackage": "@microsoft/api-extractor",
44
"toolVersion": "[test mode]",
5-
"schemaVersion": 1005,
5+
"schemaVersion": 1006,
66
"oldestForwardsCompatibleVersion": 1001,
77
"tsdocConfig": {
88
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",

build-tests/api-extractor-scenarios/etc/test-outputs/apiItemKinds/api-extractor-scenarios.api.json

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"metadata": {
33
"toolPackage": "@microsoft/api-extractor",
44
"toolVersion": "[test mode]",
5-
"schemaVersion": 1005,
5+
"schemaVersion": 1006,
66
"oldestForwardsCompatibleVersion": 1001,
77
"tsdocConfig": {
88
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
@@ -203,6 +203,7 @@
203203
],
204204
"isOptional": false,
205205
"isStatic": false,
206+
"isProtected": false,
206207
"returnTypeTokenRange": {
207208
"startIndex": 1,
208209
"endIndex": 2
@@ -256,6 +257,7 @@
256257
],
257258
"isOptional": false,
258259
"isStatic": false,
260+
"isProtected": false,
259261
"returnTypeTokenRange": {
260262
"startIndex": 3,
261263
"endIndex": 4
@@ -303,6 +305,7 @@
303305
],
304306
"isOptional": false,
305307
"isStatic": false,
308+
"isProtected": false,
306309
"returnTypeTokenRange": {
307310
"startIndex": 1,
308311
"endIndex": 4
@@ -603,6 +606,7 @@
603606
],
604607
"isOptional": false,
605608
"isStatic": false,
609+
"isProtected": false,
606610
"returnTypeTokenRange": {
607611
"startIndex": 1,
608612
"endIndex": 2
@@ -640,6 +644,7 @@
640644
],
641645
"isOptional": false,
642646
"isStatic": false,
647+
"isProtected": false,
643648
"returnTypeTokenRange": {
644649
"startIndex": 3,
645650
"endIndex": 4
@@ -683,7 +688,8 @@
683688
"startIndex": 1,
684689
"endIndex": 2
685690
},
686-
"isStatic": false
691+
"isStatic": false,
692+
"isProtected": false
687693
},
688694
{
689695
"kind": "Property",
@@ -702,7 +708,8 @@
702708
"startIndex": 0,
703709
"endIndex": 0
704710
},
705-
"isStatic": false
711+
"isStatic": false,
712+
"isProtected": false
706713
},
707714
{
708715
"kind": "Property",
@@ -729,7 +736,8 @@
729736
"startIndex": 1,
730737
"endIndex": 2
731738
},
732-
"isStatic": false
739+
"isStatic": false,
740+
"isProtected": false
733741
},
734742
{
735743
"kind": "Property",
@@ -760,7 +768,8 @@
760768
"startIndex": 1,
761769
"endIndex": 2
762770
},
763-
"isStatic": false
771+
"isStatic": false,
772+
"isProtected": false
764773
}
765774
],
766775
"implementsTokenRanges": []

build-tests/api-extractor-scenarios/etc/test-outputs/bundledPackages/api-extractor-scenarios.api.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"metadata": {
33
"toolPackage": "@microsoft/api-extractor",
44
"toolVersion": "[test mode]",
5-
"schemaVersion": 1005,
5+
"schemaVersion": 1006,
66
"oldestForwardsCompatibleVersion": 1001,
77
"tsdocConfig": {
88
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
@@ -279,7 +279,8 @@
279279
"startIndex": 1,
280280
"endIndex": 2
281281
},
282-
"isStatic": false
282+
"isStatic": false,
283+
"isProtected": false
283284
},
284285
{
285286
"kind": "Property",
@@ -306,7 +307,8 @@
306307
"startIndex": 1,
307308
"endIndex": 2
308309
},
309-
"isStatic": false
310+
"isStatic": false,
311+
"isProtected": false
310312
}
311313
],
312314
"extendsTokenRange": {

build-tests/api-extractor-scenarios/etc/test-outputs/circularImport/api-extractor-scenarios.api.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"metadata": {
33
"toolPackage": "@microsoft/api-extractor",
44
"toolVersion": "[test mode]",
5-
"schemaVersion": 1005,
5+
"schemaVersion": 1006,
66
"oldestForwardsCompatibleVersion": 1001,
77
"tsdocConfig": {
88
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
@@ -209,7 +209,8 @@
209209
"startIndex": 1,
210210
"endIndex": 2
211211
},
212-
"isStatic": false
212+
"isStatic": false,
213+
"isProtected": false
213214
}
214215
],
215216
"implementsTokenRanges": []
@@ -257,7 +258,8 @@
257258
"startIndex": 1,
258259
"endIndex": 3
259260
},
260-
"isStatic": false
261+
"isStatic": false,
262+
"isProtected": false
261263
},
262264
{
263265
"kind": "Property",
@@ -289,7 +291,8 @@
289291
"startIndex": 1,
290292
"endIndex": 3
291293
},
292-
"isStatic": false
294+
"isStatic": false,
295+
"isProtected": false
293296
}
294297
],
295298
"implementsTokenRanges": []

0 commit comments

Comments
 (0)