aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/main/javacc/SDParser.jj
diff options
context:
space:
mode:
authorArne H Juul <arnej@yahooinc.com>2022-03-08 13:50:36 +0000
committerArne H Juul <arnej@yahooinc.com>2022-03-11 13:37:02 +0000
commit136ed7365ccf60898a84bb568d83da6a5d012ec3 (patch)
treef446263ec5767c38fca976b0bc8c7a2c29bbd949 /config-model/src/main/javacc/SDParser.jj
parentee4fb1f44497518575d0cd38afee55b4a20706cf (diff)
populate struct fields on demand
* most SDField instances should know their "repo" * populate with struct fields in a lazy manner * just remember what we were told in the old API * note: old API will be renamed so it makes a bit more sense
Diffstat (limited to 'config-model/src/main/javacc/SDParser.jj')
-rw-r--r--config-model/src/main/javacc/SDParser.jj13
1 files changed, 8 insertions, 5 deletions
diff --git a/config-model/src/main/javacc/SDParser.jj b/config-model/src/main/javacc/SDParser.jj
index 1fec33c4f12..e90df2776e0 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(document, name, type, document);
+ field = new TemporarySDField(document == null ? schema.getDocument() : document, name, type, document);
}
lbrace() (fieldBody(field, schema, document) (<NL>)*)* <RBRACE>
{
@@ -668,7 +668,7 @@ void fieldSet(Schema schema) :
|
( <QUERYCOMMAND> <COLON> (queryCommand = identifierWithDash() | queryCommand = quotedString())) { queryCommands.add(queryCommand); }
|
- ( matchSetting = match(new SDField(setName, DataType.STRING)) ) { matchSettings.add(matchSetting); }
+ ( matchSetting = match(new SDField(null, setName, DataType.STRING)) ) { matchSettings.add(matchSetting); }
)(<NL>)*)+
<RBRACE>
{
@@ -811,7 +811,11 @@ SDDocumentType structDefinition(Schema schema, SDDocumentType repo) :
SDDocumentType struct;
}
{
- ( <STRUCT> name = identifier() (<NL>)* { struct = new SDDocumentType(name, schema); }
+ ( <STRUCT> name = identifier() (<NL>)* {
+ if (repo == null)
+ throw new IllegalArgumentException("Can't add struct '"+name+"' to a document type, define a document type first or declare the struct inside of one.");
+ struct = new SDDocumentType(name, schema);
+ }
[ inheritsDocument(struct) (<NL>)* ]
lbrace() (structFieldDefinition(repo, struct) (<NL>)*)* <RBRACE> )
{
@@ -821,7 +825,6 @@ SDDocumentType structDefinition(Schema schema, SDDocumentType repo) :
} catch (IllegalArgumentException e) {
// empty
}
- if (repo==null) throw new IllegalArgumentException("Can't add struct '"+name+"' to a document type, define a document type first or declare the struct inside of one.");
SDDocumentType sdtype = repo.getOwnedType(struct.getDocumentName());
DataType stype = sdtype != null
? sdtype.getStruct()
@@ -830,7 +833,7 @@ SDDocumentType structDefinition(Schema schema, SDDocumentType repo) :
return struct;
}
}
-
+
/**
* This rule consumes a data type block from within a field element.
*