diff --git a/gradle-plugin/gradle.properties b/gradle-plugin/gradle.properties
index d782d221..803360f6 100644
--- a/gradle-plugin/gradle.properties
+++ b/gradle-plugin/gradle.properties
@@ -1,2 +1,2 @@
-courierVersion=2.0.10
+courierVersion=2.1.0
scalaMajorVersion=2.11
diff --git a/idea-plugin/src/org/coursera/courier/Courier.bnf b/idea-plugin/src/org/coursera/courier/Courier.bnf
index e4778132..5182a1b9 100644
--- a/idea-plugin/src/org/coursera/courier/Courier.bnf
+++ b/idea-plugin/src/org/coursera/courier/Courier.bnf
@@ -47,7 +47,8 @@ fullyQualifiedName ::= IDENTIFIER (DOT IDENTIFIER)*
typeDeclaration ::= namedTypeDeclaration | anonymousTypeDeclaration
-namedTypeDeclaration ::= annotations? (recordDeclaration | enumDeclaration | typerefDeclaration | fixedDeclaration)
+namedTypeDeclaration ::= annotations? (recordDeclaration | enumDeclaration | typerefDeclaration |
+ fixedDeclaration | keyDeclaration)
anonymousTypeDeclaration ::= unionDeclaration | arrayDeclaration | mapDeclaration
@@ -70,6 +71,8 @@ propJsonValueWithParams ::= OPEN_PAREN jsonValue CLOSE_PAREN {pin=1}
recordDeclaration ::= RECORD_KEYWORD typeNameDeclaration fieldSelection {pin=1}
+keyDeclaration ::= KEY_KEYWORD typeNameDeclaration fieldSelection {pin=1}
+
enumDeclaration ::= ENUM_KEYWORD typeNameDeclaration enumSymbolDeclarations {pin=1}
enumSymbolDeclarations ::= OPEN_BRACE enumSymbolDeclaration* CLOSE_BRACE {pin=1}
diff --git a/idea-plugin/src/org/coursera/courier/codestyle/CourierSyntaxHighlighter.java b/idea-plugin/src/org/coursera/courier/codestyle/CourierSyntaxHighlighter.java
index 3a5b585c..e3aa4193 100644
--- a/idea-plugin/src/org/coursera/courier/codestyle/CourierSyntaxHighlighter.java
+++ b/idea-plugin/src/org/coursera/courier/codestyle/CourierSyntaxHighlighter.java
@@ -61,6 +61,7 @@ public class CourierSyntaxHighlighter extends SyntaxHighlighterBase {
KEYWORDS.add(CourierTypes.ENUM_KEYWORD);
KEYWORDS.add(CourierTypes.FIXED_KEYWORD);
KEYWORDS.add(CourierTypes.RECORD_KEYWORD);
+ KEYWORDS.add(CourierTypes.KEY_KEYWORD);
KEYWORDS.add(CourierTypes.TYPEREF_KEYWORD);
KEYWORDS.add(CourierTypes.TRUE);
KEYWORDS.add(CourierTypes.FALSE);
diff --git a/idea-plugin/src/org/coursera/courier/psi/Courier.flex b/idea-plugin/src/org/coursera/courier/psi/Courier.flex
index ef00cf5c..d4abc595 100644
--- a/idea-plugin/src/org/coursera/courier/psi/Courier.flex
+++ b/idea-plugin/src/org/coursera/courier/psi/Courier.flex
@@ -53,6 +53,7 @@ StringLiteral = \" ( [^\"\\] | \\ ( [\"\\/bfnrt] | u[0-9]{4} ) )* \"
"namespace" { return CourierTypes.NAMESPACE_KEYWORD; }
"import" { return CourierTypes.IMPORT_KEYWORD; }
"record" { return CourierTypes.RECORD_KEYWORD; }
+ "key" { return CourierTypes.KEY_KEYWORD; }
"enum" { return CourierTypes.ENUM_KEYWORD; }
"fixed" { return CourierTypes.FIXED_KEYWORD; }
"typeref" { return CourierTypes.TYPEREF_KEYWORD; }
diff --git a/maven-plugin/pom.xml b/maven-plugin/pom.xml
index a39107d1..48524eb9 100644
--- a/maven-plugin/pom.xml
+++ b/maven-plugin/pom.xml
@@ -35,7 +35,7 @@
UTF-8
2.11
2.11.5
- 2.0.10
+ 2.1.0
1.7
http://github.com/coursera/courier
diff --git a/project/Build.scala b/project/Build.scala
index 098aad11..5371d59f 100644
--- a/project/Build.scala
+++ b/project/Build.scala
@@ -36,7 +36,8 @@ object Courier extends Build with OverridablePublishSettings {
override lazy val settings = super.settings ++ overridePublishSettings ++
Seq(
- organization := "org.coursera.courier")
+ organization := "org.coursera.courier",
+ isSnapshot := true)
//
// Cross building
diff --git a/schema-language/src/main/antlr4/Courier.g4 b/schema-language/src/main/antlr4/Courier.g4
index b5aee177..b2b9d213 100644
--- a/schema-language/src/main/antlr4/Courier.g4
+++ b/schema-language/src/main/antlr4/Courier.g4
@@ -20,7 +20,8 @@ typeReference returns [String value]: qualifiedIdentifier {
typeDeclaration: namedTypeDeclaration | anonymousTypeDeclaration;
namedTypeDeclaration: doc=schemadoc? props+=propDeclaration*
- (recordDeclaration | enumDeclaration | typerefDeclaration | fixedDeclaration);
+ (recordDeclaration | keyDeclaration | enumDeclaration | typerefDeclaration |
+ fixedDeclaration);
anonymousTypeDeclaration: unionDeclaration | arrayDeclaration | mapDeclaration;
@@ -42,6 +43,10 @@ recordDeclaration returns [String name]: RECORD identifier recordDecl=fieldSelec
$name = $identifier.value;
};
+keyDeclaration returns [String name]: KEY identifier keyDecl=fieldSelection {
+ $name = $identifier.value;
+};
+
enumDeclaration returns [String name]: ENUM identifier enumDecl=enumSymbolDeclarations {
$name = $identifier.value;
};
@@ -138,6 +143,7 @@ NAMESPACE: 'namespace';
RECORD: 'record';
TYPEREF: 'typeref';
UNION: 'union';
+KEY: 'key';
OPEN_PAREN: '(';
CLOSE_PAREN: ')';
diff --git a/schema-language/src/main/java/org/coursera/courier/grammar/CourierSchemaParser.java b/schema-language/src/main/java/org/coursera/courier/grammar/CourierSchemaParser.java
index 52f9870f..23b73eb3 100644
--- a/schema-language/src/main/java/org/coursera/courier/grammar/CourierSchemaParser.java
+++ b/schema-language/src/main/java/org/coursera/courier/grammar/CourierSchemaParser.java
@@ -57,6 +57,7 @@
import org.coursera.courier.grammar.CourierParser.ImportDeclarationContext;
import org.coursera.courier.grammar.CourierParser.ImportDeclarationsContext;
import org.coursera.courier.grammar.CourierParser.JsonValueContext;
+import org.coursera.courier.grammar.CourierParser.KeyDeclarationContext;
import org.coursera.courier.grammar.CourierParser.MapDeclarationContext;
import org.coursera.courier.grammar.CourierParser.NamedTypeDeclarationContext;
import org.coursera.courier.grammar.CourierParser.ObjectEntryContext;
@@ -164,6 +165,7 @@ public void parse(Reader reader) {
parser.addErrorListener(errorRecorder);
DocumentContext antlrDocument = parser.document();
+// System.out.println("\n!!!!!!!!\n"+antlrDocument.toStringTree()+"\n!!!!!!!!\n");
parse(antlrDocument);
if (errorRecorder.errors.size() > 0) {
@@ -326,6 +328,8 @@ private NamedDataSchema parseNamedType(
return parseFixed(namedType, namedType.fixedDeclaration());
} else if (namedType.enumDeclaration() != null) {
return parseEnum(namedType, namedType.enumDeclaration());
+ } else if (namedType.keyDeclaration() != null) {
+ return parseKey(namedType, namedType.keyDeclaration());
} else {
throw new ParseException(namedType,
"Unrecognized named type parse node: " + namedType.getText());
@@ -469,9 +473,24 @@ private UnionDataSchema parseUnion(
return schema;
}
- private RecordDataSchema parseRecord(
+ private RecordDataSchema parseKey(
NamedTypeDeclarationContext context,
- RecordDeclarationContext record) throws ParseException {
+ KeyDeclarationContext key) throws ParseException {
+ Name name = toName(key.name);
+ RecordDataSchema schema = new RecordDataSchema(name, RecordDataSchema.RecordType.RECORD);
+
+ bindNameToSchema(name, schema);
+ FieldsAndIncludes fieldsAndIncludes = parseFields(schema, key.keyDecl);
+ schema.setFields(fieldsAndIncludes.fields, errorMessageBuilder());
+ validateDefaults(schema);
+ schema.setInclude(fieldsAndIncludes.includes);
+ setProperties(context, schema);
+ return schema;
+ }
+
+ private RecordDataSchema parseRecord(
+ NamedTypeDeclarationContext context,
+ RecordDeclarationContext record) throws ParseException {
Name name = toName(record.name);
RecordDataSchema schema = new RecordDataSchema(name, RecordDataSchema.RecordType.RECORD);
diff --git a/scripts/publish-local b/scripts/publish-local
index 2964da41..10d53129 100755
--- a/scripts/publish-local
+++ b/scripts/publish-local
@@ -1,9 +1,9 @@
#!/bin/bash
sbt fullpublish-mavenlocal # publish courier to maven local so that the gradle build for gradle-plugin can depend on it
sbt fullpublish-ivylocal
-(cd gradle-plugin; ./gradlew install)
-if hash mvn 2>/dev/null; then
- (cd maven-plugin; mvn clean install)
-else
- echo "mvn not install, skipping publish for maven-plugin"
-fi
+#(cd gradle-plugin; ./gradlew install)
+#if hash mvn 2>/dev/null; then
+# (cd maven-plugin; mvn clean install)
+#else
+# echo "mvn not install, skipping publish for maven-plugin"
+#fi
diff --git a/version.sbt b/version.sbt
index 9b2c2b84..40e8e6e9 100644
--- a/version.sbt
+++ b/version.sbt
@@ -1 +1 @@
-version in ThisBuild := "2.0.10"
\ No newline at end of file
+version in ThisBuild := "2.1.0"
\ No newline at end of file