diff options
author | Arne H Juul <arnej@yahooinc.com> | 2022-03-08 11:27:42 +0000 |
---|---|---|
committer | Arne H Juul <arnej@yahooinc.com> | 2022-03-11 13:36:53 +0000 |
commit | ee4fb1f44497518575d0cd38afee55b4a20706cf (patch) | |
tree | 8af4f9454558b53452fd62a801e04c08581e7ecb /config-model/src/main/javacc/SDParser.jj | |
parent | ba2758ab815ebe7ab2fa9b702b3ace7d5c0fd0d7 (diff) |
even TemporarySDField should be connected to a "repo"
Diffstat (limited to 'config-model/src/main/javacc/SDParser.jj')
-rw-r--r-- | config-model/src/main/javacc/SDParser.jj | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/config-model/src/main/javacc/SDParser.jj b/config-model/src/main/javacc/SDParser.jj index 1a0b518bbb2..1fec33c4f12 100644 --- a/config-model/src/main/javacc/SDParser.jj +++ b/config-model/src/main/javacc/SDParser.jj @@ -639,7 +639,7 @@ void field(SDDocumentType document, Schema schema) : if (name != null && Schema.isReservedName(name.toLowerCase())) { throw new IllegalArgumentException("Reserved name '" + name + "' can not be used as a field name."); } - field = new TemporarySDField(name, type, document); + field = new TemporarySDField(document, name, type, document); } lbrace() (fieldBody(field, schema, document) (<NL>)*)* <RBRACE> { @@ -698,11 +698,13 @@ void annotationOutside(Schema schema) : <ANNOTATION> name = identifier() { type = new SDAnnotationType(name.trim()); + if (schema.getDocument() == null) { + throw new IllegalArgumentException("Can't add annotation '"+name+"' to a document type, define a document type first or declare the annotation inside of one."); + } } [ inheritsAnnotation(type) (<NL>)* ] - lbrace() (type = annotationBody(schema, type)) <RBRACE> + lbrace() (type = annotationBody(schema, schema.getDocument(), type)) <RBRACE> { - if (schema.getDocument()==null) throw new IllegalArgumentException("Can't add annotation '"+name+"' to a document type, define a document type first or declare the annotation inside of one."); schema.addAnnotation(type); } } @@ -723,7 +725,7 @@ void annotation(Schema schema, SDDocumentType document) : type = new SDAnnotationType(name.trim()); } [ inheritsAnnotation(type) (<NL>)* ] - lbrace() (type = annotationBody(schema, type)) <RBRACE> + lbrace() (type = annotationBody(schema, document, type)) <RBRACE> { document.addAnnotation(type); } @@ -737,12 +739,12 @@ void annotation(Schema schema, SDDocumentType document) : * @param type the type being built * @return a modified or new AnnotationType instance */ -SDAnnotationType annotationBody(Schema schema, SDAnnotationType type) : +SDAnnotationType annotationBody(Schema schema, SDDocumentType repo, SDAnnotationType type) : { SDDocumentType struct = new SDDocumentType("annotation." + type.getName(), schema); } { - (structFieldDefinition(struct) (<NL>)*)* + (structFieldDefinition(repo, struct) (<NL>)*)* { if (struct.getFieldCount() > 0) { // Must account for the temporary TemporarySDField. type = new SDAnnotationType(type.getName(), struct, type.getInherits()); @@ -811,7 +813,7 @@ SDDocumentType structDefinition(Schema schema, SDDocumentType repo) : { ( <STRUCT> name = identifier() (<NL>)* { struct = new SDDocumentType(name, schema); } [ inheritsDocument(struct) (<NL>)* ] - lbrace() (structFieldDefinition(struct) (<NL>)*)* <RBRACE> ) + lbrace() (structFieldDefinition(repo, struct) (<NL>)*)* <RBRACE> ) { try { docMan.getDataType(name); @@ -921,7 +923,7 @@ DataType wildCardType() : * * @param struct The struct to modify. */ -void structFieldDefinition(SDDocumentType struct) : +void structFieldDefinition(SDDocumentType document, SDDocumentType struct) : { String name; SDField field; @@ -932,7 +934,7 @@ void structFieldDefinition(SDDocumentType struct) : if (name != null && Schema.isReservedName(name.toLowerCase())) { throw new IllegalArgumentException("Reserved name '" + name + "' can not be used as a field name."); } - field = new TemporarySDField(name, type, struct); + field = new TemporarySDField(document, name, type, struct); struct.addField(field); } lbrace() (id(field,struct) (<NL>)*)? (match(field) (<NL>)*)* <RBRACE> { |