Mercurial > vim
changeset 35299:2cc507d1afa2
runtime(java): Improve the matching of lambda expressions (#14880)
Commit: https://github.com/vim/vim/commit/7129f2ad2fd9de3e3812a569ba3ad6bf162fd238
Author: Aliaksei Budavei <32549825+zzzyxwvut@users.noreply.github.com>
Date: Fri May 31 12:11:34 2024 +0300
runtime(java): Improve the matching of lambda expressions (https://github.com/vim/vim/issues/14880)
- Distinguish some formal parameters.
- Support multi-line definitions.
Signed-off-by: Aliaksei Budavei <0x000c70@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Fri, 31 May 2024 11:15:05 +0200 |
parents | 3cefa0d2b54d |
children | 062a50be417d |
files | runtime/syntax/java.vim runtime/syntax/testdir/dumps/java_lambda_expressions_00.dump runtime/syntax/testdir/dumps/java_lambda_expressions_01.dump runtime/syntax/testdir/dumps/java_lambda_expressions_02.dump runtime/syntax/testdir/dumps/java_lambda_expressions_03.dump runtime/syntax/testdir/dumps/java_lambda_expressions_04.dump runtime/syntax/testdir/dumps/java_lambda_expressions_05.dump runtime/syntax/testdir/dumps/java_lambda_expressions_99.dump runtime/syntax/testdir/input/java_lambda_expressions.java |
diffstat | 9 files changed, 263 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/runtime/syntax/java.vim +++ b/runtime/syntax/java.vim @@ -3,7 +3,7 @@ " Maintainer: Aliaksei Budavei <0x000c70 AT gmail DOT com> " Former Maintainer: Claudio Fleiner <claudio@fleiner.com> " Repository: https://github.com/zzzyxwvut/java-vim.git -" Last Change: 2024 May 10 +" Last Change: 2024 May 30 " Please check :help java.vim for comments on some of the options available. @@ -348,7 +348,6 @@ if exists("java_highlight_functions") exec 'syn region javaFuncDef start=/' . s:ff.Engine('\%#=2', '') . '^\s\+\%(\%(@\%(\K\k*\.\)*\K\k*\>\)\s\+\)*\%(p\%(ublic\|rotected\|rivate\)\s\+\)\=\%(\%(abstract\|default\)\s\+\|\%(\%(final\|\%(native\|strictfp\)\|s\%(tatic\|ynchronized\)\)\s\+\)*\)\=\%(<.*[[:space:]-]\@' . s:ff.Peek('1', '') . '<!>\s\+\)\=\%(void\|\%(b\%(oolean\|yte\)\|char\|short\|int\|long\|float\|double\|\%(\<\K\k*\>\.\)*\<' . s:ff.UpperCase('[$_[:upper:]]', '[^a-z0-9]') . '\k*\>\%(<[^(){}]*[[:space:]-]\@' . s:ff.Peek('1', '') . '<!>\)\=\)\%(\[\]\)*\)\s\+\<' . s:ff.LowerCase('[$_[:lower:]]', '[^A-Z0-9]') . '\k*\>\s*(/ end=/)/ skip=/\/\*.\{-}\*\/\|\/\/.*$/ contains=@javaFuncParams' endif - exec 'syn match javaLambdaDef "\<\K\k*\>\%(\<default\>\)\@' . s:ff.Peek('7', '') . '<!\s*->"' syn match javaBraces "[{}]" endif @@ -421,9 +420,26 @@ syn match javaParenError "\]" hi def link javaParenError javaError +" Lambda expressions (JLS-17, §15.27). if exists("java_highlight_functions") " Make ()-matching definitions after the parenthesis error catcher. - exec 'syn match javaLambdaDef "\k\@' . s:ff.Peek('4', '') . '<!(\%(\k\|[[:space:]<>?\[\]@,.]\)*)\s*->"' + " + " Match: ([@A [@B ...] final] var a[, var b, ...]) -> + " | ([@A [@B ...] final] T[<α>][[][]] a[, T b, ...]) -> + " There is no recognition of expressions interspersed with comments + " or of expressions whose parameterised parameter types are written + " across multiple lines. + exec 'syn match javaLambdaDef "\k\@' . s:ff.Peek('4', '') . '<!([[:space:]\n]*\%(\%(@\%(\K\k*\.\)*\K\k*\>\%((\_.\{-1,})\)\{-,1}[[:space:]\n]\+\)*\%(final[[:space:]\n]\+\)\=\%(\<\K\k*\>\.\)*\<\K\k*\>\%(<[^(){}]*[[:space:]-]\@' . s:ff.Peek('1', '') . '<!>\)\=\%(\%(\%(\[\]\)\+\|\.\.\.\)\)\=[[:space:]\n]\+\<\K\k*\>\%(\[\]\)*\%(,[[:space:]\n]*\)\=\)\+)[[:space:]\n]*->" contains=javaAnnotation,javaParamModifier,javaLambdaVarType,javaType,@javaClasses,javaVarArg' + " Match: () -> + " | (a[, b, ...]) -> + exec 'syn match javaLambdaDef "\k\@' . s:ff.Peek('4', '') . '<!([[:space:]\n]*\%(\<\K\k*\>\%(,[[:space:]\n]*\)\=\)*)[[:space:]\n]*->"' + " Match: a -> + exec 'syn match javaLambdaDef "\<\K\k*\>\%(\<default\>\)\@' . s:ff.Peek('7', '') . '<![[:space:]\n]*->"' + + syn keyword javaParamModifier contained final + hi def link javaParamModifier javaConceptKind + syn keyword javaLambdaVarType contained var + hi def link javaLambdaVarType javaOperator endif " The @javaTop cluster comprises non-contained Java syntax groups.
new file mode 100644 --- /dev/null +++ b/runtime/syntax/testdir/dumps/java_lambda_expressions_00.dump @@ -0,0 +1,20 @@ +>/+0#0000e05#ffffff0@1| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |l|e|t| |g|:|j|a|v|a|_|h|i|g|h|l|i|g|h|t|_|f|u|n|c|t|i|o|n|s| |=| |'|s|t|y|l|e|'| +0#0000000&@16 +@75 +@75 +|i+0#e000e06&|m|p|o|r|t| +0#0000000&|j|a|v|a|.|l|a|n|g|.|a|n@1|o|t|a|t|i|o|n|.|E|l|e|m|e|n|t|T|y|p|e|;| @34 +|i+0#e000e06&|m|p|o|r|t| +0#0000000&|j|a|v|a|.|u|t|i|l|.|f|u|n|c|t|i|o|n|.|B|i|n|a|r|y|O|p|e|r|a|t|o|r|;| @33 +|i+0#e000e06&|m|p|o|r|t| +0#0000000&|j|a|v|a|.|u|t|i|l|.|f|u|n|c|t|i|o|n|.|F|u|n|c|t|i|o|n|;| @39 +@75 +|c+0#00e0003&|l|a|s@1| +0#0000000&|L|a|m|b|d|a|E|x|p|r|e|s@1|i|o|n|s|T|e|s|t|s| @46 +|{+0#00e0e07&| +0#0000000&@73 +| +0#00e0e07&@3|<|I|1|,| |C|1|,| |C|2|,| |T|1|,| |T|2|,| |T|3|,| |Z|1|,| |Z|2|,| |Z|3|,| |S|1|,| |S|2|,| |S|3|>| |v+0#00e0003&|o|i|d| +0#00e0e07&|t|e|s|t|(|)| +0#0000000&@10 +@4|{+0#00e0e07&| +0#0000000&@2|/+0#0000e05&@1| |S|c|h|ö|n|f|i|n|k|e|l|'|s| |f|u|n|c|t|i|o|n|s|.| +0#0000000&@39 +@8|I|<|I|1|>| |i| |=| |x+0#00e0e07&| |-|>| +0#0000000&|x|;| @49 +@8|C|<|C|1|,| |C|2|>| |c| |=| |x+0#00e0e07&| |-|>| +0#0000000&|y+0#00e0e07&| |-|>| +0#0000000&|x|;| @40 +@8|T|<|T|1|,| |T|2|,| |T|3|>| |t| |=| |f+0#00e0e07&| |-|>| +0#0000000&|y+0#00e0e07&| |-|>| +0#0000000&|x+0#00e0e07&| |-|>| +0#0000000&|f|.|a|p@1|l|y|(|x|)|.|a|p@1|l|y|(|y|)|;| @13 +@8|Z|<|Z|1|,| |Z|2|,| |Z|3|>| |z| |=| |f+0#00e0e07&| |-|>| +0#0000000&|g+0#00e0e07&| |-|>| +0#0000000&|x+0#00e0e07&| |-|>| +0#0000000&|f|.|a|p@1|l|y|(|g|.|a|p@1|l|y|(|x|)@1|;| @13 +@8|S|<|S|1|,| |S|2|,| |S|3|>| |s| |=| |f+0#00e0e07&| |-|>| +0#0000000&|g+0#00e0e07&| |-|>| +0#0000000&|x+0#00e0e07&| |-|>| +0#0000000&|f|.|a|p@1|l|y|(|x|)| @23 +@24|.|a|p@1|l|y|(|g|.|a|p@1|l|y|(|x|)@1|;| @31 +@75 +@8|I|<|I|1|>| |i|0|1| |=| |(+0#00e0e07&|v+0#af5f00255&|a|r| +0#00e0e07&|x|)| |-|>| +0#0000000&|x|;| @41 +@57|1|,|1| @10|T|o|p|
new file mode 100644 --- /dev/null +++ b/runtime/syntax/testdir/dumps/java_lambda_expressions_01.dump @@ -0,0 +1,20 @@ +| +0&#ffffff0@7|T|<|T|1|,| |T|2|,| |T|3|>| |t| |=| |f+0#00e0e07&| |-|>| +0#0000000&|y+0#00e0e07&| |-|>| +0#0000000&|x+0#00e0e07&| |-|>| +0#0000000&|f|.|a|p@1|l|y|(|x|)|.|a|p@1|l|y|(|y|)|;| @13 +@8|Z|<|Z|1|,| |Z|2|,| |Z|3|>| |z| |=| |f+0#00e0e07&| |-|>| +0#0000000&|g+0#00e0e07&| |-|>| +0#0000000&|x+0#00e0e07&| |-|>| +0#0000000&|f|.|a|p@1|l|y|(|g|.|a|p@1|l|y|(|x|)@1|;| @13 +@8|S|<|S|1|,| |S|2|,| |S|3|>| |s| |=| |f+0#00e0e07&| |-|>| +0#0000000&|g+0#00e0e07&| |-|>| +0#0000000&|x+0#00e0e07&| |-|>| +0#0000000&|f|.|a|p@1|l|y|(|x|)| @23 +@24|.|a|p@1|l|y|(|g|.|a|p@1|l|y|(|x|)@1|;| @31 +@75 +@8>I|<|I|1|>| |i|0|1| |=| |(+0#00e0e07&|v+0#af5f00255&|a|r| +0#00e0e07&|x|)| |-|>| +0#0000000&|x|;| @41 +@8|I|<|I|1|>| |i|0|2| |=| |(+0#00e0e07&|@+0#e000e06&|T|a|g@1|a|b|l|e| +0#00e0e07&|v+0#af5f00255&|a|r| +0#00e0e07&|x|)| |-|>| +0#0000000&|x|;| @31 +@8|I|<|I|1|>| |i|0|3| |=| |(+0#00e0e07&|@+0#e000e06&|T|a|g@1|a|b|l|e| +0#00e0e07&|@+0#e000e06&|T|a|g@1|a|b|l|e| +0#00e0e07&|v+0#af5f00255&|a|r| +0#00e0e07&|x|)| |-|>| +0#0000000&|x|;| @21 +@8|I|<|I|1|>| |i|0|4| |=| |(+0#00e0e07&|f+0#4040ff13&|i|n|a|l| +0#00e0e07&|v+0#af5f00255&|a|r| +0#00e0e07&|x|)| |-|>| +0#0000000&|x|;| @35 +@8|I|<|I|1|>| |i|0|5| |=| |(+0#00e0e07&|@+0#e000e06&|T|a|g@1|a|b|l|e| +0#00e0e07&|f+0#4040ff13&|i|n|a|l| +0#00e0e07&|v+0#af5f00255&|a|r| +0#00e0e07&|x|)| |-|>| +0#0000000&|x|;| @25 +@8|I|<|I|1|>| |i|0|6| |=| |(+0#00e0e07&|@+0#e000e06&|T|a|g@1|a|b|l|e| +0#00e0e07&|@+0#e000e06&|T|a|g@1|a|b|l|e| +0#00e0e07&|f+0#4040ff13&|i|n|a|l| +0#00e0e07&|v+0#af5f00255&|a|r| +0#00e0e07&|x|)| |-|>| +0#0000000&|x|;| @15 +@8|I|<|I|1|>| |i|0|7| |=| |(+0#00e0e07&|I|1| |x|)| |-|>| +0#0000000&|x|;| @42 +@8|I|<|I|1|>| |i|0|8| |=| |(+0#00e0e07&|@+0#e000e06&|T|a|g@1|a|b|l|e| +0#00e0e07&|I|1| |x|)| |-|>| +0#0000000&|x|;| @32 +@8|I|<|I|1|>| |i|0|9| |=| |(+0#00e0e07&|@+0#e000e06&|T|a|g@1|a|b|l|e| +0#00e0e07&|@+0#e000e06&|T|a|g@1|a|b|l|e| +0#00e0e07&|I|1| |x|)| |-|>| +0#0000000&|x|;| @22 +@8|I|<|I|1|>| |i|1|0| |=| |(+0#00e0e07&|f+0#4040ff13&|i|n|a|l| +0#00e0e07&|I|1| |x|)| |-|>| +0#0000000&|x|;| @36 +@8|I|<|I|1|>| |i|1@1| |=| |(+0#00e0e07&|@+0#e000e06&|T|a|g@1|a|b|l|e| +0#00e0e07&|f+0#4040ff13&|i|n|a|l| +0#00e0e07&|I|1| |x|)| |-|>| +0#0000000&|x|;| @26 +@8|I|<|I|1|>| |i|1|2| |=| |(+0#00e0e07&|@+0#e000e06&|T|a|g@1|a|b|l|e| +0#00e0e07&|@+0#e000e06&|T|a|g@1|a|b|l|e| +0#00e0e07&|f+0#4040ff13&|i|n|a|l| +0#00e0e07&|I|1| |x|)| |-|>| +0#0000000&|x|;| @16 +@75 +@8|I|<|I|1|[|]|>| |i@1|0|1| |=| |(+0#00e0e07&|I|1|.@2| |x|)| |-|>| +0#0000000&|x|;| @36 +@57|1|9|,|3|-|9| @7|1|5|%|
new file mode 100644 --- /dev/null +++ b/runtime/syntax/testdir/dumps/java_lambda_expressions_02.dump @@ -0,0 +1,20 @@ +| +0&#ffffff0@7|I|<|I|1|[|]|>| |i@1|0|1| |=| |(+0#00e0e07&|I|1|.@2| |x|)| |-|>| +0#0000000&|x|;| @36 +@8|I|<|I|1|[|]|>| |i@1|0|2| |=| |(+0#00e0e07&|@+0#e000e06&|T|a|g@1|a|b|l|e| +0#00e0e07&|I|1|.@2| |x|)| |-|>| +0#0000000&|x|;| @26 +@8|I|<|I|1|[|]|>| |i@1|0|3| |=| |(+0#00e0e07&|@+0#e000e06&|T|a|g@1|a|b|l|e| +0#00e0e07&|@+0#e000e06&|T|a|g@1|a|b|l|e| +0#00e0e07&|I|1|.@2| |x|)| |-|>| +0#0000000&|x|;| @16 +@8|I|<|I|1|[|]|>| |i@1|0|4| |=| |(+0#00e0e07&|f+0#4040ff13&|i|n|a|l| +0#00e0e07&|I|1|.@2| |x|)| |-|>| +0#0000000&|x|;| @30 +@8|I|<|I|1|[|]|>| |i@1|0|5| |=| |(+0#00e0e07&|@+0#e000e06&|T|a|g@1|a|b|l|e| +0#00e0e07&|f+0#4040ff13&|i|n|a|l| +0#00e0e07&|I|1|.@2| |x|)| |-|>| +0#0000000&|x|;| @20 +@8>I|<|I|1|[|]|>| |i@1|0|6| |=| |(+0#00e0e07&|@+0#e000e06&|T|a|g@1|a|b|l|e| +0#00e0e07&|@+0#e000e06&|T|a|g@1|a|b|l|e| +0#00e0e07&|f+0#4040ff13&|i|n|a|l| +0#00e0e07&|I|1|.@2| |x|)| |-|>| +0#0000000&|x|;| @10 +@75 +@8|B|i|n|a|r|y|O|p|e|r|a|t|o|r|<|I|1|>| |l|e|f|t|C|o|n|s|t|0|1| |=| |(+0#00e0e07&|v+0#af5f00255&|a|r| +0#00e0e07&|x|,| |v+0#af5f00255&|a|r| +0#00e0e07&|y|)| |-|>| +0#0000000&|x|;| @13 +@8|B|i|n|a|r|y|O|p|e|r|a|t|o|r|<|I|1|>| |l|e|f|t|C|o|n|s|t|0|2| |=| |(+0#00e0e07&|@+0#e000e06&|T|a|g@1|a|b|l|e| +0#00e0e07&|v+0#af5f00255&|a|r| +0#00e0e07&|x|,| +0#0000000&@16 +| +0#00e0e07&@19|@+0#e000e06&|T|a|g@1|a|b|l|e| +0#00e0e07&|v+0#af5f00255&|a|r| +0#00e0e07&|y|)| |-|>| +0#0000000&|x|;| @32 +@8|B|i|n|a|r|y|O|p|e|r|a|t|o|r|<|I|1|>| |l|e|f|t|C|o|n|s|t|0|3| |=| |(+0#00e0e07&|@+0#e000e06&|T|a|g@1|a|b|l|e| +0#00e0e07&|@+0#e000e06&|T|a|g@1|a|b|l|e| +0#00e0e07&|v+0#af5f00255&|a|r| +0#0000000&@9 +| +0#00e0e07&@19|x|,| |@+0#e000e06&|T|a|g@1|a|b|l|e| +0#00e0e07&|@+0#e000e06&|T|a|g@1|a|b|l|e| +0#00e0e07&|v+0#af5f00255&|a|r| +0#00e0e07&|y|)| |-|>| +0#0000000&|x|;| @19 +@8|B|i|n|a|r|y|O|p|e|r|a|t|o|r|<|I|1|>| |l|e|f|t|C|o|n|s|t|0|4| |=| |(+0#00e0e07&|f+0#4040ff13&|i|n|a|l| +0#00e0e07&|v+0#af5f00255&|a|r| +0#00e0e07&|x|,| +0#0000000&@20 +| +0#00e0e07&@19|f+0#4040ff13&|i|n|a|l| +0#00e0e07&|v+0#af5f00255&|a|r| +0#00e0e07&|y|)| |-|>| +0#0000000&|x|;| @36 +@8|B|i|n|a|r|y|O|p|e|r|a|t|o|r|<|I|1|>| |l|e|f|t|C|o|n|s|t|0|5| |=| |(+0#00e0e07&|@+0#e000e06&|T|a|g@1|a|b|l|e| +0#00e0e07&|f+0#4040ff13&|i|n|a|l| +0#0000000&@17 +| +0#00e0e07&@19|v+0#af5f00255&|a|r| +0#00e0e07&|x|,| |@+0#e000e06&|T|a|g@1|a|b|l|e| +0#00e0e07&|f+0#4040ff13&|i|n|a|l| +0#00e0e07&|v+0#af5f00255&|a|r| +0#00e0e07&|y|)| |-|>| +0#0000000&|x|;| @19 +@8|B|i|n|a|r|y|O|p|e|r|a|t|o|r|<|I|1|>| |l|e|f|t|C|o|n|s|t|0|6| |=| |(+0#00e0e07&|@+0#e000e06&|T|a|g@1|a|b|l|e| +0#0000000&@23 +| +0#00e0e07&@19|@+0#e000e06&|T|a|g@1|a|b|l|e| +0#00e0e07&|f+0#4040ff13&|i|n|a|l| +0#00e0e07&|v+0#af5f00255&|a|r| +0#00e0e07&|x|,| +0#0000000&@32 +| +0#00e0e07&@19|@+0#e000e06&|T|a|g@1|a|b|l|e| +0#0000000&@45 +@57|3|7|,|3|-|9| @7|3|6|%|
new file mode 100644 --- /dev/null +++ b/runtime/syntax/testdir/dumps/java_lambda_expressions_03.dump @@ -0,0 +1,20 @@ +| +0#00e0e07#ffffff0@19|@+0#e000e06&|T|a|g@1|a|b|l|e| +0#0000000&@45 +| +0#00e0e07&@19|@+0#e000e06&|T|a|g@1|a|b|l|e| +0#00e0e07&|f+0#4040ff13&|i|n|a|l| +0#00e0e07&|v+0#af5f00255&|a|r| +0#00e0e07&|y|)| |-|>| +0#0000000&|x|;| @26 +@8|B|i|n|a|r|y|O|p|e|r|a|t|o|r|<|I|1|>| |l|e|f|t|C|o|n|s|t|0|7| |=| |(+0#00e0e07&|I|1| |x|,| |I|1| |y|)| |-|>| +0#0000000&|x|;| @15 +@8|B|i|n|a|r|y|O|p|e|r|a|t|o|r|<|I|1|>| |l|e|f|t|C|o|n|s|t|0|8| |=| |(+0#00e0e07&|@+0#e000e06&|T|a|g@1|a|b|l|e| +0#00e0e07&|I|1| |x|,| +0#0000000&@17 +| +0#00e0e07&@19|@+0#e000e06&|T|a|g@1|a|b|l|e| +0#00e0e07&|I|1| |y|)| |-|>| +0#0000000&|x|;| @33 +@8>B|i|n|a|r|y|O|p|e|r|a|t|o|r|<|I|1|>| |l|e|f|t|C|o|n|s|t|0|9| |=| |(+0#00e0e07&|@+0#e000e06&|T|a|g@1|a|b|l|e| +0#00e0e07&|@+0#e000e06&|T|a|g@1|a|b|l|e| +0#00e0e07&|I|1| +0#0000000&@10 +| +0#00e0e07&@19|x|,| |@+0#e000e06&|T|a|g@1|a|b|l|e| +0#00e0e07&|@+0#e000e06&|T|a|g@1|a|b|l|e| +0#00e0e07&|I|1| |y|)| |-|>| +0#0000000&|x|;| @20 +@8|B|i|n|a|r|y|O|p|e|r|a|t|o|r|<|I|1|>| |l|e|f|t|C|o|n|s|t|1|0| |=| |(+0#00e0e07&|f+0#4040ff13&|i|n|a|l| +0#00e0e07&|I|1| |x|,| +0#0000000&@21 +| +0#00e0e07&@19|f+0#4040ff13&|i|n|a|l| +0#00e0e07&|I|1| |y|)| |-|>| +0#0000000&|x|;| @37 +@8|B|i|n|a|r|y|O|p|e|r|a|t|o|r|<|I|1|>| |l|e|f|t|C|o|n|s|t|1@1| |=| |(+0#00e0e07&|@+0#e000e06&|T|a|g@1|a|b|l|e| +0#00e0e07&|f+0#4040ff13&|i|n|a|l| +0#0000000&@17 +| +0#00e0e07&@19|I|1| |x|,| |@+0#e000e06&|T|a|g@1|a|b|l|e| +0#00e0e07&|f+0#4040ff13&|i|n|a|l| +0#00e0e07&|I|1| |y|)| |-|>| +0#0000000&|x|;| @21 +@8|B|i|n|a|r|y|O|p|e|r|a|t|o|r|<|I|1|>| |l|e|f|t|C|o|n|s|t|1|2| |=| |(+0#00e0e07&|@+0#e000e06&|T|a|g@1|a|b|l|e| +0#0000000&@23 +| +0#00e0e07&@19|@+0#e000e06&|T|a|g@1|a|b|l|e| +0#00e0e07&|f+0#4040ff13&|i|n|a|l| +0#00e0e07&|I|1| |x|,| +0#0000000&@33 +| +0#00e0e07&@19|@+0#e000e06&|T|a|g@1|a|b|l|e| +0#0000000&@45 +| +0#00e0e07&@19|@+0#e000e06&|T|a|g@1|a|b|l|e| +0#00e0e07&|f+0#4040ff13&|i|n|a|l| +0#00e0e07&|I|1| |y|)| |-|>| +0#0000000&|x|;| @27 +@75 +@8|R|u|n@1|a|b|l|e| |n|o|O|p| |=| |(+0#00e0e07&|)| |-|>| +0#0000000&|{+0#00e0e07&|}|;+0#0000000&| @41 +@8|B|i|n|a|r|y|O|p|e|r|a|t|o|r|<|I|1|>| |l|e|f|t|C|o|n|s|t| |=| |(+0#00e0e07&|x|,| |y|)| |-|>| +0#0000000&|x|;| @23 +@8|I|<|I|1|>| |i|d|1| |=| |(+0#00e0e07&|x|)| |-|>| +0#0000000&|(|x|)|;| @43 +@57|5@1|,|3|-|9| @7|5|7|%|
new file mode 100644 --- /dev/null +++ b/runtime/syntax/testdir/dumps/java_lambda_expressions_04.dump @@ -0,0 +1,20 @@ +| +0&#ffffff0@7|I|<|I|1|>| |i|d|1| |=| |(+0#00e0e07&|x|)| |-|>| +0#0000000&|(|x|)|;| @43 +@8|@+0#e000e06&|S|u|p@1|r|e|s@1|W|a|r|n|i|n|g|s|(+0#0000000&|"+0#e000002&|u|n|c|h|e|c|k|e|d|"|)+0#0000000&| |I|<|I|1|>| |i|d|2| |=| @24 +@16|(@1|I|<|I|<|I|1|>@1|)| |(|I|<|?|>|)| |(|F|u|n|c|t|i|o|n|<|I|1|,| @26 +@20|I|1|>| |x|)| |-|>| |x|)|.|a|p@1|l|y|(|s+0#af5f00255&|w|i|t|c|h| +0#0000000&|(|0+0#e000002&|)+0#0000000&| |{+0#00e0e07&| +0#0000000&@23 +@16|c+0#af5f00255&|a|s|e| +0#0000000&|(@1|i+0#00e0003&|n|t|)+0#0000000&| |(|b+0#00e0003&|y|t|e|)+0#0000000&| |1+0#e000002&|)+0#0000000&| |-|>| |(+0#00e0e07&|I|1| |x|)| |-|>| +0#0000000&|x|;| @21 +@16>d+0#af5f00255&|e|f|a|u|l|t| +0#0000000&|-|>| |(+0#00e0e07&|@+0#e000e06&|T|a|g@1|a|b|l|e| +0#00e0e07&|I|1| |x|)| |-|>| +0#0000000&|x|;| |}+0#00e0e07&|)+0#0000000&|;| @21 +@8|C|<|C|1|,| |C|2|>| |c|o|n|s|t|1| |=| |(+0#00e0e07&|x|)| |-|>| +0#0000000&|(+0#00e0e07&|y|)| |-|>| +0#0000000&|(|x|)|;| @29 +@8|C|<|C|1|,| |C|2|>| |c|o|n|s|t|2| |=| |s+0#af5f00255&|w|i|t|c|h|(+0#0000000&|s+0#af5f00255&|w|i|t|c|h| +0#0000000&|(|"+0#e000002&@1|)+0#0000000&| |{+0#00e0e07&| +0#0000000&@27 +@24|c+0#af5f00255&|a|s|e| +0#0000000&|"+0#e000002&|-|>|"|-+0#0000000&|>|"+0#e000002&|(|s|)|-|>|(|s|)|"|;+0#0000000&| @28 +@24|d+0#af5f00255&|e|f|a|u|l|t|-+0#0000000&|>|"+0#e000002&|d|e|f|a|u|l|t|"|;+0#0000000&| |}+0#00e0e07&|)+0#0000000&| |{+0#00e0e07&| +0#0000000&@26 +@12|c+0#af5f00255&|a|s|e| +0#0000000&|(|"+0#e000002&|-|>|"|)+0#0000000&|-|>|(+0#00e0e07&|v+0#af5f00255&|a|r| +0#00e0e07&|x|)|-|>|(|v+0#af5f00255&|a|r| +0#00e0e07&|y|)|-|>|(+0#0000000&|x|)|;| @27 +@12|d+0#af5f00255&|e|f|a|u|l|t|-+0#0000000&|>|(+0#00e0e07&|@+0#e000e06&|T|a|g@1|a|b|l|e| +0#00e0e07&|v+0#af5f00255&|a|r| +0#00e0e07&|x|)|-|>|(|@+0#e000e06&|T|a|g@1|a|b|l|e| +0#00e0e07&|v+0#af5f00255&|a|r| +0#00e0e07&|y|)| +0#0000000&@17 +| +0#00e0e07&@15|-|>|(+0#0000000&|x|)|;| @52 +@8|}+0#00e0e07&|;+0#0000000&| @64 +@4|}+0#00e0e07&| +0#0000000&@69 +@75 +@4|@+0#e000e06&|j|a|v|a|.|l|a|n|g|.|a|n@1|o|t|a|t|i|o|n|.|T|a|r|g|e|t|(+0#0000000&|E|l|e|m|e|n|t|T|y|p|e|.|P|A|R|A|M|E|T|E|R|)| @19 +@4|@+0#e000e06&|j|a|v|a|.|l|a|n|g|.|a|n@1|o|t|a|t|i|o|n|.|R|e|p|e|a|t|a|b|l|e|(+0#0000000&|T|a|g@1|a|b|l|e|s|.|c+0#00e0003&|l|a|s@1|)+0#0000000&| @21 +@4|@+0#00e0003&|i|n|t|e|r|f|a|c|e| +0#0000000&|T|a|g@1|a|b|l|e| |{+0#00e0e07&| +0#0000000&|S|t|r|i|n|g|[|]| |v|a|l|u|e|(|)| |d+0#4040ff13&|e|f|a|u|l|t| +0#0000000&|"+0#e000002&@1|;+0#0000000&| |}+0#00e0e07&| +0#0000000&@18 +@57|7|3|,|5|-|1|7| @6|7|8|%|
new file mode 100644 --- /dev/null +++ b/runtime/syntax/testdir/dumps/java_lambda_expressions_05.dump @@ -0,0 +1,20 @@ +| +0&#ffffff0@3|@+0#00e0003&|i|n|t|e|r|f|a|c|e| +0#0000000&|T|a|g@1|a|b|l|e| |{+0#00e0e07&| +0#0000000&|S|t|r|i|n|g|[|]| |v|a|l|u|e|(|)| |d+0#4040ff13&|e|f|a|u|l|t| +0#0000000&|"+0#e000002&@1|;+0#0000000&| |}+0#00e0e07&| +0#0000000&@18 +@75 +@4|@+0#e000e06&|j|a|v|a|.|l|a|n|g|.|a|n@1|o|t|a|t|i|o|n|.|T|a|r|g|e|t|(+0#0000000&|E|l|e|m|e|n|t|T|y|p|e|.|P|A|R|A|M|E|T|E|R|)| @19 +@4|@+0#00e0003&|i|n|t|e|r|f|a|c|e| +0#0000000&|T|a|g@1|a|b|l|e|s| |{+0#00e0e07&| +0#0000000&|T|a|g@1|a|b|l|e|[|]| |v|a|l|u|e|(|)|;| |}+0#00e0e07&| +0#0000000&@26 +@75 +@4>i+0#00e0003&|n|t|e|r|f|a|c|e| +0#0000000&|I|<|A|1|>| |e+0#00e0003&|x|t|e|n|d|s| +0#0000000&|F|u|n|c|t|i|o|n|<|A|1|,| |A|1|>| |{+0#00e0e07&| +0#0000000&|}+0#00e0e07&| +0#0000000&@26 +@4|i+0#00e0003&|n|t|e|r|f|a|c|e| +0#0000000&|C|<|A|1|,| |A|2|>| |e+0#00e0003&|x|t|e|n|d|s| +0#0000000&|F|u|n|c|t|i|o|n|<|A|1|,| |F|u|n|c|t|i|o|n|<|A|2|,| |A|1|>@1| |{+0#00e0e07&| +0#0000000&|}+0#00e0e07&| +0#0000000&@8 +@4|i+0#00e0003&|n|t|e|r|f|a|c|e| +0#0000000&|T|<|A|1|,| |A|2|,| |A|3|>| |e+0#00e0003&|x|t|e|n|d|s| +0#0000000&@39 +@16|F|u|n|c|t|i|o|n|<|F|u|n|c|t|i|o|n|<|A|1|,| |F|u|n|c|t|i|o|n|<|A|2|,| |A|3|>@1|,| @18 +@20|F|u|n|c|t|i|o|n|<|A|2|,| @42 +@20|F|u|n|c|t|i|o|n|<|A|1|,| |A|3|>@2| |{+0#00e0e07&| +0#0000000&|}+0#00e0e07&| +0#0000000&@32 +@4|i+0#00e0003&|n|t|e|r|f|a|c|e| +0#0000000&|Z|<|A|1|,| |A|2|,| |A|3|>| |e+0#00e0003&|x|t|e|n|d|s| +0#0000000&|F|u|n|c|t|i|o|n|<|F|u|n|c|t|i|o|n|<|A|2|,| |A|3|>|,| @12 +@20|F|u|n|c|t|i|o|n|<|F|u|n|c|t|i|o|n|<|A|1|,| |A|2|>|,| @28 +@20|F|u|n|c|t|i|o|n|<|A|1|,| |A|3|>@2| |{+0#00e0e07&| +0#0000000&|}+0#00e0e07&| +0#0000000&@32 +@4|i+0#00e0003&|n|t|e|r|f|a|c|e| +0#0000000&|S|<|A|1|,| |A|2|,| |A|3|>| |e+0#00e0003&|x|t|e|n|d|s| +0#0000000&@39 +@16|F|u|n|c|t|i|o|n|<|F|u|n|c|t|i|o|n|<|A|1|,| |F|u|n|c|t|i|o|n|<|A|2|,| |A|3|>@1|,| @18 +@20|F|u|n|c|t|i|o|n|<|F|u|n|c|t|i|o|n|<|A|1|,| |A|2|>|,| @28 +@20|F|u|n|c|t|i|o|n|<|A|1|,| |A|3|>@2| |{+0#00e0e07&| +0#0000000&|}+0#00e0e07&| +0#0000000&@32 +|}+0#00e0e07&| +0#0000000&@73 +@57|9|1|,|2|-|5| @7|B|o|t|
new file mode 100644 --- /dev/null +++ b/runtime/syntax/testdir/dumps/java_lambda_expressions_99.dump @@ -0,0 +1,20 @@ +| +0&#ffffff0@3|@+0#00e0003&|i|n|t|e|r|f|a|c|e| +0#0000000&|T|a|g@1|a|b|l|e| |{+0#00e0e07&| +0#0000000&|S|t|r|i|n|g|[|]| |v|a|l|u|e|(|)| |d+0#4040ff13&|e|f|a|u|l|t| +0#0000000&|"+0#e000002&@1|;+0#0000000&| |}+0#00e0e07&| +0#0000000&@18 +@75 +@4|@+0#e000e06&|j|a|v|a|.|l|a|n|g|.|a|n@1|o|t|a|t|i|o|n|.|T|a|r|g|e|t|(+0#0000000&|E|l|e|m|e|n|t|T|y|p|e|.|P|A|R|A|M|E|T|E|R|)| @19 +@4|@+0#00e0003&|i|n|t|e|r|f|a|c|e| +0#0000000&|T|a|g@1|a|b|l|e|s| |{+0#00e0e07&| +0#0000000&|T|a|g@1|a|b|l|e|[|]| |v|a|l|u|e|(|)|;| |}+0#00e0e07&| +0#0000000&@26 +@75 +@4|i+0#00e0003&|n|t|e|r|f|a|c|e| +0#0000000&|I|<|A|1|>| |e+0#00e0003&|x|t|e|n|d|s| +0#0000000&|F|u|n|c|t|i|o|n|<|A|1|,| |A|1|>| |{+0#00e0e07&| +0#0000000&|}+0#00e0e07&| +0#0000000&@26 +@4|i+0#00e0003&|n|t|e|r|f|a|c|e| +0#0000000&|C|<|A|1|,| |A|2|>| |e+0#00e0003&|x|t|e|n|d|s| +0#0000000&|F|u|n|c|t|i|o|n|<|A|1|,| |F|u|n|c|t|i|o|n|<|A|2|,| |A|1|>@1| |{+0#00e0e07&| +0#0000000&|}+0#00e0e07&| +0#0000000&@8 +@4|i+0#00e0003&|n|t|e|r|f|a|c|e| +0#0000000&|T|<|A|1|,| |A|2|,| |A|3|>| |e+0#00e0003&|x|t|e|n|d|s| +0#0000000&@39 +@16|F|u|n|c|t|i|o|n|<|F|u|n|c|t|i|o|n|<|A|1|,| |F|u|n|c|t|i|o|n|<|A|2|,| |A|3|>@1|,| @18 +@20|F|u|n|c|t|i|o|n|<|A|2|,| @42 +@20|F|u|n|c|t|i|o|n|<|A|1|,| |A|3|>@2| |{+0#00e0e07&| +0#0000000&|}+0#00e0e07&| +0#0000000&@32 +@4|i+0#00e0003&|n|t|e|r|f|a|c|e| +0#0000000&|Z|<|A|1|,| |A|2|,| |A|3|>| |e+0#00e0003&|x|t|e|n|d|s| +0#0000000&|F|u|n|c|t|i|o|n|<|F|u|n|c|t|i|o|n|<|A|2|,| |A|3|>|,| @12 +@20|F|u|n|c|t|i|o|n|<|F|u|n|c|t|i|o|n|<|A|1|,| |A|2|>|,| @28 +@20|F|u|n|c|t|i|o|n|<|A|1|,| |A|3|>@2| |{+0#00e0e07&| +0#0000000&|}+0#00e0e07&| +0#0000000&@32 +@4|i+0#00e0003&|n|t|e|r|f|a|c|e| +0#0000000&|S|<|A|1|,| |A|2|,| |A|3|>| |e+0#00e0003&|x|t|e|n|d|s| +0#0000000&@39 +@16|F|u|n|c|t|i|o|n|<|F|u|n|c|t|i|o|n|<|A|1|,| |F|u|n|c|t|i|o|n|<|A|2|,| |A|3|>@1|,| @18 +@20|F|u|n|c|t|i|o|n|<|F|u|n|c|t|i|o|n|<|A|1|,| |A|2|>|,| @28 +@20|F|u|n|c|t|i|o|n|<|A|1|,| |A|3|>@2| |{+0#00e0e07&| +0#0000000&|}+0#00e0e07&| +0#0000000&@32 +>}+0#00e0e07&| +0#0000000&@73 +@57|1|0|4|,|1| @8|B|o|t|
new file mode 100644 --- /dev/null +++ b/runtime/syntax/testdir/input/java_lambda_expressions.java @@ -0,0 +1,104 @@ +// VIM_TEST_SETUP let g:java_highlight_functions = 'style' + + +import java.lang.annotation.ElementType; +import java.util.function.BinaryOperator; +import java.util.function.Function; + +class LambdaExpressionsTests +{ + <I1, C1, C2, T1, T2, T3, Z1, Z2, Z3, S1, S2, S3> void test() + { // Schönfinkel's functions. + I<I1> i = x -> x; + C<C1, C2> c = x -> y -> x; + T<T1, T2, T3> t = f -> y -> x -> f.apply(x).apply(y); + Z<Z1, Z2, Z3> z = f -> g -> x -> f.apply(g.apply(x)); + S<S1, S2, S3> s = f -> g -> x -> f.apply(x) + .apply(g.apply(x)); + + I<I1> i01 = (var x) -> x; + I<I1> i02 = (@Taggable var x) -> x; + I<I1> i03 = (@Taggable @Taggable var x) -> x; + I<I1> i04 = (final var x) -> x; + I<I1> i05 = (@Taggable final var x) -> x; + I<I1> i06 = (@Taggable @Taggable final var x) -> x; + I<I1> i07 = (I1 x) -> x; + I<I1> i08 = (@Taggable I1 x) -> x; + I<I1> i09 = (@Taggable @Taggable I1 x) -> x; + I<I1> i10 = (final I1 x) -> x; + I<I1> i11 = (@Taggable final I1 x) -> x; + I<I1> i12 = (@Taggable @Taggable final I1 x) -> x; + + I<I1[]> ii01 = (I1... x) -> x; + I<I1[]> ii02 = (@Taggable I1... x) -> x; + I<I1[]> ii03 = (@Taggable @Taggable I1... x) -> x; + I<I1[]> ii04 = (final I1... x) -> x; + I<I1[]> ii05 = (@Taggable final I1... x) -> x; + I<I1[]> ii06 = (@Taggable @Taggable final I1... x) -> x; + + BinaryOperator<I1> leftConst01 = (var x, var y) -> x; + BinaryOperator<I1> leftConst02 = (@Taggable var x, + @Taggable var y) -> x; + BinaryOperator<I1> leftConst03 = (@Taggable @Taggable var + x, @Taggable @Taggable var y) -> x; + BinaryOperator<I1> leftConst04 = (final var x, + final var y) -> x; + BinaryOperator<I1> leftConst05 = (@Taggable final + var x, @Taggable final var y) -> x; + BinaryOperator<I1> leftConst06 = (@Taggable + @Taggable final var x, + @Taggable + @Taggable final var y) -> x; + BinaryOperator<I1> leftConst07 = (I1 x, I1 y) -> x; + BinaryOperator<I1> leftConst08 = (@Taggable I1 x, + @Taggable I1 y) -> x; + BinaryOperator<I1> leftConst09 = (@Taggable @Taggable I1 + x, @Taggable @Taggable I1 y) -> x; + BinaryOperator<I1> leftConst10 = (final I1 x, + final I1 y) -> x; + BinaryOperator<I1> leftConst11 = (@Taggable final + I1 x, @Taggable final I1 y) -> x; + BinaryOperator<I1> leftConst12 = (@Taggable + @Taggable final I1 x, + @Taggable + @Taggable final I1 y) -> x; + + Runnable noOp = () -> {}; + BinaryOperator<I1> leftConst = (x, y) -> x; + I<I1> id1 = (x) -> (x); + @SuppressWarnings("unchecked") I<I1> id2 = + ((I<I<I1>>) (I<?>) (Function<I1, + I1> x) -> x).apply(switch (0) { + case ((int) (byte) 1) -> (I1 x) -> x; + default -> (@Taggable I1 x) -> x; }); + C<C1, C2> const1 = (x) -> (y) -> (x); + C<C1, C2> const2 = switch(switch ("") { + case "->"->"(s)->(s)"; + default->"default"; }) { + case ("->")->(var x)->(var y)->(x); + default->(@Taggable var x)->(@Taggable var y) + ->(x); + }; + } + + @java.lang.annotation.Target(ElementType.PARAMETER) + @java.lang.annotation.Repeatable(Taggables.class) + @interface Taggable { String[] value() default ""; } + + @java.lang.annotation.Target(ElementType.PARAMETER) + @interface Taggables { Taggable[] value(); } + + interface I<A1> extends Function<A1, A1> { } + interface C<A1, A2> extends Function<A1, Function<A2, A1>> { } + interface T<A1, A2, A3> extends + Function<Function<A1, Function<A2, A3>>, + Function<A2, + Function<A1, A3>>> { } + interface Z<A1, A2, A3> extends Function<Function<A2, A3>, + Function<Function<A1, A2>, + Function<A1, A3>>> { } + interface S<A1, A2, A3> extends + Function<Function<A1, Function<A2, A3>>, + Function<Function<A1, A2>, + Function<A1, A3>>> { } +}