This repository has been archived by the owner on Jan 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
definitionSystem.ts
1321 lines (1077 loc) · 32 KB
/
definitionSystem.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
export import rt=require("raml-typesystem")
import typeSystem=rt.nominalTypes;
export function getSchemaUtils(): any {
return rt.getSchemaUtils();
}
function registerAdapters(a:typeSystem.Adaptable){
if ((<any>a)["isUnion"]) {
a.addAdapter(new RAMLService(<AbstractType>a))
}
else if ((<any>a)["range"]) {
a.addAdapter(new RAMLPropertyService(<Property>a))
}
}
export type IHighLevelNode=any
export type IParseResult=any
export type Named=typeSystem.NamedId;
export type IHasExtra = rt.IHasExtra;
export var TOP_LEVEL_EXTRA = rt.TOP_LEVEL_EXTRA;
export var DEFINED_IN_TYPES_EXTRA = rt.DEFINED_IN_TYPES_EXTRA;
export var USER_DEFINED_EXTRA = rt.USER_DEFINED_EXTRA;
export var SOURCE_EXTRA = rt.SOURCE_EXTRA;
export var tsInterfaces = rt.tsInterfaces;
// export function instanceOfHasExtra(instance : any) : instance is rt.IHasExtra {
// return rt.instanceOfHasExtra(instance);
// }
export var injector={
inject(a:typeSystem.Adaptable){
registerAdapters(a);
}
}
typeSystem.registerInjector(injector);
/**
* What is our universe at first we have node types
* they have following fundamental properties:
* some nodes can fold to another kinds of nodes
*
*/
export type IType = typeSystem.ITypeDefinition
export type ITypeDefinition = typeSystem.ITypeDefinition
export type IProperty=typeSystem.IProperty
export class AbstractType extends typeSystem.AbstractType implements typeSystem.ITypeDefinition{}
export class ValueType extends typeSystem.ValueType implements IType{}
export class SourceProvider {
public static CLASS_IDENTIFIER = "definitionSystem.SourceProvider";
public static isInstance(instance : any) : instance is SourceProvider {
if(instance != null && instance.getClassIdentifier
&& typeof(instance.getClassIdentifier) == "function"){
for (let currentIdentifier of instance.getClassIdentifier()){
if(currentIdentifier == SourceProvider.CLASS_IDENTIFIER) return true;
}
}
return false;
}
public getClassIdentifier() : string[] {
var superIdentifiers = [];
return superIdentifiers.concat(SourceProvider.CLASS_IDENTIFIER);
}
getSource() : any {
return null;
}
}
export function isSourceProvider(object : any) : object is SourceProvider {
return object.getSource && typeof(object.getSource) == "function";
}
export class EnumType extends ValueType{
private static CLASS_IDENTIFIER = "definitionSystem.EnumType";
public static isInstance(instance : any) : instance is EnumType {
if(instance != null && instance.getClassIdentifier
&& typeof(instance.getClassIdentifier) == "function"){
for (let currentIdentifier of instance.getClassIdentifier()){
if(currentIdentifier == EnumType.CLASS_IDENTIFIER) return true;
}
}
return false;
}
public getClassIdentifier() : string[] {
var superIdentifiers = [];
return superIdentifiers.concat(EnumType.CLASS_IDENTIFIER);
}
values:string[]=[];
}
export interface IValueDocProvider{
(v:string):string
}
export interface IValueSuggester{
(node:IHighLevelNode):string[]
}
export class ReferenceType extends ValueType{
private static CLASS_IDENTIFIER = "definitionSystem.ReferenceType";
public static isInstance(instance : any) : instance is ReferenceType {
if(instance != null && instance.getClassIdentifier
&& typeof(instance.getClassIdentifier) == "function"){
for (let currentIdentifier of instance.getClassIdentifier()){
if(currentIdentifier == ReferenceType.CLASS_IDENTIFIER) return true;
}
}
return false;
}
public getClassIdentifier() : string[] {
var superIdentifiers = [];
return superIdentifiers.concat(ReferenceType.CLASS_IDENTIFIER);
}
constructor(name:string,path:string,private referenceTo:string,_universe:Universe){
super(name,_universe,path)
}
getReferencedType():NodeClass{
return <NodeClass>this.universe().type(this.referenceTo);
}
hasStructure():boolean{
return true;
}
}
export class NodeClass extends typeSystem.StructuredType implements IType,typeSystem.ITypeDefinition{
private static CLASS_IDENTIFIER = "definitionSystem.NodeClass";
public static isInstance(instance : any) : instance is NodeClass {
if(instance != null && instance.getClassIdentifier
&& typeof(instance.getClassIdentifier) == "function"){
for (let currentIdentifier of instance.getClassIdentifier()){
if(currentIdentifier == NodeClass.CLASS_IDENTIFIER) return true;
}
}
return false;
}
public getClassIdentifier() : string[] {
var superIdentifiers = [];
return superIdentifiers.concat(NodeClass.CLASS_IDENTIFIER);
}
constructor(_name:string,universe:Universe,path:string,_description="") {
super(_name,universe,path)
}
allProperties(v:{ [name:string]: typeSystem.ITypeDefinition}={}):Property[]{
return <Property[]>super.allProperties(v);
}
}
export class UserDefinedClass extends NodeClass{
private static CLASS_IDENTIFIER_UserDefinedClass = "definitionSystem.UserDefinedClass";
public static isInstance(instance : any) : instance is UserDefinedClass {
if(instance != null && instance.getClassIdentifier
&& typeof(instance.getClassIdentifier) == "function"){
for (let currentIdentifier of instance.getClassIdentifier()){
if(currentIdentifier == UserDefinedClass.CLASS_IDENTIFIER_UserDefinedClass) return true;
}
}
return false;
}
public getClassIdentifier() : string[] {
var superIdentifiers = super.getClassIdentifier();
return superIdentifiers.concat(UserDefinedClass.CLASS_IDENTIFIER_UserDefinedClass);
}
key(){
return null;
}
isUserDefined(): boolean{
return true;
}
typeId():string{
var rs= this.nameId();
var node=this.getAdapter(RAMLService).getDeclaringNode();
if (node){
rs=rs+node.lowLevel().start();
var unit = node.lowLevel().unit();
if (unit) {
rs = rs + unit.absolutePath();
}
}
return rs;
}
constructor(name:string, universe:Universe, hl:IHighLevelNode,path:string, description:string) {
super(name, universe, path, description);
this.getAdapter(RAMLService).setDeclaringNode(hl);
}
_value:boolean;
hasValueTypeInHierarchy(){
if (this._value){
return true;
}
if (this.isAssignableFrom("ObjectTypeDeclaration")){
return false;
}
return false;
}
/**
* Returns whether this type contain genuine user defined type in its hierarchy.
* Genuine user defined type is a type user intentionally defined and filled with
* properties or facets, or having user-defined name as opposed to a synthetic user-defined type.
*/
isGenuineUserDefinedType() : boolean {
return this.genuineUserDefinedType() != null;
}
/**
* Returns nearest genuine user-define type in the hierarchy.
* Genuine user defined type is a type user intentionally defined and filled with
* properties or facets, or having user-defined name as opposed to a synthetic user-defined type.
*/
genuineUserDefinedType() : typeSystem.ITypeDefinition {
var declaringNode=this.getAdapter(RAMLService).getDeclaringNode();
if (!declaringNode) {
return null;
}
return this;
}
}
/**
* Instanceof for UserDefinedClass class.
* @param clazz
* @returns
*/
export function isUserDefinedClass(clazz: any) : clazz is UserDefinedClass {
var anyClazz = <any>clazz;
return anyClazz.genuineUserDefinedType && anyClazz.isUserDefined
&& anyClazz.isUserDefined();
}
export class AnnotationType extends UserDefinedClass{
allProperties(ps:{[name:string]:typeSystem.ITypeDefinition}={}):Property[]{
var rs=this.superTypes()[0].allProperties();
if (rs.length==0){
var node = this.getAdapter(RAMLService).getDeclaringNode();
var up=new UserDefinedProp("value", node);
up.withDomain(this);
up.withCanBeValue();
up.withRequired(false);
var tp=this.superTypes()[0];
rs=[];
up.withRange(up.node().asElement().definition().universe().type("string"));
rs.push(up);
}
return <any>rs;
}
isAnnotationType(){
return true;
}
}
export interface IUniverseDescriptor{
[name:string]:typeSystem.NamedId;
}
export class Universe extends typeSystem.Described implements typeSystem.IUniverse{
private _classes:IType[]=[]
private _uversion:string="RAML08"
private _topLevel:string;
private _originalTopLevelText:string;
private matchedObjects;
private _typedVersion:string;
matched():IUniverseDescriptor{
if (this.matchedObjects){
return this.matchedObjects;
}
if (this._parent){
return this._parent.matched();
}
}
setTopLevel(t:string){
this._topLevel=t;
}
getTopLevel(){
return this._topLevel;
}
setOriginalTopLevelText(t:string){
this._originalTopLevelText=t;
}
getOriginalTopLevelText(){
return this._originalTopLevelText;
}
setTypedVersion(tv:string){
this._typedVersion=tv;
}
getTypedVersion(){
return this._typedVersion;
}
version(){
return this._uversion;
}
setUniverseVersion(version:string){
this._uversion=version;
}
types():IType[]{
var result=[].concat(this._classes);
if (this._parent!=null){
result=result.concat(this._parent.types());
}
return result;
}
type(name:string):ITypeDefinition{
if(this.aMap[name]){
return this.aMap[name];
}
var tp:ITypeDefinition;
for (var i=0;i<this._classes.length;i++){
if (this._classes[i].nameId()==name){
tp=this._classes[i];
break;
}
}
if(tp==null){
if (this._parent){
var tp= this._parent.type(name);
if (tp instanceof AbstractType){
var at=<AbstractType><any>tp;
at._universe=this;//FIXME
}
}
}
return tp;
}
register(t:IType){
this._classes.push(t);
if (t instanceof NodeClass) {
this._classes.forEach(x=> {
if (x instanceof NodeClass) {
var nc =<NodeClass> x;
if (nc.getAdapter(RAMLService).getExtendedType() == t) {
t.getAdapter(RAMLService).getRuntimeExtenders().push(x)
}
}}
)
}
return this;
}
private aMap:{ [name:string]:IType}={}
registerAlias(a:string,t:IType){
this.aMap[a]=t;
}
unregister(t:IType){
this._classes=this._classes.filter(x=>x!=t);
var st=t.superTypes();
st.forEach(x=>{
var a:AbstractType=(<any>x);
a._superTypes=a._superTypes.filter(x=>x!=t);
})
st=t.subTypes();
st.forEach(x=>{
var a:AbstractType=(<any>x);
a._subTypes=a._subTypes.filter(x=>x!=t);
})
return this;
}
constructor(dec:IUniverseDescriptor,name:string="",private _parent:Universe=null,v:string="RAML08"){
super(name)
this.matchedObjects=dec;
this._uversion=v;
}
registerSuperClass(t0:IType,t1:IType){
var a0:AbstractType=(<any>t0);
var a1:AbstractType=(<any>t1);
a0._superTypes.push(t1);
a1._subTypes.push(t0);
}
}
export function prop(name:string,desc:string,domain:NodeClass,range:IType,custom?:boolean):Property{
var prop=new Property(name,desc);
return <Property>prop.withDomain(domain,custom).withRange(range)
}
export class ChildValueConstraint{
constructor(public name:string,public value:string){}
}
export class Property extends typeSystem.Property implements typeSystem.IProperty{
private _isFromParentValue:boolean=false;
private _isFromParentKey:boolean=false;
private _key:boolean=false;
private _declaresFields:boolean=false
private _describes:string=null;
private _inheritsValueFromContext:string;
private _canBeDuplicator:boolean=false
private _allowsNull:boolean=false
private _canBeValue:boolean=false
private _isInherited:boolean=false
private _oftenKeys:string[]
private _vprovider:IValueDocProvider
private _suggester:IValueSuggester
private _selfNode=false;
private _noDirectParse:boolean=false;
private static CLASS_IDENTIFIER_Property_def = "definitionSystem.Property";
public static isInstance(instance : any) : instance is Property {
if(instance != null && instance.getClassIdentifier
&& typeof(instance.getClassIdentifier) == "function"){
for (let currentIdentifier of instance.getClassIdentifier()){
if(currentIdentifier == Property.CLASS_IDENTIFIER_Property_def) return true;
}
}
return false;
}
public getClassIdentifier() : string[] {
let superIdentifiers = super.getClassIdentifier();
return superIdentifiers.concat(Property.CLASS_IDENTIFIER_Property_def);
}
isPrimitive(){
return this.range().isValueType()&&!(this.range() instanceof ReferenceType);
}
withNoDirectParse(){
this._noDirectParse=true;
}
isNoDirectParse(){
return this._noDirectParse;
}
withSelfNode(){
this._selfNode=true;
}
isSelfNode(){
return this._selfNode;
}
matchKey(k:string):boolean{
if (this._groupName!=null){
if (this.isAnnotation()){
if (k.charAt(0)=='('&&k.charAt(k.length-1)==')'){
return true;
}
return false;
}
return this._groupName==k;
}
else{
return super.matchKey(k);
}
}
valueDocProvider():IValueDocProvider{
return this._vprovider;
}
setValueDocProvider(v:IValueDocProvider){
this._vprovider=v;
return this;
}
suggester():IValueSuggester{
return this._suggester;
}
setValueSuggester(s:IValueSuggester){
this._suggester=s;
}
enumOptions():string[]{
if (this._enumOptions && typeof this._enumOptions == 'string') {
return [this._enumOptions + ""];
}
return this._enumOptions;
}
getOftenKeys(){
return this._oftenKeys;
}
withOftenKeys(keys:string[]){
this._oftenKeys=keys;
return this;
}
withCanBeValue(){
this._canBeValue=true;
return this;
}
withInherited(w:boolean){
this._isInherited=w;
}
isInherited(){
return this._isInherited;
}
isAllowNull(){
return this._allowsNull;
}
withAllowNull(){
this._allowsNull=true;
}
getCanBeDuplicator(){
return this._canBeDuplicator
}
canBeValue():boolean{
return this._canBeValue;
}
setCanBeDuplicator(){
this._canBeDuplicator=true;
return true;
}
inheritedContextValue(){
return this._inheritsValueFromContext;
}
withInheritedContextValue(v:string){
this._inheritsValueFromContext=v;
return this;
}
private _contextReq:{name:string;value:string}[]=[]
withContextRequirement(name:string,value:string){
this._contextReq.push({name:name,value:value});
}
getContextRequirements(){
return this._contextReq;
}
withDescribes(a:string){
this._describes=a;
return this;
}
describesAnnotation(){
return this._describes!=null;
}
describedAnnotation(){
return this._describes
}
private _newInstanceName:string;
isReference(){
return this.range() instanceof ReferenceType
}
referencesTo():IType{
return <IType>(<ReferenceType>this.range()).getReferencedType();
}
newInstanceName():string{
if (this._newInstanceName){
return this._newInstanceName;
}
return this.range().nameId()
}
withThisPropertyDeclaresFields(b:boolean=true){
this._declaresFields=b;
return this;
}
isThisPropertyDeclaresTypeFields(){
return this._declaresFields;
}
withNewInstanceName(name:string){
this._newInstanceName=name;
return this;
}
private determinesChildValues:ChildValueConstraint[]=[]
addChildValueConstraint(c:ChildValueConstraint){
this.determinesChildValues.push(c);
}
getChildValueConstraints():ChildValueConstraint[]{
return this.determinesChildValues;
}
childRestrictions():{name:string;value:any}[]{
return this.determinesChildValues;
}
_id;
id(){
if (this._id){
return this._id;
}
if (!this._groupName){
return null;
}
if (this.domain().getAdapter(RAMLService).getDeclaringNode()){
return null;
}
this._id=this._groupName+this.domain().nameId();
return this._id;
}
isAnnotation(){
return this._groupName=="annotations" &&
this.domain()&&!this.domain().isUserDefined();
}
withFromParentValue(v:boolean=true){
this._isFromParentValue=v;
return this;
}
withFromParentKey(v:boolean=true){
this._isFromParentKey=v;
return this;
}
isFromParentKey(){
return this._isFromParentKey;
}
isFromParentValue():boolean{
return this._isFromParentValue;
}
withGroupName(gname:string){
this._groupName=gname;
return this;
}
unmerge(){
this._groupName=this.nameId();
return this;
}
merge(){
this._groupName=null;
return this;
}
withKey(isKey:boolean){
this._key=isKey;
return this;
}
/**
* TODO THIS STUFF SHOULD BE MORE ABSTRACT (LATER...)
* @param keyShouldStartFrom
* @returns {Property}
*/
isKey(){
return this._key;
}
isMerged(){
return this._groupName==null;
}
groupName():string{
return this._groupName;
}
key():typeSystem.NamedId {
//TODO implement that
return null
}
}
export type Array= typeSystem.Array
export class UserDefinedProp extends Property{
private _node: IParseResult;
private sourceProvider;
_displayName:string
private static CLASS_IDENTIFIER = "definitionSystem.UserDefinedProp";
public static isInstance(instance : any) : instance is UserDefinedProp {
if(instance != null && instance.getClassIdentifier
&& typeof(instance.getClassIdentifier) == "function"){
var identifiers = instance.getClassIdentifier();
for(var i=0; i<identifiers.length; i++) {
if(identifiers[i] == UserDefinedProp.CLASS_IDENTIFIER) return true;
}
}
return false;
}
public getClassIdentifier() : string[] {
let superIdentifiers = super.getClassIdentifier();
return superIdentifiers.concat(UserDefinedProp.CLASS_IDENTIFIER);
}
constructor(name : string, source : IParseResult) {
super(name)
this._node = source;
}
withDisplayName(name:string){
this._displayName=name;
}
getDisplayName(){
return this._displayName;
}
node(){
if(!this._node && this.sourceProvider != null) {
this._node = this.sourceProvider.getSource();
}
return this._node;
}
setSourceProvider(sourceProvider : SourceProvider) : void {
this.sourceProvider = sourceProvider;
}
}
export class RAMLPropertyDocumentationService{
//!!!
private _markdownDescription:string
//!!!
private _documentationTableName:string
//!!!
private _isHidden:boolean
//!!!
private _valueDescription:string
setDocTableName(val:string){
this._documentationTableName = val;
}
docTableName():string{
return this._documentationTableName;
}
setHidden(val:boolean){
this._isHidden = val;
}
isHidden():boolean{
return this._isHidden;
}
setMarkdownDescription(val:string){
this._markdownDescription = val;
}
markdownDescription():string{
return this._markdownDescription;
}
setValueDescription(val:string){
this._valueDescription = val;
}
valueDescription():string{
return this._valueDescription;
}
}
export class RAMLPropertyParserService extends RAMLPropertyDocumentationService{
//!!!
private _isEmbededMap:boolean
//!!!
private _isSystemProperty:boolean;
isSystem(){
return this._isSystemProperty;
}
withSystem(s:boolean){
this._isSystemProperty=s;
return this;
}
isEmbedMap(){
return this._isEmbededMap
}
withEmbedMap(){
this._isEmbededMap=true;
return this;
}
}
export class RAMLPropertyService extends RAMLPropertyParserService{
constructor(private _property:IProperty){
super();
if (!_property){
throw new Error();
}
}
private _meta:{[key:string]:any} = {};
valueDocProvider(){
return (<Property>this._property).valueDocProvider();
}
//!!!
private _propertyGrammarType:string;
withPropertyGrammarType(pt:string){
this._propertyGrammarType=pt;
}
getPropertyGrammarType(){
return this._propertyGrammarType;
}
id(){
return this._property.nameId();
}
range():ITypeDefinition{
return this._property.range();
}
domain():ITypeDefinition{
return this._property.domain();
}
isAllowNull(){
return (<Property>this._property).isAllowNull();
}
referencesTo():ITypeDefinition{
return (<Property>this._property).referencesTo();
}
isReference(){
return (<Property>this._property).isReference();
}
texpr:boolean;
nameId(){
return this._property.nameId();
}
priority () : number {
if (this.isKey()) return 128;
else if (this.isReference()) return 64;
else if (this.isTypeExpr()) return 32;
else if (this.nameId() == 'example') return 0;
else return -1024;
}
isKey(){
if (this._property instanceof Property) {
return (<Property>this._property).isKey();
}
return false;
}
isMerged(){
if (this._property instanceof Property) {
return (<Property>this._property).isMerged();
}
return false;
}
public isTypeExpr() {
return this.texpr;
}
isExampleProperty(){
return this.example;
}
example:boolean;
setExample(e:boolean){
this.example=e;
}
setTypeExpression(e:boolean){
this.texpr=e;
}
isDescriminating(){
return this._property.isDescriminator();
}
putMeta(key:string,value:any){
this._meta[key] = value;
}
meta(key:string){
return this._meta[key];
}
}
export declare interface ValueRequirement {
name: string;
value: string;
}
export class RAMLService {
private _node:any
private _type:ITypeDefinition;
private _representationOf:ITypeDefinition;
//!!!
private _allowsAnyChildren:boolean
//!!!
private _allowsOptionalProperties:boolean=false;
private _possibleInterfaces:ITypeDefinition[] = [];
withAllowQuestion(){
this._allowsOptionalProperties=true;
}
getAllowQuestion(){
return this._allowsOptionalProperties;
}
//!!!
private _canInherit:string[]=[];
withCanInherit(clazz:string){
this._canInherit.push(clazz);
}
//!!!???
private _referenceIs:string;
getReferenceIs(){
return this._referenceIs;
}
withReferenceIs(fname:string){
this._referenceIs=fname;
}
descriminatorValue():string{