commit
6eb36fda4c
4 files changed
+61
-4
No files matched your search
@@ -34,6 +34,7 @@ This is a {{ site.pmd.release_type }} release.
|
||||
|
||||
### External Contributions
|
||||
|
||||
* [#2666](https://github.com/pmd/pmd/pull/2666): \[swift] Manage swift5 string literals - [kenji21](https://github.com/kenji21)
|
||||
* [#2959](https://github.com/pmd/pmd/pull/2959): \[apex] New Rule: override equals and hashcode rule - [recdevs](https://github.com/recdevs)
|
||||
* [#2964](https://github.com/pmd/pmd/pull/2964): \[cs] Update C# grammar for additional C# 7 and C# 8 features - [Maikel Steneker](https://github.com/maikelsteneker)
|
||||
* [#2983](https://github.com/pmd/pmd/pull/2983): \[java] LiteralsFirstInComparisons should consider constant fields - [Ozan Gulle](https://github.com/ozangulle)
|
||||
|
||||
@@ -1018,7 +1018,7 @@ ImplicitParameterName : '$' DecimalLiteral ; // TODO: don't allow '_' here
|
||||
// GRAMMAR OF A LITERAL
|
||||
|
||||
booleanLiteral: BooleanLiteral ;
|
||||
literal : numericLiteral | MultiStringLiteral | SingleStringLiteral | BooleanLiteral | NilLiteral ;
|
||||
literal : numericLiteral | MultiStringLiteral | SingleStringLiteral | BooleanLiteral | NilLiteral | RawMultiStringLiteral | RawSingleStringLiteral ;
|
||||
|
||||
// GRAMMAR OF AN INTEGER LITERAL
|
||||
|
||||
@@ -1073,11 +1073,16 @@ TRIPLEDQUOTES : '"""' ;
|
||||
|
||||
MultiStringLiteral : TRIPLEDQUOTES '\n' .*? '\n' TRIPLEDQUOTES ;
|
||||
fragment MultiQuotedText : MultiQuotedTextItem+ ;
|
||||
fragment MultiQuotedTextItem : MultiInterpolatedString
|
||||
| ~[\\\u000A\u000D]
|
||||
;
|
||||
fragment MultiQuotedTextItem : MultiInterpolatedString | ~[\\\u000A\u000D] ;
|
||||
fragment MultiInterpolatedString: '\\(' (MultiQuotedTextItem | SingleStringLiteral)* ')';
|
||||
|
||||
// swift 5 extended delimiter, eg ##"abc"##
|
||||
RawSingleStringLiteral : '#"' RawSingleQuotedTextItem* '"#' | '#' RawSingleStringLiteral '#';
|
||||
fragment RawSingleQuotedTextItem : ~[\u000A\u000D] ;
|
||||
|
||||
RawMultiStringLiteral : '#"""' RawMultiQuotedTextItem* '"""#' | '#' RawMultiStringLiteral '#';
|
||||
fragment RawMultiQuotedTextItem : . ;
|
||||
|
||||
// StringLiteral : '"' QuotedText? '"' ;
|
||||
SingleStringLiteral : '"' QuotedText? '"' ;
|
||||
fragment SingleDoubleQuote : '"' | ~["] ;
|
||||
|
||||
+13
@@ -38,3 +38,16 @@ var x = 2
|
||||
print(x[keyPath: id]) // prints 2
|
||||
x[keyPath: id] = 3
|
||||
print(x[keyPath: id]) // prints 3
|
||||
|
||||
// https://www.swiftbysundell.com/articles/string-literals-in-swift/
|
||||
let rawString = #"Press "Continue" to close this dialog."#
|
||||
extension URL {
|
||||
func html(withTitle title: String) -> String {
|
||||
return ##"<a \href="\#(absoluteString)">\#(title)</a>"##
|
||||
}
|
||||
}
|
||||
|
||||
let rawMultiString = ###"a\###"###
|
||||
let rawMultiString2 = ###"""a\###
|
||||
""hey""
|
||||
"""###
|
||||
+38
@@ -197,4 +197,42 @@ L40
|
||||
[id] 18 19
|
||||
[\]] 20 20
|
||||
[)] 21 21
|
||||
L43
|
||||
[let] 1 3
|
||||
[rawString] 5 13
|
||||
[=] 15 15
|
||||
[#"Press "Continue" to close this d[ 17 58
|
||||
L44
|
||||
[extension] 1 9
|
||||
[URL] 11 13
|
||||
[{] 15 15
|
||||
L45
|
||||
[func] 5 8
|
||||
[html] 10 13
|
||||
[(] 14 14
|
||||
[withTitle] 15 23
|
||||
[title] 25 29
|
||||
[:] 30 30
|
||||
[String] 32 37
|
||||
[)] 38 38
|
||||
[->] 40 41
|
||||
[String] 43 48
|
||||
[{] 50 50
|
||||
L46
|
||||
[return] 9 14
|
||||
[##"<a \\href="\\#(absoluteString)"[ 16 64
|
||||
L47
|
||||
[}] 5 5
|
||||
L48
|
||||
[}] 1 1
|
||||
L50
|
||||
[let] 1 3
|
||||
[rawMultiString] 5 18
|
||||
[=] 20 20
|
||||
[###"a\\###"###] 22 34
|
||||
L51
|
||||
[let] 1 3
|
||||
[rawMultiString2] 5 19
|
||||
[=] 21 21
|
||||
[###"""a\\###\n""hey""\n"""###] 23 6
|
||||
EOF
|
||||
Reference in new issue
Block a user