-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
scrooge: add all thrift keywords to ThriftParser
Problem: Scrooge [[ #259 | doesn't respect the same keywords ]] as Apache thrift. This mismatch prevents us from upgrading thrift, and it creates friction for customers generating code from existing scrooge-compatible thrift files via apache thrift. Solution: Update our forbidden keywords in ThriftParser to include [[ https://github.com/apache/thrift/blob/f7e6c654bde5d9832bede2b48b460c3e1bbbbb92/doc/specs/idl.md#reserved-keywords | the keywords ]] Apache Thrift disallows, and fix affected files. JIRA Issues: CSL-11183 Differential Revision: https://phabricator.twitter.biz/D707116
- Loading branch information
1 parent
2c5f856
commit 884f360
Showing
12 changed files
with
172 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,7 +103,7 @@ enum NamespaceCollisions | |
Iterable, | ||
Unit, | ||
Nothing, | ||
protected | ||
Protected | ||
} | ||
|
||
/** doc, ignored */ | ||
|
136 changes: 136 additions & 0 deletions
136
scrooge-generator/src/main/scala/com/twitter/scrooge/frontend/ThriftKeywords.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
package com.twitter.scrooge.frontend | ||
|
||
/** | ||
* | ||
* Set of Thrift keywords so we can raise errors or warnings when used in thrift files | ||
* | ||
* Many of these keywords are reserved in alignment with ApacheThrift | ||
* See https://github.com/apache/thrift/blob/master/doc/specs/idl.md#reserved-keywords | ||
*/ | ||
private object ThriftKeywords { | ||
private[this] val set = Set[String]( | ||
"abstract", | ||
"alias", | ||
"and", | ||
"args", | ||
"as", | ||
"assert", | ||
"async", | ||
"begin", | ||
"break", | ||
"case", | ||
"catch", | ||
"class", | ||
"clone", | ||
"continue", | ||
"const", | ||
"declare", | ||
"def", | ||
"default", | ||
"del", | ||
"delete", | ||
"do", | ||
"dynamic", | ||
"elif", | ||
"else", | ||
"elseif", | ||
"elsif", | ||
"end", | ||
"enddeclare", | ||
"endfor", | ||
"endforeach", | ||
"endif", | ||
"endswitch", | ||
"endwhile", | ||
"ensure", | ||
"enum", | ||
"except", | ||
"exec", | ||
"exception", | ||
"extends", | ||
"finally", | ||
"float", | ||
"for", | ||
"foreach", | ||
"from", | ||
"function", | ||
"global", | ||
"goto", | ||
"if", | ||
"implements", | ||
"import", | ||
"in", | ||
"include", | ||
"inline", | ||
"instanceof", | ||
"interface", | ||
"is", | ||
"lambda", | ||
"module", | ||
"namespace", | ||
"native", | ||
"new", | ||
"next", | ||
"nil", | ||
"not", | ||
"optional", | ||
"or", | ||
"package", | ||
"pass", | ||
"public", | ||
"print", | ||
"private", | ||
"protected", | ||
"raise", | ||
"redo", | ||
"rescue", | ||
"retry", | ||
"register", | ||
"return", | ||
"required", | ||
"self", | ||
"service", | ||
"sizeof", | ||
"static", | ||
"struct", | ||
"super", | ||
"switch", | ||
"synchronized", | ||
"then", | ||
"this", | ||
"throw", | ||
"throws", | ||
"transient", | ||
"try", | ||
"typedef", | ||
"undef", | ||
"union", | ||
"unless", | ||
"unsigned", | ||
"until", | ||
"use", | ||
"var", | ||
"virtual", | ||
"void", | ||
"volatile", | ||
"when", | ||
"while", | ||
"with", | ||
"xor", | ||
"yield", | ||
// Built-in types are also keywords. | ||
"binary", | ||
"bool", | ||
"byte", | ||
"double", | ||
"i16", | ||
"i32", | ||
"i64", | ||
"list", | ||
"map", | ||
"set", | ||
"string" | ||
) | ||
|
||
def contains(str: String): Boolean = set.contains(str) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters