Attributes cannot be placed on a reserved member.
FIDL-727 #done
Change-Id: I32a536f7a9d6bdcfa76874bb7f797db4e71177ac
diff --git a/resources/META-INF/plugin.xml b/resources/META-INF/plugin.xml
index e833ad1..589638f 100644
--- a/resources/META-INF/plugin.xml
+++ b/resources/META-INF/plugin.xml
@@ -21,6 +21,7 @@
<li><b>0.13</b>
<ul>
<li>Add exception handle subtype and strict keyword for xunion</li>
+ <li>Produce error when attributes are added to restricted table fields</li>
</ul>
</li>
<li><b>0.12</b>
diff --git a/src/fuchsia/developer/plugin/fidl/ContextAwareHighlighter.java b/src/fuchsia/developer/plugin/fidl/ContextAwareHighlighter.java
index 4bbcce1..806caa4 100644
--- a/src/fuchsia/developer/plugin/fidl/ContextAwareHighlighter.java
+++ b/src/fuchsia/developer/plugin/fidl/ContextAwareHighlighter.java
@@ -314,5 +314,18 @@
}
}
}
+
+ // Attributes cannot be placed on a reserved member.
+ if (thisType == Types.RESERVED) {
+ // Parent is TABLE_FIELD_DECL, Grandparent is TABLE_FIELD
+ ASTNode grandParent = element.getParent().getParent().getNode();
+ if (grandParent.getElementType() == Types.TABLE_FIELD) {
+ ASTNode maybeAttributeList = grandParent.findChildByType(Types.ATTRIBUTE_LIST);
+ if (maybeAttributeList != null) {
+ holder.createErrorAnnotation(
+ maybeAttributeList, "Attributes are not allowed on reserved table members");
+ }
+ }
+ }
}
}
diff --git a/src/fuchsia/developer/plugin/fidl/Fidl.bnf b/src/fuchsia/developer/plugin/fidl/Fidl.bnf
index ccb9b35..294ce64 100644
--- a/src/fuchsia/developer/plugin/fidl/Fidl.bnf
+++ b/src/fuchsia/developer/plugin/fidl/Fidl.bnf
@@ -88,7 +88,7 @@
union-field ::= attribute-list? type-constructor identifier-token
-table-declaration ::= attribute-list? TABLE identifier-token OBRACE ( attribute-list? table-field SEMICOLON )* CBRACE
+table-declaration ::= attribute-list? TABLE identifier-token OBRACE ( table-field SEMICOLON )* CBRACE
table-field ::= attribute-list? table-field-ordinal table-field-decl