Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManoj Palat2019-09-19 08:30:33 +0000
committerSarika Sinha2019-09-19 09:48:37 +0000
commita3466b0f64e8842e5ed6a3a28165da341fb76cc0 (patch)
treeadc5e09ee603628bfbb88a247a105743b26d47fc
parentc842004634d661ef8d9d485e77e9c84af231e888 (diff)
downloadeclipse.jdt.core-a3466b0f64e8842e5ed6a3a28165da341fb76cc0.tar.gz
eclipse.jdt.core-a3466b0f64e8842e5ed6a3a28165da341fb76cc0.tar.xz
eclipse.jdt.core-a3466b0f64e8842e5ed6a3a28165da341fb76cc0.zip
Merge remote-tracking branch 'origin/BETA_JAVA13'I20190919-1800I20190919-0850
# Conflicts: # org.eclipse.jdt.compiler.apt/META-INF/MANIFEST.MF # org.eclipse.jdt.compiler.apt/pom.xml # org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF # org.eclipse.jdt.core.tests.compiler/pom.xml # org.eclipse.jdt.core.tests.model/META-INF/MANIFEST.MF # org.eclipse.jdt.core.tests.model/pom.xml # org.eclipse.jdt.core/META-INF/MANIFEST.MF # org.eclipse.jdt.core/pom.xml Change-Id: I2562d3b2833b1b63e3b8cfc46eb533bffcae6bd9
-rw-r--r--org.eclipse.jdt.apt.core/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.jdt.apt.core/pom.xml2
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/BaseProcessorEnv.java10
-rw-r--r--org.eclipse.jdt.apt.tests/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.jdt.apt.tests/pom.xml2
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/ReadAnnotationTests2.java6
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/.classpath2
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/META-INF/MANIFEST.MF4
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/build.properties2
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors8.jarbin259552 -> 267940 bytes
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/lib/java13api.jar (renamed from org.eclipse.jdt.compiler.apt.tests/lib/java10api.jar)bin109915 -> 111292 bytes
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/pom.xml2
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/processors8/META-INF/services/javax.annotation.processing.Processor1
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/processors8/org/eclipse/jdt/compiler/apt/tests/processors/elements/Java11ElementProcessor.java2
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/processors8/org/eclipse/jdt/compiler/apt/tests/processors/elements/Java12ElementProcessor.java2
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/processors8/org/eclipse/jdt/compiler/apt/tests/processors/elements/Java13ElementProcessor.java251
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/Java13ElementsTests.java98
-rw-r--r--org.eclipse.jdt.compiler.apt/build.properties4
-rw-r--r--org.eclipse.jdt.compiler.apt/lib/java13api.jar (renamed from org.eclipse.jdt.compiler.apt/lib/java10api.jar)bin109915 -> 111292 bytes
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BaseProcessingEnvImpl.java33
-rw-r--r--org.eclipse.jdt.compiler.tool.tests/.classpath2
-rw-r--r--org.eclipse.jdt.compiler.tool.tests/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.jdt.compiler.tool.tests/build.properties6
-rw-r--r--org.eclipse.jdt.compiler.tool.tests/lib/java13api.jar (renamed from org.eclipse.jdt.compiler.tool.tests/lib/java10api.jar)bin109915 -> 111292 bytes
-rw-r--r--org.eclipse.jdt.compiler.tool.tests/pom.xml2
-rw-r--r--org.eclipse.jdt.compiler.tool/.classpath2
-rw-r--r--org.eclipse.jdt.compiler.tool/META-INF/MANIFEST.MF4
-rw-r--r--org.eclipse.jdt.compiler.tool/build.properties6
-rw-r--r--org.eclipse.jdt.compiler.tool/lib/java13api.jar (renamed from org.eclipse.jdt.compiler.tool/lib/java10api.jar)bin109915 -> 111292 bytes
-rw-r--r--org.eclipse.jdt.compiler.tool/pom.xml2
-rw-r--r--org.eclipse.jdt.core.tests.builder/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.jdt.core.tests.builder/pom.xml2
-rw-r--r--org.eclipse.jdt.core.tests.compiler/pom.xml30
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ComplianceDiagnoseTest.java14
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/JavadocCompletionParserTest.java1
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ParserTest.java34
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionParserTest12.java293
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionParserTest13.java1070
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestAll.java22
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java46
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java48
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java704
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JEP286Test.java1
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java255
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ResourceLeakTests.java14
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ScannerTest.java68
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionTest.java1231
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionsYieldTest.java3483
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchTest.java2
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java20
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Unicode12_1Test.java65
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/dom/StandAloneASTParserTest.java45
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/StandardVMLauncher.java6
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/AbstractCompilerTest.java43
-rw-r--r--org.eclipse.jdt.core.tests.model/JCL/jclMin13.jarbin0 -> 21029 bytes
-rw-r--r--org.eclipse.jdt.core.tests.model/JCL/jclMin13src.zipbin0 -> 9434 bytes
-rw-r--r--org.eclipse.jdt.core.tests.model/pom.xml31
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/RunAllJava12Tests.java9
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/RunAllJava13Tests.java96
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/RunOnlyJava12Tests.java11
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/RunOnlyJava13Tests.java82
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter10Test.java3
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter11Test.java1
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter13Test.java (renamed from org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter12Test.java)308
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter9Test.java92
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTStructuralPropertyTest.java2
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTTest.java28
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/AbstractASTTests.java4
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ConverterTestSetup.java6
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/RunConverterTests.java2
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/TypeAnnotationsConverterTest.java4
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java18
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java44
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AccessRestrictionsTests.java2
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java4
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java4
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs12Tests.java626
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs13Tests.java1047
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/NullAnnotationModelTests.java10
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java4
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests9.java18
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/RunCompletionModelTests.java1
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingStatementsTest.java30
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingSwitchExpressionsTest.java20
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingTest.java4
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ImportRewriteTest.java4
-rw-r--r--org.eclipse.jdt.core.tests.model/workspace/Converter13/.classpath (renamed from org.eclipse.jdt.core.tests.model/workspace/Converter12/.classpath)0
-rw-r--r--org.eclipse.jdt.core.tests.model/workspace/Converter13/.project (renamed from org.eclipse.jdt.core.tests.model/workspace/Converter12/.project)0
-rw-r--r--org.eclipse.jdt.core.tests.model/workspace/Converter13/src/X.java (renamed from org.eclipse.jdt.core.tests.model/workspace/Converter12/src/X.java)0
-rw-r--r--org.eclipse.jdt.core.tests.model/workspace/Formatter/test390720/A_out.java22
-rw-r--r--org.eclipse.jdt.core.tests.model/workspace/Formatter/test390720/B_out.java22
-rw-r--r--org.eclipse.jdt.core.tests.model/workspace/Formatter/test390720/in.java22
-rw-r--r--org.eclipse.jdt.core.tests.model/workspace/Formatter/test543818/A_out.java8
-rw-r--r--org.eclipse.jdt.core.tests.model/workspace/Formatter/test543818/B_out.java8
-rw-r--r--org.eclipse.jdt.core.tests.model/workspace/Formatter/test543818/C_out.java8
-rw-r--r--org.eclipse.jdt.core.tests.model/workspace/Formatter/test543818/D_out.java8
-rw-r--r--org.eclipse.jdt.core.tests.model/workspace/Formatter/test543818/E_out.java8
-rw-r--r--org.eclipse.jdt.core.tests.model/workspace/Formatter/test543818/F_out.java8
-rw-r--r--org.eclipse.jdt.core.tests.model/workspace/Formatter/test543818/G_out.java8
-rw-r--r--org.eclipse.jdt.core.tests.model/workspace/Formatter/test543818/in.java8
-rw-r--r--org.eclipse.jdt.core.tests.performance/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.jdt.core.tests.performance/pom.xml2
-rw-r--r--org.eclipse.jdt.core.tests.performance/src/org/eclipse/jdt/core/tests/performance/SecondaryTypesPerformanceTest.java4
-rw-r--r--org.eclipse.jdt.core/.settings/.api_filters84
-rw-r--r--org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java14
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java64
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistParser.java9
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/Keywords.java5
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/CategorizedProblem.java3
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java113
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ASTVisitor.java8
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/Compiler.java17
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/BreakStatement.java81
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java13
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Statement.java5
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchExpression.java58
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java15
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TextBlock.java20
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java15
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java18
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/YieldStatement.java182
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileConstants.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowContext.java18
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/SwitchFlowContext.java3
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java3
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/messages.properties2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java5
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/ConflictedParser.java5
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/JavadocTagConstants.java6
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java1224
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/ParserBasicInformation.java26
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java356
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/ScannerHelper.java21
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/TerminalTokens.java173
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/diagnose/DiagnoseParser.java7
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser1.rscbin34470 -> 34178 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser10.rscbin596 -> 596 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser11.rscbin596 -> 596 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser12.rscbin596 -> 596 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser13.rscbin596 -> 596 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser14.rscbin2362 -> 2360 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser15.rscbin1490 -> 1540 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser16.rscbin2338 -> 2338 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser17.rscbin870 -> 872 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser18.rscbin15614 -> 15994 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser19.rscbin596 -> 596 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser2.rscbin32730 -> 32434 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser20.rscbin16888 -> 16952 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser21.rscbin6960 -> 6976 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser22.rscbin796 -> 798 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser23.rscbin90 -> 90 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser24.rscbin796 -> 798 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser3.rscbin2338 -> 2338 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser4.rscbin3468 -> 3500 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser5.rscbin2338 -> 2338 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser6.rscbin1416 -> 1418 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser7.rscbin262 -> 264 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser8.rscbin796 -> 798 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser9.rscbin15488 -> 15904 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/readableNames.props1
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/unicode12_1/part0.rscbin0 -> 8192 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/unicode12_1/part1.rscbin0 -> 8192 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/unicode12_1/part14.rscbin0 -> 8192 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/unicode12_1/part2.rscbin0 -> 8192 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/unicode12_1/start0.rscbin0 -> 8192 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/unicode12_1/start1.rscbin0 -> 8192 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/unicode12_1/start2.rscbin0 -> 8192 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblem.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java114
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties25
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Messages.java1
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.java233
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java64
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTMatcher.java56
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTNode.java60
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTParser.java1
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTVisitor.java70
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/BreakStatement.java76
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultASTVisitor.java18
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java1
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SwitchCase.java36
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SwitchExpression.java17
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TextBlock.java296
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/YieldStatement.java247
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/rewrite/ImportRewrite.java2
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/NaiveASTFlattener.java42
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteAnalyzer.java38
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteFlattener.java44
-rw-r--r--org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatter.java6
-rw-r--r--org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/LineBreaksPreparator.java9
-rw-r--r--org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/SpacePreparator.java15
-rw-r--r--org.eclipse.jdt.core/grammar/java.g20
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java8
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CopyResourceElementsOperation.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateElementInCUOperation.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateTypeMemberOperation.java4
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeleteElementsOperation.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/CommentRecorderParser.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/PublicScanner.java1
-rw-r--r--org.eclipse.jdt.tests.latestBREE/.classpath15
-rw-r--r--org.eclipse.jdt.tests.latestBREE/.project28
-rw-r--r--org.eclipse.jdt.tests.latestBREE/.settings/org.eclipse.core.resources.prefs2
-rw-r--r--org.eclipse.jdt.tests.latestBREE/.settings/org.eclipse.jdt.core.prefs115
-rw-r--r--org.eclipse.jdt.tests.latestBREE/META-INF/MANIFEST.MF22
-rw-r--r--org.eclipse.jdt.tests.latestBREE/build.properties4
-rw-r--r--org.eclipse.jdt.tests.latestBREE/pom.xml78
-rw-r--r--org.eclipse.jdt.tests.latestBREE/src/org/eclipse/jdt/core/tests/compiler/regression/latest/TestAll.java34
-rw-r--r--org.eclipse.jdt.tests.latestBREE/src/org/eclipse/jdt/core/tests/compiler/regression/latest/TextBlockTest.java879
-rw-r--r--org.eclipse.jdt.tests.latestBREE/src/org/eclipse/jdt/core/tests/model/CompletionTests13.java (renamed from org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests12.java)849
-rw-r--r--org.eclipse.jdt.tests.latestBREE/src/org/eclipse/jdt/tests/latestbree/Activator.java22
-rw-r--r--org.eclipse.jdt.tests.latestBREE/test.xml68
-rw-r--r--pom.xml2
212 files changed, 13557 insertions, 3256 deletions
diff --git a/org.eclipse.jdt.apt.core/META-INF/MANIFEST.MF b/org.eclipse.jdt.apt.core/META-INF/MANIFEST.MF
index f1ea17f592..9ca7812987 100644
--- a/org.eclipse.jdt.apt.core/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.apt.core/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jdt.apt.core; singleton:=true
-Bundle-Version: 3.6.500.qualifier
+Bundle-Version: 3.6.550.qualifier
Bundle-Localization: plugin
Export-Package: com.sun.mirror.apt,
com.sun.mirror.declaration,
diff --git a/org.eclipse.jdt.apt.core/pom.xml b/org.eclipse.jdt.apt.core/pom.xml
index 618043fbdd..d6b10df7cc 100644
--- a/org.eclipse.jdt.apt.core/pom.xml
+++ b/org.eclipse.jdt.apt.core/pom.xml
@@ -18,6 +18,6 @@
</parent>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.apt.core</artifactId>
- <version>3.6.500-SNAPSHOT</version>
+ <version>3.6.550-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/BaseProcessorEnv.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/BaseProcessorEnv.java
index a772cef6fe..c893542686 100644
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/BaseProcessorEnv.java
+++ b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/BaseProcessorEnv.java
@@ -86,7 +86,7 @@ import com.sun.mirror.util.Types;
public class BaseProcessorEnv implements AnnotationProcessorEnvironment
{
static{
- final AST ast = AST.newAST(AST.JLS11, false);
+ final AST ast = AST.newAST(AST.JLS13, true);
EMPTY_AST_UNIT = ast.newCompilationUnit();
}
public static final CompilationUnit EMPTY_AST_UNIT;
@@ -508,7 +508,7 @@ public class BaseProcessorEnv implements AnnotationProcessorEnvironment
}
final BindingRequestor requestor = new BindingRequestor();
- final ASTParser parser = ASTParser.newParser(AST.JLS11);
+ final ASTParser parser = ASTParser.newParser(AST.JLS13);
parser.setResolveBindings(true);
parser.setBindingsRecovery(true);
parser.setProject(_javaProject);
@@ -719,7 +719,7 @@ public class BaseProcessorEnv implements AnnotationProcessorEnvironment
if( astUnit != null ) return astUnit;
else{
// Note: very expensive operation. we are re-compiling a file with binding information.
- final ASTParser parser = ASTParser.newParser(AST.JLS11);
+ final ASTParser parser = ASTParser.newParser(AST.JLS13);
parser.setResolveBindings(true);
parser.setBindingsRecovery(true);
parser.setSource(unit);
@@ -868,7 +868,7 @@ public class BaseProcessorEnv implements AnnotationProcessorEnvironment
String bogusKey = BindingKey.createTypeBindingKey("java.lang.Object"); //$NON-NLS-1$
String[] keys = new String[] {bogusKey};
- ASTParser p = ASTParser.newParser( AST.JLS11 );
+ ASTParser p = ASTParser.newParser( AST.JLS13 );
p.setResolveBindings(true);
p.setBindingsRecovery(true);
p.setProject( javaProject );
@@ -898,7 +898,7 @@ public class BaseProcessorEnv implements AnnotationProcessorEnvironment
}
CompilationUnitRequestor requestor = new CompilationUnitRequestor();
- ASTParser p = ASTParser.newParser( AST.JLS11 );
+ ASTParser p = ASTParser.newParser( AST.JLS13 );
p.setResolveBindings(true);
p.setBindingsRecovery(true);
p.setProject( javaProject );
diff --git a/org.eclipse.jdt.apt.tests/META-INF/MANIFEST.MF b/org.eclipse.jdt.apt.tests/META-INF/MANIFEST.MF
index b36858f0bd..056e70f0e9 100644
--- a/org.eclipse.jdt.apt.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.apt.tests/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jdt.apt.tests; singleton:=true
-Bundle-Version: 3.4.500.qualifier
+Bundle-Version: 3.4.550.qualifier
Bundle-ClassPath: apt.jar,
aptext.jar,
.
diff --git a/org.eclipse.jdt.apt.tests/pom.xml b/org.eclipse.jdt.apt.tests/pom.xml
index 487982f994..9ec0feeed9 100644
--- a/org.eclipse.jdt.apt.tests/pom.xml
+++ b/org.eclipse.jdt.apt.tests/pom.xml
@@ -20,7 +20,7 @@
</parent>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.apt.tests</artifactId>
- <version>3.4.500-SNAPSHOT</version>
+ <version>3.4.550-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<properties>
<testSuite>${project.artifactId}</testSuite>
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/ReadAnnotationTests2.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/ReadAnnotationTests2.java
index 338f6a637a..4bb75181c6 100644
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/ReadAnnotationTests2.java
+++ b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/ReadAnnotationTests2.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2013 BEA Systems, Inc.
+ * Copyright (c) 2005, 2019 BEA Systems, Inc.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* tyeung@bea.com - initial API and implementation
*******************************************************************************/
@@ -187,7 +187,7 @@ public class ReadAnnotationTests2 extends BuilderTests {
}
final BindingRequestor requestor = new BindingRequestor();
- final ASTParser parser = ASTParser.newParser(AST.JLS11);
+ final ASTParser parser = ASTParser.newParser(AST.JLS13);
parser.setResolveBindings(true);
parser.setProject(javaProj);
parser.setIgnoreMethodBodies(true);
diff --git a/org.eclipse.jdt.compiler.apt.tests/.classpath b/org.eclipse.jdt.compiler.apt.tests/.classpath
index 8102373411..6d7726d275 100644
--- a/org.eclipse.jdt.compiler.apt.tests/.classpath
+++ b/org.eclipse.jdt.compiler.apt.tests/.classpath
@@ -16,7 +16,7 @@
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="lib" path="lib/java10api.jar"/>
+ <classpathentry kind="lib" path="lib/java13api.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/org.eclipse.jdt.compiler.apt.tests/META-INF/MANIFEST.MF b/org.eclipse.jdt.compiler.apt.tests/META-INF/MANIFEST.MF
index 1a73c03f52..6c7e345b25 100644
--- a/org.eclipse.jdt.compiler.apt.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.compiler.apt.tests/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jdt.compiler.apt.tests;singleton:=true
-Bundle-Version: 1.1.900.qualifier
+Bundle-Version: 1.1.850.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
@@ -19,6 +19,6 @@ Export-Package: org.eclipse.jdt.compiler.apt.tests,
org.eclipse.jdt.compiler.apt.tests.processors.visitors
Import-Package: org.eclipse.jdt.internal.compiler.tool;resolution:=optional
Eclipse-BundleShape: dir
-Bundle-ClassPath: lib/java10api.jar,
+Bundle-ClassPath: lib/java13api.jar,
.
Automatic-Module-Name: org.eclipse.jdt.compiler.apt.tests
diff --git a/org.eclipse.jdt.compiler.apt.tests/build.properties b/org.eclipse.jdt.compiler.apt.tests/build.properties
index e9a85ccd3b..cddfe5d640 100644
--- a/org.eclipse.jdt.compiler.apt.tests/build.properties
+++ b/org.eclipse.jdt.compiler.apt.tests/build.properties
@@ -27,4 +27,4 @@ bin.includes = about.html,\
.
src.includes = about.html
compilerArg=-proc:none
-jars.extra.classpath = lib/java10api.jar
+jars.extra.classpath = lib/java13api.jar
diff --git a/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors8.jar b/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors8.jar
index e51a6bcf7f..c0e46191a6 100644
--- a/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors8.jar
+++ b/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors8.jar
Binary files differ
diff --git a/org.eclipse.jdt.compiler.apt.tests/lib/java10api.jar b/org.eclipse.jdt.compiler.apt.tests/lib/java13api.jar
index 464b69134f..d8bbb8b501 100644
--- a/org.eclipse.jdt.compiler.apt.tests/lib/java10api.jar
+++ b/org.eclipse.jdt.compiler.apt.tests/lib/java13api.jar
Binary files differ
diff --git a/org.eclipse.jdt.compiler.apt.tests/pom.xml b/org.eclipse.jdt.compiler.apt.tests/pom.xml
index 8406059ff3..06f74dd605 100644
--- a/org.eclipse.jdt.compiler.apt.tests/pom.xml
+++ b/org.eclipse.jdt.compiler.apt.tests/pom.xml
@@ -20,7 +20,7 @@
</parent>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.compiler.apt.tests</artifactId>
- <version>1.1.900-SNAPSHOT</version>
+ <version>1.1.850-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<properties>
diff --git a/org.eclipse.jdt.compiler.apt.tests/processors8/META-INF/services/javax.annotation.processing.Processor b/org.eclipse.jdt.compiler.apt.tests/processors8/META-INF/services/javax.annotation.processing.Processor
index 22707a258c..f706af86b9 100644
--- a/org.eclipse.jdt.compiler.apt.tests/processors8/META-INF/services/javax.annotation.processing.Processor
+++ b/org.eclipse.jdt.compiler.apt.tests/processors8/META-INF/services/javax.annotation.processing.Processor
@@ -2,3 +2,4 @@ org.eclipse.jdt.compiler.apt.tests.processors.elements.Java8ElementProcessor
org.eclipse.jdt.compiler.apt.tests.processors.elements.Java9ElementProcessor
org.eclipse.jdt.compiler.apt.tests.processors.elements.Java11ElementProcessor
org.eclipse.jdt.compiler.apt.tests.processors.elements.Java12ElementProcessor
+org.eclipse.jdt.compiler.apt.tests.processors.elements.Java13ElementProcessor
diff --git a/org.eclipse.jdt.compiler.apt.tests/processors8/org/eclipse/jdt/compiler/apt/tests/processors/elements/Java11ElementProcessor.java b/org.eclipse.jdt.compiler.apt.tests/processors8/org/eclipse/jdt/compiler/apt/tests/processors/elements/Java11ElementProcessor.java
index 590205e9d7..71cae2d8e7 100644
--- a/org.eclipse.jdt.compiler.apt.tests/processors8/org/eclipse/jdt/compiler/apt/tests/processors/elements/Java11ElementProcessor.java
+++ b/org.eclipse.jdt.compiler.apt.tests/processors8/org/eclipse/jdt/compiler/apt/tests/processors/elements/Java11ElementProcessor.java
@@ -33,7 +33,7 @@ import javax.tools.JavaFileObject;
import org.eclipse.jdt.compiler.apt.tests.processors.base.BaseProcessor;
/**
- * A processor that explores the java 9 specific elements and validates the lambda and
+ * A processor that explores the java 11 specific elements and validates the lambda and
* type annotated elements. To enable this processor, add
* -Aorg.eclipse.jdt.compiler.apt.tests.processors.elements.Java11ElementProcessor to the command line.
* @since 3.14
diff --git a/org.eclipse.jdt.compiler.apt.tests/processors8/org/eclipse/jdt/compiler/apt/tests/processors/elements/Java12ElementProcessor.java b/org.eclipse.jdt.compiler.apt.tests/processors8/org/eclipse/jdt/compiler/apt/tests/processors/elements/Java12ElementProcessor.java
index f8699c6b7c..51c634a4f8 100644
--- a/org.eclipse.jdt.compiler.apt.tests/processors8/org/eclipse/jdt/compiler/apt/tests/processors/elements/Java12ElementProcessor.java
+++ b/org.eclipse.jdt.compiler.apt.tests/processors8/org/eclipse/jdt/compiler/apt/tests/processors/elements/Java12ElementProcessor.java
@@ -40,7 +40,7 @@ import javax.lang.model.element.TypeElement;
import org.eclipse.jdt.compiler.apt.tests.processors.base.BaseProcessor;
/**
- * A processor that explores the java 9 specific elements and validates the lambda and
+ * A processor that explores the java 12 specific elements and validates the lambda and
* type annotated elements. To enable this processor, add
* -Aorg.eclipse.jdt.compiler.apt.tests.processors.elements.Java11ElementProcessor to the command line.
* @since 3.14
diff --git a/org.eclipse.jdt.compiler.apt.tests/processors8/org/eclipse/jdt/compiler/apt/tests/processors/elements/Java13ElementProcessor.java b/org.eclipse.jdt.compiler.apt.tests/processors8/org/eclipse/jdt/compiler/apt/tests/processors/elements/Java13ElementProcessor.java
new file mode 100644
index 0000000000..5dcb8be92a
--- /dev/null
+++ b/org.eclipse.jdt.compiler.apt.tests/processors8/org/eclipse/jdt/compiler/apt/tests/processors/elements/Java13ElementProcessor.java
@@ -0,0 +1,251 @@
+/*******************************************************************************
+ * Copyright (c) 2019 IBM Corporation.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.jdt.compiler.apt.tests.processors.elements;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.annotation.processing.Filer;
+import javax.annotation.processing.Messager;
+import javax.annotation.processing.ProcessingEnvironment;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.Modifier;
+import javax.lang.model.element.ModuleElement;
+import javax.lang.model.element.PackageElement;
+import javax.lang.model.element.TypeElement;
+
+import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
+import org.eclipse.jdt.compiler.apt.tests.processors.base.BaseProcessor;
+
+/**
+ * A processor that explores the java 13 specific elements and validates the lambda and
+ * type annotated elements. To enable this processor, add
+ * -Aorg.eclipse.jdt.compiler.apt.tests.processors.elements.Java11ElementProcessor to the command line.
+ * @since 3.14
+ */
+@SupportedAnnotationTypes("*")
+public class Java13ElementProcessor extends BaseProcessor {
+ boolean reportSuccessAlready = true;
+ RoundEnvironment roundEnv = null;
+ Messager _messager = null;
+ Filer _filer = null;
+ boolean isBinaryMode = false;
+ String mode;
+ @Override
+ public synchronized void init(ProcessingEnvironment processingEnv) {
+ super.init(processingEnv);
+ _elementUtils = processingEnv.getElementUtils();
+ _messager = processingEnv.getMessager();
+ _filer = processingEnv.getFiler();
+ }
+ // Always return false from this processor, because it supports "*".
+ // The return value does not signify success or failure!
+ @Override
+ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+ if (roundEnv.processingOver()) {
+ return false;
+ }
+
+ this.roundEnv = roundEnv;
+ Map<String, String> options = processingEnv.getOptions();
+ if (!options.containsKey(this.getClass().getName())) {
+ // Disable this processor unless we are intentionally performing the test.
+ return false;
+ } else {
+ try {
+ if (options.containsKey("binary")) {
+ this.isBinaryMode = true;
+ this.mode = "binary";
+ } else {
+ this.mode = "source";
+ }
+ if (!invokeTestMethods(options)) {
+ testAll();
+ }
+ if (this.reportSuccessAlready) {
+ super.reportSuccess();
+ }
+ } catch (AssertionFailedError e) {
+ super.reportError(getExceptionStackTrace(e));
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+ return false;
+ }
+
+ private boolean invokeTestMethods(Map<String, String> options) throws Throwable {
+ Method testMethod = null;
+ Set<String> keys = options.keySet();
+ boolean testsFound = false;
+ for (String option : keys) {
+ if (option.startsWith("test")) {
+ try {
+ testMethod = this.getClass().getDeclaredMethod(option, new Class[0]);
+ if (testMethod != null) {
+ testsFound = true;
+ testMethod.invoke(this, new Object[0]);
+ }
+ } catch (InvocationTargetException e) {
+ throw e.getCause();
+ } catch (Exception e) {
+ super.reportError(getExceptionStackTrace(e));
+ }
+ }
+ }
+ return testsFound;
+ }
+
+ public void testAll() throws AssertionFailedError, IOException {
+ testPreviewFlagTrue();
+ testPreviewFlagFalse();
+ }
+
+ public void testPreviewFlagTrue() throws IOException {
+ if (this.processingEnv instanceof BaseProcessingEnvImpl) {
+ boolean preview = ((BaseProcessingEnvImpl) this.processingEnv).isPreviewEnabled();
+ assertTrue("Preview flag not seen as enabled", preview);
+ }
+ }
+ public void testPreviewFlagFalse() throws IOException {
+ if (this.processingEnv instanceof BaseProcessingEnvImpl) {
+ boolean preview = ((BaseProcessingEnvImpl) this.processingEnv).isPreviewEnabled();
+ assertFalse("Preview flag not seen as enabled", preview);
+ }
+ }
+
+ @Override
+ public void reportError(String msg) {
+ throw new AssertionFailedError(msg);
+ }
+ private String getExceptionStackTrace(Throwable t) {
+ StringBuffer buf = new StringBuffer(t.getMessage());
+ StackTraceElement[] traces = t.getStackTrace();
+ for (int i = 0; i < traces.length; i++) {
+ StackTraceElement trace = traces[i];
+ buf.append("\n\tat " + trace);
+ if (i == 12)
+ break; // Don't dump all stacks
+ }
+ return buf.toString();
+ }
+ protected String getElementsAsString(List<? extends Element> list) {
+ StringBuilder builder = new StringBuilder("[");
+ for (Element element : list) {
+ if (element instanceof PackageElement) {
+ builder.append(((PackageElement) element).getQualifiedName());
+ } else if (element instanceof ModuleElement) {
+ builder.append(((ModuleElement) element).getQualifiedName());
+ } else if (element instanceof TypeElement) {
+ builder.append(((TypeElement) element).getQualifiedName());
+ } else {
+ builder.append(element.getSimpleName());
+ }
+ builder.append(", ");
+ }
+ builder.append("]");
+ return builder.toString();
+ }
+ public void assertModifiers(Set<Modifier> modifiers, String[] expected) {
+ assertEquals("Incorrect no of modifiers", modifiers.size(), expected.length);
+ Set<String> actual = new HashSet<String>(expected.length);
+ for (Modifier modifier : modifiers) {
+ actual.add(modifier.toString());
+ }
+ for(int i = 0, length = expected.length; i < length; i++) {
+ boolean result = actual.remove(expected[i]);
+ if (!result) reportError("Modifier not present :" + expected[i]);
+ }
+ if (!actual.isEmpty()) {
+ reportError("Unexpected modifiers present:" + actual.toString());
+ }
+ }
+ public void assertTrue(String msg, boolean value) {
+ if (!value) reportError(msg);
+ }
+ public void assertFalse(String msg, boolean value) {
+ if (value) reportError(msg);
+ }
+ public void assertSame(String msg, Object obj1, Object obj2) {
+ if (obj1 != obj2) {
+ reportError(msg + ", should be " + obj1.toString() + " but " + obj2.toString());
+ }
+ }
+ public void assertNotSame(String msg, Object obj1, Object obj2) {
+ if (obj1 == obj2) {
+ reportError(msg + ", " + obj1.toString() + " should not be same as " + obj2.toString());
+ }
+ }
+ public void assertNotNull(String msg, Object obj) {
+ if (obj == null) {
+ reportError(msg);
+ }
+ }
+ public void assertNull(String msg, Object obj) {
+ if (obj != null) {
+ reportError(msg);
+ }
+ }
+ public void assertEquals(String message, Object expected, Object actual) {
+ if (equalsRegardingNull(expected, actual)) {
+ return;
+ } else {
+ reportError(message + ", expected " + expected.toString() + " but was " + actual.toString());
+ }
+ }
+
+ public void assertEquals(String message, Object expected, Object alternateExpected, Object actual) {
+ if (equalsRegardingNull(expected, actual) || equalsRegardingNull(alternateExpected, actual)) {
+ return;
+ } else {
+ reportError(message + ", expected " + expected.toString() + " but was " + actual.toString());
+ }
+ }
+
+ static boolean equalsRegardingNull(Object expected, Object actual) {
+ if (expected == null) {
+ return actual == null;
+ }
+ return expected.equals(actual);
+ }
+
+ public void assertEquals(String msg, int expected, int actual) {
+ if (expected != actual) {
+ StringBuffer buf = new StringBuffer();
+ buf.append(msg);
+ buf.append(", expected " + expected + " but was " + actual);
+ reportError(buf.toString());
+ }
+ }
+ public void assertEquals(Object expected, Object actual) {
+ if (expected != actual) {
+
+ }
+ }
+ private class AssertionFailedError extends Error {
+ private static final long serialVersionUID = 1L;
+
+ public AssertionFailedError(String msg) {
+ super(msg);
+ }
+ }
+}
diff --git a/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/Java13ElementsTests.java b/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/Java13ElementsTests.java
new file mode 100644
index 0000000000..78aa8b7204
--- /dev/null
+++ b/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/Java13ElementsTests.java
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2019 IBM Corporation.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.jdt.compiler.apt.tests;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.lang.model.SourceVersion;
+import javax.tools.JavaCompiler;
+
+import org.eclipse.jdt.internal.compiler.tool.EclipseCompiler;
+
+import junit.framework.TestCase;
+
+public class Java13ElementsTests extends TestCase {
+ private static final String MODULE_PROC = "org.eclipse.jdt.compiler.apt.tests.processors.elements.Java13ElementProcessor";
+
+ public void testPreviewFlagTrue() throws IOException {
+ JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
+ internalTestWithPreview(compiler, MODULE_PROC, "13", "testPreviewFlagTrue", null, "modules2", true);
+ }
+ public void testPreviewFlagFalse() throws IOException {
+ JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
+ internalTestWithPreview(compiler, MODULE_PROC, "13", "testPreviewFlagFalse", null, "modules2", false);
+ }
+
+ protected void internalTestWithPreview(JavaCompiler compiler, String processor, String compliance,
+ String testMethod, String testClass, String resourceArea, boolean preview) throws IOException {
+ if (!canRunJava13()) {
+ return;
+ }
+ System.clearProperty(processor);
+ File targetFolder = TestUtils.concatPath(BatchTestUtils.getSrcFolderName(), "mod_locations", resourceArea);
+ if (testClass == null || testClass.equals("")) {
+ BatchTestUtils.copyResources("mod_locations/" + resourceArea, targetFolder);
+ } else {
+ BatchTestUtils.copyResource("mod_locations/" + resourceArea + "/" + testClass, targetFolder);
+ }
+
+ List<String> options = new ArrayList<String>();
+ options.add("-A" + processor);
+ options.add("-A" + testMethod);
+ options.add("-processor");
+ options.add(processor);
+ // Javac 1.8 doesn't (yet?) support the -1.8 option
+ if (compiler instanceof EclipseCompiler) {
+ options.add("-" + compliance);
+ } else {
+ options.add("-source");
+ options.add(compliance);
+ }
+ if (preview)
+ options.add("--enable-preview");
+ BatchTestUtils.compileInModuleMode(compiler, options, processor, targetFolder, null, true);
+ // If it succeeded, the processor will have set this property to "succeeded";
+ // if not, it will set it to an error value.
+ assertEquals("succeeded", System.getProperty(processor));
+ }
+ public boolean canRunJava13() {
+ try {
+ SourceVersion.valueOf("RELEASE_13");
+ } catch(IllegalArgumentException iae) {
+ return false;
+ }
+ return true;
+ }
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ BatchTestUtils.init();
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.compiler.apt/build.properties b/org.eclipse.jdt.compiler.apt/build.properties
index 7e1102b5c5..6b49b018ed 100644
--- a/org.eclipse.jdt.compiler.apt/build.properties
+++ b/org.eclipse.jdt.compiler.apt/build.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2005, 2017 IBM Corporation and others.
+# Copyright (c) 2005, 2019 IBM Corporation and others.
#
# This program and the accompanying materials
# are made available under the terms of the Eclipse Public License 2.0
@@ -22,4 +22,4 @@ jars.compile.order = .
output.. = bin/
source.. = src/
-jars.extra.classpath = lib/java10api.jar
+jars.extra.classpath = lib/java13api.jar
diff --git a/org.eclipse.jdt.compiler.apt/lib/java10api.jar b/org.eclipse.jdt.compiler.apt/lib/java13api.jar
index 464b69134f..d8bbb8b501 100644
--- a/org.eclipse.jdt.compiler.apt/lib/java10api.jar
+++ b/org.eclipse.jdt.compiler.apt/lib/java13api.jar
Binary files differ
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BaseProcessingEnvImpl.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BaseProcessingEnvImpl.java
index f288a44543..5a088fbf6e 100644
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BaseProcessingEnvImpl.java
+++ b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BaseProcessingEnvImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2015 BEA Systems, Inc.
+ * Copyright (c) 2007, 2019 BEA Systems, Inc.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -129,11 +129,33 @@ public abstract class BaseProcessingEnvImpl implements ProcessingEnvironment {
return SourceVersion.RELEASE_6;
}
try {
- return SourceVersion.valueOf("RELEASE_7"); //$NON-NLS-1$
+ if (this._compiler.options.sourceLevel == ClassFileConstants.JDK1_7) {
+ return SourceVersion.valueOf("RELEASE_7"); //$NON-NLS-1$
+ }
+ if (this._compiler.options.sourceLevel == ClassFileConstants.JDK1_8) {
+ return SourceVersion.valueOf("RELEASE_8"); //$NON-NLS-1$
+ }
+ if (this._compiler.options.sourceLevel == ClassFileConstants.JDK9) {
+ return SourceVersion.valueOf("RELEASE_9"); //$NON-NLS-1$
+ }
+ if (this._compiler.options.sourceLevel == ClassFileConstants.JDK10) {
+ return SourceVersion.valueOf("RELEASE_10"); //$NON-NLS-1$
+ }
+ if (this._compiler.options.sourceLevel == ClassFileConstants.JDK11) {
+ return SourceVersion.valueOf("RELEASE_11"); //$NON-NLS-1$
+ }
+ if (this._compiler.options.sourceLevel == ClassFileConstants.JDK12) {
+ return SourceVersion.valueOf("RELEASE_12"); //$NON-NLS-1$
+ }
+ if (this._compiler.options.sourceLevel == ClassFileConstants.JDK13) {
+ return SourceVersion.valueOf("RELEASE_13"); //$NON-NLS-1$
+ }
} catch(IllegalArgumentException e) {
// handle call on a JDK 6
return SourceVersion.RELEASE_6;
}
+ // handle call on a JDK 6 by default
+ return SourceVersion.RELEASE_6;
}
/**
@@ -174,5 +196,12 @@ public abstract class BaseProcessingEnvImpl implements ProcessingEnvironment {
_addedClassFiles.toArray(result);
return result;
}
+ /*
+ * This overrides ProcessingEnvironment, but can't declare so since
+ * we are still compiling against JDK 8.
+ */
+ public boolean isPreviewEnabled() {
+ return this._compiler.options.enablePreviewFeatures;
+ }
}
diff --git a/org.eclipse.jdt.compiler.tool.tests/.classpath b/org.eclipse.jdt.compiler.tool.tests/.classpath
index fc20dc52b3..1aaf22970c 100644
--- a/org.eclipse.jdt.compiler.tool.tests/.classpath
+++ b/org.eclipse.jdt.compiler.tool.tests/.classpath
@@ -6,7 +6,7 @@
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="lib" path="lib/java10api.jar"/>
+ <classpathentry kind="lib" path="lib/java13api.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/org.eclipse.jdt.compiler.tool.tests/META-INF/MANIFEST.MF b/org.eclipse.jdt.compiler.tool.tests/META-INF/MANIFEST.MF
index eb56b0df36..54d07eb5eb 100644
--- a/org.eclipse.jdt.compiler.tool.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.compiler.tool.tests/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jdt.compiler.tool.tests
-Bundle-Version: 1.2.500.qualifier
+Bundle-Version: 1.2.550.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
diff --git a/org.eclipse.jdt.compiler.tool.tests/build.properties b/org.eclipse.jdt.compiler.tool.tests/build.properties
index c7599cfabc..e40bb4927f 100644
--- a/org.eclipse.jdt.compiler.tool.tests/build.properties
+++ b/org.eclipse.jdt.compiler.tool.tests/build.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2018 IBM Corporation and others.
+# Copyright (c) 2000, 2019 IBM Corporation and others.
#
# This program and the accompanying materials
# are made available under the terms of the Eclipse Public License 2.0
@@ -16,9 +16,9 @@ bin.includes = META-INF/,\
about.html,\
plugin.properties,\
test.xml,\
- lib/java10api.jar,\
+ lib/java13api.jar,\
resources/
src.includes = about.html
source.. = src/
output.. = bin/
-jars.extra.classpath = lib/java10api.jar
+jars.extra.classpath = lib/java13api.jar
diff --git a/org.eclipse.jdt.compiler.tool.tests/lib/java10api.jar b/org.eclipse.jdt.compiler.tool.tests/lib/java13api.jar
index 464b69134f..d8bbb8b501 100644
--- a/org.eclipse.jdt.compiler.tool.tests/lib/java10api.jar
+++ b/org.eclipse.jdt.compiler.tool.tests/lib/java13api.jar
Binary files differ
diff --git a/org.eclipse.jdt.compiler.tool.tests/pom.xml b/org.eclipse.jdt.compiler.tool.tests/pom.xml
index 753355545b..6960622abb 100644
--- a/org.eclipse.jdt.compiler.tool.tests/pom.xml
+++ b/org.eclipse.jdt.compiler.tool.tests/pom.xml
@@ -20,7 +20,7 @@
</parent>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.compiler.tool.tests</artifactId>
- <version>1.2.500-SNAPSHOT</version>
+ <version>1.2.550-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<properties>
<testSuite>${project.artifactId}</testSuite>
diff --git a/org.eclipse.jdt.compiler.tool/.classpath b/org.eclipse.jdt.compiler.tool/.classpath
index a3b97caae2..59c1bb0063 100644
--- a/org.eclipse.jdt.compiler.tool/.classpath
+++ b/org.eclipse.jdt.compiler.tool/.classpath
@@ -2,7 +2,7 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="lib" path="lib/java10api.jar"/>
+ <classpathentry kind="lib" path="lib/java13api.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/org.eclipse.jdt.compiler.tool/META-INF/MANIFEST.MF b/org.eclipse.jdt.compiler.tool/META-INF/MANIFEST.MF
index 0a2c73252c..aff73d2838 100644
--- a/org.eclipse.jdt.compiler.tool/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.compiler.tool/META-INF/MANIFEST.MF
@@ -2,13 +2,13 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %fragmentName
Bundle-SymbolicName: org.eclipse.jdt.compiler.tool;singleton:=true
-Bundle-Version: 1.2.600.qualifier
+Bundle-Version: 1.2.550.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: compiler_tool_fragment
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: META-INF.services,
org.eclipse.jdt.internal.compiler.tool;x-internal:=true
Fragment-Host: org.eclipse.jdt.core;bundle-version="[3.3.0,4.0.0)"
-Bundle-ClassPath: lib/java10api.jar,
+Bundle-ClassPath: lib/java13api.jar,
.
Automatic-Module-Name: org.eclipse.jdt.compiler.tool
diff --git a/org.eclipse.jdt.compiler.tool/build.properties b/org.eclipse.jdt.compiler.tool/build.properties
index fd418f7960..42961c2cfe 100644
--- a/org.eclipse.jdt.compiler.tool/build.properties
+++ b/org.eclipse.jdt.compiler.tool/build.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2018 IBM Corporation and others.
+# Copyright (c) 2000, 2019 IBM Corporation and others.
#
# This program and the accompanying materials
# are made available under the terms of the Eclipse Public License 2.0
@@ -18,6 +18,6 @@ bin.includes = META-INF/,\
.,\
about.html,\
compiler_tool_fragment.properties,\
- lib/java10api.jar
+ lib/java13api.jar
src.includes = about.html
-jars.extra.classpath = lib/java10api.jar \ No newline at end of file
+jars.extra.classpath = lib/java13api.jar \ No newline at end of file
diff --git a/org.eclipse.jdt.compiler.tool/lib/java10api.jar b/org.eclipse.jdt.compiler.tool/lib/java13api.jar
index 464b69134f..d8bbb8b501 100644
--- a/org.eclipse.jdt.compiler.tool/lib/java10api.jar
+++ b/org.eclipse.jdt.compiler.tool/lib/java13api.jar
Binary files differ
diff --git a/org.eclipse.jdt.compiler.tool/pom.xml b/org.eclipse.jdt.compiler.tool/pom.xml
index f95ed986f8..ec877471e6 100644
--- a/org.eclipse.jdt.compiler.tool/pom.xml
+++ b/org.eclipse.jdt.compiler.tool/pom.xml
@@ -18,7 +18,7 @@
</parent>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.compiler.tool</artifactId>
- <version>1.2.600-SNAPSHOT</version>
+ <version>1.2.550-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<build>
diff --git a/org.eclipse.jdt.core.tests.builder/META-INF/MANIFEST.MF b/org.eclipse.jdt.core.tests.builder/META-INF/MANIFEST.MF
index 92bb29bd9b..ccf9aba998 100644
--- a/org.eclipse.jdt.core.tests.builder/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.core.tests.builder/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jdt.core.tests.builder; singleton:=true
-Bundle-Version: 3.10.700.qualifier
+Bundle-Version: 3.10.750.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package: org.eclipse.jdt.core.tests.builder
diff --git a/org.eclipse.jdt.core.tests.builder/pom.xml b/org.eclipse.jdt.core.tests.builder/pom.xml
index 4822c31313..e6d81e716a 100644
--- a/org.eclipse.jdt.core.tests.builder/pom.xml
+++ b/org.eclipse.jdt.core.tests.builder/pom.xml
@@ -19,7 +19,7 @@
</parent>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.core.tests.builder</artifactId>
- <version>3.10.700-SNAPSHOT</version>
+ <version>3.10.750-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<properties>
diff --git a/org.eclipse.jdt.core.tests.compiler/pom.xml b/org.eclipse.jdt.core.tests.compiler/pom.xml
index 71cb2981a5..f3fd207c78 100644
--- a/org.eclipse.jdt.core.tests.compiler/pom.xml
+++ b/org.eclipse.jdt.core.tests.compiler/pom.xml
@@ -169,6 +169,36 @@
<tycho.surefire.argLine>--add-modules ALL-SYSTEM -Dcompliance=1.4,1.7,1.8,12</tycho.surefire.argLine>
</properties>
</profile>
+ <profile>
+ <id>test-on-javase-13</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-toolchains-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+ <execution>
+ <phase>validate</phase>
+ <goals>
+ <goal>toolchain</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <toolchains>
+ <jdk>
+ <id>JavaSE-13</id>
+ </jdk>
+ </toolchains>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <properties>
+ <tycho.surefire.argLine>--add-modules ALL-SYSTEM -Dcompliance=1.4,1.7,1.8,13</tycho.surefire.argLine>
+ </properties>
+ </profile>
</profiles>
</project>
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ComplianceDiagnoseTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ComplianceDiagnoseTest.java
index 28d1790c30..2423bcf082 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ComplianceDiagnoseTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ComplianceDiagnoseTest.java
@@ -3549,22 +3549,22 @@ public void testBug531714_001() {
" default -> 3;\n" +
" };\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
- "The preview feature Switch Expressions is only available with source level 12 and above\n" +
+ "The preview feature Switch Expressions is only available with source level 13 and above\n" +
"----------\n" +
"2. ERROR in X.java (at line 4)\n" +
" case 0 -> i * 0;\n" +
" ^^^^^^\n" +
- "The preview feature Case Labels with \'->\' is only available with source level 12 and above\n" +
+ "The preview feature Case Labels with \'->\' is only available with source level 13 and above\n" +
"----------\n" +
"3. ERROR in X.java (at line 5)\n" +
" case 1 -> 2;\n" +
" ^^^^^^\n" +
- "The preview feature Case Labels with \'->\' is only available with source level 12 and above\n" +
+ "The preview feature Case Labels with \'->\' is only available with source level 13 and above\n" +
"----------\n" +
"4. ERROR in X.java (at line 6)\n" +
" default -> 3;\n" +
" ^^^^^^^\n" +
- "The preview feature Case Labels with \'->\' is only available with source level 12 and above\n" +
+ "The preview feature Case Labels with \'->\' is only available with source level 13 and above\n" +
"----------\n";
runComplianceParserTest(
@@ -3601,17 +3601,17 @@ public void testBug531714_002() {
"1. ERROR in X.java (at line 4)\n" +
" case 0 -> i * 0;\n" +
" ^^^^^^\n" +
- "The preview feature Case Labels with \'->\' is only available with source level 12 and above\n" +
+ "The preview feature Case Labels with \'->\' is only available with source level 13 and above\n" +
"----------\n" +
"2. ERROR in X.java (at line 5)\n" +
" case 1 -> 2;\n" +
" ^^^^^^\n" +
- "The preview feature Case Labels with \'->\' is only available with source level 12 and above\n" +
+ "The preview feature Case Labels with \'->\' is only available with source level 13 and above\n" +
"----------\n" +
"3. ERROR in X.java (at line 6)\n" +
" default -> 3;\n" +
" ^^^^^^^\n" +
- "The preview feature Case Labels with \'->\' is only available with source level 12 and above\n" +
+ "The preview feature Case Labels with \'->\' is only available with source level 13 and above\n" +
"----------\n";
runComplianceParserTest(
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/JavadocCompletionParserTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/JavadocCompletionParserTest.java
index 9b78ee7553..789fd412dc 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/JavadocCompletionParserTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/JavadocCompletionParserTest.java
@@ -57,6 +57,7 @@ static {
// org.eclipse.jdt.internal.codeassist.CompletionEngine.DEBUG = true;
// TESTS_NUMBERS = new int[] { 8 };
// TESTS_RANGE = new int[] { 20, -1 };
+// TESTS_NAMES = new String[] { "test001" };
}
public static Test suite() {
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ParserTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ParserTest.java
index 7048f31f84..e9c12ebb8a 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ParserTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ParserTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -17,6 +17,7 @@ import java.util.Hashtable;
import java.util.Map;
import org.eclipse.jdt.core.tests.compiler.regression.AbstractRegressionTest;
+import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
@SuppressWarnings({ "unchecked", "rawtypes" })
@@ -753,6 +754,25 @@ public void test027() {
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=239198
*/
public void test028() {
+ String error = (this.complianceLevel == ClassFileConstants.JDK13) ?
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " Srtring bar = \"\"\"\n" +
+ " }\n" +
+ " ^^^^^^^^^\n" +
+ "Text block is not properly closed with the delimiter\n" +
+ "----------\n" :
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " Srtring bar = \"\"\"\n" +
+ " ^^\n" +
+ "Non-externalized string literal; it should be followed by //$NON-NLS-<n>$\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " Srtring bar = \"\"\"\n" +
+ " ^\n" +
+ "String literal is not properly closed by a double-quote\n" +
+ "----------\n";
Map options = getCompilerOptions();
options.put(CompilerOptions.OPTION_ReportNonExternalizedStringLiteral, CompilerOptions.ERROR);
runNegativeTest(
@@ -765,17 +785,7 @@ public void test028() {
" }\n" +
"}"
},
- "----------\n" +
- "1. ERROR in X.java (at line 4)\n" +
- " Srtring bar = \"\"\"\n" +
- " ^^\n" +
- "Non-externalized string literal; it should be followed by //$NON-NLS-<n>$\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 4)\n" +
- " Srtring bar = \"\"\"\n" +
- " ^\n" +
- "String literal is not properly closed by a double-quote\n" +
- "----------\n",
+ error,
null,
true,
options);
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionParserTest12.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionParserTest12.java
index d8de1163d2..7912c9e4b6 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionParserTest12.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionParserTest12.java
@@ -500,11 +500,13 @@ public void test010() throws JavaModelException {
" public X() {\n" +
" }\n" +
" public static void foo(Num num_) {\n" +
- " {\n" +
- " {\n" +
- " int i_j;\n" +
- " <SelectOnName:i_j>;\n" +
- " }\n" +
+ " switch (num_) {\n" +
+ " case THREE ->\n" +
+ " {\n" +
+ " int i_j;\n" +
+ " System.out.println(<SelectOnName:i_j>);\n" +
+ " break;\n" +
+ " }\n" +
" }\n" +
" }\n" +
"}\n";
@@ -786,285 +788,4 @@ public void test017() throws JavaModelException {
checkMethodParse(string.toCharArray(), selectionStart, selectionEnd, expectedSelection, expectedUnitDisplayString,
selectionIdentifier, expectedReplacedSource, testName);
}
-public void test018() throws JavaModelException {
- String string = "import org.eclipse.jdt.annotation.*;\n" +
- "import java.util.function.*;\n" +
- "interface IN0 {} \n" +
- "interface IN1 extends IN0 {} \n" +
- "interface IN2 extends IN0 {}\n" +
- "public class X {\n" +
- " IN1 n_1() { return new IN1() {}; } \n" +
- " IN2 n_2() { return null; } \n" +
- " <M> void m( Supplier< M> m2) { } \n" +
- " void testSw(int i) { \n" +
- " m(switch(i) { \n" +
- " case 1 -> this::n_1; \n" +
- " default -> this::n_2; }); \n" +
- " }\n" +
- "}";
-
- String selection = "n_1";
- String selectKey = "<SelectionOnReferenceExpressionName:this::";
- String expectedSelection = selectKey + selection + ">";
-
- String selectionIdentifier = "n_1";
- String expectedUnitDisplayString =
- "import org.eclipse.jdt.annotation.*;\n" +
- "import java.util.function.*;\n" +
- "interface IN0 {\n" +
- "}\n" +
- "interface IN1 extends IN0 {\n" +
- "}\n" +
- "interface IN2 extends IN0 {\n" +
- "}\n" +
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " IN1 n_1() {\n" +
- " }\n" +
- " IN2 n_2() {\n" +
- " }\n" +
- " <M>void m(Supplier<M> m2) {\n" +
- " }\n" +
- " void testSw(int i) {\n" +
- " m(switch (i) {\n" +
- "case 1 ->\n" +
- " <SelectionOnReferenceExpressionName:this::n_1>;\n" +
- "default ->\n" +
- " this::n_2;\n" +
- "});\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "this::n_1";
- String testName = "X.java";
-
- int selectionStart = string.lastIndexOf(selection);
- int selectionEnd = selectionStart + selection.length() - 1;
-
- checkMethodParse(string.toCharArray(), selectionStart, selectionEnd, expectedSelection, expectedUnitDisplayString,
- selectionIdentifier, expectedReplacedSource, testName);
-}
-public void test019() throws JavaModelException {
- String string = "import org.eclipse.jdt.annotation.*;\n" +
- "import java.util.function.*;\n" +
- "interface IN0 {} \n" +
- "interface IN1 extends IN0 {} \n" +
- "interface IN2 extends IN0 {}\n" +
- "public class X {\n" +
- " IN1 n_1() { return new IN1() {}; } \n" +
- " IN2 n_2() { return null; } \n" +
- " <M> void m( Supplier< M> m2) { } \n" +
- " void testSw(int i) { \n" +
- " m(switch(i) { \n" +
- " case 2 -> () -> n_1(); \n" +
- " default -> this::n_2; }); \n" +
- " }\n" +
- "}";
-
- String selection = "n_1";
- String selectKey = "<SelectOnMessageSend:";
- String expectedSelection = selectKey + selection + "()>";
-
- String selectionIdentifier = "n_1";
- String expectedUnitDisplayString =
- "import org.eclipse.jdt.annotation.*;\n" +
- "import java.util.function.*;\n" +
- "interface IN0 {\n" +
- "}\n" +
- "interface IN1 extends IN0 {\n" +
- "}\n" +
- "interface IN2 extends IN0 {\n" +
- "}\n" +
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " IN1 n_1() {\n" +
- " }\n" +
- " IN2 n_2() {\n" +
- " }\n" +
- " <M>void m(Supplier<M> m2) {\n" +
- " }\n" +
- " void testSw(int i) {\n" +
- " m(switch (i) {\n" +
- "case 2 ->\n" +
- " () -> <SelectOnMessageSend:n_1()>;\n" +
- "default ->\n" +
- " this::n_2;\n" +
- "});\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "n_1()";
- String testName = "X.java";
-
- int selectionStart = string.lastIndexOf(selection);
- int selectionEnd = selectionStart + selection.length() - 1;
-
- checkMethodParse(string.toCharArray(), selectionStart, selectionEnd, expectedSelection, expectedUnitDisplayString,
- selectionIdentifier, expectedReplacedSource, testName);
-}
-public void test020() throws JavaModelException {
- String string = "import org.eclipse.jdt.annotation.*;\n" +
- "import java.util.function.*;\n" +
- "interface IN0 {} \n" +
- "interface IN1 extends IN0 {} \n" +
- "interface IN2 extends IN0 {}\n" +
- "public class X {\n" +
- " IN1 n_1() { return new IN1() {}; } \n" +
- " IN2 n_2() { return null; } \n" +
- " <M> void m( Supplier< M> m2) { } \n" +
- " void testSw(int i) { \n" +
- " m(switch(i) { \n" +
- " default -> this::n_2; }); \n" +
- " }\n" +
- "}";
-
- String selection = "n_2";
- String selectKey = "<SelectionOnReferenceExpressionName:this::";
- String expectedSelection = selectKey + selection + ">";
-
- String selectionIdentifier = "n_2";
- String expectedUnitDisplayString =
- "import org.eclipse.jdt.annotation.*;\n" +
- "import java.util.function.*;\n" +
- "interface IN0 {\n" +
- "}\n" +
- "interface IN1 extends IN0 {\n" +
- "}\n" +
- "interface IN2 extends IN0 {\n" +
- "}\n" +
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " IN1 n_1() {\n" +
- " }\n" +
- " IN2 n_2() {\n" +
- " }\n" +
- " <M>void m(Supplier<M> m2) {\n" +
- " }\n" +
- " void testSw(int i) {\n" +
- " m(switch (i) {\n" +
- "default ->\n" +
- " <SelectionOnReferenceExpressionName:this::n_2>;\n" +
- "});\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "this::n_2";
- String testName = "X.java";
-
- int selectionStart = string.lastIndexOf(selection);
- int selectionEnd = selectionStart + selection.length() - 1;
-
- checkMethodParse(string.toCharArray(), selectionStart, selectionEnd, expectedSelection, expectedUnitDisplayString,
- selectionIdentifier, expectedReplacedSource, testName);
-}
-public void test021() throws JavaModelException {
- String string = "import org.eclipse.jdt.annotation.*;\n" +
- "import java.util.function.*;\n" +
- "interface IN0 {} \n" +
- "interface IN1 extends IN0 {} \n" +
- "interface IN2 extends IN0 {}\n" +
- "public class X {\n" +
- " IN1 n_1(int ijk) { return new IN1() {}; } \n" +
- " IN2 n_2() { return null; } \n" +
- " <M> void m( Supplier< M> m2) { } \n" +
- " void testSw(int ijk) { \n" +
- " m(switch(ijk) { \n" +
- " default -> () -> n_1(ijk); }); \n" +
- " }\n" +
- "}";
-
- String selection = "n_1";
- String selectKey = "<SelectOnMessageSend:";
- String expectedSelection = selectKey + selection + "(ijk)>";
-
- String selectionIdentifier = "n_1";
- String expectedUnitDisplayString =
- "import org.eclipse.jdt.annotation.*;\n" +
- "import java.util.function.*;\n" +
- "interface IN0 {\n" +
- "}\n" +
- "interface IN1 extends IN0 {\n" +
- "}\n" +
- "interface IN2 extends IN0 {\n" +
- "}\n" +
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " IN1 n_1(int ijk) {\n" +
- " }\n" +
- " IN2 n_2() {\n" +
- " }\n" +
- " <M>void m(Supplier<M> m2) {\n" +
- " }\n" +
- " void testSw(int ijk) {\n" +
- " m(switch (ijk) {\n" +
- "default ->\n" +
- " () -> <SelectOnMessageSend:n_1(ijk)>;\n" +
- "});\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "n_1(ijk)";
- String testName = "X.java";
-
- int selectionStart = string.lastIndexOf(selection);
- int selectionEnd = selectionStart + selection.length() - 1;
-
- checkMethodParse(string.toCharArray(), selectionStart, selectionEnd, expectedSelection, expectedUnitDisplayString,
- selectionIdentifier, expectedReplacedSource, testName);
-}
-public void test022() throws JavaModelException {
- String string = "import org.eclipse.jdt.annotation.*;\n" +
- "import java.util.function.*;\n" +
- "interface IN0 {} \n" +
- "interface IN1 extends IN0 {} \n" +
- "interface IN2 extends IN0 {}\n" +
- "public class X {\n" +
- " IN1 n_1(int ijk) { return new IN1() {}; } \n" +
- " IN2 n_2() { return null; } \n" +
- " <M> void m( Supplier< M> m2) { } \n" +
- " void testSw(int ijk) { \n" +
- " m(switch(ijk) { \n" +
- " default -> () -> n_1(ijk); }); \n" +
- " }\n" +
- "}";
-
- String selection = "ijk";
- String selectKey = "<SelectOnName:";
- String expectedSelection = selectKey + selection + ">";
-
- String selectionIdentifier = "ijk";
- String expectedUnitDisplayString =
- "import org.eclipse.jdt.annotation.*;\n" +
- "import java.util.function.*;\n" +
- "interface IN0 {\n" +
- "}\n" +
- "interface IN1 extends IN0 {\n" +
- "}\n" +
- "interface IN2 extends IN0 {\n" +
- "}\n" +
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " IN1 n_1(int ijk) {\n" +
- " }\n" +
- " IN2 n_2() {\n" +
- " }\n" +
- " <M>void m(Supplier<M> m2) {\n" +
- " }\n" +
- " void testSw(int ijk) {\n" +
- " m(switch (ijk) {\n" +
- "default ->\n" +
- " () -> n_1(<SelectOnName:ijk>);\n" +
- "});\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "ijk";
- String testName = "X.java";
-
- int selectionStart = string.lastIndexOf(selection);
- int selectionEnd = selectionStart + selection.length() - 1;
-
- checkMethodParse(string.toCharArray(), selectionStart, selectionEnd, expectedSelection, expectedUnitDisplayString,
- selectionIdentifier, expectedReplacedSource, testName);
-}
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionParserTest13.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionParserTest13.java
new file mode 100644
index 0000000000..854d12db87
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionParserTest13.java
@@ -0,0 +1,1070 @@
+/*******************************************************************************
+ * Copyright (c) 2019 IBM Corporation and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.compiler.parser;
+
+import org.eclipse.jdt.core.JavaModelException;
+
+import junit.framework.Test;
+
+public class SelectionParserTest13 extends AbstractSelectionTest {
+static {
+// TESTS_NUMBERS = new int[] { 1 };
+// TESTS_NAMES = new String[] { "test005" };
+}
+public static Test suite() {
+ return buildMinimalComplianceTestSuite(SelectionParserTest13.class, F_13);
+}
+
+public SelectionParserTest13(String testName) {
+ super(testName);
+}
+/*
+ * Multi constant case statement with ':', selection node is the string constant
+ */
+public void test001() throws JavaModelException {
+ String string = "public class X {\n" +
+ "static final String ONE=\"One\", TWO = \"Two\", THREE=\"Three\";\n" +
+ " public static void foo(String num) {\n" +
+ " switch (num) {\n" +
+ " case ONE, TWO, THREE:\n" +
+ " System.out.println(num);\n" +
+ " break;\n" +
+ " }" +
+ " }\n" +
+ "}";
+
+ String selection = "ONE";
+ String selectKey = "<SelectOnName:";
+ String expectedSelection = selectKey + selection + ">";
+
+ String selectionIdentifier = "ONE";
+ String expectedUnitDisplayString =
+ "public class X {\n" +
+ " static final String ONE;\n" +
+ " static final String TWO;\n" +
+ " static final String THREE;\n" +
+ " <clinit>() {\n" +
+ " }\n" +
+ " public X() {\n" +
+ " }\n" +
+ " public static void foo(String num) {\n" +
+ " {\n" +
+ " switch (num) {\n" +
+ " case <SelectOnName:ONE> :\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ String expectedReplacedSource = "ONE";
+ String testName = "X.java";
+
+ int selectionStart = string.lastIndexOf(selection);
+ int selectionEnd = string.lastIndexOf(selection) + selection.length() - 1;
+
+ checkMethodParse(string.toCharArray(), selectionStart, selectionEnd, expectedSelection, expectedUnitDisplayString,
+ selectionIdentifier, expectedReplacedSource, testName);
+}
+/*
+ * Multi constant case statement with ':', selection node is the first enum constant
+ */
+public void test002() throws JavaModelException {
+ String string = "public class X {\n" +
+ " public static void foo(Num num) {\n" +
+ " switch (num) {\n" +
+ " case ONE, TWO, THREE:\n" +
+ " System.out.println(num);\n" +
+ " break;\n" +
+ " }" +
+ " }\n" +
+ " enum Num { ONE, TWO, THREE;}\n" +
+ "}";
+
+ String selection = "ONE";
+ String selectKey = "<SelectOnName:";
+ String expectedSelection = selectKey + selection + ">";
+
+ String selectionIdentifier = "ONE";
+ String expectedUnitDisplayString =
+ "public class X {\n" +
+ " enum Num {\n" +
+ " ONE(),\n" +
+ " TWO(),\n" +
+ " THREE(),\n" +
+ " <clinit>() {\n" +
+ " }\n" +
+ " Num() {\n" +
+ " }\n" +
+ " }\n" +
+ " public X() {\n" +
+ " }\n" +
+ " public static void foo(Num num) {\n" +
+ " {\n" +
+ " switch (num) {\n" +
+ " case <SelectOnName:ONE> :\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ String expectedReplacedSource = "ONE";
+ String testName = "X.java";
+
+ int selectionStart = string.indexOf(selection);
+ int selectionEnd = selectionStart + selection.length() - 1;
+
+ checkMethodParse(string.toCharArray(), selectionStart, selectionEnd, expectedSelection, expectedUnitDisplayString,
+ selectionIdentifier, expectedReplacedSource, testName);
+}
+/*
+ * Multi constant case statement with ':', selection node is the second string constant
+ */
+public void test003() throws JavaModelException {
+ String string = "public class X {\n" +
+ "static final String ONE=\"One\", TWO = \"Two\", THREE=\"Three\";\n" +
+ " public static void foo(String num) {\n" +
+ " switch (num) {\n" +
+ " case ONE, TWO, THREE:\n" +
+ " System.out.println(num);\n" +
+ " break;\n" +
+ " }" +
+ " }\n" +
+ "}";
+
+ String selection = "TWO";
+ String selectKey = "<SelectOnName:";
+ String expectedSelection = selectKey + selection + ">";
+
+ String selectionIdentifier = "TWO";
+ String expectedUnitDisplayString =
+ "public class X {\n" +
+ " static final String ONE;\n" +
+ " static final String TWO;\n" +
+ " static final String THREE;\n" +
+ " <clinit>() {\n" +
+ " }\n" +
+ " public X() {\n" +
+ " }\n" +
+ " public static void foo(String num) {\n" +
+ " {\n" +
+ " switch (num) {\n" +
+ " case <SelectOnName:TWO> :\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ String expectedReplacedSource = "TWO";
+ String testName = "X.java";
+
+ int selectionStart = string.lastIndexOf(selection);
+ int selectionEnd = string.lastIndexOf(selection) + selection.length() - 1;
+
+ checkMethodParse(string.toCharArray(), selectionStart, selectionEnd, expectedSelection, expectedUnitDisplayString,
+ selectionIdentifier, expectedReplacedSource, testName);
+}
+/*
+ * Multi constant case statement with ':', selection node is the second enum constant
+ */
+public void test004() throws JavaModelException {
+ String string = "public class X {\n" +
+ " public static void foo(Num num) {\n" +
+ " switch (num) {\n" +
+ " case ONE, TWO, THREE:\n" +
+ " System.out.println(num);\n" +
+ " break;\n" +
+ " }" +
+ " }\n" +
+ " enum Num { ONE, TWO, THREE;}\n" +
+ "}";
+
+ String selection = "TWO";
+ String selectKey = "<SelectOnName:";
+ String expectedSelection = selectKey + selection + ">";
+
+ String selectionIdentifier = "TWO";
+ String expectedUnitDisplayString =
+ "public class X {\n" +
+ " enum Num {\n" +
+ " ONE(),\n" +
+ " TWO(),\n" +
+ " THREE(),\n" +
+ " <clinit>() {\n" +
+ " }\n" +
+ " Num() {\n" +
+ " }\n" +
+ " }\n" +
+ " public X() {\n" +
+ " }\n" +
+ " public static void foo(Num num) {\n" +
+ " {\n" +
+ " switch (num) {\n" +
+ " case <SelectOnName:TWO> :\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ String expectedReplacedSource = "TWO";
+ String testName = "X.java";
+
+ int selectionStart = string.indexOf(selection);
+ int selectionEnd = selectionStart + selection.length() - 1;
+
+ checkMethodParse(string.toCharArray(), selectionStart, selectionEnd, expectedSelection, expectedUnitDisplayString,
+ selectionIdentifier, expectedReplacedSource, testName);
+}
+/*
+ * Multi constant case statement with '->', selection node is the string constant
+ */
+public void test005() throws JavaModelException {
+ String string = "public class X {\n" +
+ "static final String ONE=\"One\", TWO = \"Two\", THREE=\"Three\";\n" +
+ " public static void foo(String num) {\n" +
+ " switch (num) {\n" +
+ " case ONE, TWO, THREE ->\n" +
+ " System.out.println(num);\n" +
+ " }" +
+ " }\n" +
+ "}";
+ /*
+ * Note: The completion parser ignores the -> that follows and we end up creating
+ * the CaseStatement without maring it as an Expression, hence the ':' instead of the '->'
+ */
+ String selection = "ONE";
+ String selectKey = "<SelectOnName:";
+ String expectedSelection = selectKey + selection + ">";
+ String selectionIdentifier = "ONE";
+ String expectedUnitDisplayString =
+ "public class X {\n" +
+ " static final String ONE;\n" +
+ " static final String TWO;\n" +
+ " static final String THREE;\n" +
+ " <clinit>() {\n" +
+ " }\n" +
+ " public X() {\n" +
+ " }\n" +
+ " public static void foo(String num) {\n" +
+ " {\n" +
+ " switch (num) {\n" +
+ " case <SelectOnName:ONE> :\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ String expectedReplacedSource = "ONE";
+ String testName = "X.java";
+
+ int selectionStart = string.lastIndexOf(selection);
+ int selectionEnd = string.lastIndexOf(selection) + selection.length() - 1;
+
+ checkMethodParse(string.toCharArray(), selectionStart, selectionEnd, expectedSelection, expectedUnitDisplayString,
+ selectionIdentifier, expectedReplacedSource, testName);
+}
+/*
+ * Multi constant case statement with '->', selection node is the first enum constant
+ */
+public void test006() throws JavaModelException {
+ String string = "public class X {\n" +
+ " public static void foo(Num num) {\n" +
+ " switch (num) {\n" +
+ " case ONE, TWO, THREE ->\n" +
+ " System.out.println(num);\n" +
+ " break; // illegal, but should be ignored and shouldn't matter\n" +
+ " }" +
+ " }\n" +
+ " enum Num { ONE, TWO, THREE;}\n" +
+ "}";
+
+ String selection = "ONE";
+ String selectKey = "<SelectOnName:";
+ String expectedSelection = selectKey + selection + ">";
+
+ String selectionIdentifier = "ONE";
+ String expectedUnitDisplayString =
+ "public class X {\n" +
+ " enum Num {\n" +
+ " ONE(),\n" +
+ " TWO(),\n" +
+ " THREE(),\n" +
+ " <clinit>() {\n" +
+ " }\n" +
+ " Num() {\n" +
+ " }\n" +
+ " }\n" +
+ " public X() {\n" +
+ " }\n" +
+ " public static void foo(Num num) {\n" +
+ " {\n" +
+ " switch (num) {\n" +
+ " case <SelectOnName:ONE> :\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ String expectedReplacedSource = "ONE";
+ String testName = "X.java";
+
+ int selectionStart = string.indexOf(selection);
+ int selectionEnd = selectionStart + selection.length() - 1;
+
+ checkMethodParse(string.toCharArray(), selectionStart, selectionEnd, expectedSelection, expectedUnitDisplayString,
+ selectionIdentifier, expectedReplacedSource, testName);
+}
+/*
+ * Multi constant case statement with '->', selection node is the second string constant
+ */
+public void test007() throws JavaModelException {
+ String string = "public class X {\n" +
+ "static final String ONE=\"One\", TWO = \"Two\", THREE=\"Three\";\n" +
+ " public static void foo(String num) {\n" +
+ " switch (num) {\n" +
+ " case ONE, TWO, THREE ->\n" +
+ " System.out.println(num);\n" +
+ " break;\n" +
+ " }" +
+ " }\n" +
+ "}";
+
+ String selection = "TWO";
+ String selectKey = "<SelectOnName:";
+ String expectedSelection = selectKey + selection + ">";
+
+ String selectionIdentifier = "TWO";
+ String expectedUnitDisplayString =
+ "public class X {\n" +
+ " static final String ONE;\n" +
+ " static final String TWO;\n" +
+ " static final String THREE;\n" +
+ " <clinit>() {\n" +
+ " }\n" +
+ " public X() {\n" +
+ " }\n" +
+ " public static void foo(String num) {\n" +
+ " {\n" +
+ " switch (num) {\n" +
+ " case <SelectOnName:TWO> :\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ String expectedReplacedSource = "TWO";
+ String testName = "X.java";
+
+ int selectionStart = string.lastIndexOf(selection);
+ int selectionEnd = string.lastIndexOf(selection) + selection.length() - 1;
+
+ checkMethodParse(string.toCharArray(), selectionStart, selectionEnd, expectedSelection, expectedUnitDisplayString,
+ selectionIdentifier, expectedReplacedSource, testName);
+}
+/*
+ * Multi constant case statement with '->', selection node is the second enum constant
+ */
+public void test008() throws JavaModelException {
+ String string = "public class X {\n" +
+ " public static void foo(Num num) {\n" +
+ " switch (num) {\n" +
+ " case ONE, TWO, THREE ->\n" +
+ " System.out.println(num);\n" +
+ " break;\n" +
+ " }" +
+ " }\n" +
+ " enum Num { ONE, TWO, THREE;}\n" +
+ "}";
+
+ String selection = "TWO";
+ String selectKey = "<SelectOnName:";
+ String expectedSelection = selectKey + selection + ">";
+
+ String selectionIdentifier = "TWO";
+ String expectedUnitDisplayString =
+ "public class X {\n" +
+ " enum Num {\n" +
+ " ONE(),\n" +
+ " TWO(),\n" +
+ " THREE(),\n" +
+ " <clinit>() {\n" +
+ " }\n" +
+ " Num() {\n" +
+ " }\n" +
+ " }\n" +
+ " public X() {\n" +
+ " }\n" +
+ " public static void foo(Num num) {\n" +
+ " {\n" +
+ " switch (num) {\n" +
+ " case <SelectOnName:TWO> :\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ String expectedReplacedSource = "TWO";
+ String testName = "X.java";
+
+ int selectionStart = string.indexOf(selection);
+ int selectionEnd = selectionStart + selection.length() - 1;
+
+ checkMethodParse(string.toCharArray(), selectionStart, selectionEnd, expectedSelection, expectedUnitDisplayString,
+ selectionIdentifier, expectedReplacedSource, testName);
+}
+/*
+ * Multi constant case statement with '->', selection is a reference in the case block
+ * which same as the switch's expression
+ */
+public void test009() throws JavaModelException {
+ String string = "public class X {\n" +
+ " public static void foo(Num num_) {\n" +
+ " switch (num_) {\n" +
+ " case ONE, TWO, THREE ->\n" +
+ " System.out.println(num_);\n" +
+ " break;\n" +
+ " }" +
+ " }\n" +
+ " enum Num { ONE, TWO, THREE;}\n" +
+ "}";
+
+ String selection = "num_";
+ String selectKey = "<SelectOnName:";
+ String expectedSelection = selectKey + selection + ">";
+
+ String selectionIdentifier = "num_";
+ String expectedUnitDisplayString =
+ "public class X {\n" +
+ " enum Num {\n" +
+ " ONE(),\n" +
+ " TWO(),\n" +
+ " THREE(),\n" +
+ " <clinit>() {\n" +
+ " }\n" +
+ " Num() {\n" +
+ " }\n" +
+ " }\n" +
+ " public X() {\n" +
+ " }\n" +
+ " public static void foo(Num num_) {\n" +
+ " {\n" +
+ " <SelectOnName:num_>;\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ String expectedReplacedSource = "num_";
+ String testName = "X.java";
+
+ int selectionStart = string.lastIndexOf(selection);
+ int selectionEnd = selectionStart + selection.length() - 1;
+
+ checkMethodParse(string.toCharArray(), selectionStart, selectionEnd, expectedSelection, expectedUnitDisplayString,
+ selectionIdentifier, expectedReplacedSource, testName);
+}
+/*
+ * Multi constant case statement with '->', selection is a reference in the case block
+ * which is referencing a local variable defined in the case block
+ */
+public void test010() throws JavaModelException {
+ String string = "public class X {\n" +
+ " public static void foo(Num num_) {\n" +
+ " switch (num_) {\n" +
+ " case ONE, TWO, THREE -> {\n" +
+ " int i_j = 0;" +
+ " System.out.println(i_j);\n" +
+ " break;" +
+ " }\n" +
+ " }" +
+ " }\n" +
+ " enum Num { ONE, TWO, THREE;}\n" +
+ "}";
+
+ String selection = "i_j";
+ String selectKey = "<SelectOnName:";
+ String expectedSelection = selectKey + selection + ">";
+
+ String selectionIdentifier = "i_j";
+ String expectedUnitDisplayString =
+ "public class X {\n" +
+ " enum Num {\n" +
+ " ONE(),\n" +
+ " TWO(),\n" +
+ " THREE(),\n" +
+ " <clinit>() {\n" +
+ " }\n" +
+ " Num() {\n" +
+ " }\n" +
+ " }\n" +
+ " public X() {\n" +
+ " }\n" +
+ " public static void foo(Num num_) {\n" +
+ " {\n" +
+ " {\n" +
+ " int i_j;\n" +
+ " <SelectOnName:i_j>;\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ String expectedReplacedSource = "i_j";
+ String testName = "X.java";
+
+ int selectionStart = string.lastIndexOf(selection);
+ int selectionEnd = selectionStart + selection.length() - 1;
+
+ checkMethodParse(string.toCharArray(), selectionStart, selectionEnd, expectedSelection, expectedUnitDisplayString,
+ selectionIdentifier, expectedReplacedSource, testName);
+}
+/*
+ * Multi constant case statement with '->', selection is a referenced name of type enum in switch expression
+ */
+public void test011() throws JavaModelException {
+ String string = "public class X {\n" +
+ " public static void foo(Num num_) {\n" +
+ " switch (num_) {\n" +
+ " case ONE, TWO, THREE -> {\n" +
+ " break;" +
+ " }\n" +
+ " }" +
+ " }\n" +
+ " enum Num { ONE, TWO, THREE;}\n" +
+ "}";
+
+ String selection = "num_";
+ String selectKey = "<SelectOnName:";
+ String expectedSelection = selectKey + selection + ">";
+
+ String selectionIdentifier = "num_";
+ String expectedUnitDisplayString =
+ "public class X {\n" +
+ " enum Num {\n" +
+ " ONE(),\n" +
+ " TWO(),\n" +
+ " THREE(),\n" +
+ " <clinit>() {\n" +
+ " }\n" +
+ " Num() {\n" +
+ " }\n" +
+ " }\n" +
+ " public X() {\n" +
+ " }\n" +
+ " public static void foo(Num num_) {\n" +
+ " <SelectOnName:num_>;\n" +
+ " }\n" +
+ "}\n";
+ String expectedReplacedSource = "num_";
+ String testName = "X.java";
+
+ int selectionStart = string.lastIndexOf(selection);
+ int selectionEnd = selectionStart + selection.length() - 1;
+
+ checkMethodParse(string.toCharArray(), selectionStart, selectionEnd, expectedSelection, expectedUnitDisplayString,
+ selectionIdentifier, expectedReplacedSource, testName);
+}
+/*
+ * Multi constant case statement with '->', selection is a referenced name of type int in switch expression
+ */
+public void test012() throws JavaModelException {
+ String string = "public class X {\n" +
+ " public static void foo(int num_) {\n" +
+ " switch (num_ + 1) {\n" +
+ " case 1, 2, 3 -> {\n" +
+ " break;" +
+ " }\n" +
+ " }" +
+ " }\n" +
+ "}";
+
+ String selection = "num_";
+ String selectKey = "<SelectOnName:";
+ String expectedSelection = selectKey + selection + ">";
+
+ String selectionIdentifier = "num_";
+ String expectedUnitDisplayString =
+ "public class X {\n" +
+ " public X() {\n" +
+ " }\n" +
+ " public static void foo(int num_) {\n" +
+ " <SelectOnName:num_>;\n" +
+ " }\n" +
+ "}\n";
+ String expectedReplacedSource = "num_";
+ String testName = "X.java";
+
+ int selectionStart = string.lastIndexOf(selection);
+ int selectionEnd = selectionStart + selection.length() - 1;
+
+ checkMethodParse(string.toCharArray(), selectionStart, selectionEnd, expectedSelection, expectedUnitDisplayString,
+ selectionIdentifier, expectedReplacedSource, testName);
+}
+/*
+ * Multi constant case statement with '->', selection is a referenced name of type int in switch expression
+ */
+public void test013() throws JavaModelException {
+ String string = "public class X {\n" +
+ " public static void foo(int num_) {\n" +
+ " int i = switch (num_) {\n" +
+ " case 1, 2, 3 -> (num_ + 1);\n" +
+ " default -> 0;\n" +
+ " }" +
+ " }\n" +
+ "}";
+
+ String selection = "num_";
+ String selectKey = "<SelectOnName:";
+ String expectedSelection = selectKey + selection + ">";
+
+ String selectionIdentifier = "num_";
+ String expectedUnitDisplayString =
+ "public class X {\n" +
+ " public X() {\n" +
+ " }\n" +
+ " public static void foo(int num_) {\n" +
+ " int i;\n" +
+ " {\n" +
+ " <SelectOnName:num_>;\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ String expectedReplacedSource = "num_";
+ String testName = "X.java";
+
+ int selectionStart = string.lastIndexOf(selection);
+ int selectionEnd = selectionStart + selection.length() - 1;
+
+ checkMethodParse(string.toCharArray(), selectionStart, selectionEnd, expectedSelection, expectedUnitDisplayString,
+ selectionIdentifier, expectedReplacedSource, testName);
+}
+/*
+ * Multi constant case statement with '->', selection is a referenced name of type int in switch expression
+ */
+public void test014() throws JavaModelException {
+ String string = "public class X {\n" +
+ " public static void foo(int num_) {\n" +
+ " int i = switch (num_) {\n" +
+ " case 1, 2, 3 -> 0;\n" +
+ " default -> (num_ + 1);\n" +
+ " }" +
+ " }\n" +
+ "}";
+
+ String selection = "num_";
+ String selectKey = "<SelectOnName:";
+ String expectedSelection = selectKey + selection + ">";
+
+ String selectionIdentifier = "num_";
+ String expectedUnitDisplayString =
+ "public class X {\n" +
+ " public X() {\n" +
+ " }\n" +
+ " public static void foo(int num_) {\n" +
+ " int i;\n" +
+ " {\n" +
+ " <SelectOnName:num_>;\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ String expectedReplacedSource = "num_";
+ String testName = "X.java";
+
+ int selectionStart = string.lastIndexOf(selection);
+ int selectionEnd = selectionStart + selection.length() - 1;
+
+ checkMethodParse(string.toCharArray(), selectionStart, selectionEnd, expectedSelection, expectedUnitDisplayString,
+ selectionIdentifier, expectedReplacedSource, testName);
+}
+/*
+ * Multi constant case statement with '->', selection is a referenced name of type int in switch expression
+ */
+public void test015() throws JavaModelException {
+ String string = "public class X {\n" +
+ " public static void foo(int num_) {\n" +
+ " int i = switch (num_) {\n" +
+ " case 1, 2, 3 -> 0;\n" +
+ " default -> (num_ + 1);\n" +
+ " }" +
+ " }\n" +
+ "}";
+
+ String selection = "num_";
+ String selectKey = "<SelectOnName:";
+ String expectedSelection = selectKey + selection + ">";
+
+ String selectionIdentifier = "num_";
+ String expectedUnitDisplayString =
+ "public class X {\n" +
+ " public X() {\n" +
+ " }\n" +
+ " public static void foo(int num_) {\n" +
+ " int i;\n" +
+ " {\n" +
+ " <SelectOnName:num_>;\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ String expectedReplacedSource = "num_";
+ String testName = "X.java";
+
+ int selectionStart = string.lastIndexOf(selection);
+ int selectionEnd = selectionStart + selection.length() - 1;
+
+ checkMethodParse(string.toCharArray(), selectionStart, selectionEnd, expectedSelection, expectedUnitDisplayString,
+ selectionIdentifier, expectedReplacedSource, testName);
+}
+/*
+ * Multi constant case statement with '->', selection is a referenced name of type int in switch expression
+ */
+public void test016() throws JavaModelException {
+ String string = "public class X {\n" +
+ " public void bar(int s) {\n" +
+ " int i_j = switch (s) {\n" +
+ " case 1, 2, 3 -> (s+1);\n" +
+ " default -> i_j;\n" +
+ " };\n" +
+ " }\n" +
+ "}\n";
+
+ String selection = "i_j";
+ String selectKey = "<SelectOnName:";
+ String expectedSelection = selectKey + selection + ">";
+
+ String selectionIdentifier = "i_j";
+ String expectedUnitDisplayString =
+ "public class X {\n" +
+ " public X() {\n" +
+ " }\n" +
+ " public void bar(int s) {\n" +
+ " int i_j;\n" +
+ " {\n" +
+ " <SelectOnName:i_j>;\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ String expectedReplacedSource = "i_j";
+ String testName = "X.java";
+
+ int selectionStart = string.lastIndexOf(selection);
+ int selectionEnd = selectionStart + selection.length() - 1;
+
+ checkMethodParse(string.toCharArray(), selectionStart, selectionEnd, expectedSelection, expectedUnitDisplayString,
+ selectionIdentifier, expectedReplacedSource, testName);
+}
+public void test017() throws JavaModelException {
+ String string = "public class X {\n" +
+ " public void bar(int s) {\n" +
+ " int i_j = switch (s) {\n" +
+ " case 1, 2, 3 -> (s+1);\n" +
+ " default -> (1+i_j);\n" +
+ " };\n" +
+ " }\n" +
+ "}\n";
+
+ String selection = "i_j";
+ String selectKey = "<SelectOnName:";
+ String expectedSelection = selectKey + selection + ">";
+
+ String selectionIdentifier = "i_j";
+ String expectedUnitDisplayString =
+ "public class X {\n" +
+ " public X() {\n" +
+ " }\n" +
+ " public void bar(int s) {\n" +
+ " int i_j;\n" +
+ " {\n" +
+ " <SelectOnName:i_j>;\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ String expectedReplacedSource = "i_j";
+ String testName = "X.java";
+
+ int selectionStart = string.lastIndexOf(selection);
+ int selectionEnd = selectionStart + selection.length() - 1;
+
+ checkMethodParse(string.toCharArray(), selectionStart, selectionEnd, expectedSelection, expectedUnitDisplayString,
+ selectionIdentifier, expectedReplacedSource, testName);
+}
+public void test018() throws JavaModelException {
+ String string = "import org.eclipse.jdt.annotation.*;\n" +
+ "import java.util.function.*;\n" +
+ "interface IN0 {} \n" +
+ "interface IN1 extends IN0 {} \n" +
+ "interface IN2 extends IN0 {}\n" +
+ "public class X {\n" +
+ " IN1 n_1() { return new IN1() {}; } \n" +
+ " IN2 n_2() { return null; } \n" +
+ " <M> void m( Supplier< M> m2) { } \n" +
+ " void testSw(int i) { \n" +
+ " m(switch(i) { \n" +
+ " case 1 -> this::n_1; \n" +
+ " default -> this::n_2; }); \n" +
+ " }\n" +
+ "}";
+
+ String selection = "n_1";
+ String selectKey = "<SelectionOnReferenceExpressionName:this::";
+ String expectedSelection = selectKey + selection + ">";
+
+ String selectionIdentifier = "n_1";
+ String expectedUnitDisplayString =
+ "import org.eclipse.jdt.annotation.*;\n" +
+ "import java.util.function.*;\n" +
+ "interface IN0 {\n" +
+ "}\n" +
+ "interface IN1 extends IN0 {\n" +
+ "}\n" +
+ "interface IN2 extends IN0 {\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " }\n" +
+ " IN1 n_1() {\n" +
+ " }\n" +
+ " IN2 n_2() {\n" +
+ " }\n" +
+ " <M>void m(Supplier<M> m2) {\n" +
+ " }\n" +
+ " void testSw(int i) {\n" +
+ " m(switch (i) {\n" +
+ "case 1 ->\n" +
+ " <SelectionOnReferenceExpressionName:this::n_1>;\n" +
+ "default ->\n" +
+ " this::n_2;\n" +
+ "});\n" +
+ " }\n" +
+ "}\n";
+ String expectedReplacedSource = "this::n_1";
+ String testName = "X.java";
+
+ int selectionStart = string.lastIndexOf(selection);
+ int selectionEnd = selectionStart + selection.length() - 1;
+
+ checkMethodParse(string.toCharArray(), selectionStart, selectionEnd, expectedSelection, expectedUnitDisplayString,
+ selectionIdentifier, expectedReplacedSource, testName);
+}
+public void test019() throws JavaModelException {
+ String string = "import org.eclipse.jdt.annotation.*;\n" +
+ "import java.util.function.*;\n" +
+ "interface IN0 {} \n" +
+ "interface IN1 extends IN0 {} \n" +
+ "interface IN2 extends IN0 {}\n" +
+ "public class X {\n" +
+ " IN1 n_1() { return new IN1() {}; } \n" +
+ " IN2 n_2() { return null; } \n" +
+ " <M> void m( Supplier< M> m2) { } \n" +
+ " void testSw(int i) { \n" +
+ " m(switch(i) { \n" +
+ " case 2 -> () -> n_1(); \n" +
+ " default -> this::n_2; }); \n" +
+ " }\n" +
+ "}";
+
+ String selection = "n_1";
+ String selectKey = "<SelectOnMessageSend:";
+ String expectedSelection = selectKey + selection + "()>";
+
+ String selectionIdentifier = "n_1";
+ String expectedUnitDisplayString =
+ "import org.eclipse.jdt.annotation.*;\n" +
+ "import java.util.function.*;\n" +
+ "interface IN0 {\n" +
+ "}\n" +
+ "interface IN1 extends IN0 {\n" +
+ "}\n" +
+ "interface IN2 extends IN0 {\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " }\n" +
+ " IN1 n_1() {\n" +
+ " }\n" +
+ " IN2 n_2() {\n" +
+ " }\n" +
+ " <M>void m(Supplier<M> m2) {\n" +
+ " }\n" +
+ " void testSw(int i) {\n" +
+ " m(switch (i) {\n" +
+ "case 2 ->\n" +
+ " () -> <SelectOnMessageSend:n_1()>;\n" +
+ "default ->\n" +
+ " this::n_2;\n" +
+ "});\n" +
+ " }\n" +
+ "}\n";
+ String expectedReplacedSource = "n_1()";
+ String testName = "X.java";
+
+ int selectionStart = string.lastIndexOf(selection);
+ int selectionEnd = selectionStart + selection.length() - 1;
+
+ checkMethodParse(string.toCharArray(), selectionStart, selectionEnd, expectedSelection, expectedUnitDisplayString,
+ selectionIdentifier, expectedReplacedSource, testName);
+}
+public void test020() throws JavaModelException {
+ String string = "import org.eclipse.jdt.annotation.*;\n" +
+ "import java.util.function.*;\n" +
+ "interface IN0 {} \n" +
+ "interface IN1 extends IN0 {} \n" +
+ "interface IN2 extends IN0 {}\n" +
+ "public class X {\n" +
+ " IN1 n_1() { return new IN1() {}; } \n" +
+ " IN2 n_2() { return null; } \n" +
+ " <M> void m( Supplier< M> m2) { } \n" +
+ " void testSw(int i) { \n" +
+ " m(switch(i) { \n" +
+ " default -> this::n_2; }); \n" +
+ " }\n" +
+ "}";
+
+ String selection = "n_2";
+ String selectKey = "<SelectionOnReferenceExpressionName:this::";
+ String expectedSelection = selectKey + selection + ">";
+
+ String selectionIdentifier = "n_2";
+ String expectedUnitDisplayString =
+ "import org.eclipse.jdt.annotation.*;\n" +
+ "import java.util.function.*;\n" +
+ "interface IN0 {\n" +
+ "}\n" +
+ "interface IN1 extends IN0 {\n" +
+ "}\n" +
+ "interface IN2 extends IN0 {\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " }\n" +
+ " IN1 n_1() {\n" +
+ " }\n" +
+ " IN2 n_2() {\n" +
+ " }\n" +
+ " <M>void m(Supplier<M> m2) {\n" +
+ " }\n" +
+ " void testSw(int i) {\n" +
+ " m(switch (i) {\n" +
+ "default ->\n" +
+ " <SelectionOnReferenceExpressionName:this::n_2>;\n" +
+ "});\n" +
+ " }\n" +
+ "}\n";
+ String expectedReplacedSource = "this::n_2";
+ String testName = "X.java";
+
+ int selectionStart = string.lastIndexOf(selection);
+ int selectionEnd = selectionStart + selection.length() - 1;
+
+ checkMethodParse(string.toCharArray(), selectionStart, selectionEnd, expectedSelection, expectedUnitDisplayString,
+ selectionIdentifier, expectedReplacedSource, testName);
+}
+public void test021() throws JavaModelException {
+ String string = "import org.eclipse.jdt.annotation.*;\n" +
+ "import java.util.function.*;\n" +
+ "interface IN0 {} \n" +
+ "interface IN1 extends IN0 {} \n" +
+ "interface IN2 extends IN0 {}\n" +
+ "public class X {\n" +
+ " IN1 n_1(int ijk) { return new IN1() {}; } \n" +
+ " IN2 n_2() { return null; } \n" +
+ " <M> void m( Supplier< M> m2) { } \n" +
+ " void testSw(int ijk) { \n" +
+ " m(switch(ijk) { \n" +
+ " default -> () -> n_1(ijk); }); \n" +
+ " }\n" +
+ "}";
+
+ String selection = "n_1";
+ String selectKey = "<SelectOnMessageSend:";
+ String expectedSelection = selectKey + selection + "(ijk)>";
+
+ String selectionIdentifier = "n_1";
+ String expectedUnitDisplayString =
+ "import org.eclipse.jdt.annotation.*;\n" +
+ "import java.util.function.*;\n" +
+ "interface IN0 {\n" +
+ "}\n" +
+ "interface IN1 extends IN0 {\n" +
+ "}\n" +
+ "interface IN2 extends IN0 {\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " }\n" +
+ " IN1 n_1(int ijk) {\n" +
+ " }\n" +
+ " IN2 n_2() {\n" +
+ " }\n" +
+ " <M>void m(Supplier<M> m2) {\n" +
+ " }\n" +
+ " void testSw(int ijk) {\n" +
+ " m(switch (ijk) {\n" +
+ "default ->\n" +
+ " () -> <SelectOnMessageSend:n_1(ijk)>;\n" +
+ "});\n" +
+ " }\n" +
+ "}\n";
+ String expectedReplacedSource = "n_1(ijk)";
+ String testName = "X.java";
+
+ int selectionStart = string.lastIndexOf(selection);
+ int selectionEnd = selectionStart + selection.length() - 1;
+
+ checkMethodParse(string.toCharArray(), selectionStart, selectionEnd, expectedSelection, expectedUnitDisplayString,
+ selectionIdentifier, expectedReplacedSource, testName);
+}
+public void test022() throws JavaModelException {
+ String string = "import org.eclipse.jdt.annotation.*;\n" +
+ "import java.util.function.*;\n" +
+ "interface IN0 {} \n" +
+ "interface IN1 extends IN0 {} \n" +
+ "interface IN2 extends IN0 {}\n" +
+ "public class X {\n" +
+ " IN1 n_1(int ijk) { return new IN1() {}; } \n" +
+ " IN2 n_2() { return null; } \n" +
+ " <M> void m( Supplier< M> m2) { } \n" +
+ " void testSw(int ijk) { \n" +
+ " m(switch(ijk) { \n" +
+ " default -> () -> n_1(ijk); }); \n" +
+ " }\n" +
+ "}";
+
+ String selection = "ijk";
+ String selectKey = "<SelectOnName:";
+ String expectedSelection = selectKey + selection + ">";
+
+ String selectionIdentifier = "ijk";
+ String expectedUnitDisplayString =
+ "import org.eclipse.jdt.annotation.*;\n" +
+ "import java.util.function.*;\n" +
+ "interface IN0 {\n" +
+ "}\n" +
+ "interface IN1 extends IN0 {\n" +
+ "}\n" +
+ "interface IN2 extends IN0 {\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " }\n" +
+ " IN1 n_1(int ijk) {\n" +
+ " }\n" +
+ " IN2 n_2() {\n" +
+ " }\n" +
+ " <M>void m(Supplier<M> m2) {\n" +
+ " }\n" +
+ " void testSw(int ijk) {\n" +
+ " m(switch (ijk) {\n" +
+ "default ->\n" +
+ " () -> n_1(<SelectOnName:ijk>);\n" +
+ "});\n" +
+ " }\n" +
+ "}\n";
+ String expectedReplacedSource = "ijk";
+ String testName = "X.java";
+
+ int selectionStart = string.lastIndexOf(selection);
+ int selectionEnd = selectionStart + selection.length() - 1;
+
+ checkMethodParse(string.toCharArray(), selectionStart, selectionEnd, expectedSelection, expectedUnitDisplayString,
+ selectionIdentifier, expectedReplacedSource, testName);
+}
+}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestAll.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestAll.java
index 8699a67c45..5f0c5c3b34 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestAll.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestAll.java
@@ -207,6 +207,28 @@ public static TestSuite getTestSuite(boolean addComplianceDiagnoseTest) {
TestCase.RUN_ONLY_ID = null;
all.addTest(AbstractCompilerTest.buildComplianceTestSuite(ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_12), tests_12));
}
+ if ((possibleComplianceLevels & AbstractCompilerTest.F_13) != 0) {
+ ArrayList tests_13 = (ArrayList)testClasses.clone();
+ tests_13.addAll(TEST_CLASSES_1_5);
+ tests_13.add(ParserTest1_7.class);
+ tests_13.add(LambdaExpressionSyntaxTest.class);
+ tests_13.add(ReferenceExpressionSyntaxTest.class);
+ tests_13.add(TypeAnnotationSyntaxTest.class);
+ tests_13.add(CompletionParserTest18.class);
+ tests_13.add(SelectionParserTest18.class);
+ tests_13.add(SelectionParserTest9.class);
+ tests_13.add(SelectionParserTest10.class);
+ tests_13.add(SelectionParserTest12.class);
+ tests_13.add(ModuleDeclarationSyntaxTest.class);
+ tests_13.add(JEP286ReservedWordTest.class);
+ // Reset forgotten subsets tests
+ TestCase.TESTS_PREFIX = null;
+ TestCase.TESTS_NAMES = null;
+ TestCase.TESTS_NUMBERS= null;
+ TestCase.TESTS_RANGE = null;
+ TestCase.RUN_ONLY_ID = null;
+ all.addTest(AbstractCompilerTest.buildComplianceTestSuite(ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_13), tests_13));
+ }
return all;
}
public static Test suite() {
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java
index 31f5fb6c72..55553d1ffd 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java
@@ -302,6 +302,8 @@ static class JavacCompiler {
return JavaCore.VERSION_11;
} else if(rawVersion.startsWith("12")) {
return JavaCore.VERSION_12;
+ } else if(rawVersion.startsWith("13")) {
+ return JavaCore.VERSION_13;
} else {
throw new RuntimeException("unknown javac version: " + rawVersion);
}
@@ -423,6 +425,20 @@ static class JavacCompiler {
return 0200;
}
}
+ if (version == JavaCore.VERSION_13) {
+ if ("13-ea".equals(rawVersion)) {
+ return 0000;
+ }
+ if ("13".equals(rawVersion)) {
+ return 0000;
+ }
+ if ("13.0.1".equals(rawVersion)) {
+ return 0100;
+ }
+ if ("13.0.2".equals(rawVersion)) {
+ return 0200;
+ }
+ }
throw new RuntimeException("unknown raw javac version: " + rawVersion);
}
// returns 0L if everything went fine; else the lower word contains the
@@ -565,6 +581,20 @@ protected static class JavacTestOptions {
throw new IllegalArgumentException("preview not supported at release "+release);
return options;
}
+ @java.lang.SuppressWarnings("synthetic-access")
+ static JavacTestOptions forReleaseWithPreview(String release, String additionalOptions) {
+ JavacTestOptions options = new JavacTestOptions(Long.parseLong(release));
+ if (isJRE9Plus) {
+ String result = "--release "+release+" --enable-preview -Xlint:-preview";
+ if (additionalOptions != null)
+ result = result + " " + additionalOptions;
+ options.setCompilerOptions(result);
+
+ }
+ else
+ throw new IllegalArgumentException("preview not supported at release "+release);
+ return options;
+ }
public static class SuppressWarnings extends JavacTestOptions {
public SuppressWarnings(String token) {
setCompilerOptions("-Xlint:-"+token);
@@ -947,7 +977,7 @@ protected static class JavacTestOptions {
JavacBug8144832 = RUN_JAVAC ? // https://bugs.openjdk.java.net/browse/JDK-8144832
new JavacHasABug(MismatchType.JavacErrorsEclipseNone, ClassFileConstants.JDK9, 0000) : null,
JavacBug8179483_switchExpression = RUN_JAVAC ? // https://bugs.openjdk.java.net/browse/JDK-8179483
- new JavacBug8179483(" --release 12 --enable-preview -Xlint:-preview") : null,
+ new JavacBug8179483(" --release 13 --enable-preview -Xlint:-preview") : null,
JavacBug8221413_switchExpression = RUN_JAVAC ? // https://bugs.openjdk.java.net/browse/JDK-8221413
new JavacBug8221413(" --release 12 --enable-preview -Xlint:-preview") : null,
JavacBug8226510_switchExpression = RUN_JAVAC ? // https://bugs.openjdk.java.net/browse/JDK-8226510
@@ -1759,7 +1789,7 @@ protected static class JavacTestOptions {
skipJavac ? JavacTestOptions.SKIP :
javacTestOptions != null ? javacTestOptions : JavacTestOptions.DEFAULT /* default javac test options */);
}
- protected void runConformTest(String[] testFiles, Map customOptions) {
+ protected void runConformTest(String[] testFiles, Map<String, String> customOptions) {
runTest(
// test directory preparation
true /* flush output directory */,
@@ -1781,10 +1811,10 @@ protected static class JavacTestOptions {
// javac options
JavacTestOptions.DEFAULT /* default javac test options */);
}
- protected void runConformTest(String[] testFiles, String expectedOutput, Map customOptions) {
+ protected void runConformTest(String[] testFiles, String expectedOutput, Map<String, String> customOptions) {
runConformTest(testFiles, expectedOutput, customOptions, null);
}
- protected void runConformTest(String[] testFiles, String expectedOutput, Map customOptions, String[] vmArguments) {
+ protected void runConformTest(String[] testFiles, String expectedOutput, Map<String, String> customOptions, String[] vmArguments) {
runTest(
// test directory preparation
true /* flush output directory */,
@@ -1865,7 +1895,7 @@ protected static class JavacTestOptions {
String[] classLibraries,
boolean shouldFlushOutputDirectory,
String[] vmArguments,
- Map customOptions,
+ Map<String, String> customOptions,
ICompilerRequestor customRequestor) {
runTest(
// test directory preparation
@@ -2951,7 +2981,7 @@ protected void runNegativeTest(boolean skipJavac, JavacTestOptions javacTestOpti
String[] testFiles,
// compiler options
String[] classLibraries,
- Map customOptions,
+ Map<String, String> customOptions,
boolean performStatementsRecovery,
ICompilerRequestor customRequestor,
// compiler results
@@ -3091,7 +3121,7 @@ protected void runNegativeTest(boolean skipJavac, JavacTestOptions javacTestOpti
// compiler options
String[] classLibraries,
boolean libsOnModulePath,
- Map customOptions,
+ Map<String, String> customOptions,
boolean performStatementsRecovery,
ICompilerRequestor customRequestor,
// compiler results
@@ -3126,7 +3156,7 @@ protected void runNegativeTest(boolean skipJavac, JavacTestOptions javacTestOpti
requestor.outputPath = OUTPUT_DIR.endsWith(File.separator) ? OUTPUT_DIR : OUTPUT_DIR + File.separator;
// WORK should not have to test a constant?
- Map options = getCompilerOptions();
+ Map<String, String> options = getCompilerOptions();
if (customOptions != null) {
options.putAll(customOptions);
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java
index 4d3f57f1ed..342f50c582 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java
@@ -299,7 +299,7 @@ public class CompilerInvocationTests extends AbstractRegressionTest {
// templates, which can occur downstream in the localization process (assuming
// that we always release the English version right)
public void test009_missing_message_templates() {
- assertEquals("Unable to retrieve the error message for problem id: 4194303. Check compiler resources.",
+ assertEquals("Unable to retrieve the error message for problem id: 2097151. Check compiler resources.",
new DefaultProblemFactory().getLocalizedMessage(Integer.MAX_VALUE, new String[] {}));
}
@@ -807,6 +807,7 @@ public void test011_problem_categories() {
expectedProblemAttributes.put("MissingSynchronizedModifierInInheritedMethod", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("MissingTypeInConstructor", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("MissingTypeInLambda", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
+ expectedProblemAttributes.put("UnterminatedTextBlock", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
expectedProblemAttributes.put("MissingTypeInMethod", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("MissingValueForAnnotationMember", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("MissingValueFromLambda", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
@@ -1180,7 +1181,27 @@ public void test011_problem_categories() {
expectedProblemAttributes.put("PreviewFeatureDisabled", new ProblemAttributes(CategorizedProblem.CAT_COMPLIANCE));
expectedProblemAttributes.put("PreviewFeatureUsed", new ProblemAttributes(CategorizedProblem.CAT_COMPLIANCE));
expectedProblemAttributes.put("PreviewFeatureNotSupported", new ProblemAttributes(CategorizedProblem.CAT_COMPLIANCE));
- StringBuffer failures = new StringBuffer();
+ expectedProblemAttributes.put("PreviewFeaturesNotAllowed", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("SwitchExpressionsYieldIncompatibleResultExpressionTypes", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("SwitchExpressionsYieldEmptySwitchBlock", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("SwitchExpressionsYieldNoResultExpression", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("SwitchExpressionaYieldSwitchLabeledBlockCompletesNormally", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("SwitchExpressionsYieldLastStatementCompletesNormally", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("SwitchExpressionsYieldTrailingSwitchLabels", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("SwitchPreviewMixedCase", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("SwitchExpressionsYieldMissingDefaultCase", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("SwitchExpressionsYieldMissingValue", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("SwitchExpressionsYieldMissingEnumConstantCase", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("SwitchExpressionsYieldIllegalLastStatement", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("SwitchExpressionsYieldBreakNotAllowed", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("SwitchExpressionsYieldUnqualifiedMethodWarning", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("SwitchExpressionsYieldUnqualifiedMethodError", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("SwitchExpressionsYieldOutsideSwitchExpression", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("SwitchExpressionsYieldRestrictedGeneralWarning", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("SwitchExpressionsYieldIllegalStatement", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("SwitchExpressionsYieldTypeDeclarationWarning", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("SwitchExpressionsYieldTypeDeclarationError", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ StringBuffer failures = new StringBuffer();
StringBuffer correctResult = new StringBuffer(70000);
Field[] fields = (iProblemClass = IProblem.class).getFields();
Arrays.sort(fields, new Comparator() {
@@ -1757,6 +1778,7 @@ public void test012_compiler_problems_tuning() {
expectedProblemAttributes.put("MissingSynchronizedModifierInInheritedMethod", new ProblemAttributes(JavaCore.COMPILER_PB_MISSING_SYNCHRONIZED_ON_INHERITED_METHOD));
expectedProblemAttributes.put("MissingTypeInConstructor", SKIP);
expectedProblemAttributes.put("MissingTypeInLambda", SKIP);
+ expectedProblemAttributes.put("UnterminatedTextBlock", SKIP);
expectedProblemAttributes.put("MissingTypeInMethod", SKIP);
expectedProblemAttributes.put("MissingValueForAnnotationMember", SKIP);
expectedProblemAttributes.put("MissingValueFromLambda", SKIP);
@@ -2130,7 +2152,27 @@ public void test012_compiler_problems_tuning() {
expectedProblemAttributes.put("PreviewFeatureDisabled", SKIP);
expectedProblemAttributes.put("PreviewFeatureUsed", SKIP);
expectedProblemAttributes.put("PreviewFeatureNotSupported", SKIP);
- Map constantNamesIndex = new HashMap();
+ expectedProblemAttributes.put("PreviewFeaturesNotAllowed", SKIP);
+ expectedProblemAttributes.put("SwitchExpressionsYieldIncompatibleResultExpressionTypes", SKIP);
+ expectedProblemAttributes.put("SwitchExpressionsYieldEmptySwitchBlock", SKIP);
+ expectedProblemAttributes.put("SwitchExpressionsYieldNoResultExpression", SKIP);
+ expectedProblemAttributes.put("SwitchExpressionaYieldSwitchLabeledBlockCompletesNormally", SKIP);
+ expectedProblemAttributes.put("SwitchExpressionsYieldLastStatementCompletesNormally", SKIP);
+ expectedProblemAttributes.put("SwitchExpressionsYieldTrailingSwitchLabels", SKIP);
+ expectedProblemAttributes.put("SwitchPreviewMixedCase", SKIP);
+ expectedProblemAttributes.put("SwitchExpressionsYieldMissingDefaultCase", SKIP);
+ expectedProblemAttributes.put("SwitchExpressionsYieldMissingValue", SKIP);
+ expectedProblemAttributes.put("SwitchExpressionsYieldMissingEnumConstantCase", SKIP);
+ expectedProblemAttributes.put("SwitchExpressionsYieldIllegalLastStatement", SKIP);
+ expectedProblemAttributes.put("SwitchExpressionsYieldBreakNotAllowed", SKIP);
+ expectedProblemAttributes.put("SwitchExpressionsYieldUnqualifiedMethodWarning", SKIP);
+ expectedProblemAttributes.put("SwitchExpressionsYieldUnqualifiedMethodError", SKIP);
+ expectedProblemAttributes.put("SwitchExpressionsYieldOutsideSwitchExpression", SKIP);
+ expectedProblemAttributes.put("SwitchExpressionsYieldRestrictedGeneralWarning", SKIP);
+ expectedProblemAttributes.put("SwitchExpressionsYieldIllegalStatement", SKIP);
+ expectedProblemAttributes.put("SwitchExpressionsYieldTypeDeclarationWarning", SKIP);
+ expectedProblemAttributes.put("SwitchExpressionsYieldTypeDeclarationError", SKIP);
+ Map constantNamesIndex = new HashMap();
Field[] fields = JavaCore.class.getFields();
for (int i = 0, length = fields.length; i < length; i++) {
Field field = fields[i];
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java
index b0514b8936..6fc90320ea 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java
@@ -2904,19 +2904,19 @@ public void testBug537804_comment5() {
"The local variable action may not have been initialized\n" +
"----------\n");
}
-public void testBug542707_001() {
- if (this.complianceLevel != ClassFileConstants.JDK12)
+public void testBug548318_001() {
+ if (this.complianceLevel != ClassFileConstants.JDK13)
return;
Map<String, String> defaultOptions = super.getCompilerOptions();
- defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_12);
+ defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_13);
defaultOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
defaultOptions.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
String expectedProblemLog =
"----------\n" +
"1. ERROR in X.java (at line 11)\n" +
- " break k;\n" +
+ " yield k;\n" +
" ^\n" +
"The local variable k may not have been initialized\n" +
"----------\n" +
@@ -2934,10 +2934,10 @@ public void testBug542707_001() {
" int it = switch (i) { \n" +
" case 1 -> {\n" +
" k = 1;\n" +
- " break k ;\n" +
+ " yield k ;\n" +
" }\n" +
" default -> {\n" +
- " break k;\n" +
+ " yield k;\n" +
" }\n" +
" };\n" +
" return k + it;\n" +
@@ -2959,13 +2959,13 @@ public void testBug542707_001() {
defaultOptions);
}
-public void testBug542707_002() {
- if (this.complianceLevel != ClassFileConstants.JDK12)
+public void testBug548318_002() {
+ if (this.complianceLevel != ClassFileConstants.JDK13)
return;
Map<String, String> defaultOptions = super.getCompilerOptions();
- defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_12);
+ defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_13);
defaultOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
defaultOptions.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
String expectedProblemLog =
@@ -2976,7 +2976,7 @@ public void testBug542707_002() {
"The final local variable k may already have been assigned\n" +
"----------\n" +
"2. ERROR in X.java (at line 11)\n" +
- " break k;\n" +
+ " yield k;\n" +
" ^\n" +
"The local variable k may not have been initialized\n" +
"----------\n";
@@ -2989,10 +2989,10 @@ public void testBug542707_002() {
" k = switch (i) { \n" +
" case 1 -> {\n" +
" k = 1;\n" +
- " break k ;\n" +
+ " yield k ;\n" +
" }\n" +
" default -> {\n" +
- " break k;\n" +
+ " yield k;\n" +
" }\n" +
" };\n" +
" return k;\n" +
@@ -3016,13 +3016,13 @@ public void testBug542707_002() {
/*
* k is definitely assigned - no errors on that front.
*/
-public void testBug542707_003() {
- if (this.complianceLevel != ClassFileConstants.JDK12)
+public void testBug548318_003() {
+ if (this.complianceLevel != ClassFileConstants.JDK13)
return;
Map<String, String> defaultOptions = super.getCompilerOptions();
- defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_12);
+ defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_13);
defaultOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
defaultOptions.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
String expectedProblemLog =
@@ -3041,15 +3041,15 @@ public void testBug542707_003() {
" int it = switch (i) { \n" +
" case 1 -> {\n" +
" k = 1;\n" +
- " break k ;\n" +
+ " yield k ;\n" +
" }\n" +
" case 2 -> {\n" +
" k = 2;\n" +
- " break k ;\n" +
+ " yield k ;\n" +
" }\n" +
" default -> {\n" +
" k = 3;\n" +
- " break k;\n" +
+ " yield k;\n" +
" }\n" +
" };\n" +
" return k;\n" +
@@ -3071,13 +3071,13 @@ public void testBug542707_003() {
true,
defaultOptions);
}
-public void testBug542707_004() {
- if (this.complianceLevel != ClassFileConstants.JDK12)
+public void testBug548318_004() {
+ if (this.complianceLevel != ClassFileConstants.JDK13)
return;
Map<String, String> defaultOptions = super.getCompilerOptions();
- defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_12);
+ defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_13);
defaultOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
defaultOptions.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
String expectedProblemLog =
@@ -3111,15 +3111,15 @@ public void testBug542707_004() {
" int it = switch (i) { \n" +
" case 1 -> {\n" +
" k = 1;\n" +
- " break k ;\n" +
+ " yield k ;\n" +
" }\n" +
" case 2 -> {\n" +
" k = 2;\n" +
- " break k ;\n" +
+ " yield k ;\n" +
" }\n" +
" default -> {\n" +
" k = 3;\n" +
- " break k;\n" +
+ " yield k;\n" +
" }\n" +
" };\n" +
" return k;\n" +
@@ -3141,19 +3141,19 @@ public void testBug542707_004() {
true,
defaultOptions);
}
-public void testBug542707_005() {
- if (this.complianceLevel != ClassFileConstants.JDK12)
+public void testBug548318_005() {
+ if (this.complianceLevel != ClassFileConstants.JDK13)
return;
Map<String, String> defaultOptions = super.getCompilerOptions();
- defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_12);
+ defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_13);
defaultOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
defaultOptions.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
String expectedProblemLog =
"----------\n" +
"1. ERROR in X.java (at line 11)\n" +
- " break k ;\n" +
+ " yield k ;\n" +
" ^\n" +
"The local variable k may not have been initialized\n" +
"----------\n" +
@@ -3176,14 +3176,14 @@ public void testBug542707_005() {
" int it = switch (i) { \n" +
" case 1 -> {\n" +
" k = 1;\n" +
- " break k ;\n" +
+ " yield k ;\n" +
" }\n" +
" case 2 -> {\n" +
- " break k ;\n" +
+ " yield k ;\n" +
" }\n" +
" default -> {\n" +
" k = 3;\n" +
- " break k;\n" +
+ " yield k;\n" +
" }\n" +
" };\n" +
" return k;\n" +
@@ -3206,20 +3206,20 @@ public void testBug542707_005() {
defaultOptions);
}
/**
- * From JLS 12 16.1.7 , Suppose that the switch expression has result expressions e1, …, en, all of
+ * From JLS 13 16.1.7 , Suppose that the switch expression has result expressions e1, …, en, all of
* which are boolean-valued.
- * V is definitely assigned after a switch expression when true iff for every value break statement with
+ * V is definitely assigned after a switch expression when true iff for every value yield statement with
* expression e in the switch block that may exit the switch expression, V is definitely assigned after e when true.
- * V is definitely assigned after a switch expression when false iff for every value break statement with
+ * V is definitely assigned after a switch expression when false iff for every value yield statement with
* expression e in the switch block that may exit the switch expression, V is definitely assigned after e when false.
*/
-public void testBug542707_006() {
- if (this.complianceLevel != ClassFileConstants.JDK12)
+public void testBug548318_006() {
+ if (this.complianceLevel != ClassFileConstants.JDK13)
return;
Map<String, String> defaultOptions = super.getCompilerOptions();
- defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_12);
+ defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_13);
defaultOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
defaultOptions.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
String expectedProblemLog =
@@ -3237,14 +3237,14 @@ public void testBug542707_006() {
" boolean b = switch (i) {\n" +
" case 1 :\n" +
" v = 1;\n" +
- " break true;\n" +
+ " yield true;\n" +
" case 2 : {\n" +
" v = 2;\n" +
- " break true;\n" +
+ " yield true;\n" +
" }\n" +
" default : {\n" +
" v = 3;\n" +
- " break false;\n" +
+ " yield false;\n" +
" }\n" +
" };\n" +
" int d = b == true ? 0 : 1; \n" +
@@ -3268,22 +3268,22 @@ public void testBug542707_006() {
defaultOptions);
}
/**
- * From JLS 12 16.1.7 , Suppose that the switch expression has result expressions e1, …, en, all of
+ * From JLS 13 16.1.7 , Suppose that the switch expression has result expressions e1, …, en, all of
* which are boolean-valued.
- * V is definitely unassigned after a switch expression when true iff for every value break statement with expression
- * e in the switch block that may exit the switch expression, V is definitely unassigned before the value break
+ * V is definitely unassigned after a switch expression when true iff for every value yield statement with expression
+ * e in the switch block that may exit the switch expression, V is definitely unassigned before the value yield
* statement and V is definitely unassigned after e when true.
- * V is definitely unassigned after a switch expression when false iff for every value break statement with expression
- * e in the switch block that may exit the switch expression, V is definitely unassigned before the value break
+ * V is definitely unassigned after a switch expression when false iff for every value yield statement with expression
+ * e in the switch block that may exit the switch expression, V is definitely unassigned before the value yield
* statement and V is definitely unassigned after e when false.
*/
-public void testBug542707_007() {
- if (this.complianceLevel != ClassFileConstants.JDK12)
+public void testBug548318_007() {
+ if (this.complianceLevel != ClassFileConstants.JDK13)
return;
Map<String, String> defaultOptions = super.getCompilerOptions();
- defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_12);
+ defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_13);
defaultOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
defaultOptions.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
String expectedProblemLog =
@@ -3306,14 +3306,14 @@ public void testBug542707_007() {
" boolean b = switch (i) {\n" +
" case 1 :\n" +
" //v = 1;\n" +
- " break true;\n" +
+ " yield true;\n" +
" case 2 : {\n" +
" //v = 2;\n" +
- " break true;\n" +
+ " yield true;\n" +
" }\n" +
" default : {\n" +
" //v = 3;\n" +
- " break false;\n" +
+ " yield false;\n" +
" }\n" +
" };\n" +
" int d = b == true ? 0 : 1; \n" +
@@ -3337,17 +3337,17 @@ public void testBug542707_007() {
defaultOptions);
}
/**
- * From JLS 12 16.1.7 , Suppose that the switch expression has result expressions e1, …, en, all of
+ * From JLS 13 16.1.7 , Suppose that the switch expression has result expressions e1, …, en, all of
* which are boolean-valued.
* V is [un]assigned before the selector expression iff V is [un]assigned before the switch statement.
*/
-public void testBug542707_008() {
- if (this.complianceLevel != ClassFileConstants.JDK12)
+public void testBug548318_008() {
+ if (this.complianceLevel != ClassFileConstants.JDK13)
return;
Map<String, String> defaultOptions = super.getCompilerOptions();
- defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_12);
+ defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_13);
defaultOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
defaultOptions.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
String expectedProblemLog =
@@ -3365,14 +3365,14 @@ public void testBug542707_008() {
" boolean b = switch (i) {\n" +
" case 1 :\n" +
" //v = 1;\n" +
- " break true;\n" +
+ " yield true;\n" +
" case 2 : {\n" +
" //v = 2;\n" +
- " break true;\n" +
+ " yield true;\n" +
" }\n" +
" default : {\n" +
" //v = 3;\n" +
- " break false;\n" +
+ " yield false;\n" +
" }\n" +
" };\n" +
" int d = b == true ? 0 : 1; \n" +
@@ -3396,17 +3396,17 @@ public void testBug542707_008() {
defaultOptions);
}
/**
- * From JLS 12 16.1.7 , Suppose that the switch expression has result expressions e1, …, en, all of
+ * From JLS 13 16.1.7 , Suppose that the switch expression has result expressions e1, …, en, all of
* which are boolean-valued.
* V is [un]assigned before the selector expression iff V is [un]assigned before the switch statement.
*/
-public void testBug542707_009() {
- if (this.complianceLevel != ClassFileConstants.JDK12)
+public void testBug548318_009() {
+ if (this.complianceLevel != ClassFileConstants.JDK13)
return;
Map<String, String> defaultOptions = super.getCompilerOptions();
- defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_12);
+ defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_13);
defaultOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
defaultOptions.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
String expectedProblemLog =
@@ -3429,14 +3429,14 @@ public void testBug542707_009() {
" boolean b = switch (v) {\n" +
" case 1 :\n" +
" v = 1;\n" +
- " break true;\n" +
+ " yield true;\n" +
" case 2 : {\n" +
" v = 2;\n" +
- " break true;\n" +
+ " yield true;\n" +
" }\n" +
" default : {\n" +
" v = 3;\n" +
- " break false;\n" +
+ " yield false;\n" +
" }\n" +
" };\n" +
" int d = b == true ? 0 : 1; \n" +
@@ -3460,18 +3460,18 @@ public void testBug542707_009() {
defaultOptions);
}
/**
- * From JLS 12 16.1.7 , Suppose that the switch expression has result expressions e1, …, en, all of
+ * From JLS 13 16.1.7 , Suppose that the switch expression has result expressions e1, …, en, all of
* which are boolean-valued.
* V is [un]assigned before the first statement of the first switch labeled statement group in the switch block
* iff V is [un]assigned after the selector expression.
*/
-public void testBug542707_010() {
- if (this.complianceLevel != ClassFileConstants.JDK12)
+public void testBug548318_010() {
+ if (this.complianceLevel != ClassFileConstants.JDK13)
return;
Map<String, String> defaultOptions = super.getCompilerOptions();
- defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_12);
+ defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_13);
defaultOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
defaultOptions.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
String expectedProblemLog =
@@ -3489,14 +3489,14 @@ public void testBug542707_010() {
" boolean b = switch (i + (v =1)) {\n" +
" case 1 :\n" +
" v += 1;\n" +
- " break true;\n" +
+ " yield true;\n" +
" case 2 : {\n" +
" v = 2;\n" +
- " break true;\n" +
+ " yield true;\n" +
" }\n" +
" default : {\n" +
" v = 3;\n" +
- " break false;\n" +
+ " yield false;\n" +
" }\n" +
" };\n" +
" int d = b == true ? 0 : 1; \n" +
@@ -3520,18 +3520,18 @@ public void testBug542707_010() {
defaultOptions);
}
/**
- * From JLS 12 16.1.7 , Suppose that the switch expression has result expressions e1, …, en, all of
+ * From JLS 13 16.1.7 , Suppose that the switch expression has result expressions e1, …, en, all of
* which are boolean-valued.
* V is [un]assigned before the first statement of the first switch labeled statement group in the switch block
* iff V is [un]assigned after the selector expression.
*/
-public void testBug542707_011() {
- if (this.complianceLevel != ClassFileConstants.JDK12)
+public void testBug548318_011() {
+ if (this.complianceLevel != ClassFileConstants.JDK13)
return;
Map<String, String> defaultOptions = super.getCompilerOptions();
- defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_12);
+ defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_13);
defaultOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
defaultOptions.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
String expectedProblemLog =
@@ -3554,14 +3554,14 @@ public void testBug542707_011() {
" boolean b = switch (i) {\n" +
" case 1 :\n" +
" v += 1;\n" +
- " break true;\n" +
+ " yield true;\n" +
" case 2 : {\n" +
" v = 2;\n" +
- " break true;\n" +
+ " yield true;\n" +
" }\n" +
" default : {\n" +
" v = 3;\n" +
- " break false;\n" +
+ " yield false;\n" +
" }\n" +
" };\n" +
" int d = b == true ? 0 : 1; \n" +
@@ -3585,20 +3585,19 @@ public void testBug542707_011() {
defaultOptions);
}
/**
- * From JLS 12 16.1.7 , Suppose that the switch expression has result expressions e1, …, en, all of
+ * From JLS 13 16.1.7 , Suppose that the switch expression has result expressions e1, …, en, all of
* which are boolean-valued.
* V is [un]assigned before the first statement of any switch labeled statement group other than the first iff
* V is [un]assigned after the selector expression and V is [un]assigned after the preceding statement.
- * TODO: the second part - "and V is [un]assigned after the preceding statement" needs to be checked, now it looks identical to the
- * preceding rule
+ * and V is [un]assigned after the preceding statement
*/
-public void testBug542707_012() {
- if (this.complianceLevel != ClassFileConstants.JDK12)
+public void testBug548318_012() {
+ if (this.complianceLevel != ClassFileConstants.JDK13)
return;
Map<String, String> defaultOptions = super.getCompilerOptions();
- defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_12);
+ defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_13);
defaultOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
defaultOptions.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
String expectedProblemLog =
@@ -3616,14 +3615,14 @@ public void testBug542707_012() {
" boolean b = switch (i + (v =1)) {\n" +
" case 1 :\n" +
" v = 1;\n" +
- " break true;\n" +
+ " yield true;\n" +
" case 2 : {\n" +
" v += 2;\n" +
- " break true;\n" +
+ " yield true;\n" +
" }\n" +
" default : {\n" +
" v = 3;\n" +
- " break false;\n" +
+ " yield false;\n" +
" }\n" +
" };\n" +
" int d = b == true ? 0 : 1; \n" +
@@ -3647,20 +3646,82 @@ public void testBug542707_012() {
defaultOptions);
}
/**
- * From JLS 12 16.1.7 , Suppose that the switch expression has result expressions e1, …, en, all of
+ * From JLS 13 16.1.7 , Suppose that the switch expression has result expressions e1, …, en, all of
+ * which are boolean-valued.
+ * V is [un]assigned before the first statement of any switch labeled statement group other than the first iff
+ * V is [un]assigned after the selector expression and V is [un]assigned after the preceding statement.
+ * and V is [un]assigned after the preceding statement"
+ */
+public void testBug548318_012b() {
+ if (this.complianceLevel != ClassFileConstants.JDK13)
+ return;
+ Map<String, String> defaultOptions = super.getCompilerOptions();
+ defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ defaultOptions.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 15)\n" +
+ " return v + d;\n" +
+ " ^\n" +
+ "The local variable v may not have been initialized\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 19)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n";
+ String[] testFiles = new String[] {
+ "X.java", // =================
+ "public class X {\n" +
+ " public static int foo(int i) {\n" +
+ " int v;\n" +
+ " boolean b = switch (i) {\n" +
+ " case 1 :i =1;\n" +
+ " case 2 : {\n" +
+ " yield true;\n" +
+ " }\n" +
+ " default : {\n" +
+ " v = 3;\n" +
+ " yield false;\n" +
+ " }\n" +
+ " };\n" +
+ " int d = b == true ? 0 : 1; \n" +
+ " return v + d;\n" +
+ " }\n" +
+ "\n" +
+ " public boolean bar() {\n" +
+ " Zork();\n" +
+ " return true;\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(foo(3));\n" +
+ " }\n" +
+ "}\n",
+ };
+ this.runNegativeTest(
+ testFiles,
+ expectedProblemLog,
+ null,
+ true,
+ defaultOptions);
+}
+/**
+ * From JLS 13 16.1.7 , Suppose that the switch expression has result expressions e1, …, en, all of
* which are boolean-valued.
* V is [un]assigned before the first statement of any switch labeled statement group other than the first iff
* V is [un]assigned after the selector expression and V is [un]assigned after the preceding statement.
- * TODO: the second part - "and V is [un]assigned after the preceding statement" needs to be checked, now it looks identical to the
- * preceding rule
+ * and V is [un]assigned after the preceding statement" needs to be checked
*/
-public void testBug542707_013() {
- if (this.complianceLevel != ClassFileConstants.JDK12)
+public void testBug548318_013() {
+ if (this.complianceLevel != ClassFileConstants.JDK13)
return;
Map<String, String> defaultOptions = super.getCompilerOptions();
- defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_12);
+ defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_13);
defaultOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
defaultOptions.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
String expectedProblemLog =
@@ -3683,14 +3744,14 @@ public void testBug542707_013() {
" boolean b = switch (i) {\n" +
" case 1 :\n" +
" v = 1;\n" +
- " break true;\n" +
+ " yield true;\n" +
" case 2 : {\n" +
" v += 2;\n" +
- " break true;\n" +
+ " yield true;\n" +
" }\n" +
" default : {\n" +
" v = 3;\n" +
- " break false;\n" +
+ " yield false;\n" +
" }\n" +
" };\n" +
" int d = b == true ? 0 : 1; \n" +
@@ -3714,28 +3775,28 @@ public void testBug542707_013() {
defaultOptions);
}
/**
- * From JLS 12 16.1.7 , Suppose that the switch expression has result expressions e1, …, en, all of
+ * From JLS 13 16.1.7 , Suppose that the switch expression has result expressions e1, …, en, all of
* which are boolean-valued.
* The following rules apply only if the switch block of a switch expression consists of switch labeled rules:
* V is definitely assigned after a switch expression when true iff for every switch labeled rule one of the following is true:
* It is a switch labeled expression e and V is definitely assigned after e when true.
- * It is a switch labeled block b and for every value break statement expression e contained in b that may exit the switch expression,
+ * It is a switch labeled block b and for every value yield statement expression e contained in b that may exit the switch expression,
* V is definitely assigned after e when true.
* It is a switch labeled throw statement.
*
* V is definitely assigned after a switch expression when false iff for every switch labeled rule one of the following is true:
* It is a switch labeled expression e and V is definitely assigned after e when false.
- * It is a switch labeled block b and for every value break statement expression e contained in b that may exit the switch expression,
+ * It is a switch labeled block b and for every value yield statement expression e contained in b that may exit the switch expression,
* V is definitely assigned after e when false.
* It is a switch labeled throw statement.
*/
-public void testBug542707_014() {
- if (this.complianceLevel != ClassFileConstants.JDK12)
+public void testBug548318_014() {
+ if (this.complianceLevel != ClassFileConstants.JDK13)
return;
Map<String, String> defaultOptions = super.getCompilerOptions();
- defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_12);
+ defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_13);
defaultOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
defaultOptions.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
String expectedProblemLog =
@@ -3756,11 +3817,11 @@ public void testBug542707_014() {
" case 1 -> (v = 1) == 0;\n" +
" case 2 -> {\n" +
" v = 2;\n" +
- " break true;\n" +
+ " yield true;\n" +
" }\n" +
" case 3 -> {\n" +
" v = 3;\n" +
- " break false;\n" +
+ " yield false;\n" +
" }\n" +
" default -> throw new IOException();\n" +
" };\n" +
@@ -3789,30 +3850,30 @@ public void testBug542707_014() {
defaultOptions);
}
/**
- * From JLS 12 16.1.7 , Suppose that the switch expression has result expressions e1, …, en, all of
+ * From JLS 13 16.1.7 , Suppose that the switch expression has result expressions e1, …, en, all of
* which are boolean-valued.
* The following rules apply only if the switch block of a switch expression consists of switch labeled rules:
* V is definitely unassigned after a switch expression when true iff for every switch labeled rule one of the following is true:
* It is a switch labeled expression e and V is definitely unassigned after e when true .
- * It is a switch labeled block b and for every value break statement expression e contained in b that
- * may exit the switch expression, V is definitely unassigned before the value break statement and
+ * It is a switch labeled block b and for every value yield statement expression e contained in b that
+ * may exit the switch expression, V is definitely unassigned before the value yield statement and
* V is definitely unassigned after e when true.
* It is a switch labeled throw statement.
*
* V is definitely unassigned after a switch expression when false iff for every switch labeled rule one of the following is true:
* It is a switch labeled expression e and V is definitely unassigned after e when false.
- * It is a switch labeled block b and for every value break statement expression e contained in b that may
- * exit the switch expression, V is definitely unassigned before the value break statement and V is definitely unassigned
+ * It is a switch labeled block b and for every value yield statement expression e contained in b that may
+ * exit the switch expression, V is definitely unassigned before the value yield statement and V is definitely unassigned
* after e when false.
* It is a switch labeled throw statement.
*/
-public void testBug542707_015() {
- if (this.complianceLevel != ClassFileConstants.JDK12)
+public void testBug548318_015() {
+ if (this.complianceLevel != ClassFileConstants.JDK13)
return;
Map<String, String> defaultOptions = super.getCompilerOptions();
- defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_12);
+ defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_13);
defaultOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
defaultOptions.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
String expectedProblemLog =
@@ -3837,10 +3898,10 @@ public void testBug542707_015() {
" case 0 -> true;\n" +
" case 1 -> false;\n" +
" case 2 -> {\n" +
- " break true;\n" +
+ " yield true;\n" +
" }\n" +
" case 3 -> {\n" +
- " break false;\n" +
+ " yield false;\n" +
" }\n" +
" default -> throw new IOException();\n" +
" };\n" +
@@ -3869,18 +3930,18 @@ public void testBug542707_015() {
defaultOptions);
}
/**
- * From JLS 12 16.1.7 , Suppose that the switch expression has result expressions e1, …, en, all of
+ * From JLS 13 16.1.7 , Suppose that the switch expression has result expressions e1, …, en, all of
* which are boolean-valued.
* V is [un]assigned before any switch labeled expression or statement in the switch
* block iff V is [un]assigned after the selector expression.
*/
-public void testBug542707_016() {
- if (this.complianceLevel != ClassFileConstants.JDK12)
+public void testBug548318_016() {
+ if (this.complianceLevel != ClassFileConstants.JDK13)
return;
Map<String, String> defaultOptions = super.getCompilerOptions();
- defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_12);
+ defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_13);
defaultOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
defaultOptions.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
String expectedProblemLog =
@@ -3925,19 +3986,19 @@ public void testBug542707_016() {
defaultOptions);
}
/**
- * From JLS 12 16.1.7 , Suppose that the switch expression has result expressions e1, …, en, all of
+ * From JLS 13 16.1.7 , Suppose that the switch expression has result expressions e1, …, en, all of
* which are boolean-valued.
* The following rules apply only if the switch block of a switch expression consists of switch labeled rules:
* V is [un]assigned before any switch labeled expression or statement in the switch
* block iff V is [un]assigned after the selector expression.
*/
-public void testBug542707_017() {
- if (this.complianceLevel != ClassFileConstants.JDK12)
+public void testBug548318_017() {
+ if (this.complianceLevel != ClassFileConstants.JDK13)
return;
Map<String, String> defaultOptions = super.getCompilerOptions();
- defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_12);
+ defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_13);
defaultOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
defaultOptions.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
String expectedProblemLog =
@@ -3992,21 +4053,18 @@ public void testBug542707_017() {
defaultOptions);
}
/**
- * From JLS 12 16.1.8, Suppose that the switch expression has result expressions e1, …, en, not all of
- * which are boolean-valued.
- * The following rules apply only if the switch block of a switch expression (15.28) consists of switch
- * labeled statement groups:
- * V is definitely assigned after a switch expression iff for every value break statement with expression e
- * in the switch block that may exit the switch expression, either V is definitely assigned before the value
- * break statement or V is definitely assigned after e.
+ * From JLS 13 16.1.8, V is [un]assigned after a switch expression (15.28) iff all of the following are true:
+ * V is [un]assigned before every yield statement that may exit the switch statement.
+ * For each switch labeled rule (14.11.1) in the switch block, V is [un]assigned after the
+ * expression, block, or throw statement of the switch labeled rule.
*/
-public void testBug542707_018() {
- if (this.complianceLevel != ClassFileConstants.JDK12)
+public void testBug548318_018() {
+ if (this.complianceLevel != ClassFileConstants.JDK13)
return;
Map<String, String> defaultOptions = super.getCompilerOptions();
- defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_12);
+ defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_13);
defaultOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
defaultOptions.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
String expectedProblemLog =
@@ -4023,14 +4081,14 @@ public void testBug542707_018() {
" int v;\n" +
" int t = switch (i) {\n" +
" case 0 : {\n" +
- " v = 1; // definitely assigned before break\n" +
- " break v;\n" +
+ " v = 1; // definitely assigned before yield\n" +
+ " yield v;\n" +
" }\n" +
" case 2 : {\n" +
- " break v =1; // definitely assigned after e\n" +
+ " yield v =1; // definitely assigned after e\n" +
" }\n" +
" default : {\n" +
- " break v = 2;\n" +
+ " yield v = 2;\n" +
" }\n" +
" };\n" +
" return v + t;\n" +
@@ -4053,21 +4111,18 @@ public void testBug542707_018() {
defaultOptions);
}
/**
- * From JLS 12 16.1.8, Suppose that the switch expression has result expressions e1, …, en, not all of
- * which are boolean-valued.
- * The following rules apply only if the switch block of a switch expression (15.28) consists of switch
- * labeled statement groups:
- * V is definitely unassigned after a switch expression iff for every value break statement with expression e
- * in the switch block that may exit the switch expression, V is definitely unassigned before the value break
- * statement and V is definitely unassigned after e.
+ * From JLS 13 16.1.8, V is [un]assigned after a switch expression (15.28) iff all of the following are true:
+ * V is [un]assigned before every yield statement that may exit the switch statement.
+ * For each switch labeled rule (14.11.1) in the switch block, V is [un]assigned after the
+ * expression, block, or throw statement of the switch labeled rule.
*/
-public void testBug542707_019() {
- if (this.complianceLevel != ClassFileConstants.JDK12)
+public void testBug548318_019() {
+ if (this.complianceLevel != ClassFileConstants.JDK13)
return;
Map<String, String> defaultOptions = super.getCompilerOptions();
- defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_12);
+ defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_13);
defaultOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
defaultOptions.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
String expectedProblemLog =
@@ -4089,13 +4144,13 @@ public void testBug542707_019() {
" int v;\n" +
" int t = switch (i) {\n" +
" case 0 : {\n" +
- " break 1;\n" +
+ " yield 1;\n" +
" }\n" +
" case 2 : {\n" +
- " break 2;\n" +
+ " yield 2;\n" +
" }\n" +
" default : {\n" +
- " break 3;\n" +
+ " yield 3;\n" +
" }\n" +
" };\n" +
" return v + t;\n" +
@@ -4118,19 +4173,17 @@ public void testBug542707_019() {
defaultOptions);
}
/**
- * From JLS 12 16.1.8, Suppose that the switch expression has result expressions e1, …, en, not all of
+ * From JLS 13 16.1.8, Suppose that the switch expression has result expressions e1, …, en, not all of
* which are boolean-valued.
- * The following rules apply only if the switch block of a switch expression (15.28) consists of switch
- * labeled statement groups:
* V is [un]assigned before the selector expression iff V is [un]assigned before the switch statement.
*/
-public void testBug542707_020() {
- if (this.complianceLevel != ClassFileConstants.JDK12)
+public void testBug548318_020() {
+ if (this.complianceLevel != ClassFileConstants.JDK13)
return;
Map<String, String> defaultOptions = super.getCompilerOptions();
- defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_12);
+ defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_13);
defaultOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
defaultOptions.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
String expectedProblemLog =
@@ -4147,13 +4200,13 @@ public void testBug542707_020() {
" int v =1;\n" +
" int t = switch (v) {\n" +
" case 0 : {\n" +
- " break 1;\n" +
+ " yield 1;\n" +
" }\n" +
" case 2 : {\n" +
- " break 2;\n" +
+ " yield 2;\n" +
" }\n" +
" default : {\n" +
- " break 3;\n" +
+ " yield 3;\n" +
" }\n" +
" };\n" +
" return t;\n" +
@@ -4176,19 +4229,17 @@ public void testBug542707_020() {
defaultOptions);
}
/**
- * From JLS 12 16.1.8, Suppose that the switch expression has result expressions e1, …, en, not all of
+ * From JLS 13 16.1.8, Suppose that the switch expression has result expressions e1, …, en, not all of
* which are boolean-valued.
- * The following rules apply only if the switch block of a switch expression (15.28) consists of switch
- * labeled statement groups:
* V is [un]assigned before the selector expression iff V is [un]assigned before the switch statement.
*/
-public void testBug542707_021() {
- if (this.complianceLevel != ClassFileConstants.JDK12)
+public void testBug548318_021() {
+ if (this.complianceLevel != ClassFileConstants.JDK13)
return;
Map<String, String> defaultOptions = super.getCompilerOptions();
- defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_12);
+ defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_13);
defaultOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
defaultOptions.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
String expectedProblemLog =
@@ -4210,13 +4261,13 @@ public void testBug542707_021() {
" int v;\n" +
" int t = switch (v) {\n" +
" case 0 : {\n" +
- " break 1;\n" +
+ " yield 1;\n" +
" }\n" +
" case 2 : {\n" +
- " break 2;\n" +
+ " yield 2;\n" +
" }\n" +
" default : {\n" +
- " break 3;\n" +
+ " yield 3;\n" +
" }\n" +
" };\n" +
" return t;\n" +
@@ -4239,20 +4290,21 @@ public void testBug542707_021() {
defaultOptions);
}
/**
- * From JLS 12 16.1.8, Suppose that the switch expression has result expressions e1, …, en, not all of
+ * From JLS 13 16.1.8, Suppose that the switch expression has result expressions e1, …, en, not all of
* which are boolean-valued.
- * The following rules apply only if the switch block of a switch expression (15.28) consists of switch
- * labeled statement groups:
- * V is [un]assigned before the first statement of the first switch labeled statement group in the switch block
- * iff V is [un]assigned after the selector expression.
+ * V is [un]assigned before the first block statement of a switch labeled statement group (14.11.1) of a switch expression
+ * iff both of following are true:
+ * V is [un]assigned after the selector expression of the switch statement.
+ * If the switch labeled statement group is not the first in the switch block,
+ * V is [un]assigned after the last block statement of the preceding switch labeled statement group.
*/
-public void testBug542707_022() {
- if (this.complianceLevel != ClassFileConstants.JDK12)
+public void testBug548318_022() {
+ if (this.complianceLevel != ClassFileConstants.JDK13)
return;
Map<String, String> defaultOptions = super.getCompilerOptions();
- defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_12);
+ defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_13);
defaultOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
defaultOptions.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
String expectedProblemLog =
@@ -4269,13 +4321,13 @@ public void testBug542707_022() {
" int v =1;\n" +
" int t = switch (v) {\n" +
" case 0 : {\n" +
- " break v;\n" +
+ " yield v;\n" +
" }\n" +
" case 2 : {\n" +
- " break 2;\n" +
+ " yield 2;\n" +
" }\n" +
" default : {\n" +
- " break 3;\n" +
+ " yield 3;\n" +
" }\n" +
" };\n" +
" return t;\n" +
@@ -4298,26 +4350,27 @@ public void testBug542707_022() {
defaultOptions);
}
/**
- * From JLS 12 16.1.8, Suppose that the switch expression has result expressions e1, …, en, not all of
+ * From JLS 13 16.1.8, Suppose that the switch expression has result expressions e1, …, en, not all of
* which are boolean-valued.
- * The following rules apply only if the switch block of a switch expression (15.28) consists of switch
- * labeled statement groups:
- * V is [un]assigned before the first statement of the first switch labeled statement group in the switch block
- * iff V is [un]assigned after the selector expression.
+ * V is [un]assigned before the first block statement of a switch labeled statement group (14.11.1) of a switch expression
+ * iff both of following are true:
+ * V is [un]assigned after the selector expression of the switch statement.
+ * If the switch labeled statement group is not the first in the switch block,
+ * V is [un]assigned after the last block statement of the preceding switch labeled statement group.
*/
-public void testBug542707_023() {
- if (this.complianceLevel != ClassFileConstants.JDK12)
+public void testBug548318_023() {
+ if (this.complianceLevel != ClassFileConstants.JDK13)
return;
Map<String, String> defaultOptions = super.getCompilerOptions();
- defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_12);
+ defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_13);
defaultOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
defaultOptions.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
String expectedProblemLog =
"----------\n" +
"1. ERROR in X.java (at line 6)\n" +
- " break v;\n" +
+ " yield v;\n" +
" ^\n" +
"The local variable v may not have been initialized\n" +
"----------\n" +
@@ -4333,13 +4386,13 @@ public void testBug542707_023() {
" int v;\n" +
" int t = switch (i) {\n" +
" case 0 : {\n" +
- " break v;\n" +
+ " yield v;\n" +
" }\n" +
" case 2 : {\n" +
- " break 2;\n" +
+ " yield 2;\n" +
" }\n" +
" default : {\n" +
- " break 3;\n" +
+ " yield 3;\n" +
" }\n" +
" };\n" +
" return t;\n" +
@@ -4362,26 +4415,27 @@ public void testBug542707_023() {
defaultOptions);
}
/**
- * From JLS 12 16.1.8, Suppose that the switch expression has result expressions e1, …, en, not all of
+ * From JLS 13 16.1.8, Suppose that the switch expression has result expressions e1, …, en, not all of
* which are boolean-valued.
- * The following rules apply only if the switch block of a switch expression (15.28) consists of switch
- * labeled statement groups:
- * V is [un]assigned before the first statement of any switch labeled statement group other than the first iff V is [un]assigned
- * after the selector expression and V is [un]assigned after the preceding statement.
+ * V is [un]assigned before the first block statement of a switch labeled statement group (14.11.1) of a switch expression
+ * iff both of following are true:
+ * V is [un]assigned after the selector expression of the switch statement.
+ * If the switch labeled statement group is not the first in the switch block,
+ * V is [un]assigned after the last block statement of the preceding switch labeled statement group.
*/
-public void testBug542707_024() {
- if (this.complianceLevel != ClassFileConstants.JDK12)
+public void testBug548318_024() {
+ if (this.complianceLevel != ClassFileConstants.JDK13)
return;
Map<String, String> defaultOptions = super.getCompilerOptions();
- defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_12);
+ defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_13);
defaultOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
defaultOptions.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
String expectedProblemLog =
"----------\n" +
"1. ERROR in X.java (at line 9)\n" +
- " break v;\n" +
+ " yield v;\n" +
" ^\n" +
"The local variable v may not have been initialized\n" +
"----------\n" +
@@ -4397,13 +4451,13 @@ public void testBug542707_024() {
" int v ;\n" +
" int t = switch (i) {\n" +
" case 0 : {\n" +
- " break 1;\n" +
+ " yield 1;\n" +
" }\n" +
" case 2 : {\n" +
- " break v;\n" +
+ " yield v;\n" +
" }\n" +
" default : {\n" +
- " break 3;\n" +
+ " yield 3;\n" +
" }\n" +
" };\n" +
" return t;\n" +
@@ -4426,23 +4480,18 @@ public void testBug542707_024() {
defaultOptions);
}
/**
- * From JLS 12 16.1.8, Suppose that the switch expression has result expressions e1, …, en, not all of
- * which are boolean-valued.
- * The following rules apply only if the switch block of a switch expression consists of switch labeled rules:
- * V is definitely assigned after a switch expression iff for every switch labeled rule one of the following is true:
- * It is a switch labeled expression e and V is definitely assigned after e.
- * It is a switch labeled block b and for every value break statement expression e contained in b that may exit
- * the switch expression, either V is definitely assigned before the value break statement or V is definitely
- * assigned after e.
- * It is a switch labeled throw statement.
+ * From JLS 13 16.1.8, V is [un]assigned after a switch expression (15.28) iff all of the following are true:
+ * V is [un]assigned before every yield statement that may exit the switch statement.
+ * For each switch labeled rule (14.11.1) in the switch block, V is [un]assigned after the
+ * expression, block, or throw statement of the switch labeled rule.
*/
-public void testBug542707_025() {
- if (this.complianceLevel != ClassFileConstants.JDK12)
+public void testBug548318_025() {
+ if (this.complianceLevel != ClassFileConstants.JDK13)
return;
Map<String, String> defaultOptions = super.getCompilerOptions();
- defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_12);
+ defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_13);
defaultOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
defaultOptions.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
String expectedProblemLog =
@@ -4463,9 +4512,9 @@ public void testBug542707_025() {
" case 0 -> v = 1;\n" +
" case 2 -> {\n" +
" if (i > 1) {\n" +
- " break v = 2;\n" +
+ " yield v = 2;\n" +
" }\n" +
- " break v = 3;\n" +
+ " yield v = 3;\n" +
" }\n" +
" default -> throw new IOException();\n" +
" };\n" +
@@ -4494,23 +4543,18 @@ public void testBug542707_025() {
defaultOptions);
}
/**
- * From JLS 12 16.1.8, Suppose that the switch expression has result expressions e1, …, en, not all of
- * which are boolean-valued.
- * The following rules apply only if the switch block of a switch expression consists of switch labeled rules:
- * V is definitely unassigned after a switch expression iff for every switch labeled rule one of the following is true:
- * It is a switch labeled expression e and V is definitely unassigned after e.
- * It is a switch labeled block b and for every value break statement expression e contained in b that may exit the
- * switch expression, V is definitely unassigned before the value break statement
- * and V is definitely unassigned after e.
- * It is a switch labeled throw statement.
+ * From JLS 13 16.1.8, V is [un]assigned after a switch expression (15.28) iff all of the following are true:
+ * V is [un]assigned before every yield statement that may exit the switch statement.
+ * For each switch labeled rule (14.11.1) in the switch block, V is [un]assigned after the
+ * expression, block, or throw statement of the switch labeled rule.
*/
-public void testBug542707_026() {
- if (this.complianceLevel != ClassFileConstants.JDK12)
+public void testBug548318_026() {
+ if (this.complianceLevel != ClassFileConstants.JDK13)
return;
Map<String, String> defaultOptions = super.getCompilerOptions();
- defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_12);
+ defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_13);
defaultOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
defaultOptions.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
String expectedProblemLog =
@@ -4536,9 +4580,9 @@ public void testBug542707_026() {
" case 0 -> 1;\n" +
" case 2 -> {\n" +
" if (i > 1) {\n" +
- " break 2;\n" +
+ " yield 2;\n" +
" }\n" +
- " break 3;\n" +
+ " yield 3;\n" +
" }\n" +
" default -> throw new IOException();\n" +
" };\n" +
@@ -4567,19 +4611,18 @@ public void testBug542707_026() {
defaultOptions);
}
/**
- * From JLS 12 16.1.8, Suppose that the switch expression has result expressions e1, …, en, not all of
+ * From JLS 13 16.1.8, Suppose that the switch expression has result expressions e1, …, en, not all of
* which are boolean-valued.
- * The following rules apply only if the switch block of a switch expression consists of switch labeled rules:
- * V is [un]assigned before any switch labeled expression or statement in the switch block iff
- * V is [un]assigned after the selector expression.
+ * V is [un]assigned before the expression, block, or throw statement of a switch labeled rule of a
+ * switch expression iff V is [un]assigned after the selector expression of the switch expression.
*/
-public void testBug542707_027() {
- if (this.complianceLevel != ClassFileConstants.JDK12)
+public void testBug548318_027() {
+ if (this.complianceLevel != ClassFileConstants.JDK13)
return;
Map<String, String> defaultOptions = super.getCompilerOptions();
- defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_12);
+ defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_13);
defaultOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
defaultOptions.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
String expectedProblemLog =
@@ -4600,9 +4643,9 @@ public void testBug542707_027() {
" case 0 -> v;\n" +
" case 2 -> {\n" +
" if (i > 1) {\n" +
- " break 2;\n" +
+ " yield 2;\n" +
" }\n" +
- " break 3;\n" +
+ " yield 3;\n" +
" }\n" +
" default -> throw new IOException();\n" +
" };\n" +
@@ -4631,19 +4674,18 @@ public void testBug542707_027() {
defaultOptions);
}
/**
- * From JLS 12 16.1.8, Suppose that the switch expression has result expressions e1, …, en, not all of
+ * From JLS 13 16.1.8, Suppose that the switch expression has result expressions e1, …, en, not all of
* which are boolean-valued.
- * The following rules apply only if the switch block of a switch expression consists of switch labeled rules:
- * V is [un]assigned before any switch labeled expression or statement in the switch block iff
- * V is [un]assigned after the selector expression.
+ * V is [un]assigned before the expression, block, or throw statement of a switch labeled rule of a
+ * switch expression iff V is [un]assigned after the selector expression of the switch expression.
*/
-public void testBug542707_028() {
- if (this.complianceLevel != ClassFileConstants.JDK12)
+public void testBug548318_028() {
+ if (this.complianceLevel != ClassFileConstants.JDK13)
return;
Map<String, String> defaultOptions = super.getCompilerOptions();
- defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_12);
+ defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_13);
defaultOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
defaultOptions.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
String expectedProblemLog =
@@ -4669,9 +4711,9 @@ public void testBug542707_028() {
" case 0 -> v;\n" +
" case 2 -> {\n" +
" if (i > 1) {\n" +
- " break 2;\n" +
+ " yield 2;\n" +
" }\n" +
- " break 3;\n" +
+ " yield 3;\n" +
" }\n" +
" default -> throw new IOException();\n" +
" };\n" +
@@ -4700,25 +4742,28 @@ public void testBug542707_028() {
defaultOptions);
}
/**
- * From JLS 12 16.2.9, The following rules apply only if the switch block of the switch statement consists of switch labeled rules:
- * V is [un]assigned after a switch statement iff for every switch labeled rule one of the following is true:
- * It is a switch labeled expression e and either V is [un]assigned after e or after the selector expression.
- * It is a switch labeled block b and either V is [un]assigned after e or V is [un]assigned before every
- * break statement contained in b that may exit the switch statement.
- * It is a switch labeled throw statement.
+ * From JLS 13 16.2.9, [tests the second rule - assigned]
+ * V is [un]assigned after a switch statement (14.11) iff all of the following are true:
+ * V is [un]assigned before every break statement that may exit the switch statement.
+ * For each switch labeled rule (14.11.1) in the switch block, V is [un]assigned after the
+ * expression, block, or throw statement of the switch labeled rule.
+ * If there is a switch labeled statement group (14.11.1) in the switch block, then V is [un]assigned
+ * after the last block statement of the last switch labeled statement group.
+ * If there is no default label in the switch block, or if the switch block ends with a switch label
+ * followed by }, then V is [un]assigned after the selector expression
*/
-public void testBug542707_029() {
- if (this.complianceLevel != ClassFileConstants.JDK12)
+public void testBug548318_029() {
+ if (this.complianceLevel != ClassFileConstants.JDK13)
return;
Map<String, String> defaultOptions = super.getCompilerOptions();
- defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_12);
+ defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_13);
defaultOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
defaultOptions.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
String expectedProblemLog =
"----------\n" +
- "2. ERROR in X.java (at line 24)\n" +
+ "1. ERROR in X.java (at line 24)\n" +
" Zork();\n" +
" ^^^^\n" +
"The method Zork() is undefined for the type X\n" +
@@ -4769,20 +4814,23 @@ public void testBug542707_029() {
defaultOptions);
}
/**
- * From JLS 12 16.2.9, The following rules apply only if the switch block of the switch statement consists of switch labeled rules:
- * V is [un]assigned after a switch statement iff for every switch labeled rule one of the following is true:
- * It is a switch labeled expression e and either V is [un]assigned after e or after the selector expression.
- * It is a switch labeled block b and either V is [un]assigned after e or V is [un]assigned before every
- * break statement contained in b that may exit the switch statement.
- * It is a switch labeled throw statement.
+ * From JLS 13 16.2.9, [tests the second rule - unassigned]
+ * V is [un]assigned after a switch statement (14.11) iff all of the following are true:
+ * V is [un]assigned before every break statement that may exit the switch statement.
+ * For each switch labeled rule (14.11.1) in the switch block, V is [un]assigned after the
+ * expression, block, or throw statement of the switch labeled rule.
+ * If there is a switch labeled statement group (14.11.1) in the switch block, then V is [un]assigned
+ * after the last block statement of the last switch labeled statement group.
+ * If there is no default label in the switch block, or if the switch block ends with a switch label
+ * followed by }, then V is [un]assigned after the selector expression
*/
-public void testBug542707_030() {
- if (this.complianceLevel != ClassFileConstants.JDK12)
+public void testBug548318_030() {
+ if (this.complianceLevel != ClassFileConstants.JDK13)
return;
Map<String, String> defaultOptions = super.getCompilerOptions();
- defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_12);
- defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_12);
+ defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_13);
defaultOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
defaultOptions.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
String expectedProblemLog =
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JEP286Test.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JEP286Test.java
index 4d1d261c6b..466ee9ce15 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JEP286Test.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JEP286Test.java
@@ -69,7 +69,6 @@ static {
simpleTypeNames.put("ComparableAny", "Comparable<?>");
simpleTypeNames.put("CollectionExt_ComparableAny", "Collection<? extends Comparable<?>>");
simpleTypeNames.put("CollectionSuperComparableAny", "Collection<? super Comparable<?>>");
- isJRE12Plus = isJRELevel(F_12);
if (isJRE12Plus)
simpleTypeNames.put("IntLongFloat", "java.lang.Number & Comparable<?> & java.lang.constant.Constable & java.lang.constant.ConstantDesc");
else
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java
index 571e5f4400..6a62db3454 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java
@@ -10404,15 +10404,10 @@ public void testBug542707_001() {
},
options,
"----------\n" +
- "1. ERROR in X.java (at line 12)\n" +
- " x = null;\n" +
- " ^^^^\n" +
- "Null type mismatch: required \'@NonNull X\' but the provided value is null\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 15)\n" +
- " default -> null;\n" +
- " ^^^^\n" +
- "Null type mismatch: required \'@NonNull X\' but the provided value is null\n" +
+ "1. ERROR in X.java (at line 0)\n" +
+ " import java.io.IOException;\n" +
+ " ^\n" +
+ "Preview features enabled at an invalid source release level 12, preview can be enabled only at source level 13\n" +
"----------\n"
);
}
@@ -10450,10 +10445,10 @@ public void testBug542707_002() {
},
options,
"----------\n" +
- "1. ERROR in X.java (at line 13)\n" +
- " Zork();\n" +
- " ^^^^\n" +
- "The method Zork() is undefined for the type X\n" +
+ "1. ERROR in X.java (at line 0)\n" +
+ " import org.eclipse.jdt.annotation.*;\n" +
+ " ^\n" +
+ "Preview features enabled at an invalid source release level 12, preview can be enabled only at source level 13\n" +
"----------\n"
);
}
@@ -10479,12 +10474,18 @@ public void testBug542707_003() {
" }\n" +
"}\n"
};
- runner.expectedCompilerLog =
+ runner.expectedCompilerLog = this.complianceLevel == ClassFileConstants.JDK13 ?
"----------\n" +
"1. ERROR in X.java (at line 7)\n" +
" default -> i == 3 ? maybe() : \"\";\n" +
" ^^^^^^^\n" +
- "Null type mismatch (type annotations): required '@NonNull String' but this expression has type '@Nullable String'\n" +
+ "Null type mismatch (type annotations): required \'@NonNull String\' but this expression has type \'@Nullable String\'\n" +
+ "----------\n" :
+ "----------\n" +
+ "1. ERROR in X.java (at line 0)\n" +
+ " import org.eclipse.jdt.annotation.*;\n" +
+ " ^\n" +
+ "Preview features enabled at an invalid source release level 12, preview can be enabled only at source level 13\n" +
"----------\n";
runner.runNegativeTest();
}
@@ -10544,12 +10545,18 @@ public void testBug542707_005() {
" }\n" +
"}\n"
};
- runner.expectedCompilerLog =
+ runner.expectedCompilerLog = this.complianceLevel == ClassFileConstants.JDK13 ?
"----------\n" +
"1. ERROR in X.java (at line 5)\n" +
" return switch(day) {\n" +
" ^^^\n" +
"Potential null pointer access: this expression has a \'@Nullable\' type\n" +
+ "----------\n" :
+ "----------\n" +
+ "1. ERROR in X.java (at line 0)\n" +
+ " import org.eclipse.jdt.annotation.*;\n" +
+ " ^\n" +
+ "Preview features enabled at an invalid source release level 12, preview can be enabled only at source level 13\n" +
"----------\n";
runner.runNegativeTest();
}
@@ -10575,17 +10582,23 @@ public void testBug542707_006() {
" }\n" +
"}\n"
};
- runner.expectedCompilerLog =
+ runner.expectedCompilerLog = this.complianceLevel == ClassFileConstants.JDK13 ?
"----------\n" +
"2. ERROR in X.java (at line 5)\n" +
" return switch(day) {\n" +
" ^^^\n" +
"Potential null pointer access: The variable day may be null at this location\n" +
+ "----------\n" :
+ "----------\n" +
+ "1. ERROR in X.java (at line 0)\n" +
+ " enum SomeDays { Mon, Wed, Fri }\n" +
+ " ^\n" +
+ "Preview features enabled at an invalid source release level 12, preview can be enabled only at source level 13\n" +
"----------\n";
runner.runNegativeTest();
}
public void testBug545715() {
- if (this.complianceLevel < ClassFileConstants.JDK12) return; // switch expression
+ if (this.complianceLevel < ClassFileConstants.JDK13) return; // switch expression
Map<String, String> customOptions = getCompilerOptions();
customOptions.put(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
customOptions.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -10607,6 +10620,209 @@ public void testBug545715() {
customOptions,
new String[] {"--enable-preview"});
}
+public void testBug548418_001a() {
+ if (this.complianceLevel < ClassFileConstants.JDK13)
+ return;
+ Map options = getCompilerOptions();
+ options.put(JavaCore.COMPILER_PB_POTENTIAL_NULL_REFERENCE, JavaCore.ERROR);
+ options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_13);
+ options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_13);
+ options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_13);
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
+ runNegativeTestWithLibs(
+ new String[] {
+ "X.java",
+ "import java.io.IOException;\n"+
+ "\n"+
+ "import org.eclipse.jdt.annotation.NonNull;\n"+
+ "\n"+
+ "public class X {\n"+
+ " public static int foo(int i) throws IOException {\n"+
+ " int k = 0;\n"+
+ " @NonNull\n"+
+ " X x = new X();\n"+
+ " x = switch (i) { \n"+
+ " case 1 -> {\n"+
+ " x = null;\n"+
+ " break x;\n"+
+ " }\n"+
+ " default -> null;\n"+
+ " };\n"+
+ "\n"+
+ " return k ;\n"+
+ " }\n"+
+ "\n"+
+ " public static void main(String[] args) {\n"+
+ " try {\n"+
+ " System.out.println(foo(3));\n"+
+ " } catch (IOException e) {\n"+
+ " // do nothing\n"+
+ " }\n"+
+ " }\n"+
+ "}\n"
+ },
+ options,
+ "----------\n" +
+ "1. ERROR in X.java (at line 12)\n" +
+ " x = null;\n" +
+ " ^^^^\n" +
+ "Null type mismatch: required \'@NonNull X\' but the provided value is null\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 13)\n" +
+ " break x;\n" +
+ " ^^^^^^^^\n" +
+ "The label x is missing\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 15)\n" +
+ " default -> null;\n" +
+ " ^^^^\n" +
+ "Null type mismatch: required \'@NonNull X\' but the provided value is null\n" +
+ "----------\n"
+ );
+}
+public void testBug548418_001b() {
+ if (this.complianceLevel < ClassFileConstants.JDK13)
+ return;
+ Map options = getCompilerOptions();
+ options.put(JavaCore.COMPILER_PB_POTENTIAL_NULL_REFERENCE, JavaCore.ERROR);
+ options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_13);
+ options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_13);
+ options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_13);
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
+ runNegativeTestWithLibs(
+ new String[] {
+ "X.java",
+ "import java.io.IOException;\n"+
+ "\n"+
+ "import org.eclipse.jdt.annotation.NonNull;\n"+
+ "\n"+
+ "public class X {\n"+
+ " public static int foo(int i) throws IOException {\n"+
+ " int k = 0;\n"+
+ " @NonNull\n"+
+ " X x = new X();\n"+
+ " x = switch (i) { \n"+
+ " case 1 -> {\n"+
+ " x = null;\n"+
+ " yield x;\n"+
+ " }\n"+
+ " default -> null;\n"+
+ " };\n"+
+ "\n"+
+ " return k ;\n"+
+ " }\n"+
+ "\n"+
+ " public static void main(String[] args) {\n"+
+ " try {\n"+
+ " System.out.println(foo(3));\n"+
+ " } catch (IOException e) {\n"+
+ " // do nothing\n"+
+ " }\n"+
+ " }\n"+
+ "}\n"
+ },
+ options,
+ "----------\n" +
+ "1. ERROR in X.java (at line 12)\n" +
+ " x = null;\n" +
+ " ^^^^\n" +
+ "Null type mismatch: required \'@NonNull X\' but the provided value is null\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 15)\n" +
+ " default -> null;\n" +
+ " ^^^^\n" +
+ "Null type mismatch: required \'@NonNull X\' but the provided value is null\n" +
+ "----------\n"
+ );
+}
+public void testBug548418_002a() {
+ if (this.complianceLevel != ClassFileConstants.JDK13)
+ return;
+ Map options = getCompilerOptions();
+ options.put(JavaCore.COMPILER_PB_POTENTIAL_NULL_REFERENCE, JavaCore.ERROR);
+ options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_13);
+ options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_13);
+ options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_13);
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
+ runNegativeTestWithLibs(
+ new String[] {
+ "X.java",
+ "import org.eclipse.jdt.annotation.*;\n" +
+ "public class X {\n" +
+ " void m1(@NonNull String a) {}\n" +
+ " void m2(@Nullable String b, int i) {\n" +
+ " m1(switch(i) {\n" +
+ " case 0 : {\n" +
+ " break \"hello\";\n" +
+ " }\n" +
+ " default : break \"world\";\n" +
+ " });\n" +
+ " }\n" +
+ " void m3() {\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}\n"
+ },
+ options,
+ "----------\n" +
+ "1. ERROR in X.java (at line 7)\n" +
+ " break \"hello\";\n" +
+ " ^^^^^^^\n" +
+ "Syntax error on token \"\"hello\"\", delete this token\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 9)\n" +
+ " default : break \"world\";\n" +
+ " ^^^^^^^\n" +
+ "Syntax error on token \"\"world\"\", delete this token\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 13)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n"
+ );
+}
+public void testBug548418_002b() {
+ if (this.complianceLevel != ClassFileConstants.JDK13)
+ return;
+ Map options = getCompilerOptions();
+ options.put(JavaCore.COMPILER_PB_POTENTIAL_NULL_REFERENCE, JavaCore.ERROR);
+ options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_13);
+ options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_13);
+ options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_13);
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
+ runNegativeTestWithLibs(
+ new String[] {
+ "X.java",
+ "import org.eclipse.jdt.annotation.*;\n" +
+ "public class X {\n" +
+ " void m1(@NonNull String a) {}\n" +
+ " void m2(@Nullable String b, int i) {\n" +
+ " m1(switch(i) {\n" +
+ " case 0 : {\n" +
+ " yield \"hello\";\n" +
+ " }\n" +
+ " default : yield \"world\";\n" +
+ " });\n" +
+ " }\n" +
+ " void m3() {\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}\n"
+ },
+ options,
+ "----------\n" +
+ "1. ERROR in X.java (at line 13)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n"
+ );
+}
public void testBug499714() {
runConformTestWithLibs(
new String[] {
@@ -10639,8 +10855,7 @@ public void testBug499714() {
"",
},
getCompilerOptions(),
- ""
- );
+ "");
}
public void testBug481931_source() {
runNegativeTestWithLibs(
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ResourceLeakTests.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ResourceLeakTests.java
index 76b77b3bca..d79f1ee407 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ResourceLeakTests.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ResourceLeakTests.java
@@ -5497,7 +5497,7 @@ public void testBug541705b() {
runner.runConformTest();
}
public void testBug542707_001() {
- if (this.complianceLevel < ClassFileConstants.JDK12) return; // uses switch expression
+ if (this.complianceLevel < ClassFileConstants.JDK13) return; // uses switch expression
Map options = getCompilerOptions();
options.put(JavaCore.COMPILER_PB_UNCLOSED_CLOSEABLE, CompilerOptions.ERROR);
options.put(JavaCore.COMPILER_PB_POTENTIALLY_UNCLOSED_CLOSEABLE, CompilerOptions.ERROR);
@@ -5517,7 +5517,7 @@ public void testBug542707_001() {
" x = new X();\n"+
" x = switch (i) { \n"+
" case 1 -> {\n"+
- " break x;\n"+
+ " yield x;\n"+
" }\n"+
" default -> x;\n"+
" };\n"+
@@ -5549,7 +5549,7 @@ public void testBug542707_001() {
options);
}
public void testBug542707_002() {
- if (this.complianceLevel < ClassFileConstants.JDK12) return; // uses switch expression
+ if (this.complianceLevel < ClassFileConstants.JDK13) return; // uses switch expression
Map options = getCompilerOptions();
options.put(JavaCore.COMPILER_PB_UNCLOSED_CLOSEABLE, CompilerOptions.ERROR);
options.put(JavaCore.COMPILER_PB_POTENTIALLY_UNCLOSED_CLOSEABLE, CompilerOptions.ERROR);
@@ -5570,7 +5570,7 @@ public void testBug542707_002() {
" x = switch (i) { \n"+
" case 1 -> {\n"+
" x = new X();\n"+
- " break x;\n"+
+ " yield x;\n"+
" }\n"+
" default -> x;\n"+
" };\n"+
@@ -5607,7 +5607,7 @@ public void testBug542707_002() {
options);
}
public void testBug542707_003() {
- if (this.complianceLevel < ClassFileConstants.JDK12) return; // uses switch expression
+ if (this.complianceLevel < ClassFileConstants.JDK13) return; // uses switch expression
Map options = getCompilerOptions();
options.put(JavaCore.COMPILER_PB_UNCLOSED_CLOSEABLE, CompilerOptions.ERROR);
options.put(JavaCore.COMPILER_PB_POTENTIALLY_UNCLOSED_CLOSEABLE, CompilerOptions.ERROR);
@@ -5627,7 +5627,7 @@ public void testBug542707_003() {
" x = new X();\n"+
" x = switch (i) { \n"+
" case 1 -> {\n"+
- " break new X();\n"+
+ " yield new X();\n"+
" }\n"+
" default -> x;\n"+
" };\n"+
@@ -5654,7 +5654,7 @@ public void testBug542707_003() {
"1. ERROR in X.java (at line 10)\n" +
" x = switch (i) { \n" +
" case 1 -> {\n" +
- " break new X();\n" +
+ " yield new X();\n" +
" }\n" +
" default -> x;\n" +
" };\n" +
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ScannerTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ScannerTest.java
index 5959d4bff8..3f8bd30cc2 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ScannerTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ScannerTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -1475,4 +1475,70 @@ public class ScannerTest extends AbstractRegressionTest {
});
}
}
+ public void testBug531716_001_since_13() {
+ char[] source = ("class X {\n" +
+ " String s = \"\"\"This is the new String\"\"\";\n" +
+ "}").toCharArray();
+ Scanner scanner = new Scanner(false, false, false, ClassFileConstants.getLatestJDKLevel(), null, null, false);
+ scanner.setSource(source);
+ scanner.resetTo(0, source.length - 1);
+ try {
+ int token;
+ StringBuffer buffer = new StringBuffer();
+ while ((token = scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
+ try {
+ switch(token) {
+ case TerminalTokens.TokenNameTextBlock :
+ buffer.append( new String(scanner.getCurrentTextBlock()));
+ break;
+ case TerminalTokens.TokenNameStringLiteral :
+ break;
+ case TerminalTokens.TokenNameEOF :
+ break;
+ default :
+ break;
+ }
+ } catch (ArrayIndexOutOfBoundsException e) {
+ e.printStackTrace();
+ }
+ }
+ assertEquals("Wrong contents", "", String.valueOf(buffer));
+ } catch (InvalidInputException e) {
+ assertTrue(false);
+ }
+ }
+ public void testBug531716_001_since_13_1() {
+ char[] source = ("class X {\n" +
+ " String s = \"\"\"\nThis is the new String\"\"\";\n" +
+ "}").toCharArray();
+ Scanner scanner = new Scanner(false, false, false, ClassFileConstants.getLatestJDKLevel(), null, null, false);
+ scanner.previewEnabled = true;
+ scanner.setSource(source);
+ scanner.resetTo(0, source.length - 1);
+ try {
+ int token;
+ StringBuffer buffer = new StringBuffer();
+ while ((token = scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
+ try {
+ switch(token) {
+ case TerminalTokens.TokenNameTextBlock :
+ buffer.append( new String(scanner.getCurrentTextBlock()));
+ break;
+ case TerminalTokens.TokenNameStringLiteral :
+ break;
+ case TerminalTokens.TokenNameEOF :
+ break;
+ default :
+ break;
+ }
+ } catch (ArrayIndexOutOfBoundsException e) {
+ e.printStackTrace();
+ }
+ }
+ assertEquals("Wrong contents", "This is the new String", String.valueOf(buffer));
+ } catch (InvalidInputException e) {
+ assertTrue(false);
+ }
+ }
+
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionTest.java
index fc14e13d23..1fef2d022a 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionTest.java
@@ -14,7 +14,6 @@ package org.eclipse.jdt.core.tests.compiler.regression;
import java.util.Map;
-import org.eclipse.jdt.core.tests.compiler.regression.AbstractRegressionTest.JavacTestOptions.JavacHasABug;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
@@ -47,38 +46,18 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
defaultOptions.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
return defaultOptions;
}
-
+
@Override
- protected void runConformTest(String[] testFiles, String expectedOutput) {
- runConformTest(testFiles, expectedOutput, getCompilerOptions());
+ protected void runConformTest(String[] testFiles, Map<String, String> customOptions) {
+ super.runConformTest(testFiles, "", null, true, new String[] {"--enable-preview"}, customOptions, null);
}
@Override
- protected void runConformTest(String[] testFiles, String expectedOutput, Map customOptions) {
- Runner runner = new Runner();
- runner.testFiles = testFiles;
- runner.expectedOutputString = expectedOutput;
- runner.vmArguments = new String[] {"--enable-preview"};
- runner.customOptions = customOptions;
- runner.javacTestOptions = JavacTestOptions.forReleaseWithPreview("12");
- runner.runConformTest();
- }
- @Override
- protected void runNegativeTest(String[] testFiles, String expectedCompilerLog) {
- runNegativeTest(testFiles, expectedCompilerLog, JavacTestOptions.forReleaseWithPreview("12"));
- }
- protected void runWarningTest(String[] testFiles, String expectedCompilerLog, Map<String, String> customOptions) {
- Runner runner = new Runner();
- runner.testFiles = testFiles;
- runner.expectedCompilerLog = expectedCompilerLog;
- runner.customOptions = customOptions;
- runner.vmArguments = new String[] {"--enable-preview"};
- runner.javacTestOptions = JavacTestOptions.forReleaseWithPreview("12");
- runner.runWarningTest();
+ protected void runConformTest(String[] testFiles, String expectedOutput, Map<String, String> customOptions) {
+ super.runConformTest(testFiles, expectedOutput, null, true, new String[] {"--enable-preview"}, customOptions, null);
}
-
public void testSimpleExpressions() {
- runConformTest(
+ runNegativeTest(
new String[] {
"X.java",
"public class X {\n" +
@@ -95,10 +74,15 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
" }\n" +
"}\n"
},
- "3");
+ "----------\n" +
+ "1. ERROR in X.java (at line 0)\n" +
+ " public class X {\n" +
+ " ^\n" +
+ "Preview features enabled at an invalid source release level 12, preview can be enabled only at source level 13\n" +
+ "----------\n");
}
public void testSwitchExpression_531714_002() {
- runConformTest(
+ runNegativeTest(
new String[] {
"X.java",
"public class X {\n"+
@@ -127,9 +111,14 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
" }\n"+
"}\n"
},
- "Got Exception - expected");
+ "----------\n" +
+ "1. ERROR in X.java (at line 0)\n" +
+ " public class X {\n" +
+ " ^\n" +
+ "Preview features enabled at an invalid source release level 12, preview can be enabled only at source level 13\n" +
+ "----------\n");
}
- public void testBug531714_error_003() {
+ public void _testBug531714_error_003() {
this.runNegativeTest(
new String[] {
"X.java",
@@ -157,7 +146,7 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
"A switch expression should have a default case\n" +
"----------\n");
}
- public void testBug531714_error_004() {
+ public void _testBug531714_error_004() {
this.runNegativeTest(
new String[] {
"X.java",
@@ -180,13 +169,13 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
"}\n",
},
"----------\n" +
- "1. ERROR in X.java (at line 12)\n" +
- " case \"hello\" -> throw new java.io.IOException(\"hello\");\n" +
- " ^^^^^^^\n" +
- "Type mismatch: cannot convert from String to int\n" +
+ "1. ERROR in X.java (at line 10)\n" +
+ " break 1;\n" +
+ " ^\n" +
+ "Syntax error on token \"1\", delete this token\n" +
"----------\n");
}
- public void testBug531714_error_005() {
+ public void _testBug531714_error_005() {
this.runNegativeTest(
new String[] {
"X.java",
@@ -208,10 +197,10 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
"}\n",
},
"----------\n" +
- "1. ERROR in X.java (at line 6)\n" +
- " int tw = switch (i) {\n" +
- " ^\n" +
- "A switch expression should have a default case\n" +
+ "1. ERROR in X.java (at line 10)\n" +
+ " break 1;\n" +
+ " ^\n" +
+ "Syntax error on token \"1\", delete this token\n" +
"----------\n");
}
/**
@@ -221,7 +210,7 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
* must contain all the enum constants of that enum type
* Add a missing enum test case
*/
- public void _testBug531714_error_006() {
+ public void __testBug531714_error_006() {
this.runNegativeTest(
new String[] {
"X.java",
@@ -258,33 +247,43 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
* should compile - test for adding additional nesting in variables
* dev note: ref consumeToken().case Switch
*/
- public void testBug531714_error_007() {
- runConformTest(
- new String[] {
- "X.java",
- "public class X {\n"+
- " static int foo(int i) {\n"+
- " int tw = \n"+
- " switch (i) {\n"+
- " case 1 -> \n"+
- " {\n"+
- " int z = 100;\n"+
- " break z;\n"+
- " }\n"+
- " default -> {\n"+
- " break 12;\n"+
- " }\n"+
- " };\n"+
- " return tw;\n"+
- " }\n"+
- " public static void main(String[] args) {\n"+
- " System.out.print(foo(1));\n"+
- " }\n"+
- "}\n"
- },
- "100");
+ public void _testBug531714_error_007() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " static int foo(int i) {\n"+
+ " int tw = \n"+
+ " switch (i) {\n"+
+ " case 1 -> \n"+
+ " {\n"+
+ " int z = 100;\n"+
+ " break z;\n"+
+ " }\n"+
+ " default -> {\n"+
+ " break 12;\n"+
+ " }\n"+
+ " };\n"+
+ " return tw;\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.print(foo(1));\n"+
+ " }\n"+
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 10)\n" +
+ " default -> {\n" +
+ " ^^^^^^^\n" +
+ "The preview feature Case Labels with \'->\' is only available with source level 13 and above\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 11)\n" +
+ " break 12;\n" +
+ " ^^\n" +
+ "Syntax error on token \"12\", delete this token\n" +
+ "----------\n");
}
- public void testBug531714_008() {
+ public void _testBug531714_008() {
Map<String, String> disablePreviewOptions = getCompilerOptions();
disablePreviewOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
String[] testFiles = new String[] {
@@ -328,7 +327,7 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
"4. ERROR in X.java (at line 6)\n" +
" default -> 3;\n" +
" ^^^^^^^\n" +
- "Case Labels with '->' is a preview feature and disabled by default. Use --enable-preview to enable\n" +
+ "The preview feature Case Labels with \'->\' is only available with source level 13 and above\n" +
"----------\n";
this.runNegativeTest(
@@ -338,8 +337,8 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
true,
disablePreviewOptions);
}
- public void testBug543667_001() {
- runConformTest(
+ public void _testBug543667_001() {
+ runNegativeTest(
new String[] {
"X.java",
"public class X {\n" +
@@ -355,9 +354,14 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
" }\n" +
"}\n"
},
- "hello");
+ "----------\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " default -> System.out.println(\"DEFAULT\");\n" +
+ " ^^^^^^^\n" +
+ "The preview feature Case Labels with \'->\' is only available with source level 13 and above\n" +
+ "----------\n");
}
- public void testBug531714_009() {
+ public void _testBug531714_009() {
Map<String, String> disablePreviewOptions = getCompilerOptions();
disablePreviewOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
String[] testFiles = new String[] {
@@ -392,7 +396,7 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
"3. ERROR in X.java (at line 6)\n" +
" default -> 3;\n" +
" ^^^^^^^\n" +
- "Case Labels with \'->\' is a preview feature and disabled by default. Use --enable-preview to enable\n" +
+ "The preview feature Case Labels with \'->\' is only available with source level 13 and above\n" +
"----------\n";
this.runNegativeTest(
testFiles,
@@ -401,7 +405,7 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
true,
disablePreviewOptions);
}
- public void testBug531714_010() {
+ public void _testBug531714_010() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.ERROR);
@@ -425,7 +429,7 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
"1. ERROR in X.java (at line 4)\n" +
" default -> 3;\n" +
" ^^^^^^^\n" +
- "You are using a preview language feature that may or may not be supported in a future release\n" +
+ "The preview feature Case Labels with \'->\' is only available with source level 13 and above\n" +
"----------\n" +
"2. ERROR in X.java (at line 4)\n" +
" default -> 3;\n" +
@@ -439,7 +443,7 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
true,
options);
}
- public void testBug531714_011() {
+ public void _testBug531714_011() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.WARNING);
@@ -463,12 +467,20 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
"----------\n" +
"1. ERROR in X.java (at line 5)\n" +
" default -> 3;\n" +
+ " ^^^^^^^\n" +
+ "The preview feature Case Labels with \'->\' is only available with source level 13 and above\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 5)\n" +
+ " default -> 3;\n" +
" ^\n" +
"Invalid expression as statement\n" +
"----------\n";
this.runNegativeTest(
testFiles,
- expectedProblemLog);
+ expectedProblemLog,
+ null,
+ true,
+ getCompilerOptions());
}
public void testBug531714_012() {
Map<String, String> options = getCompilerOptions();
@@ -494,15 +506,10 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
String expectedProblemLog =
"----------\n" +
- "1. ERROR in X.java (at line 4)\n" +
- " default -> 3;\n" +
- " ^^^^^^^\n" +
- "The preview feature Case Labels with \'->\' is only available with source level 12 and above\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 4)\n" +
- " default -> 3;\n" +
- " ^\n" +
- "Invalid expression as statement\n" +
+ "1. ERROR in X.java (at line 0)\n" +
+ " public class X {\n" +
+ " ^\n" +
+ "Preview features enabled at an invalid source release level 11, preview can be enabled only at source level 13\n" +
"----------\n";
this.runNegativeTest(
testFiles,
@@ -514,7 +521,7 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
options.put(CompilerOptions.OPTION_Source, release);
}
}
- public void testBug531714_013() {
+ public void _testBug531714_013() {
String[] testFiles = new String[] {
"X.java",
"public class X {\n" +
@@ -540,10 +547,10 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
String expectedProblemLog =
"----------\n" +
- "1. ERROR in X.java (at line 8)\n" +
- " default :v = 2;\n" +
- " ^^^^^\n" +
- "A switch labeled block in a switch expression should not complete normally\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " break 0;\n" +
+ " ^\n" +
+ "Syntax error on token \"0\", delete this token\n" +
"----------\n";
this.runNegativeTest(
testFiles,
@@ -552,7 +559,7 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
true,
getCompilerOptions());
}
- public void testBug531714_014() {
+ public void _testBug531714_014() {
// switch expression is not a Primary
Runner runner = new Runner();
runner.customOptions = getCompilerOptions();
@@ -572,16 +579,20 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
};
runner.expectedCompilerLog =
"----------\n" +
- "1. ERROR in X.java (at line 6)\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " default -> null;\n" +
+ " ^^^^^^^\n" +
+ "The preview feature Case Labels with \'->\' is only available with source level 13 and above\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 6)\n" +
" }.toLowerCase());\n" +
" ^\n" +
"Syntax error on token \".\", , expected\n" +
"----------\n";
- runner.javacTestOptions = JavacTestOptions.forReleaseWithPreview("12");
runner.runNegativeTest();
}
- public void testBug543673_001() {
- runConformTest(
+ public void _testBug543673_001() {
+ runNegativeTest(
new String[] {
"X.java",
"public class X {\n" +
@@ -603,12 +614,17 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
" MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY;\n" +
"}\n"
},
- "6");
+ "----------\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " default -> 10;\n" +
+ " ^^^^^^^\n" +
+ "The preview feature Case Labels with \'->\' is only available with source level 13 and above\n" +
+ "----------\n");
}
/*
* A simple multi constant case statement, compiled and run as expected
*/
- public void testBug543240_1() {
+ public void _testBug543240_1() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -631,16 +647,24 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
"enum Day { SATURDAY, SUNDAY, MONDAY;}",
};
- String expectedOutput =
- "SUNDAY";
- this.runConformTest(
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " case SATURDAY, SUNDAY: \n" +
+ " ^^^^^^^^^^^^^^^^^^^^^\n" +
+ "The preview feature Multi constant case is only available with source level 13 and above\n" +
+ "----------\n";
+ this.runNegativeTest(
testFiles,
- expectedOutput);
+ expectedProblemLog,
+ null,
+ true,
+ options);
}
/*
* A simple multi constant case statement, compiler reports missing enum constants
*/
- public void testBug543240_1a() {
+ public void _testBug543240_1a() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -668,16 +692,24 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
" switch (day) {\n" +
" ^^^\n" +
"The enum constant TUESDAY needs a corresponding case label in this enum switch on Day\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 6)\n" +
+ " case SATURDAY, SUNDAY: \n" +
+ " ^^^^^^^^^^^^^^^^^^^^^\n" +
+ "The preview feature Multi constant case is only available with source level 13 and above\n" +
"----------\n";
- this.runWarningTest(
+ this.runNegativeTest(
testFiles,
expectedProblemLog,
+ null,
+ true,
+ new String[] { "--enable-preview"},
options);
}
/*
* A simple multi constant case statement with duplicate enums
*/
- public void testBug543240_2() {
+ public void _testBug543240_2() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -702,16 +734,21 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
String expectedProblemLog =
"----------\n" +
- "1. ERROR in X.java (at line 4)\n" +
- " case SATURDAY, SUNDAY: \n" +
- " ^^^^^^^^^^^^^^^^^^^^^\n" +
- "Duplicate case\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 7)\n" +
- " case SUNDAY : System.out.println(Day.SUNDAY);\n" +
- " ^^^^^^^^^^^\n" +
- "Duplicate case\n" +
- "----------\n";
+ "1. ERROR in X.java (at line 4)\n" +
+ " case SATURDAY, SUNDAY: \n" +
+ " ^^^^^^^^^^^^^^^^^^^^^\n" +
+ "The preview feature Multi constant case is only available with source level 13 and above\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " case SATURDAY, SUNDAY: \n" +
+ " ^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Duplicate case\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 7)\n" +
+ " case SUNDAY : System.out.println(Day.SUNDAY);\n" +
+ " ^^^^^^^^^^^\n" +
+ "Duplicate case\n" +
+ "----------\n";
this.runNegativeTest(
testFiles,
expectedProblemLog,
@@ -722,7 +759,7 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
/*
* A simple multi constant case statement with duplicate enums
*/
- public void testBug543240_2a() {
+ public void _testBug543240_2a() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -752,15 +789,25 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
"----------\n" +
"2. ERROR in X.java (at line 4)\n" +
" case SATURDAY, SUNDAY: \n" +
- " ^^^^^^^^^^^^^^^^^^^^^\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^\n" +
+ "The preview feature Multi constant case is only available with source level 13 and above\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 4)\n" +
+ " case SATURDAY, SUNDAY: \n" +
+ " ^^^^^^^^^^^^^^^^^^^^^\n" +
"Duplicate case\n" +
"----------\n" +
- "3. ERROR in X.java (at line 7)\n" +
+ "4. ERROR in X.java (at line 7)\n" +
+ " case SUNDAY, SATURDAY : \n" +
+ " ^^^^^^^^^^^^^^^^^^^^^\n" +
+ "The preview feature Multi constant case is only available with source level 13 and above\n" +
+ "----------\n" +
+ "5. ERROR in X.java (at line 7)\n" +
" case SUNDAY, SATURDAY : \n" +
" ^^^^^^^^^^^^^^^^^^^^^\n" +
"Duplicate case\n" +
"----------\n" +
- "4. ERROR in X.java (at line 7)\n" +
+ "6. ERROR in X.java (at line 7)\n" +
" case SUNDAY, SATURDAY : \n" +
" ^^^^^^^^^^^^^^^^^^^^^\n" +
"Duplicate case\n" +
@@ -775,7 +822,7 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
/*
*
*/
- public void testBug543240_3() {
+ public void _testBug543240_3() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -804,13 +851,21 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
" switch (day) {\n" +
" ^^^\n" +
"The enum constant MONDAY needs a corresponding case label in this enum switch on Day\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " case SATURDAY, SUNDAY: \n" +
+ " ^^^^^^^^^^^^^^^^^^^^^\n" +
+ "The preview feature Multi constant case is only available with source level 13 and above\n" +
"----------\n";
- this.runWarningTest(
+ this.runNegativeTest(
testFiles,
expectedProblemLog,
+ null,
+ true,
+ new String[] {"--enable-preview"},
options);
}
- public void testBug543240_4() {
+ public void _testBug543240_4() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -836,18 +891,23 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
};
String expectedProblemLog =
- "SATURDAY\n" +
- "0\n" +
- "SUNDAY";
- this.runConformTest(
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " case SATURDAY, SUNDAY: \n" +
+ " ^^^^^^^^^^^^^^^^^^^^^\n" +
+ "The preview feature Multi constant case is only available with source level 13 and above\n" +
+ "----------\n";
+ this.runNegativeTest(
testFiles,
expectedProblemLog,
+ null,
+ true,
options);
}
/*
* Simple switch case with string literals
*/
- public void testBug543240_5() {
+ public void _testBug543240_5() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -886,7 +946,7 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
options,
new String[] {"--enable-preview"});
}
- public void testBug543240_6() {
+ public void _testBug543240_6() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -914,20 +974,24 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
"}",
};
String expectedProblemLog =
- "A/B\n" +
- "A/B\n" +
- "C\n" +
- "NA";
- this.runConformTest(
+ "----------\n" +
+ "1. ERROR in X.java (at line 10)\n" +
+ " case \"a\", \"b\":\n" +
+ " ^^^^^^^^^^^^^\n" +
+ "The preview feature Multi constant case is only available with source level 13 and above\n" +
+ "----------\n";
+ this.runNegativeTest(
testFiles,
expectedProblemLog,
+ null,
+ true,
options);
}
/*
* Switch with multi constant case statements with string literals
* two string literals with same hashcode
*/
- public void testBug543240_7() {
+ public void _testBug543240_7() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -955,19 +1019,23 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
"}",
};
String expectedProblemLog =
- "A\n" +
- "B\n" +
- "A\n" +
- "NA";
- this.runConformTest(
+ "----------\n" +
+ "1. ERROR in X.java (at line 10)\n" +
+ " case \"FB\", \"c\":\n" +
+ " ^^^^^^^^^^^^^^\n" +
+ "The preview feature Multi constant case is only available with source level 13 and above\n" +
+ "----------\n";
+ this.runNegativeTest(
testFiles,
expectedProblemLog,
+ null,
+ true,
options);
}
/*
* Switch with multi constant case statements with integer constants
*/
- public void testBug543240_8() {
+ public void _testBug543240_8() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -996,20 +1064,28 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
"}",
};
String expectedProblemLog =
- "Odd\n" +
- "Even\n" +
- "Odd\n" +
- "Even\n" +
- "Out of range";
- this.runConformTest(
+ "----------\n" +
+ "1. ERROR in X.java (at line 11)\n" +
+ " case 1, 3: \n" +
+ " ^^^^^^^^^\n" +
+ "The preview feature Multi constant case is only available with source level 13 and above\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 14)\n" +
+ " case 2, 4: \n" +
+ " ^^^^^^^^^\n" +
+ "The preview feature Multi constant case is only available with source level 13 and above\n" +
+ "----------\n";
+ this.runNegativeTest(
testFiles,
expectedProblemLog,
+ null,
+ true,
options);
}
/*
* Switch multi-constant with mixed constant types, reported
*/
- public void testBug543240_9() {
+ public void _testBug543240_9() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -1034,7 +1110,12 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
};
String expectedProblemLog =
"----------\n" +
- "1. ERROR in X.java (at line 9)\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " case 1, 3: \n" +
+ " ^^^^^^^^^\n" +
+ "The preview feature Multi constant case is only available with source level 13 and above\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 9)\n" +
" case \"2\": \n" +
" ^^^\n" +
"Type mismatch: cannot convert from String to int\n" +
@@ -1049,7 +1130,7 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
/*
* Switch multi-constant without break statement, reported
*/
- public void testBug543240_10() {
+ public void _testBug543240_10() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -1074,20 +1155,27 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
};
String expectedProblemLog =
"----------\n" +
- "1. WARNING in X.java (at line 8)\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " case 1, 3: \n" +
+ " ^^^^^^^^^\n" +
+ "The preview feature Multi constant case is only available with source level 13 and above\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 8)\n" +
" case 2, 4: \n" +
" ^^^^^^^^^\n" +
- "Switch case may be entered by falling through previous case. If intended, add a new comment //$FALL-THROUGH$ on the line above\n" +
+ "The preview feature Multi constant case is only available with source level 13 and above\n" +
"----------\n";
- this.runWarningTest(
+ this.runNegativeTest(
testFiles,
expectedProblemLog,
+ null,
+ true,
options);
}
/*
* Switch multi-constant without break statement, reported
*/
- public void testBug543240_11() {
+ public void _testBug543240_11() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -1113,16 +1201,28 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
" switch (i) {\n" +
" ^\n" +
"The switch statement should have a default case\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 6)\n" +
+ " case 1, 3: \n" +
+ " ^^^^^^^^^\n" +
+ "The preview feature Multi constant case is only available with source level 13 and above\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 8)\n" +
+ " case 2, 4: \n" +
+ " ^^^^^^^^^\n" +
+ "The preview feature Multi constant case is only available with source level 13 and above\n" +
"----------\n";
- this.runWarningTest(
+ this.runNegativeTest(
testFiles,
expectedProblemLog,
+ null,
+ true,
options);
}
/*
* Switch multi-constant with duplicate int constants
*/
- public void testBug543240_12() {
+ public void _testBug543240_12() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -1146,9 +1246,19 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
"1. ERROR in X.java (at line 6)\n" +
" case 1, 3: \n" +
" ^^^^^^^^^\n" +
+ "The preview feature Multi constant case is only available with source level 13 and above\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 6)\n" +
+ " case 1, 3: \n" +
+ " ^^^^^^^^^\n" +
"Duplicate case\n" +
"----------\n" +
- "2. ERROR in X.java (at line 8)\n" +
+ "3. ERROR in X.java (at line 8)\n" +
+ " case 3, 4: \n" +
+ " ^^^^^^^^^\n" +
+ "The preview feature Multi constant case is only available with source level 13 and above\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 8)\n" +
" case 3, 4: \n" +
" ^^^^^^^^^\n" +
"Duplicate case\n" +
@@ -1163,7 +1273,7 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
/*
* Switch multi-constant with duplicate String literals
*/
- public void testBug543240_13() {
+ public void _testBug543240_13() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -1187,9 +1297,19 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
"1. ERROR in X.java (at line 6)\n" +
" case \"a\", \"b\": \n" +
" ^^^^^^^^^^^^^\n" +
+ "The preview feature Multi constant case is only available with source level 13 and above\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 6)\n" +
+ " case \"a\", \"b\": \n" +
+ " ^^^^^^^^^^^^^\n" +
"Duplicate case\n" +
"----------\n" +
- "2. ERROR in X.java (at line 8)\n" +
+ "3. ERROR in X.java (at line 8)\n" +
+ " case \"b\", \"c\": \n" +
+ " ^^^^^^^^^^^^^\n" +
+ "The preview feature Multi constant case is only available with source level 13 and above\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 8)\n" +
" case \"b\", \"c\": \n" +
" ^^^^^^^^^^^^^\n" +
"Duplicate case\n" +
@@ -1204,7 +1324,7 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
/*
* Switch multi-constant with illegal qualified enum constant
*/
- public void testBug543240_14() {
+ public void _testBug543240_14() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -1226,6 +1346,11 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
"----------\n" +
"1. ERROR in X.java (at line 6)\n" +
" case ONE, Num.TWO: \n" +
+ " ^^^^^^^^^^^^^^^^^\n" +
+ "The preview feature Multi constant case is only available with source level 13 and above\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 6)\n" +
+ " case ONE, Num.TWO: \n" +
" ^^^^^^^\n" +
"The qualified case label Num.TWO must be replaced with the unqualified enum constant TWO\n" +
"----------\n";
@@ -1236,7 +1361,7 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
true,
options);
}
- public void testBug543240_15() {
+ public void _testBug543240_15() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -1253,10 +1378,15 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
};
String expectedProblemLog =
"----------\n" +
- "1. ERROR in X.java (at line 5)\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " case 1, 2, 3 -> (s+1);\n" +
+ " ^^^^^^^^^^^^\n" +
+ "The preview feature Multi constant case is only available with source level 13 and above\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 5)\n" +
" default -> j;\n" +
- " ^\n" +
- "The local variable j may not have been initialized\n" +
+ " ^^^^^^^\n" +
+ "The preview feature Case Labels with \'->\' is only available with source level 13 and above\n" +
"----------\n";
this.runNegativeTest(
testFiles,
@@ -1265,7 +1395,7 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
true,
options);
}
- public void testBug543240_16() {
+ public void _testBug543240_16() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -1283,12 +1413,27 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
" }\n" +
"}\n",
};
- this.runConformTest(
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " case 1, 2, 3 -> (s+1);\n" +
+ " ^^^^^^^^^^^^\n" +
+ "The preview feature Multi constant case is only available with source level 13 and above\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 7)\n" +
+ " default -> j;\n" +
+ " ^^^^^^^\n" +
+ "The preview feature Case Labels with \'->\' is only available with source level 13 and above\n" +
+ "----------\n";
+ this.runNegativeTest(
testFiles,
- "",
+ expectedProblemLog,
+ null,
+ true,
+ new String[] { "--enable-preview"},
options);
}
- public void testBug543795_01() {
+ public void _testBug543795_01() {
this.runNegativeTest(
new String[] {
"X.java",
@@ -1322,13 +1467,18 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
"}\n",
},
"----------\n" +
- "1. ERROR in X.java (at line 10)\n" +
- " break;\n" +
- " ^^^^^^\n" +
- "Break of a switch expression should have a value\n" +
+ "1. ERROR in X.java (at line 7)\n" +
+ " break 0;\n" +
+ " ^\n" +
+ "Syntax error on token \"0\", delete this token\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 12)\n" +
+ " default : break 10;\n" +
+ " ^^\n" +
+ "Syntax error on token \"10\", delete this token\n" +
"----------\n");
}
- public void testBug543691() {
+ public void _testBug543691() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -1359,7 +1509,7 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
true,
options);
}
- public void testBug543799_1() {
+ public void _testBug543799_1() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -1380,10 +1530,16 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
" }\n" +
"}\n"
};
- String expectedOutput = "hello world";
- runConformTest(testFiles, expectedOutput, options);
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " default -> i == 3 ? null : \"\";\n" +
+ " ^^^^^^^\n" +
+ "The preview feature Case Labels with \'->\' is only available with source level 13 and above\n" +
+ "----------\n";
+ runNegativeTest(testFiles, expectedProblemLog, null, true, options);
}
- public void testBug543799_2() {
+ public void _testBug543799_2() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -1404,10 +1560,21 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
" }\n" +
"}\n"
};
- String expectedOutput = "hello world";
- runConformTest(testFiles, expectedOutput, options);
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " case 1: break \"\";\n" +
+ " ^^\n" +
+ "Syntax error on token \"\"\"\", delete this token\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 5)\n" +
+ " default: break i == 3 ? null : \"\";\n" +
+ " ^^^^^\n" +
+ "Syntax error on token \"break\", yield expected\n" +
+ "----------\n";
+ runNegativeTest(testFiles, expectedProblemLog, null, true, options);
}
- public void testBug543799_3() {
+ public void _testBug543799_3() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -1435,10 +1602,16 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
" }\n" +
"}\n"
};
- String expectedOutput = "NPE as expected";
- runConformTest(testFiles, expectedOutput, options);
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 11)\n" +
+ " default -> b ? n1() : n2();\n" +
+ " ^^^^^^^\n" +
+ "The preview feature Case Labels with \'->\' is only available with source level 13 and above\n" +
+ "----------\n";
+ runNegativeTest(testFiles, expectedProblemLog, null, true, options);
}
- public void testBug543799_4() {
+ public void _testBug543799_4() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -1467,10 +1640,16 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
" }\n" +
"}\n"
};
- String expectedOutput = "NPE as expected";
- runConformTest(testFiles, expectedOutput, options);
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 12)\n" +
+ " default -> this::n2;\n" +
+ " ^^^^^^^\n" +
+ "The preview feature Case Labels with \'->\' is only available with source level 13 and above\n" +
+ "----------\n";
+ runNegativeTest(testFiles, expectedProblemLog, null, true, options);
}
- public void testBug543799_5() {
+ public void _testBug543799_5() {
// require resolving/inferring of poly-switch-expression during ASTNode.resolvePolyExpressionArguments()
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
@@ -1492,11 +1671,17 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
" }\n" +
"}\n"
};
- String expectedOutput = "3";
- runConformTest(testFiles, expectedOutput, options);
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " default -> i == 3 ? 3 : 5.0d;\n" +
+ " ^^^^^^^\n" +
+ "The preview feature Case Labels with \'->\' is only available with source level 13 and above\n" +
+ "----------\n";
+ runNegativeTest(testFiles, expectedProblemLog, null, true, options);
}
- public void testSwitchStatementWithBreakExpression() {
- runConformTest(
+ public void _testSwitchStatementWithBreakExpression() {
+ runNegativeTest(
new String[] {
"X.java",
"public class X {\n" +
@@ -1523,10 +1708,14 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
" }\n" +
"}"
},
- "inside foo\n"
- + "0");
+ "----------\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " default -> throw new Exception();\n" +
+ " ^^^^^^^\n" +
+ "The preview feature Case Labels with \'->\' is only available with source level 13 and above\n" +
+ "----------\n");
}
- public void testSwitchStatementWithEnumValues() {
+ public void _testSwitchStatementWithEnumValues() {
runConformTest(
new String[] {
"X.java",
@@ -1550,9 +1739,11 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
"}\n" +
""
},
- "1");
+ "1",
+ null,
+ new String[] {"--enable-preview"});
}
- public void testBug543967_01() {
+ public void _testBug543967_01() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
String[] testFiles = new String[] {
@@ -1574,6 +1765,11 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
"----------\n" +
"1. ERROR in X.java (at line 4)\n" +
" default -> 3; // should flag an error\n" +
+ " ^^^^^^^\n" +
+ "The preview feature Case Labels with \'->\' is only available with source level 13 and above\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " default -> 3; // should flag an error\n" +
" ^\n" +
"Invalid expression as statement\n" +
"----------\n";
@@ -1585,8 +1781,8 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
new String[] { "--enable-preview"},
options);
}
- public void testBug544204() {
- runConformTest(
+ public void _testBug544204() {
+ runNegativeTest(
new String[] {
"X.java",
"public class X {\n" +
@@ -1603,10 +1799,15 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
" }\n" +
"}"
},
- "1");
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " default -> i;\n" +
+ " ^^^^^^^\n" +
+ "The preview feature Case Labels with \'->\' is only available with source level 13 and above\n" +
+ "----------\n");
}
- public void testBug544204_2() {
- runConformTest(
+ public void _testBug544204_2() {
+ runNegativeTest(
new String[] {
"X.java",
"public class X {\n" +
@@ -1623,10 +1824,15 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
" }\n" +
"}"
},
- "10");
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " default -> 20L;\n" +
+ " ^^^^^^^\n" +
+ "The preview feature Case Labels with \'->\' is only available with source level 13 and above\n" +
+ "----------\n");
}
- public void testBug544223() {
- runConformTest(
+ public void _testBug544223() {
+ runNegativeTest(
new String[] {
"X.java",
"public class X {\n" +
@@ -1647,9 +1853,14 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
" }\n" +
"}"
},
- "1");
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " default -> throw new Exception();\n" +
+ " ^^^^^^^\n" +
+ "The preview feature Case Labels with \'->\' is only available with source level 13 and above\n" +
+ "----------\n");
}
- public void testBug544258_01() {
+ public void _testBug544258_01() {
this.runNegativeTest(
new String[] {
"X.java",
@@ -1683,12 +1894,34 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
"----------\n" +
"1. ERROR in X.java (at line 4)\n" +
" today = switch (day) {\n" +
+ " case SATURDAY,SUNDAY :\n" +
+ " today=1;\n" +
+ " break today;\n" +
+ " case MONDAY,TUESDAY,WEDNESDAY,THURSDAY :\n" +
+ " today=2;\n" +
+ " break today;\n" +
+ " };\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "A switch expression should have at least one result expression\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " today = switch (day) {\n" +
" ^^^\n" +
"A Switch expression should cover all possible values\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 5)\n" +
+ " case SATURDAY,SUNDAY :\n" +
+ " ^^^^^^^^^^^^^^^^^^^^\n" +
+ "The preview feature Multi constant case is only available with source level 13 and above\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 8)\n" +
+ " case MONDAY,TUESDAY,WEDNESDAY,THURSDAY :\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "The preview feature Multi constant case is only available with source level 13 and above\n" +
"----------\n");
}
- public void testBug544253() {
- runConformTest(
+ public void _testBug544253() {
+ runNegativeTest(
new String[] {
"X.java",
"public class X {\n" +
@@ -1704,10 +1937,15 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
" }\n" +
"}"
},
- "false");
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " default -> true;\n" +
+ " ^^^^^^^\n" +
+ "The preview feature Case Labels with \'->\' is only available with source level 13 and above\n" +
+ "----------\n");
}
- public void testBug544254() {
- runConformTest(
+ public void _testBug544254() {
+ runNegativeTest(
new String[] {
"X.java",
"public class X {\n" +
@@ -1726,12 +1964,17 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
" }\n" +
"}"
},
- "hello");
+ "----------\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " default -> 2;\n" +
+ " ^^^^^^^\n" +
+ "The preview feature Case Labels with \'->\' is only available with source level 13 and above\n" +
+ "----------\n");
}
- public void testBug544254_2() {
+ public void _testBug544254_2() {
Map<String, String> customOptions = getCompilerOptions();
customOptions.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.OPTIMIZE_OUT);
- runConformTest(
+ runNegativeTest(
new String[] {
"X.java",
"public class X {\n" +
@@ -1750,12 +1993,17 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
" }\n" +
"}"
},
- "hello");
+ "----------\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " default -> 2;\n" +
+ " ^^^^^^^\n" +
+ "The preview feature Case Labels with \'->\' is only available with source level 13 and above\n" +
+ "----------\n");
}
- public void testBug544254_3() {
+ public void _testBug544254_3() {
Map<String, String> customOptions = getCompilerOptions();
customOptions.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.OPTIMIZE_OUT);
- runConformTest(
+ runNegativeTest(
new String[] {
"X.java",
"public class X {\n" +
@@ -1774,12 +2022,17 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
" }\n" +
"}"
},
- "hello");
+ "----------\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " default -> 2;\n" +
+ " ^^^^^^^\n" +
+ "The preview feature Case Labels with \'->\' is only available with source level 13 and above\n" +
+ "----------\n");
}
- public void testBug544224_1() {
+ public void _testBug544224_1() {
Map<String, String> customOptions = getCompilerOptions();
customOptions.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.OPTIMIZE_OUT);
- runConformTest(
+ runNegativeTest(
new String[] {
"X.java",
"public class X {\n" +
@@ -1795,11 +2048,15 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
" }\n" +
"}\n"
},
- "",
- customOptions);
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " default -> 2;\n" +
+ " ^^^^^^^\n" +
+ "The preview feature Case Labels with \'->\' is only available with source level 13 and above\n" +
+ "----------\n");
}
- public void testBug544298() {
- runConformTest(
+ public void _testBug544298() {
+ runNegativeTest(
new String[] {
"X.java",
"public class X {\n" +
@@ -1819,10 +2076,12 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
" }\n" +
"}"
},
- "i:1");
+ "----------\n" +
+ "1. ERROR in X.java (at line 7)\n" +
+ "----------\n");
}
- public void testBug544298_2() {
- runConformTest(
+ public void _testBug544298_2() {
+ runNegativeTest(
new String[] {
"X.java",
"public class X {\n" +
@@ -1843,9 +2102,14 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
" }\n" +
"}"
},
- "i:1");
+ "----------\n" +
+ "1. ERROR in X.java (at line 9)\n" +
+ " default -> 0;\n" +
+ " ^^^^^^^\n" +
+ "The preview feature Case Labels with \'->\' is only available with source level 13 and above\n" +
+ "----------\n");
}
- public void testBug544428_01() {
+ public void _testBug544428_01() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -1870,6 +2134,11 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
" case 0 -> x;\n" +
" ^\n" +
"x cannot be resolved to a variable\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 5)\n" +
+ " default -> 1;\n" +
+ " ^^^^^^^\n" +
+ "The preview feature Case Labels with \'->\' is only available with source level 13 and above\n" +
"----------\n";
this.runNegativeTest(
testFiles,
@@ -1879,8 +2148,8 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
new String[] { "--enable-preview"},
options);
}
- public void testBug544523_01() {
- runConformTest(
+ public void _testBug544523_01() {
+ runNegativeTest(
new String[] {
"X.java",
"public class X {\n" +
@@ -1900,10 +2169,20 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
" }\n" +
"}"
},
- "0");
+ "----------\n" +
+ "1. ERROR in X.java (at line 7)\n" +
+ " default -> 1;\n" +
+ " ^^^^^^^\n" +
+ "The preview feature Case Labels with \'->\' is only available with source level 13 and above\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 9)\n" +
+ " default -> 1;\n" +
+ " ^^^^^^^\n" +
+ "The preview feature Case Labels with \'->\' is only available with source level 13 and above\n" +
+ "----------\n");
}
- public void testBug544560_01() {
- runConformTest(
+ public void _testBug544560_01() {
+ runNegativeTest(
new String[] {
"X.java",
"public class X {\n" +
@@ -1922,10 +2201,20 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
" }\n" +
"}\n"
},
- "1");
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " default -> 1;\n" +
+ " ^^^^^^^\n" +
+ "The preview feature Case Labels with \'->\' is only available with source level 13 and above\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 7)\n" +
+ " default -> 1;\n" +
+ " ^^^^^^^\n" +
+ "The preview feature Case Labels with \'->\' is only available with source level 13 and above\n" +
+ "----------\n");
}
- public void testBug544458() {
- runConformTest(
+ public void _testBug544458() {
+ runNegativeTest(
new String[] {
"X.java",
"public class X {\n" +
@@ -1941,10 +2230,20 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
" }\n" +
"}"
},
- "1");
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " case 1: i = 10; break true;\n" +
+ " ^^^^\n" +
+ "Syntax error on token \"true\", delete this token\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 5)\n" +
+ " default: break false;\n" +
+ " ^^^^^\n" +
+ "Syntax error on token \"false\", delete this token\n" +
+ "----------\n");
}
- public void testBug544458_2() {
- runConformTest(
+ public void _testBug544458_2() {
+ runNegativeTest(
new String[] {
"X.java",
"public class X {\n" +
@@ -1960,10 +2259,20 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
" }\n" +
"}"
},
- "0");
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " case 1: i++; break true;\n" +
+ " ^^^^\n" +
+ "Syntax error on token \"true\", delete this token\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 5)\n" +
+ " default: break false;\n" +
+ " ^^^^^\n" +
+ "Syntax error on token \"false\", delete this token\n" +
+ "----------\n");
}
- public void testBug544458_3() {
- runConformTest(
+ public void _testBug544458_3() {
+ runNegativeTest(
new String[] {
"X.java",
"public class X {\n" +
@@ -1979,10 +2288,20 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
" }\n" +
"}"
},
- "0");
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " case 1: i+= 10; break true;\n" +
+ " ^^^^\n" +
+ "Syntax error on token \"true\", delete this token\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 5)\n" +
+ " default: break false;\n" +
+ " ^^^^^\n" +
+ "Syntax error on token \"false\", delete this token\n" +
+ "----------\n");
}
- public void testBug544458_4() {
- runConformTest(
+ public void _testBug544458_4() {
+ runNegativeTest(
new String[] {
"X.java",
"public class X {\n" +
@@ -1998,10 +2317,20 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
" }\n" +
"}"
},
- "0");
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " case 1: switch(i) {case 4: break;}; break true;\n" +
+ " ^^^^\n" +
+ "Syntax error on token \"true\", delete this token\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 5)\n" +
+ " default: break false;\n" +
+ " ^^^^^\n" +
+ "Syntax error on token \"false\", delete this token\n" +
+ "----------\n");
}
- public void testBug544458_5() {
- runConformTest(
+ public void _testBug544458_5() {
+ runNegativeTest(
new String[] {
"X.java",
"public class X {\n" +
@@ -2017,10 +2346,20 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
" }\n" +
"}"
},
- "0");
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " case 1: foo(5); break true;\n" +
+ " ^^^^\n" +
+ "Syntax error on token \"true\", delete this token\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 5)\n" +
+ " default: break false;\n" +
+ " ^^^^^\n" +
+ "Syntax error on token \"false\", delete this token\n" +
+ "----------\n");
}
- public void testBug544601_1() {
- runConformTest(
+ public void _testBug544601_1() {
+ runNegativeTest(
new String[] {
"X.java",
"public class X {\n" +
@@ -2046,10 +2385,20 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
" }\n" +
"}\n"
},
- "1");
+ "----------\n" +
+ "1. ERROR in X.java (at line 13)\n" +
+ " break true;\n" +
+ " ^^^^\n" +
+ "Syntax error on token \"true\", delete this token\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 14)\n" +
+ " default: break false;\n" +
+ " ^^^^^\n" +
+ "Syntax error on token \"false\", delete this token\n" +
+ "----------\n");
}
- public void testBug544556() {
- runConformTest(
+ public void _testBug544556() {
+ runNegativeTest(
new String[] {
"X.java",
"public class X {\n" +
@@ -2070,10 +2419,30 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
" }\n" +
"}"
},
- "1");
- }
- public void testBug544702_01() {
- runConformTest(
+ "----------\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " case 0 -> { break 2; }\n" +
+ " ^\n" +
+ "Syntax error on token \"2\", delete this token\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 7)\n" +
+ " default -> { break 3; }\n" +
+ " ^\n" +
+ "Syntax error on token \"3\", delete this token\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 9)\n" +
+ " case 0 -> { break 0; }\n" +
+ " ^\n" +
+ "Syntax error on token \"0\", delete this token\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 10)\n" +
+ " default -> { break 1; }\n" +
+ " ^\n" +
+ "Syntax error on token \"1\", delete this token\n" +
+ "----------\n");
+ }
+ public void _testBug544702_01() {
+ runNegativeTest(
new String[] {
"X.java",
"public class X {\n" +
@@ -2092,10 +2461,15 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
"\n" +
"}\n"
},
- "Success");
- }
- public void testBug545168_01() {
- runConformTest(
+ "----------\n" +
+ "1. ERROR in X.java (at line 7)\n" +
+ " default -> k = -1;\n" +
+ " ^^^^^^^\n" +
+ "The preview feature Case Labels with \'->\' is only available with source level 13 and above\n" +
+ "----------\n");
+ }
+ public void _testBug545168_01() {
+ runNegativeTest(
new String[] {
"X.java",
"public class X {\n" +
@@ -2118,10 +2492,25 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
" MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY;\n" +
"}\n"
},
- "9");
- }
- public void testBug545255_01() {
- runConformTest(
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " case MONDAY, FRIDAY -> System.out.println(Day.SUNDAY);\n" +
+ " ^^^^^^^^^^^^^^^^^^^\n" +
+ "The preview feature Multi constant case is only available with source level 13 and above\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 7)\n" +
+ " case THURSDAY, SATURDAY -> System.out.println(8);\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "The preview feature Multi constant case is only available with source level 13 and above\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 9)\n" +
+ " default -> {}\n" +
+ " ^^^^^^^\n" +
+ "The preview feature Case Labels with \'->\' is only available with source level 13 and above\n" +
+ "----------\n");
+ }
+ public void _testBug545255_01() {
+ runNegativeTest(
new String[] {
"X.java",
"public class X {\n"+
@@ -2140,12 +2529,42 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
" }\n"+
"}\n"
},
- "0");
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " case 60, 600: break 6;\n" +
+ " ^^^^^^^^^^^^\n" +
+ "The preview feature Multi constant case is only available with source level 13 and above\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " case 60, 600: break 6;\n" +
+ " ^\n" +
+ "Syntax error on token \"6\", delete this token\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 5)\n" +
+ " case 70: break 7;\n" +
+ " ^\n" +
+ "Syntax error on token \"7\", delete this token\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 6)\n" +
+ " case 80: break 8;\n" +
+ " ^\n" +
+ "Syntax error on token \"8\", delete this token\n" +
+ "----------\n" +
+ "5. ERROR in X.java (at line 7)\n" +
+ " case 90, 900: break 9;\n" +
+ " ^\n" +
+ "Syntax error on token \"9\", delete this token\n" +
+ "----------\n" +
+ "6. ERROR in X.java (at line 8)\n" +
+ " default: break 0;\n" +
+ " ^\n" +
+ "Syntax error on token \"0\", delete this token\n" +
+ "----------\n");
}
// see comment 12 in the bug
- public void testBug513766_01() {
- Runner runner = new Runner();
- runner.testFiles = new String[] {
+ public void _testBug513766_01() {
+ this.runNegativeTest(
+ new String[] {
"X.java",
"public class X {\n"+
" @SuppressWarnings(\"preview\")\n"+
@@ -2156,26 +2575,28 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
" System.out.println(\"true, too\");\n"+
" }\n"+
" <T> T magic() { return null; }\n"+
- "}\n"};
- runner.expectedCompilerLog =
+ "}\n",
+ },
"----------\n" +
"1. ERROR in X.java (at line 4)\n" +
" if (switch(i) { default -> magic(); })\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Type mismatch: cannot convert from Object to boolean\n" +
"----------\n" +
- "2. ERROR in X.java (at line 6)\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " if (switch(i) { default -> magic(); })\n" +
+ " ^^^^^^^\n" +
+ "The preview feature Case Labels with \'->\' is only available with source level 13 and above\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 6)\n" +
" if (magic())\n" +
" ^^^^^^^\n" +
"Type mismatch: cannot convert from Object to boolean\n" +
- "----------\n";
- runner.vmArguments = new String[] {"--enable-preview"};
- runner.javacTestOptions = JavacHasABug.JavacBug8179483_switchExpression;
- runner.runNegativeTest();
+ "----------\n");
}
- public void testBug545333() {
- Runner runner = new Runner();
- runner.testFiles = new String[] {
+ public void _testBug545333() {
+ runNegativeTest(
+ new String[] {
"X.java",
"public class X {\n"+
" @SuppressWarnings(\"preview\")\n"+
@@ -2196,8 +2617,7 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
"class MyException extends Exception {\n"+
" private static final long serialVersionUID = 3461899582505930473L; \n"+
"}\n"
- };
- runner.expectedCompilerLog =
+ },
"----------\n" +
"1. ERROR in X.java (at line 4)\n" +
" int v = switch (i) {\n" +
@@ -2205,12 +2625,14 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
" };\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"A switch expression should have at least one result expression\n" +
- "----------\n";
- runner.vmArguments = new String[] {"--enable-preview"};
- runner.javacTestOptions = JavacHasABug.JavacBug8226510_switchExpression;
- runner.runNegativeTest();
+ "----------\n" +
+ "2. ERROR in X.java (at line 5)\n" +
+ " default -> throw new MyException();\n" +
+ " ^^^^^^^\n" +
+ "The preview feature Case Labels with \'->\' is only available with source level 13 and above\n" +
+ "----------\n");
}
- public void testBug545518() {
+ public void _testBug545518() {
if (this.complianceLevel < ClassFileConstants.JDK12)
return;
Map<String, String> options = getCompilerOptions();
@@ -2218,18 +2640,13 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.WARNING);
String message =
"----------\n" +
- "1. WARNING in X.java (at line 5)\n" +
+ "1. ERROR in X.java (at line 5)\n" +
" case \"ABC\", (false ? (String) \"c\" : (String) \"d\") : break;\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
- "You are using a preview language feature that may or may not be supported in a future release\n" +
- "----------\n" +
- "2. WARNING in X.java (at line 5)\n" +
- " case \"ABC\", (false ? (String) \"c\" : (String) \"d\") : break;\n" +
- " ^^^^^^^^^^^^\n" +
- "Dead code\n" +
+ "The preview feature Multi constant case is only available with source level 13 and above\n" +
"----------\n";
- this.runWarningTest(new String[] {
+ this.runNegativeTest(new String[] {
"X.java",
"public class X {\n" +
" public static void main(String [] args) {\n" +
@@ -2241,9 +2658,12 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
"}\n"
},
message,
+ null,
+ true,
+ new String[] { "--enable-preview"},
options);
}
- public void testBug545518a() {
+ public void _testBug545518a() {
if (this.complianceLevel < ClassFileConstants.JDK12)
return;
Map<String, String> options = getCompilerOptions();
@@ -2251,13 +2671,13 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
String message =
"----------\n" +
- "1. WARNING in X.java (at line 5)\n" +
+ "1. ERROR in X.java (at line 5)\n" +
" case \"ABC\", (false ? (String) \"c\" : (String) \"d\") : break;\n" +
- " ^^^^^^^^^^^^\n" +
- "Dead code\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "The preview feature Multi constant case is only available with source level 13 and above\n" +
"----------\n";
- this.runWarningTest(new String[] {
+ this.runNegativeTest(new String[] {
"X.java",
"public class X {\n" +
" public static void main(String [] args) {\n" +
@@ -2269,9 +2689,12 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
"}\n"
},
message,
+ null,
+ true,
+ new String[] { "--enable-preview"},
options);
}
- public void testBug545518b() {
+ public void _testBug545518b() {
if (this.complianceLevel < ClassFileConstants.JDK1_8)
return;
Map<String, String> options = getCompilerOptions();
@@ -2282,7 +2705,7 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
"1. ERROR in X.java (at line 5)\n" +
" case \"ABC\", (false ? (String) \"c\" : (String) \"d\") : break;\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
- "Multi constant case is a preview feature and disabled by default. Use --enable-preview to enable\n" +
+ "The preview feature Multi constant case is only available with source level 13 and above\n" +
"----------\n";
this.runNegativeTest(new String[] {
@@ -2302,8 +2725,8 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
new String[] { "--enable-preview"},
options);
}
- public void testBug545715_01() {
- runConformTest(
+ public void _testBug545715_01() {
+ runNegativeTest(
new String[] {
"X.java",
"enum X {\n"+
@@ -2321,33 +2744,40 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
" }\n"+
"}\n"
},
- "5");
- }
- public void testBug545716_01() {
- Runner runner = new Runner();
- runner.testFiles = new String[] {
- "X.java",
- "enum X {\n"+
- " A, B;\n"+
- " \n"+
- " @SuppressWarnings(\"preview\")\n"+
- " public static void main(String[] args) {\n"+
- " X myEnum = X.A;\n"+
- " int o;\n"+
- " var f = switch(myEnum) {\n"+
- " case A -> o = 5;\n"+
- " case B -> o = 10;\n"+
- " };\n"+
- " System.out.println(o);\n"+
- " }\n"+
- "} \n"
- };
- runner.expectedOutputString = "5";
- runner.vmArguments = new String[] {"--enable-preview"};
- runner.javacTestOptions = JavacHasABug.JavacBug8221413_switchExpression;
- runner.runConformTest();
- }
- public void testBug545983_01() {
+ "----------\n" +
+ "1. ERROR in X.java (at line 10)\n" +
+ " default -> o = 0;\n" +
+ " ^^^^^^^\n" +
+ "The preview feature Case Labels with \'->\' is only available with source level 13 and above\n" +
+ "----------\n");
+ }
+ public void _testBug545916_01() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "enum X {\n"+
+ " A, B;\n"+
+ " \n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public static void main(String[] args) {\n"+
+ " X myEnum = X.A;\n"+
+ " int o;\n"+
+ " var f = switch(myEnum) {\n"+
+ " case A -> o = 5;\n"+
+ " case B -> o = 10;\n"+
+ " };\n"+
+ " System.out.println(o);\n"+
+ " }\n"+
+ "} \n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 10)\n" +
+ " default -> o = 0;\n" +
+ " ^^^^^^^\n" +
+ "The preview feature Case Labels with \'->\' is only available with source level 13 and above\n" +
+ "----------\n");
+ }
+ public void _testBug545983_01() {
this.runNegativeTest(
new String[] {
"X.java",
@@ -2373,13 +2803,13 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
"}\n",
},
"----------\n" +
- "1. ERROR in X.java (at line 11)\n" +
- " continue;\n" +
- " ^^^^^^^^^\n" +
- "'continue' or 'return' cannot be the last statement in a Switch expression case body\n" +
+ "1. ERROR in X.java (at line 9)\n" +
+ " break 1;\n" +
+ " ^\n" +
+ "Syntax error on token \"1\", delete this token\n" +
"----------\n");
}
- public void testBug545983_02() {
+ public void _testBug545983_02() {
this.runNegativeTest(
new String[] {
"X.java",
@@ -2405,13 +2835,13 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
"}\n",
},
"----------\n" +
- "1. ERROR in X.java (at line 11)\n" +
- " return 2;\n" +
- " ^^^^^^^^^\n" +
- "'continue' or 'return' cannot be the last statement in a Switch expression case body\n" +
+ "1. ERROR in X.java (at line 9)\n" +
+ " break 1;\n" +
+ " ^\n" +
+ "Syntax error on token \"1\", delete this token\n" +
"----------\n");
}
- public void testBug547125_01() {
+ public void _testBug547125_01() {
this.runNegativeTest(
new String[] {
"X.java",
@@ -2435,10 +2865,16 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
"1. ERROR in X.java (at line 4)\n" +
" case SATURDAY, SUNDAY, SUNDAY:\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "The preview feature Multi constant case is only available with source level 13 and above\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " case SATURDAY, SUNDAY, SUNDAY:\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Duplicate case\n" +
+ " ^^^^^^^\n" +
"----------\n");
}
- public void testBug547125_02() {
+ public void _testBug547125_02() {
this.runNegativeTest(
new String[] {
"X.java",
@@ -2462,114 +2898,27 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
"1. ERROR in X.java (at line 4)\n" +
" case SATURDAY, SUNDAY, MONDAY:\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "The preview feature Multi constant case is only available with source level 13 and above\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " case SATURDAY, SUNDAY, MONDAY:\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Duplicate case\n" +
"----------\n" +
- "2. ERROR in X.java (at line 6)\n" +
+ "3. ERROR in X.java (at line 6)\n" +
" case MONDAY, SUNDAY:\n" +
" ^^^^^^^^^^^^^^^^^^^\n" +
- "Duplicate case\n" +
+ "The preview feature Multi constant case is only available with source level 13 and above\n" +
"----------\n" +
- "3. ERROR in X.java (at line 6)\n" +
+ "4. ERROR in X.java (at line 6)\n" +
" case MONDAY, SUNDAY:\n" +
" ^^^^^^^^^^^^^^^^^^^\n" +
"Duplicate case\n" +
- "----------\n");
- }
- public void testBug548476_01() {
- this.runNegativeTest(
- new String[] {
- "X.java",
- "class X {\n" +
- " I expr = () -> break;\n" +
- "}\n" +
- "\n" +
- "interface I {\n" +
- " void foo();\n" +
- "}",
- },
- "----------\n" +
- "1. ERROR in X.java (at line 2)\n" +
- " I expr = () -> break;\n" +
- " ^^^^^\n" +
- "Syntax error on token \"break\", invalid LambdaBody\n" +
- "----------\n");
- }
- public void testBug548476_02() {
- this.runNegativeTest(
- new String[] {
- "X.java",
- "class X {\n" +
- " void break () {}\n" +
- "}",
- },
"----------\n" +
- "1. ERROR in X.java (at line 2)\n" +
- " void break () {}\n" +
- " ^^^^^\n" +
- "Syntax error on token \"break\", Identifier expected\n" +
- "----------\n");
- }
- public void testBug548476_03() {
- this.runNegativeTest(
- new String[] {
- "X.java",
- "class X {\n" +
- "}\n" +
- "\n" +
- "class break{}\n"
- },
- "----------\n" +
- "1. ERROR in X.java (at line 4)\n" +
- " class break{}\n" +
- " ^^^^^\n" +
- "Syntax error on token \"break\", Identifier expected\n" +
- "----------\n");
- }
- public void testBug548476_04() {
- this.runNegativeTest(
- new String[] {
- "module-info.java",
- "module break.me {\n" +
- "}\n"
- },
- "----------\n" +
- "1. ERROR in module-info.java (at line 1)\n" +
- " module break.me {\n" +
- " ^^^^^\n" +
- "Syntax error on token \"break\", Identifier expected\n" +
- "----------\n");
- }
- public void testBug548476_05() {
- this.runNegativeTest(
- new String[] {
- "X.java",
- "class X {\n"+
- " public static void foo(int i) {\n"+
- " int v = switch (i) {\n"+
- " case 0 -> {\n"+
- " I k = () -> break;\n"+
- " }\n"+
- " default -> {\n"+
- " I k = () -> break;\n"+
- " break 0;\n"+
- " }\n"+
- " };\n"+
- " }\n"+
- "}\n"+
- "interface I {\n"+
- " void foo();\n"+
- "}\n"
- },
- "----------\n" +
- "1. ERROR in X.java (at line 5)\n" +
- " I k = () -> break;\n" +
- " ^^^^^\n" +
- "Syntax error on token \"break\", invalid LambdaBody\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 8)\n" +
- " I k = () -> break;\n" +
- " ^^^^^\n" +
- "Syntax error on token \"break\", invalid LambdaBody\n" +
+ "5. ERROR in X.java (at line 6)\n" +
+ " case MONDAY, SUNDAY:\n" +
+ " ^^^^^^^^^^^^^^^^^^^\n" +
+ "Duplicate case\n" +
"----------\n");
}
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionsYieldTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionsYieldTest.java
new file mode 100644
index 0000000000..f0dd255882
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionsYieldTest.java
@@ -0,0 +1,3483 @@
+/*******************************************************************************
+ * Copyright (c) 2019 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.compiler.regression;
+
+import java.util.Map;
+
+import org.eclipse.jdt.core.tests.compiler.regression.AbstractRegressionTest.JavacTestOptions.JavacHasABug;
+import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+
+import junit.framework.Test;
+
+public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
+
+ static {
+// TESTS_NUMBERS = new int [] { 40 };
+// TESTS_RANGE = new int[] { 1, -1 };
+// TESTS_NAMES = new String[] { "testBug550861_01" };
+ }
+
+ public static Class<?> testClass() {
+ return SwitchExpressionsYieldTest.class;
+ }
+ public static Test suite() {
+ return buildMinimalComplianceTestSuite(testClass(), F_13);
+ }
+ public SwitchExpressionsYieldTest(String testName){
+ super(testName);
+ }
+
+ // Enables the tests to run individually
+ protected Map<String, String> getCompilerOptions() {
+ Map<String, String> defaultOptions = super.getCompilerOptions();
+ defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_13); // FIXME
+ defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ defaultOptions.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
+ return defaultOptions;
+ }
+
+ @Override
+ protected void runConformTest(String[] testFiles, String expectedOutput) {
+ runConformTest(testFiles, expectedOutput, getCompilerOptions());
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Override
+ protected void runConformTest(String[] testFiles, String expectedOutput, Map customOptions) {
+ Runner runner = new Runner();
+ runner.testFiles = testFiles;
+ runner.expectedOutputString = expectedOutput;
+ runner.vmArguments = new String[] {"--enable-preview"};
+ runner.customOptions = customOptions;
+ runner.javacTestOptions = JavacTestOptions.forReleaseWithPreview("13");
+ runner.runConformTest();
+ }
+ @Override
+ protected void runNegativeTest(String[] testFiles, String expectedCompilerLog) {
+ runNegativeTest(testFiles, expectedCompilerLog, JavacTestOptions.forReleaseWithPreview("13"));
+ }
+ protected void runWarningTest(String[] testFiles, String expectedCompilerLog) {
+ runWarningTest(testFiles, expectedCompilerLog, null);
+ }
+ protected void runWarningTest(String[] testFiles, String expectedCompilerLog, Map<String, String> customOptions) {
+ runWarningTest(testFiles, expectedCompilerLog, customOptions, null);
+ }
+ protected void runWarningTest(String[] testFiles, String expectedCompilerLog,
+ Map<String, String> customOptions, String javacAdditionalTestOptions) {
+
+ Runner runner = new Runner();
+ runner.testFiles = testFiles;
+ runner.expectedCompilerLog = expectedCompilerLog;
+ runner.customOptions = customOptions;
+ runner.vmArguments = new String[] {"--enable-preview"};
+ runner.javacTestOptions = javacAdditionalTestOptions == null ? JavacTestOptions.forReleaseWithPreview("13") :
+ JavacTestOptions.forReleaseWithPreview("13", javacAdditionalTestOptions);
+ runner.runWarningTest();
+ }
+ public void testBug544073_000() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ "\n"+
+ " public static int yield() {\n"+
+ " return 1;\n"+
+ " }\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public static int foo(int val) {\n"+
+ " int k = switch (val) {\n"+
+ " case 1 -> { yield 1; }\n"+
+ " default -> { yield 2; }\n"+
+ " };\n"+
+ " return k;\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(X.foo(1));\n"+
+ " }\n"+
+ "}\n"
+ },
+ "1");
+ }
+ public void testBug544073_001() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " static int twice(int i) {\n" +
+ " int tw = switch (i) {\n" +
+ " case 0 -> i * 0;\n" +
+ " case 1 -> 2;\n" +
+ " default -> 3;\n" +
+ " };\n" +
+ " return tw;\n" +
+ " }\n" +
+ " public static void main(String... args) {\n" +
+ " System.out.print(twice(3));\n" +
+ " }\n" +
+ "}\n"
+ },
+ "3");
+ }
+ public void testBug544073_002() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " static int twice(int i) throws Exception {\n"+
+ " int tw = switch (i) {\n"+
+ " case 0 -> 0;\n"+
+ " case 1 -> { \n"+
+ " System.out.println(\"do_not_print\");\n"+
+ " yield 1;\n"+
+ " } \n"+
+ " case 3 -> throw new Exception();\n"+
+ " default -> throw new Exception();\n"+
+ " };\n"+
+ " return tw;\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " try {\n"+
+ " try {\n"+
+ " System.out.print(twice(3));\n"+
+ " } catch (Exception e) {\n"+
+ " System.out.print(\"Got Exception - expected\");\n"+
+ " }\n"+
+ " } catch (Exception e) {\n"+
+ " System.out.print(\"Got Exception\");\n"+
+ " }\n"+
+ " }\n"+
+ "}\n"
+ },
+ "Got Exception - expected");
+ }
+ public void testBug544073_003() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " twice(1);\n" +
+ " }\n" +
+ " public static int twice(int i) {\n" +
+ " int tw = switch (i) {\n" +
+ " };\n" +
+ " return tw;\n" +
+ " }\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " int tw = switch (i) {\n" +
+ " };\n" +
+ " ^^^^^^^^^^^^^^^^\n" +
+ "A switch expression should have a non-empty switch block\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 6)\n" +
+ " int tw = switch (i) {\n" +
+ " ^\n" +
+ "A switch expression should have a default case\n" +
+ "----------\n");
+ }
+ public void testBug544073_004() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " twice(1);\n" +
+ " }\n" +
+ " public static int twice(int i) {\n" +
+ " int tw = switch (i) {\n" +
+ " case 0 -> 0;\n" +
+ " case 1 -> { \n" +
+ " System.out.println(\"heel\");\n" +
+ " yield 1;\n" +
+ " } \n" +
+ " case \"hello\" -> throw new java.io.IOException(\"hello\");\n" +
+ " default -> throw new java.io.IOException(\"world\");\n" +
+ " };\n" +
+ " return tw;\n" +
+ " }\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 12)\n" +
+ " case \"hello\" -> throw new java.io.IOException(\"hello\");\n" +
+ " ^^^^^^^\n" +
+ "Type mismatch: cannot convert from String to int\n" +
+ "----------\n");
+ }
+ public void testBug544073_005() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " twice(1);\n" +
+ " }\n" +
+ " public static int twice(int i) {\n" +
+ " int tw = switch (i) {\n" +
+ " case 0 -> 0;\n" +
+ " case 1 -> { \n" +
+ " System.out.println(\"heel\");\n" +
+ " yield 1;\n" +
+ " } \n" +
+ " case 2 -> 2;\n" +
+ " };\n" +
+ " return tw;\n" +
+ " }\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " int tw = switch (i) {\n" +
+ " ^\n" +
+ "A switch expression should have a default case\n" +
+ "----------\n");
+ }
+ /**
+ * Add a test case for enum
+ * If the type of the selector expression is an enum type,
+ * then the set of all the case constants associated with the switch block
+ * must contain all the enum constants of that enum type
+ * Add a missing enum test case
+ */
+ public void _testBug544073_006() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " int x, y;\n" +
+ " I i = () -> {\n" +
+ " int z = 10;\n" +
+ " };\n" +
+ " i++;\n" +
+ " }\n" +
+ " public static int twice(int i) {\n" +
+ " int tw = switch (i) {\n" +
+ " case 0 -> 0;\n" +
+ " case 1 -> { \n" +
+ " System.out.println(\"heel\");\n" +
+ " yield 1;\n" +
+ " } \n" +
+ " // case 2 -> 2;\n" +
+ " case \"hello\" -> throw new IOException(\"hello\");\n" +
+ " };\n" +
+ " return tw;\n" +
+ " }\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 7)\n" +
+ " int tw = switch (i) {\n" +
+ " ^^^^^\n" +
+ " The switch expression should have a default case\n" +
+ "----------\n");
+ }
+ /*
+ * should compile - test for adding additional nesting in variables
+ * dev note: ref consumeToken().case Switch
+ */
+ public void testBug544073_007() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " static int foo(int i) {\n"+
+ " int tw = \n"+
+ " switch (i) {\n"+
+ " case 1 -> \n"+
+ " {\n"+
+ " int z = 100;\n"+
+ " yield z;\n"+
+ " }\n"+
+ " default -> {\n"+
+ " yield 12;\n"+
+ " }\n"+
+ " };\n"+
+ " return tw;\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.print(foo(1));\n"+
+ " }\n"+
+ "}\n"
+ },
+ "100");
+ }
+ public void testBug544073_008() {
+ Map<String, String> disablePreviewOptions = getCompilerOptions();
+ disablePreviewOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ String[] testFiles = new String[] {
+ "X.java",
+ "public class X {\n" +
+ " static int twice(int i) {\n" +
+ " int tw = switch (i) {\n" +
+ " case 0 -> i * 0;\n" +
+ " case 1 -> 2;\n" +
+ " default -> 3;\n" +
+ " };\n" +
+ " return tw;\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.print(twice(3));\n" +
+ " }\n" +
+ "}\n",
+ };
+
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " int tw = switch (i) {\n" +
+ " case 0 -> i * 0;\n" +
+ " case 1 -> 2;\n" +
+ " default -> 3;\n" +
+ " };\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Switch Expressions is a preview feature and disabled by default. Use --enable-preview to enable\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " case 0 -> i * 0;\n" +
+ " ^^^^^^\n" +
+ "Case Labels with '->' is a preview feature and disabled by default. Use --enable-preview to enable\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 5)\n" +
+ " case 1 -> 2;\n" +
+ " ^^^^^^\n" +
+ "Case Labels with '->' is a preview feature and disabled by default. Use --enable-preview to enable\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 6)\n" +
+ " default -> 3;\n" +
+ " ^^^^^^^\n" +
+ "Case Labels with '->' is a preview feature and disabled by default. Use --enable-preview to enable\n" +
+ "----------\n";
+
+ this.runNegativeTest(
+ testFiles,
+ expectedProblemLog,
+ null,
+ true,
+ disablePreviewOptions);
+ }
+ public void testBug544073_009() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ "\n" +
+ " public static void bar(int i) {\n" +
+ " switch (i) {\n" +
+ " case 1 -> System.out.println(\"hello\");\n" +
+ " default -> System.out.println(\"DEFAULT\");\n" +
+ " }\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " bar(1);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "hello");
+ }
+ public void testBug544073_010() {
+ Map<String, String> disablePreviewOptions = getCompilerOptions();
+ disablePreviewOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ String[] testFiles = new String[] {
+ "X.java",
+ "public class X {\n" +
+ " static int twice(int i) {\n" +
+ " switch (i) {\n" +
+ " case 0 -> i * 0;\n" +
+ " case 1 -> 2;\n" +
+ " default -> 3;\n" +
+ " }\n" +
+ " return 0;\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.print(twice(3));\n" +
+ " }\n" +
+ "}\n",
+ };
+
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " case 0 -> i * 0;\n" +
+ " ^^^^^^\n" +
+ "Case Labels with \'->\' is a preview feature and disabled by default. Use --enable-preview to enable\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 5)\n" +
+ " case 1 -> 2;\n" +
+ " ^^^^^^\n" +
+ "Case Labels with \'->\' is a preview feature and disabled by default. Use --enable-preview to enable\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 6)\n" +
+ " default -> 3;\n" +
+ " ^^^^^^^\n" +
+ "Case Labels with \'->\' is a preview feature and disabled by default. Use --enable-preview to enable\n" +
+ "----------\n";
+ this.runNegativeTest(
+ testFiles,
+ expectedProblemLog,
+ null,
+ true,
+ disablePreviewOptions);
+ }
+ public void testBug544073_011() {
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.ERROR);
+ String[] testFiles = new String[] {
+ "X.java",
+ "public class X {\n" +
+ " static int twice(int i) {\n" +
+ " switch (i) {\n" +
+ " default -> 3;\n" +
+ " }\n" +
+ " return 0;\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.print(twice(3));\n" +
+ " }\n" +
+ "}\n",
+ };
+
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " default -> 3;\n" +
+ " ^^^^^^^\n" +
+ "You are using a preview language feature that may or may not be supported in a future release\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " default -> 3;\n" +
+ " ^\n" +
+ "Invalid expression as statement\n" +
+ "----------\n";
+ this.runNegativeTest(
+ testFiles,
+ expectedProblemLog,
+ null,
+ true,
+ options);
+ }
+ public void testBug544073_012() {
+ String[] testFiles = new String[] {
+ "X.java",
+ "public class X {\n" +
+ " @SuppressWarnings(\"preview\")\n" +
+ " static int twice(int i) {\n" +
+ " switch (i) {\n" +
+ " default -> 3;\n" +
+ " }\n" +
+ " return 0;\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.print(twice(3));\n" +
+ " }\n" +
+ "}\n",
+ };
+
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " default -> 3;\n" +
+ " ^\n" +
+ "Invalid expression as statement\n" +
+ "----------\n";
+ this.runNegativeTest(
+ testFiles,
+ expectedProblemLog);
+ }
+ public void testBug544073_013() {
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.WARNING);
+ String release = options.get(CompilerOptions.OPTION_Release);
+ options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_11);
+ try {
+ String[] testFiles = new String[] {
+ "X.java",
+ "public class X {\n" +
+ " static int twice(int i) {\n" +
+ " switch (i) {\n" +
+ " default -> 3;\n" +
+ " }\n" +
+ " return 0;\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.print(twice(3));\n" +
+ " }\n" +
+ "}\n",
+ };
+
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 0)\n" +
+ " public class X {\n" +
+ " ^\n" +
+ "Preview features enabled at an invalid source release level 11, preview can be enabled only at source level 13\n" +
+ "----------\n";
+ this.runNegativeTest(
+ testFiles,
+ expectedProblemLog,
+ null,
+ true,
+ options);
+ } finally {
+ options.put(CompilerOptions.OPTION_Source, release);
+ }
+ }
+ public void testBug544073_014() {
+ String[] testFiles = new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static int foo(int i) {\n" +
+ " int v;\n" +
+ " int t = switch (i) {\n" +
+ " case 0 : {\n" +
+ " yield 0;\n" +
+ " }\n" +
+ " default :v = 2;\n" +
+ " };\n" +
+ " return t;\n" +
+ " }\n" +
+ " \n" +
+ " public boolean bar() {\n" +
+ " return true;\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(foo(3));\n" +
+ " }\n" +
+ "}\n",
+ };
+
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 8)\n" +
+ " default :v = 2;\n" +
+ " ^^^^^\n" +
+ "A switch labeled block in a switch expression should not complete normally\n" +
+ "----------\n";
+ this.runNegativeTest(
+ testFiles,
+ expectedProblemLog);
+ }
+ public void testBug544073_015() {
+ // switch expression is not a Primary
+ Runner runner = new Runner();
+ runner.customOptions = getCompilerOptions();
+ runner.testFiles = new String[] {
+ "X.java",
+ "public class X {\n" +
+ " void test(int i) {\n" +
+ " System.out.println(switch (i) {\n" +
+ " case 1 -> \"one\";\n" +
+ " default -> null;\n" +
+ " }.toLowerCase());\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " new X().test(1);\n" +
+ " }\n" +
+ "}\n"
+ };
+ runner.expectedCompilerLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " }.toLowerCase());\n" +
+ " ^\n" +
+ "Syntax error on token \".\", , expected\n" +
+ "----------\n";
+ runner.runNegativeTest();
+ }
+ public void testBug544073_016() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static int foo(Day day) {\n" +
+ "\n" +
+ " var len= switch (day) {\n" +
+ " case SUNDAY-> 6;\n" +
+ " default -> 10;\n" +
+ " };\n" +
+ "\n" +
+ " return len;\n" +
+ " }\n" +
+ "\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(foo(Day.SUNDAY));\n" +
+ " }\n" +
+ "}\n" +
+ "enum Day {\n" +
+ " MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY;\n" +
+ "}\n"
+ },
+ "6");
+ }
+ /*
+ * A simple multi constant case statement, compiled and run as expected
+ */
+ public void testBug544073_017() {
+ String[] testFiles = new String[] {
+ "X.java",
+ "public class X {\n" +
+ "public static void bar(Day day) {\n" +
+ " switch (day) {\n" +
+ " case SATURDAY, SUNDAY: \n" +
+ " System.out.println(Day.SUNDAY);\n" +
+ " break;\n" +
+ " case MONDAY : System.out.println(Day.MONDAY);\n" +
+ " break;\n" +
+ " }\n" +
+ " }" +
+ " public static void main(String[] args) {\n" +
+ " bar(Day.SATURDAY);\n" +
+ " }\n" +
+ "}\n" +
+ "enum Day { SATURDAY, SUNDAY, MONDAY;}",
+ };
+
+ String expectedProblemLog =
+ "SUNDAY";
+ this.runConformTest(
+ testFiles,
+ expectedProblemLog);
+ }
+ /*
+ * A simple multi constant case statement, compiler reports missing enum constants
+ */
+ public void testBug544073_018() {
+ String[] testFiles = new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " }\n" +
+ "public static void bar(Day day) {\n" +
+ " switch (day) {\n" +
+ " case SATURDAY, SUNDAY: \n" +
+ " System.out.println(Day.SUNDAY);\n" +
+ " break;\n" +
+ " case MONDAY : System.out.println(Day.MONDAY);\n" +
+ " break;\n" +
+ " }\n" +
+ " }" +
+ "}\n" +
+ "enum Day { SATURDAY, SUNDAY, MONDAY, TUESDAY;}",
+ };
+
+ String expectedProblemLog =
+ "----------\n" +
+ "1. WARNING in X.java (at line 5)\n" +
+ " switch (day) {\n" +
+ " ^^^\n" +
+ "The enum constant TUESDAY needs a corresponding case label in this enum switch on Day\n" +
+ "----------\n";
+ this.runWarningTest(
+ testFiles,
+ expectedProblemLog);
+ }
+ /*
+ * A simple multi constant case statement with duplicate enums
+ */
+ public void testBug544073_019() {
+ String[] testFiles = new String[] {
+ "X.java",
+ "public class X {\n" +
+ "public static void bar(Day day) {\n" +
+ " switch (day) {\n" +
+ " case SATURDAY, SUNDAY: \n" +
+ " System.out.println(Day.SUNDAY);\n" +
+ " break;\n" +
+ " case SUNDAY : System.out.println(Day.SUNDAY);\n" +
+ " break;\n" +
+ " }\n" +
+ " }" +
+ " public static void main(String[] args) {\n" +
+ " bar(Day.SATURDAY);\n" +
+ " }\n" +
+ "}\n" +
+ "enum Day { SATURDAY, SUNDAY, MONDAY;}",
+ };
+
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " case SATURDAY, SUNDAY: \n" +
+ " ^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Duplicate case\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 7)\n" +
+ " case SUNDAY : System.out.println(Day.SUNDAY);\n" +
+ " ^^^^^^^^^^^\n" +
+ "Duplicate case\n" +
+ "----------\n";
+ this.runNegativeTest(
+ testFiles,
+ expectedProblemLog);
+ }
+ /*
+ * A simple multi constant case statement with duplicate enums
+ */
+ public void testBug544073_020() {
+ String[] testFiles = new String[] {
+ "X.java",
+ "public class X {\n" +
+ "public static void bar(Day day) {\n" +
+ " switch (day) {\n" +
+ " case SATURDAY, SUNDAY: \n" +
+ " System.out.println(Day.SUNDAY);\n" +
+ " break;\n" +
+ " case SUNDAY, SATURDAY : \n" +
+ " System.out.println(Day.SUNDAY);\n" +
+ " break;\n" +
+ " }\n" +
+ " }" +
+ "}\n" +
+ "enum Day { SATURDAY, SUNDAY, MONDAY;}",
+ };
+
+ String expectedProblemLog =
+ "----------\n" +
+ "1. WARNING in X.java (at line 3)\n" +
+ " switch (day) {\n" +
+ " ^^^\n" +
+ "The enum constant MONDAY needs a corresponding case label in this enum switch on Day\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " case SATURDAY, SUNDAY: \n" +
+ " ^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Duplicate case\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 7)\n" +
+ " case SUNDAY, SATURDAY : \n" +
+ " ^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Duplicate case\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 7)\n" +
+ " case SUNDAY, SATURDAY : \n" +
+ " ^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Duplicate case\n" +
+ "----------\n";
+ this.runNegativeTest(
+ testFiles,
+ expectedProblemLog);
+ }
+ /*
+ *
+ */
+ public void testBug544073_021() {
+ String[] testFiles = new String[] {
+ "X.java",
+ "public class X {\n" +
+ "public static void bar(Day day) {\n" +
+ " switch (day) {\n" +
+ " case SATURDAY, SUNDAY: \n" +
+ " System.out.println(Day.SUNDAY);\n" +
+ " break;\n" +
+ " case TUESDAY : System.out.println(Day.SUNDAY);\n" +
+ " break;\n" +
+ " }\n" +
+ " }" +
+ " public static void main(String[] args) {\n" +
+ " bar(Day.SATURDAY);\n" +
+ " }\n" +
+ "}\n" +
+ "enum Day { SATURDAY, SUNDAY, MONDAY, TUESDAY;}",
+ };
+
+ String expectedProblemLog =
+ "----------\n" +
+ "1. WARNING in X.java (at line 3)\n" +
+ " switch (day) {\n" +
+ " ^^^\n" +
+ "The enum constant MONDAY needs a corresponding case label in this enum switch on Day\n" +
+ "----------\n";
+ this.runWarningTest(
+ testFiles,
+ expectedProblemLog);
+ }
+ public void testBug544073_022() {
+ String[] testFiles = new String[] {
+ "X.java",
+ "public class X {\n" +
+ "public static void bar(Day day) {\n" +
+ " switch (day) {\n" +
+ " case SATURDAY, SUNDAY: \n" +
+ " System.out.println(day);\n" +
+ " break;\n" +
+ " case MONDAY : System.out.println(0);\n" +
+ " break;\n" +
+ " }\n" +
+ " }" +
+ " public static void main(String[] args) {\n" +
+ " bar(Day.SATURDAY);\n" +
+ " bar(Day.MONDAY);\n" +
+ " bar(Day.SUNDAY);\n" +
+ " }\n" +
+ "}\n" +
+ "enum Day { SATURDAY, SUNDAY, MONDAY;}",
+ };
+
+ String expectedProblemLog =
+ "SATURDAY\n" +
+ "0\n" +
+ "SUNDAY";
+ this.runConformTest(
+ testFiles,
+ expectedProblemLog);
+ }
+ /*
+ * Simple switch case with string literals
+ */
+ public void testBug544073_023() {
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
+ String[] testFiles = new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " bar(\"a\");\n" +
+ " bar(\"b\");\n" +
+ " bar(\"c\");\n" +
+ " bar(\"d\");\n" +
+ " }\n" +
+ " public static void bar(String s) {\n" +
+ " switch(s) {\n" +
+ " case \"a\":\n" +
+ " case \"b\":\n" +
+ " System.out.println(\"A/B\");\n" +
+ " break;\n" +
+ " case \"c\":\n" +
+ " System.out.println(\"C\");\n" +
+ " break;\n" +
+ " default:\n" +
+ " System.out.println(\"NA\");\n" +
+ " }\n" +
+ " }\n" +
+ "}",
+ };
+ String expectedProblemLog =
+ "A/B\n" +
+ "A/B\n" +
+ "C\n" +
+ "NA";
+ this.runConformTest(
+ testFiles,
+ expectedProblemLog);
+ }
+ public void testBug544073_024() {
+ String[] testFiles = new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " bar(\"a\");\n" +
+ " bar(\"b\");\n" +
+ " bar(\"c\");\n" +
+ " bar(\"d\");\n" +
+ " }\n" +
+ " public static void bar(String s) {\n" +
+ " switch(s) {\n" +
+ " case \"a\", \"b\":\n" +
+ " System.out.println(\"A/B\");\n" +
+ " break;\n" +
+ " case \"c\":\n" +
+ " System.out.println(\"C\");\n" +
+ " break;\n" +
+ " default:\n" +
+ " System.out.println(\"NA\");\n" +
+ " }\n" +
+ " }\n" +
+ "}",
+ };
+ String expectedProblemLog =
+ "A/B\n" +
+ "A/B\n" +
+ "C\n" +
+ "NA";
+ this.runConformTest(
+ testFiles,
+ expectedProblemLog);
+ }
+ /*
+ * Switch with multi constant case statements with string literals
+ * two string literals with same hashcode
+ */
+ public void testBug544073_025() {
+ String[] testFiles = new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " bar(\"FB\");\n" +
+ " bar(\"Ea\");\n" +
+ " bar(\"c\");\n" +
+ " bar(\"D\");\n" +
+ " }\n" +
+ " public static void bar(String s) {\n" +
+ " switch(s) {\n" +
+ " case \"FB\", \"c\":\n" +
+ " System.out.println(\"A\");\n" +
+ " break;\n" +
+ " case \"Ea\":\n" +
+ " System.out.println(\"B\");\n" +
+ " break;\n" +
+ " default:\n" +
+ " System.out.println(\"NA\");\n" +
+ " }\n" +
+ " }\n" +
+ "}",
+ };
+ String expectedProblemLog =
+ "A\n" +
+ "B\n" +
+ "A\n" +
+ "NA";
+ this.runConformTest(
+ testFiles,
+ expectedProblemLog);
+ }
+ /*
+ * Switch with multi constant case statements with integer constants
+ */
+ public void testBug544073_026() {
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
+ String[] testFiles = new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " bar(1);\n" +
+ " bar(2);\n" +
+ " bar(3);\n" +
+ " bar(4);\n" +
+ " bar(5);\n" +
+ " }\n" +
+ " public static void bar(int i) {\n" +
+ " switch (i) {\n" +
+ " case 1, 3: \n" +
+ " System.out.println(\"Odd\");\n" +
+ " break;\n" +
+ " case 2, 4: \n" +
+ " System.out.println(\"Even\");\n" +
+ " break;\n" +
+ " default:\n" +
+ " System.out.println(\"Out of range\");\n" +
+ " }\n" +
+ " }\n" +
+ "}",
+ };
+ String expectedProblemLog =
+ "Odd\n" +
+ "Even\n" +
+ "Odd\n" +
+ "Even\n" +
+ "Out of range";
+ this.runConformTest(
+ testFiles,
+ expectedProblemLog);
+ }
+ /*
+ * Switch multi-constant with mixed constant types, reported
+ */
+ public void testBug544073_027() {
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
+ String[] testFiles = new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " }\n" +
+ " public static void bar(int i) {\n" +
+ " switch (i) {\n" +
+ " case 1, 3: \n" +
+ " System.out.println(\"Odd\");\n" +
+ " break;\n" +
+ " case \"2\": \n" +
+ " System.out.println(\"Even\");\n" +
+ " break;\n" +
+ " default:\n" +
+ " System.out.println(\"Out of range\");\n" +
+ " }\n" +
+ " }\n" +
+ "}",
+ };
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 9)\n" +
+ " case \"2\": \n" +
+ " ^^^\n" +
+ "Type mismatch: cannot convert from String to int\n" +
+ "----------\n";
+ this.runNegativeTest(
+ testFiles,
+ expectedProblemLog,
+ null,
+ true,
+ options);
+ }
+ /*
+ * Switch multi-constant without break statement, reported
+ */
+ public void testBug544073_028() {
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
+ options.put(CompilerOptions.OPTION_ReportFallthroughCase, CompilerOptions.WARNING);
+ String[] testFiles = new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " }\n" +
+ " public static void bar(int i) {\n" +
+ " switch (i) {\n" +
+ " case 1, 3: \n" +
+ " System.out.println(\"Odd\");\n" +
+ " case 2, 4: \n" +
+ " System.out.println(\"Even\");\n" +
+ " break;\n" +
+ " default:\n" +
+ " System.out.println(\"Out of range\");\n" +
+ " }\n" +
+ " }\n" +
+ "}",
+ };
+ String expectedProblemLog =
+ "----------\n" +
+ "1. WARNING in X.java (at line 8)\n" +
+ " case 2, 4: \n" +
+ " ^^^^^^^^^\n" +
+ "Switch case may be entered by falling through previous case. If intended, add a new comment //$FALL-THROUGH$ on the line above\n" +
+ "----------\n";
+ this.runWarningTest(
+ testFiles,
+ expectedProblemLog,
+ options,
+ "-Xlint:fallthrough");
+ }
+ /*
+ * Switch multi-constant without yield statement, reported
+ */
+ public void testBug544073_029() {
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
+ options.put(CompilerOptions.OPTION_ReportMissingDefaultCase, CompilerOptions.WARNING);
+ String[] testFiles = new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " }\n" +
+ " public static void bar(int i) {\n" +
+ " switch (i) {\n" +
+ " case 1, 3: \n" +
+ " System.out.println(\"Odd\");\n" +
+ " case 2, 4: \n" +
+ " System.out.println(\"Even\");\n" +
+ " }\n" +
+ " }\n" +
+ "}",
+ };
+ String expectedProblemLog =
+ "----------\n" +
+ "1. WARNING in X.java (at line 5)\n" +
+ " switch (i) {\n" +
+ " ^\n" +
+ "The switch statement should have a default case\n" +
+ "----------\n";
+ this.runWarningTest(
+ testFiles,
+ expectedProblemLog,
+ options);
+ }
+ /*
+ * Switch multi-constant with duplicate int constants
+ */
+ public void testBug544073_030() {
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
+ String[] testFiles = new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " }\n" +
+ " public static void bar(int i) {\n" +
+ " switch (i) {\n" +
+ " case 1, 3: \n" +
+ " System.out.println(\"Odd\");\n" +
+ " case 3, 4: \n" +
+ " System.out.println(\"Odd\");\n" +
+ " }\n" +
+ " }\n" +
+ "}",
+ };
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " case 1, 3: \n" +
+ " ^^^^^^^^^\n" +
+ "Duplicate case\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 8)\n" +
+ " case 3, 4: \n" +
+ " ^^^^^^^^^\n" +
+ "Duplicate case\n" +
+ "----------\n";
+ this.runNegativeTest(
+ testFiles,
+ expectedProblemLog,
+ null,
+ true,
+ options);
+ }
+ /*
+ * Switch multi-constant with duplicate String literals
+ */
+ public void testBug544073_031() {
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
+ String[] testFiles = new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " }\n" +
+ " public static void bar(String s) {\n" +
+ " switch (s) {\n" +
+ " case \"a\", \"b\": \n" +
+ " System.out.println(\"Odd\");\n" +
+ " case \"b\", \"c\": \n" +
+ " System.out.println(\"Odd\");\n" +
+ " }\n" +
+ " }\n" +
+ "}",
+ };
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " case \"a\", \"b\": \n" +
+ " ^^^^^^^^^^^^^\n" +
+ "Duplicate case\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 8)\n" +
+ " case \"b\", \"c\": \n" +
+ " ^^^^^^^^^^^^^\n" +
+ "Duplicate case\n" +
+ "----------\n";
+ this.runNegativeTest(
+ testFiles,
+ expectedProblemLog,
+ null,
+ true,
+ options);
+ }
+ /*
+ * Switch multi-constant with illegal qualified enum constant
+ */
+ public void testBug544073_032() {
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
+ String[] testFiles = new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " }\n" +
+ " public static void bar(Num s) {\n" +
+ " switch (s) {\n" +
+ " case ONE, Num.TWO: \n" +
+ " System.out.println(\"Odd\");\n" +
+ " }\n" +
+ " }\n" +
+ "}\n" +
+ "enum Num { ONE, TWO}\n",
+ };
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " case ONE, Num.TWO: \n" +
+ " ^^^^^^^\n" +
+ "The qualified case label Num.TWO must be replaced with the unqualified enum constant TWO\n" +
+ "----------\n";
+ this.runNegativeTest(
+ testFiles,
+ expectedProblemLog,
+ null,
+ true,
+ options);
+ }
+ public void testBug544073_033() {
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
+ String[] testFiles = new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public void bar(int s) {\n" +
+ " int j = switch (s) {\n" +
+ " case 1, 2, 3 -> (s+1);\n" +
+ " default -> j;\n" +
+ " };\n" +
+ " }\n" +
+ "}\n",
+ };
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " default -> j;\n" +
+ " ^\n" +
+ "The local variable j may not have been initialized\n" +
+ "----------\n";
+ this.runNegativeTest(
+ testFiles,
+ expectedProblemLog,
+ null,
+ true,
+ options);
+ }
+ public void testBug544073_034() {
+ String[] testFiles = new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " }\n" +
+ " public void bar(int s) {\n" +
+ " int j = 0;" +
+ " j = switch (s) {\n" +
+ " case 1, 2, 3 -> (s+1);\n" +
+ " default -> j;\n" +
+ " };\n" +
+ " }\n" +
+ "}\n",
+ };
+ this.runConformTest(
+ testFiles,
+ "");
+ }
+ public void testBug544073_035() {
+ // TODO: Fix me
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "import java.io.IOException;\n" +
+ "\n" +
+ "public class X {\n" +
+ " public static int foo(int i) throws IOException {\n" +
+ " int t = switch (i) {\n" +
+ " case 0 : {\n" +
+ " yield 0;\n" +
+ " }\n" +
+ " case 2 : {\n" +
+ " break;\n" +
+ " }\n" +
+ " default : yield 10;\n" +
+ " };\n" +
+ " return t;\n" +
+ " }\n" +
+ " \n" +
+ " public boolean bar() {\n" +
+ " return true;\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " try {\n" +
+ " System.out.println(foo(3));\n" +
+ " } catch (IOException e) {\n" +
+ " // TODO Auto-generated catch block\n" +
+ " e.printStackTrace();\n" +
+ " }\n" +
+ " }\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 10)\n" +
+ " break;\n" +
+ " ^^^^^^\n" +
+ "break out of switch expression not allowed\n" +
+ "----------\n");
+ }
+ public void testBug544073_036() {
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
+ String[] testFiles = new String[] {
+ "X.java",
+ "public class X {\n" +
+ " @SuppressWarnings(\"preview\")\n" +
+ " public static void bar(int i) {\n" +
+ " i = switch (i+0) {\n" +
+ " default: System.out.println(0);\n" +
+ " }; " +
+ " }\n" +
+ "}",
+ };
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " i = switch (i+0) {\n" +
+ " default: System.out.println(0);\n" +
+ " }; }\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "A switch expression should have at least one result expression\n" +
+ "----------\n";
+ this.runNegativeTest(
+ testFiles,
+ expectedProblemLog,
+ null,
+ true,
+ options);
+ }
+ public void testBug544073_037() {
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
+ String[] testFiles = new String[] {
+ "X.java",
+ "public class X {\n" +
+ " void test(int i) {\n" +
+ " need(switch (i) {\n" +
+ " case 1 -> \"\";\n" +
+ " default -> i == 3 ? null : \"\";\n" +
+ " }); \n" +
+ " }\n" +
+ " void need(String s) {\n" +
+ " System.out.println(s.toLowerCase());\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " new X().need(\"Hello World\");\n" +
+ " }\n" +
+ "}\n"
+ };
+ String expectedOutput = "hello world";
+ runConformTest(testFiles, expectedOutput, options);
+ }
+ public void testBug544073_038() {
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
+ String[] testFiles = new String[] {
+ "X.java",
+ "public class X {\n" +
+ " void test(int i) {\n" +
+ " need(switch (i) {\n" +
+ " case 1: yield \"\";\n" +
+ " default: yield i == 3 ? null : \"\";\n" +
+ " }); \n" +
+ " }\n" +
+ " void need(String s) {\n" +
+ " System.out.println(s.toLowerCase());\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " new X().need(\"Hello World\");\n" +
+ " }\n" +
+ "}\n"
+ };
+ String expectedOutput = "hello world";
+ runConformTest(testFiles, expectedOutput, options);
+ }
+ public void testBug544073_039() {
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
+ String[] testFiles = new String[] {
+ "X.java",
+ "interface I0 { void i(); }\n" +
+ "interface I1 extends I0 {}\n" +
+ "interface I2 extends I0 {}\n" +
+ "public class X {\n" +
+ " I1 n1() { return null; }\n" +
+ " <I extends I2> I n2() { return null; }\n" +
+ " <M> M m(M m) { return m; }\n" +
+ " void test(int i, boolean b) {\n" +
+ " m(switch (i) {\n" +
+ " case 1 -> n1();\n" +
+ " default -> b ? n1() : n2();\n" +
+ " }).i(); \n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " try {\n" +
+ " new X().test(1, true);\n" +
+ " } catch (NullPointerException e) {\n" +
+ " System.out.println(\"NPE as expected\");\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ };
+ String expectedOutput = "NPE as expected";
+ runConformTest(testFiles, expectedOutput, options);
+ }
+ public void testBug544073_040() {
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
+ String[] testFiles = new String[] {
+ "X.java",
+ "import java.util.function.Supplier;\n" +
+ "interface I0 { void i(); }\n" +
+ "interface I1 extends I0 {}\n" +
+ "interface I2 extends I0 {}\n" +
+ "public class X {\n" +
+ " I1 n1() { return null; }\n" +
+ " <I extends I2> I n2() { return null; }\n" +
+ " <M> M m(Supplier<M> m) { return m.get(); }\n" +
+ " void test(int i, boolean b) {\n" +
+ " m(switch (i) {\n" +
+ " case 1 -> this::n1;\n" +
+ " default -> this::n2;\n" +
+ " }).i(); \n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " try {\n" +
+ " new X().test(1, true);\n" +
+ " } catch (NullPointerException e) {\n" +
+ " System.out.println(\"NPE as expected\");\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ };
+ String expectedOutput = "NPE as expected";
+ runConformTest(testFiles, expectedOutput, options);
+ }
+ public void testBug544073_041() {
+ // require resolving/inferring of poly-switch-expression during ASTNode.resolvePolyExpressionArguments()
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
+ String[] testFiles = new String[] {
+ "X.java",
+ "public class X {\n" +
+ " void test(int i) {\n" +
+ " need(switch (i) {\n" +
+ " case 1 -> 1.0f;\n" +
+ " default -> i == 3 ? 3 : 5.0d;\n" +
+ " }); \n" +
+ " }\n" +
+ " <N extends Number> void need(N s) {\n" +
+ " System.out.println(s.toString());\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " new X().need(3);\n" +
+ " }\n" +
+ "}\n"
+ };
+ String expectedOutput = "3";
+ runConformTest(testFiles, expectedOutput, options);
+ }
+ public void testBug544073_042() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " static int twice(int i) throws Exception {\n" +
+ " switch (i) {\n" +
+ " case 0 -> System.out.println(\"hellow\");\n" +
+ " case 1 -> foo();\n" +
+ " default -> throw new Exception();\n" +
+ " };\n" +
+ " return 0;\n" +
+ " }\n" +
+ "\n" +
+ " static int foo() {\n" +
+ " System.out.println(\"inside foo\");\n" +
+ " return 1;\n" +
+ " }\n" +
+ "\n" +
+ " public static void main(String[] args) {\n" +
+ " try {\n" +
+ " System.out.print(twice(1));\n" +
+ " } catch (Exception e) {\n" +
+ " System.out.print(\"Got Exception\");\n" +
+ " }\n" +
+ " }\n" +
+ "}"
+ },
+ "inside foo\n"
+ + "0");
+ }
+ public void testBug544073_043() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "enum SomeDays {\n" +
+ " Mon, Wed, Fri\n" +
+ "}\n" +
+ "\n" +
+ "public class X {\n" +
+ " int testEnum(boolean b) {\n" +
+ " SomeDays day = b ? SomeDays.Mon : null;\n" +
+ " return switch(day) {\n" +
+ " case Mon -> 1;\n" +
+ " case Wed -> 2;\n" +
+ " case Fri -> 3;\n" +
+ " };\n" +
+ " }\n" +
+ "\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(new X().testEnum(true));\n" +
+ " }\n" +
+ "}\n" +
+ ""
+ },
+ "1");
+ }
+ public void testBug544073_044() {
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ String[] testFiles = new String[] {
+ "X.java",
+ "public class X {\n" +
+ " static int foo(int i) {\n" +
+ " switch (i) {\n" +
+ " default -> 3; // should flag an error\n" +
+ " \n" +
+ " };\n" +
+ " return 0;\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " foo(1);\n" +
+ " }\n" +
+ "}\n",
+ };
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " default -> 3; // should flag an error\n" +
+ " ^\n" +
+ "Invalid expression as statement\n" +
+ "----------\n";
+ this.runNegativeTest(
+ testFiles,
+ expectedProblemLog,
+ null,
+ true,
+ new String[] { "--enable-preview"},
+ options);
+ }
+ public void testBug544073_045() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public void foo(int i) {\n" +
+ " int j = switch (i) {\n" +
+ " case 1 -> i;\n" +
+ " default -> i;\n" +
+ " };\n" +
+ " System.out.println(j);\n" +
+ " }\n" +
+ " \n" +
+ " public static void main(String[] args) {\n" +
+ " new X().foo(1);\n" +
+ " }\n" +
+ "}"
+ },
+ "1");
+ }
+ public void testBug544073_046() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public void foo(int i) {\n" +
+ " long j = switch (i) {\n" +
+ " case 1 -> 10L;\n" +
+ " default -> 20L;\n" +
+ " };\n" +
+ " System.out.println(j);\n" +
+ " }\n" +
+ " \n" +
+ " public static void main(String[] args) {\n" +
+ " new X().foo(1);\n" +
+ " }\n" +
+ "}"
+ },
+ "10");
+ }
+ public void testBug544073_047() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public int foo(String s) throws Exception {\n" +
+ " int i = switch (s) {\n" +
+ " case \"hello\" -> 1;\n" +
+ " default -> throw new Exception();\n" +
+ " };\n" +
+ " return i;\n" +
+ " }\n" +
+ "\n" +
+ " public static void main(String[] argv) {\n" +
+ " try {\n" +
+ " System.out.print(new X().foo(\"hello\"));\n" +
+ " } catch (Exception e) {\n" +
+ " //\n" +
+ " }\n" +
+ " }\n" +
+ "}"
+ },
+ "1");
+ }
+ public void testBug544073_048() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public void foo(Day day) {\n" +
+ " var today = 1;\n" +
+ " today = switch (day) {\n" +
+ " case SATURDAY,SUNDAY :\n" +
+ " today=1;\n" +
+ " yield today;\n" +
+ " case MONDAY,TUESDAY,WEDNESDAY,THURSDAY :\n" +
+ " today=2;\n" +
+ " yield today;\n" +
+ " };\n" +
+ " }\n" +
+ " public static void main(String argv[]) {\n" +
+ " new X().foo(Day.FRIDAY);\n" +
+ " }\n" +
+ "}\n" +
+ "\n" +
+ "enum Day {\n" +
+ " SUNDAY,\n" +
+ " MONDAY,\n" +
+ " TUESDAY,\n" +
+ " WEDNESDAY,\n" +
+ " THURSDAY,\n" +
+ " FRIDAY,\n" +
+ " SATURDAY\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " today = switch (day) {\n" +
+ " ^^^\n" +
+ "A Switch expression should cover all possible values\n" +
+ "----------\n");
+ }
+ public void testBug544073_049() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public void foo(int i ) {\n" +
+ " boolean b = switch (i) {\n" +
+ " case 0 -> i == 1;\n" +
+ " default -> true;\n" +
+ " };\n" +
+ " System.out.println( b ? \" true\" : \"false\");\n" +
+ " }\n" +
+ " public static void main(String[] argv) {\n" +
+ " new X().foo(0);\n" +
+ " }\n" +
+ "}"
+ },
+ "false");
+ }
+ public void testBug544073_050() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public void foo(String s) {\n" +
+ " try {\n" +
+ " int i = switch (s) {\n" +
+ " case \"hello\" -> 0;\n" +
+ " default -> 2;\n" +
+ " };\n" +
+ " } finally {\n" +
+ " System.out.println(s);\n" +
+ " }\n" +
+ " }\n" +
+ " public static void main(String argv[]) {\n" +
+ " new X().foo(\"hello\");\n" +
+ " }\n" +
+ "}"
+ },
+ "hello");
+ }
+ public void testBug544073_051() {
+ Map<String, String> customOptions = getCompilerOptions();
+ customOptions.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.OPTIMIZE_OUT);
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public void foo(String s) {\n" +
+ " try {\n" +
+ " int i = switch (s) {\n" +
+ " case \"hello\" -> 0;\n" +
+ " default -> 2;\n" +
+ " };\n" +
+ " } finally {\n" +
+ " System.out.println(s);\n" +
+ " }\n" +
+ " }\n" +
+ " public static void main(String argv[]) {\n" +
+ " new X().foo(\"hello\");\n" +
+ " }\n" +
+ "}"
+ },
+ "hello");
+ }
+ public void testBug544073_052() {
+ Map<String, String> customOptions = getCompilerOptions();
+ customOptions.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.OPTIMIZE_OUT);
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public void foo(String s) {\n" +
+ " try {\n" +
+ " long l = switch (s) {\n" +
+ " case \"hello\" -> 0;\n" +
+ " default -> 2;\n" +
+ " };\n" +
+ " } finally {\n" +
+ " System.out.println(s);\n" +
+ " }\n" +
+ " }\n" +
+ " public static void main(String argv[]) {\n" +
+ " new X().foo(\"hello\");\n" +
+ " }\n" +
+ "}"
+ },
+ "hello");
+ }
+ public void testBug544073_053() {
+ Map<String, String> customOptions = getCompilerOptions();
+ customOptions.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.OPTIMIZE_OUT);
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public int foo(int i) {\n" +
+ " int j = (switch (i) {\n" +
+ " case 1 -> 1;\n" +
+ " default -> 2;\n" +
+ " });\n" +
+ " return j;\n" +
+ " }\n" +
+ " public static void main(String[] argv) {\n" +
+ " new X().foo(1);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "",
+ customOptions);
+ }
+ public void testBug544073_054() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " enum MyEnum {\n" +
+ " FIRST;\n" +
+ " }\n" +
+ "\n" +
+ " public void foo(MyEnum myEnum) {\n" +
+ " int i = switch (myEnum) {\n" +
+ " case FIRST -> 1;\n" +
+ " };\n" +
+ " System.out.println( \"i:\" + i);\n" +
+ " }\n" +
+ "\n" +
+ " public static void main(String argv[]) {\n" +
+ " new X().foo(MyEnum.FIRST);\n" +
+ " }\n" +
+ "}"
+ },
+ "i:1");
+ }
+ public void testBug544073_055() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " enum MyEnum {\n" +
+ " FIRST;\n" +
+ " }\n" +
+ "\n" +
+ " public void foo(MyEnum myEnum) {\n" +
+ " int i = switch (myEnum) {\n" +
+ " case FIRST -> 1;\n" +
+ " default -> 0;\n" +
+ " };\n" +
+ " System.out.println( \"i:\" + i);\n" +
+ " }\n" +
+ "\n" +
+ " public static void main(String argv[]) {\n" +
+ " new X().foo(MyEnum.FIRST);\n" +
+ " }\n" +
+ "}"
+ },
+ "i:1");
+ }
+ public void testBug544073_056() {
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
+ String[] testFiles = new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public int foo(int i) {\n" +
+ " var v = switch(i) {\n" +
+ " case 0 -> x;\n" +
+ " default -> 1;\n" +
+ " };\n" +
+ " return v;\n" +
+ " }\n" +
+ " public static void main(String[] argv) {\n" +
+ " System.out.println(new X().foo(0));\n" +
+ " }\n" +
+ "}",
+ };
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " case 0 -> x;\n" +
+ " ^\n" +
+ "x cannot be resolved to a variable\n" +
+ "----------\n";
+ this.runNegativeTest(
+ testFiles,
+ expectedProblemLog,
+ null,
+ true,
+ new String[] { "--enable-preview"},
+ options);
+ }
+ public void testBug544073_057() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " @SuppressWarnings(\"preview\")\n" +
+ " public int foo(int i) {\n" +
+ " int v = switch(i) {\n" +
+ " case 0 -> switch(i) {\n" +
+ " case 0 -> 0;\n" +
+ " default -> 1;\n" +
+ " };\n" +
+ " default -> 1;\n" +
+ " };\n" +
+ " return v;\n" +
+ " }\n" +
+ " public static void main(String[] argv) {\n" +
+ " System.out.println(new X().foo(0));\n" +
+ " }\n" +
+ "}"
+ },
+ "0");
+ }
+ public void testBug544073_058() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public int foo(int i) {\n" +
+ " @SuppressWarnings(\"preview\")\n" +
+ " int v = switch(switch(i) {\n" +
+ " default -> 1;\n" +
+ " }) {\n" +
+ " default -> 1;\n" +
+ " };\n" +
+ " return v;\n" +
+ " }\n" +
+ "\n" +
+ " public static void main(String[] argv) {\n" +
+ " System.out.println(new X().foo(0));\n" +
+ " }\n" +
+ "}\n"
+ },
+ "1");
+ }
+ public void testBug544073_059() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static int foo(int i) {\n" +
+ " boolean v = switch (i) {\n" +
+ " case 1: i = 10; yield true;\n" +
+ " default: yield false;\n" +
+ " };\n" +
+ " return v ? 0 : 1;\n" +
+ " }\n" +
+ " public static void main(String[] argv) {\n" +
+ " System.out.println(X.foo(0));\n" +
+ " }\n" +
+ "}"
+ },
+ "1");
+ }
+ public void testBug544073_060() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static int foo(int i) {\n" +
+ " boolean v = switch (i) {\n" +
+ " case 1: i++; yield true;\n" +
+ " default: yield false;\n" +
+ " };\n" +
+ " return v ? 0 : 1;\n" +
+ " }\n" +
+ " public static void main(String[] argv) {\n" +
+ " System.out.println(X.foo(1));\n" +
+ " }\n" +
+ "}"
+ },
+ "0");
+ }
+ public void testBug544073_061() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static int foo(int i) {\n" +
+ " boolean v = switch (i) {\n" +
+ " case 1: i+= 10; yield true;\n" +
+ " default: yield false;\n" +
+ " };\n" +
+ " return v ? 0 : 1;\n" +
+ " }\n" +
+ " public static void main(String[] argv) {\n" +
+ " System.out.println(X.foo(1));\n" +
+ " }\n" +
+ "}"
+ },
+ "0");
+ }
+ public void testBug544073_062() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static int foo(int i) {\n" +
+ " boolean v = switch (i) {\n" +
+ " case 1: switch(i) {case 4: break;}; yield true;\n" +
+ " default: yield false;\n" +
+ " };\n" +
+ " return v ? 0 : 1;\n" +
+ " }\n" +
+ " public static void main(String[] argv) {\n" +
+ " System.out.println(X.foo(1));\n" +
+ " }\n" +
+ "}"
+ },
+ "0");
+ }
+ public void testBug544073_063() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static int foo(int i) {\n" +
+ " boolean v = switch (i) {\n" +
+ " case 1: foo(5); yield true;\n" +
+ " default: yield false;\n" +
+ " };\n" +
+ " return v ? 0 : 1;\n" +
+ " }\n" +
+ " public static void main(String[] argv) {\n" +
+ " System.out.println(X.foo(1));\n" +
+ " }\n" +
+ "}"
+ },
+ "0");
+ }
+ public void testBug544073_064() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public int foo(int i) {\n" +
+ " @SuppressWarnings(\"preview\")\n" +
+ " boolean v = switch (i) {\n" +
+ " case 1:\n" +
+ " switch (i) {\n" +
+ " case 1 : i = 10;\n" +
+ " break;\n" +
+ " default :\n" +
+ " i = 2;\n" +
+ " break;\n" +
+ " }\n" +
+ " yield true;\n" +
+ " default: yield false;\n" +
+ " };\n" +
+ " return v ? 0 : 1;\n" +
+ " }\n" +
+ "\n" +
+ " public static void main(String[] argv) {\n" +
+ " System.out.println(new X().foo(0));\n" +
+ " }\n" +
+ "}\n"
+ },
+ "1");
+ }
+ public void testBug544073_065() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public int foo(int i) {\n" +
+ " @SuppressWarnings(\"preview\")\n" +
+ " int v =\n" +
+ " switch(switch(i) {\n" +
+ " case 0 -> { yield 2; }\n" +
+ " default -> { yield 3; }\n" +
+ " }) {\n" +
+ " case 0 -> { yield 0; }\n" +
+ " default -> { yield 1; }\n" +
+ " };\n" +
+ " return v == 1 ? v : 0;\n" +
+ " }\n" +
+ " public static void main(String[] argv) {\n" +
+ " System.out.println(new X().foo(0));\n" +
+ " }\n" +
+ "}"
+ },
+ "1");
+ }
+ public void testBug544073_066() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " @SuppressWarnings(\"preview\")\n" +
+ " public int foo(int i) {\n" +
+ " int k = 10;\n" +
+ " switch (i) {\n" +
+ " case 0 -> { k = 0;}\n" +
+ " default -> k = -1;\n" +
+ " }\n" +
+ " return k;\n" +
+ " }\n" +
+ " public static void main(String[] argv) {\n" +
+ " System.out.println(new X().foo(0) == 0 ? \"Success\" : \"Failure\");\n" +
+ " }\n" +
+ "\n" +
+ "}\n"
+ },
+ "Success");
+ }
+ public void testBug544073_067() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " @SuppressWarnings(\"preview\")\n" +
+ " public static void foo(Day day) {\n" +
+ " switch (day) {\n" +
+ " case MONDAY, FRIDAY -> System.out.println(Day.SUNDAY);\n" +
+ " case TUESDAY -> System.out.println(7);\n" +
+ " case THURSDAY, SATURDAY -> System.out.println(8);\n" +
+ " case WEDNESDAY -> System.out.println(9);\n" +
+ " default -> {}\n" +
+ " } \n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " X.foo(Day.WEDNESDAY);\n" +
+ " }\n" +
+ "}\n" +
+ "\n" +
+ "enum Day {\n" +
+ " MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY;\n" +
+ "}\n"
+ },
+ "9");
+ }
+ public void testBug544073_068() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " public static void foo (int i) {\n"+
+ " int v = switch (i) {\n"+
+ " case 60, 600: yield 6;\n"+
+ " case 70: yield 7;\n"+
+ " case 80: yield 8;\n"+
+ " case 90, 900: yield 9;\n"+
+ " default: yield 0;\n"+
+ " };\n"+
+ " System.out.println(v);\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " X.foo(10);\n"+
+ " }\n"+
+ "}\n"
+ },
+ "0");
+ }
+ // see comment 12 in the bug
+ public void testBug513766_01() {
+ Runner runner = new Runner();
+ runner.testFiles = new String[] {
+ "X.java",
+ "public class X {\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public void foo(int i) {\n"+
+ " if (switch(i) { default -> magic(); })\n"+
+ " System.out.println(\"true\");\n"+
+ " if (magic())\n"+
+ " System.out.println(\"true, too\");\n"+
+ " }\n"+
+ " <T> T magic() { return null; }\n"+
+ "}\n",
+ };
+ runner.expectedCompilerLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " if (switch(i) { default -> magic(); })\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Type mismatch: cannot convert from Object to boolean\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 6)\n" +
+ " if (magic())\n" +
+ " ^^^^^^^\n" +
+ "Type mismatch: cannot convert from Object to boolean\n" +
+ "----------\n";
+ runner.vmArguments = new String[] {"--enable-preview"};
+ runner.javacTestOptions = JavacHasABug.JavacBug8179483_switchExpression;
+ runner.runNegativeTest();
+ }
+ public void testBug544073_070() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public static int foo(int i) throws MyException {\n"+
+ " int v = switch (i) {\n"+
+ " default -> throw new MyException();\n"+
+ " };\n"+
+ " return v;\n"+
+ " }\n"+
+ " public static void main(String argv[]) {\n"+
+ " try {\n"+
+ " System.out.println(X.foo(1));\n"+
+ " } catch (MyException e) {\n"+
+ " System.out.println(\"Exception thrown as expected\");\n"+
+ " }\n"+
+ " }\n"+
+ "}\n"+
+ "class MyException extends Exception {\n"+
+ " private static final long serialVersionUID = 3461899582505930473L; \n"+
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " int v = switch (i) {\n" +
+ " default -> throw new MyException();\n" +
+ " };\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "A switch expression should have at least one result expression\n" +
+ "----------\n");
+ }
+ public void testBug544073_071() {
+ if (this.complianceLevel < ClassFileConstants.JDK12)
+ return;
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.WARNING);
+ String message =
+ "----------\n" +
+ "1. WARNING in X.java (at line 5)\n" +
+ " case \"ABC\", (false ? (String) \"c\" : (String) \"d\") : break;\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "You are using a preview language feature that may or may not be supported in a future release\n" +
+ "----------\n" +
+ "2. WARNING in X.java (at line 5)\n" +
+ " case \"ABC\", (false ? (String) \"c\" : (String) \"d\") : break;\n" +
+ " ^^^^^^^^^^^^\n" +
+ "Dead code\n" +
+ "----------\n";
+
+ this.runWarningTest(new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " String arg = \"ABD\";\n" +
+ " switch(arg) {\n" +
+ " case \"ABC\", (false ? (String) \"c\" : (String) \"d\") : break;\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ },
+ message,
+ options,
+ "-Xlint:preview");
+ }
+ public void testBug544073_072() {
+ if (this.complianceLevel < ClassFileConstants.JDK12)
+ return;
+ String message =
+ "----------\n" +
+ "1. WARNING in X.java (at line 5)\n" +
+ " case \"ABC\", (false ? (String) \"c\" : (String) \"d\") : break;\n" +
+ " ^^^^^^^^^^^^\n" +
+ "Dead code\n" +
+ "----------\n";
+
+ this.runWarningTest(new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " String arg = \"ABD\";\n" +
+ " switch(arg) {\n" +
+ " case \"ABC\", (false ? (String) \"c\" : (String) \"d\") : break;\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ },
+ message);
+ }
+ public void testBug544073_073() {
+ if (this.complianceLevel < ClassFileConstants.JDK1_8)
+ return;
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.WARNING);
+ String message =
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " case \"ABC\", (false ? (String) \"c\" : (String) \"d\") : break;\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Multi constant case is a preview feature and disabled by default. Use --enable-preview to enable\n" +
+ "----------\n";
+
+ this.runNegativeTest(new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " String arg = \"ABD\";\n" +
+ " switch(arg) {\n" +
+ " case \"ABC\", (false ? (String) \"c\" : (String) \"d\") : break;\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ },
+ message,
+ null,
+ true,
+ new String[] { "--enable-preview"},
+ options);
+ }
+ public void testBug544073_074() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "enum X {\n"+
+ " A, B; \n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public static void main(String[] args) {\n"+
+ " X myEnum = X.A;\n"+
+ " int o;\n"+
+ " switch(myEnum) {\n"+
+ " case A -> o = 5;\n"+
+ " case B -> o = 10;\n"+
+ " default -> o = 0;\n"+
+ " }\n"+
+ " System.out.println(o);\n"+
+ " }\n"+
+ "}\n"
+ },
+ "5");
+ }
+ public void testBug544073_075() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "enum X {\n"+
+ " A, B;\n"+
+ " \n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public static void main(String[] args) {\n"+
+ " X myEnum = X.A;\n"+
+ " int o;\n"+
+ " var f = switch(myEnum) {\n"+
+ " case A -> o = 5;\n"+
+ " case B -> o = 10;\n"+
+ " };\n"+
+ " System.out.println(o);\n"+
+ " }\n"+
+ "} \n"
+ },
+ "5");
+ }
+ public void testBug544073_076() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "\n"+
+ "public class X {\n"+
+ "\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public static int foo() {\n"+
+ " for (int i = 0; i < 1; ++i) {\n"+
+ " int k = switch (i) {\n"+
+ " case 0:\n"+
+ " yield 1;\n"+
+ " default:\n"+
+ " continue;\n"+
+ " };\n"+
+ " System.out.println(k);\n"+
+ " }\n"+
+ " return 1;\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " X.foo();\n"+
+ " }\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 11)\n" +
+ " continue;\n" +
+ " ^^^^^^^^^\n" +
+ "'continue' or 'return' cannot be the last statement in a Switch expression case body\n" +
+ "----------\n");
+ }
+ public void testBug544073_077() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "\n"+
+ "public class X {\n"+
+ "\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public static int foo() {\n"+
+ " for (int i = 0; i < 1; ++i) {\n"+
+ " int k = switch (i) {\n"+
+ " case 0:\n"+
+ " yield 1;\n"+
+ " default:\n"+
+ " return 2;\n"+
+ " };\n"+
+ " System.out.println(k);\n"+
+ " }\n"+
+ " return 1;\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " X.foo();\n"+
+ " }\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 11)\n" +
+ " return 2;\n" +
+ " ^^^^^^^^^\n" +
+ "'continue' or 'return' cannot be the last statement in a Switch expression case body\n" +
+ "----------\n");
+ }
+ public void testBug544073_078() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " void foo(Day day) {\n" +
+ " switch (day) {\n" +
+ " case SATURDAY, SUNDAY, SUNDAY:\n" +
+ " System.out.println(\"Weekend\");\n" +
+ " case MONDAY:\n" +
+ " System.out.println(\"Weekday\");\n" +
+ " default: \n" +
+ " }\n" +
+ " }\n" +
+ "}\n" +
+ "\n" +
+ "enum Day {\n" +
+ " MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY;\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " case SATURDAY, SUNDAY, SUNDAY:\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Duplicate case\n" +
+ "----------\n");
+ }
+ public void testBug544073_079() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " void foo(Day day) {\n" +
+ " switch (day) {\n" +
+ " case SATURDAY, SUNDAY, MONDAY:\n" +
+ " System.out.println(\"Weekend\");\n" +
+ " case MONDAY, SUNDAY:\n" +
+ " System.out.println(\"Weekday\");\n" +
+ " default: \n" +
+ " }\n" +
+ " }\n" +
+ "}\n" +
+ "\n" +
+ "enum Day {\n" +
+ " MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY;\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " case SATURDAY, SUNDAY, MONDAY:\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Duplicate case\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 6)\n" +
+ " case MONDAY, SUNDAY:\n" +
+ " ^^^^^^^^^^^^^^^^^^^\n" +
+ "Duplicate case\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 6)\n" +
+ " case MONDAY, SUNDAY:\n" +
+ " ^^^^^^^^^^^^^^^^^^^\n" +
+ "Duplicate case\n" +
+ "----------\n");
+ }
+ public void testBug544073_80() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "\n"+
+ "public class X {\n"+
+ "\n"+
+ " public static int yield() {\n"+
+ " return 1;\n"+
+ " }\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public static int foo(int val) {\n"+
+ " return bar (switch (val) {\n"+
+ " case 1 : { yield val == 1 ? 2 : 3; }\n"+
+ " default : { yield 2; }\n"+
+ " });\n"+
+ " }\n"+
+ " public static int bar(int val) {\n"+
+ " return val;\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(X.foo(1));\n"+
+ " }\n"+
+ "}\n"
+ },
+ "2");
+ }
+ public void testBug544073_81() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ "\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public static int foo(int val) {\n"+
+ " int k = switch (val) {\n"+
+ " case 1 : { break 1; }\n"+
+ " default : { break 2; }\n"+
+ " };\n"+
+ " return k;\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(X.foo(1));\n"+
+ " }\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " case 1 : { break 1; }\n" +
+ " ^\n" +
+ "Syntax error on token \"1\", delete this token\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 7)\n" +
+ " default : { break 2; }\n" +
+ " ^\n" +
+ "Syntax error on token \"2\", delete this token\n" +
+ "----------\n");
+ }
+ public void testBug547891_01() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " public static void yield() {}\n"+
+ " public static void main(String[] args) {\n"+
+ " yield();\n"+
+ " X.yield();\n"+
+ " }\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " yield();\n" +
+ " ^^^^^^^\n" +
+ "restricted identifier yield not allowed here - method calls need to be qualified\n" +
+ "----------\n");
+ }
+ public void testBug547891_02() {
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ String[] testFiles = new String[] {
+ "X.java",
+ "public class X {\n"+
+ " public static void yield() {}\n"+
+ " public static void main(String[] args) {\n"+
+ " yield();\n"+
+ " }\n"+
+ " public static void bar() {\n"+
+ " Zork();\n"+
+ " }\n"+
+ "}\n",
+ };
+ String expectedProblemLog =
+ "----------\n" +
+ "1. WARNING in X.java (at line 4)\n" +
+ " yield();\n" +
+ " ^^^^^^^\n" +
+ "yield may be disallowed in future - qualify method calls to avoid this message\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 7)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n";
+ this.runNegativeTest(
+ testFiles,
+ expectedProblemLog,
+ null,
+ true,
+ new String[] {""},
+ options);
+ }
+ public void testBug547891_03() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " public static void main(String[] args) {\n"+
+ " yield 1;\n"+
+ " }\n"+
+ "}\n"+
+ "class yield {\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " yield 1;\n" +
+ " ^^^^^\n" +
+ "Syntax error on token \"yield\", AssignmentOperator expected after this token\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 6)\n" +
+ " class yield {\n" +
+ " ^^^^^\n" +
+ "yield is a restricted identifier and cannot be used as type name\n" +
+ "----------\n");
+ }
+ public void testBug547891_04() {
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ String[] testFiles = new String[] {
+ "X.java",
+ "public class X {\n"+
+ " public static void main(String[] args) {\n"+
+ " yield 1;\n"+
+ " Zork();\n"+
+ " }\n"+
+ "}\n"+
+ "class yield {\n" +
+ "}\n",
+ };
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " yield 1;\n" +
+ " ^^^^^\n" +
+ "Syntax error on token \"yield\", AssignmentOperator expected after this token\n" +
+ "----------\n" +
+ "2. WARNING in X.java (at line 7)\n" +
+ " class yield {\n" +
+ " ^^^^^\n" +
+ "yield may be a restricted identifier in future and may be disallowed as a type name\n" +
+ "----------\n";
+ this.runNegativeTest(
+ testFiles,
+ expectedProblemLog,
+ null,
+ true,
+ new String[] {""},
+ options);
+ }
+ public void testBug547891_05() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " public static void main(String[] args) {\n"+
+ " yield y;\n"+
+ " }\n"+
+ "}\n"+
+ "class yield {\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " yield y;\n" +
+ " ^^^^^\n" +
+ "yield is a restricted identifier and cannot be used as type name\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 6)\n" +
+ " class yield {\n" +
+ " ^^^^^\n" +
+ "yield is a restricted identifier and cannot be used as type name\n" +
+ "----------\n");
+ }
+ public void testBug547891_06() {
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ String[] testFiles = new String[] {
+ "X.java",
+ "public class X {\n"+
+ " public static void main(String[] args) {\n"+
+ " yield y;\n"+
+ " Zork();\n"+
+ " }\n"+
+ "}\n"+
+ "class yield {\n" +
+ "}\n",
+ };
+ String expectedProblemLog =
+ "----------\n" +
+ "1. WARNING in X.java (at line 3)\n" +
+ " yield y;\n" +
+ " ^^^^^\n" +
+ "yield may be a restricted identifier in future and may be disallowed as a type name\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n" +
+ "3. WARNING in X.java (at line 7)\n" +
+ " class yield {\n" +
+ " ^^^^^\n" +
+ "yield may be a restricted identifier in future and may be disallowed as a type name\n" +
+ "----------\n";
+ this.runNegativeTest(
+ testFiles,
+ expectedProblemLog,
+ null,
+ true,
+ new String[] {""},
+ options);
+ }
+ public void testBug547891_07() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " public static void main(String[] args) {\n"+
+ " yield y = null;\n"+
+ " }\n"+
+ "}\n"+
+ "class yield {\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " yield y = null;\n" +
+ " ^^^^^\n" +
+ "yield is a restricted identifier and cannot be used as type name\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 6)\n" +
+ " class yield {\n" +
+ " ^^^^^\n" +
+ "yield is a restricted identifier and cannot be used as type name\n" +
+ "----------\n");
+ }
+ public void testBug547891_08() {
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ String[] testFiles = new String[] {
+ "X.java",
+ "public class X {\n"+
+ " public static void main(String[] args) {\n"+
+ " yield y = null;\n"+
+ " Zork();\n"+
+ " }\n"+
+ "}\n"+
+ "class yield {\n" +
+ "}\n",
+ };
+ String expectedProblemLog =
+ "----------\n" +
+ "1. WARNING in X.java (at line 3)\n" +
+ " yield y = null;\n" +
+ " ^^^^^\n" +
+ "yield may be a restricted identifier in future and may be disallowed as a type name\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n" +
+ "3. WARNING in X.java (at line 7)\n" +
+ " class yield {\n" +
+ " ^^^^^\n" +
+ "yield may be a restricted identifier in future and may be disallowed as a type name\n" +
+ "----------\n";
+ this.runNegativeTest(
+ testFiles,
+ expectedProblemLog,
+ null,
+ true,
+ new String[] {""},
+ options);
+ } public void testBug547891_09() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " public static void main(String[] args) {\n"+
+ " }\n"+
+ "}\n"+
+ "class yield {\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " class yield {\n" +
+ " ^^^^^\n" +
+ "yield is a restricted identifier and cannot be used as type name\n" +
+ "----------\n");
+ }
+ public void testBug547891_10() {
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ String[] testFiles = new String[] {
+ "X.java",
+ "public class X {\n"+
+ " public static void main(String[] args) {\n"+
+ " Zork();\n"+
+ " }\n"+
+ "}\n"+
+ "class yield {\n" +
+ "}\n",
+ };
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n" +
+ "2. WARNING in X.java (at line 6)\n" +
+ " class yield {\n" +
+ " ^^^^^\n" +
+ "yield may be a restricted identifier in future and may be disallowed as a type name\n" +
+ "----------\n";
+ this.runNegativeTest(
+ testFiles,
+ expectedProblemLog,
+ null,
+ true,
+ new String[] {""},
+ options);
+ }
+ public void testBug547891_11() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " public static void main(String[] args) {\n"+
+ " new yield();\n"+
+ " }\n"+
+ "}\n"+
+ "class yield {\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " new yield();\n" +
+ " ^^^^^\n" +
+ "yield is a restricted identifier and cannot be used as type name\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 6)\n" +
+ " class yield {\n" +
+ " ^^^^^\n" +
+ "yield is a restricted identifier and cannot be used as type name\n" +
+ "----------\n");
+ }
+ public void testBug547891_12() {
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ String[] testFiles = new String[] {
+ "X.java",
+ "public class X {\n"+
+ " public static void main(String[] args) {\n"+
+ " new yield();\n"+
+ " Zork();\n"+
+ " }\n"+
+ "}\n"+
+ "class yield {\n" +
+ "}\n",
+ };
+ String expectedProblemLog =
+ "----------\n" +
+ "1. WARNING in X.java (at line 3)\n" +
+ " new yield();\n" +
+ " ^^^^^\n" +
+ "yield may be a restricted identifier in future and may be disallowed as a type name\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n" +
+ "3. WARNING in X.java (at line 7)\n" +
+ " class yield {\n" +
+ " ^^^^^\n" +
+ "yield may be a restricted identifier in future and may be disallowed as a type name\n" +
+ "----------\n";
+ this.runNegativeTest(
+ testFiles,
+ expectedProblemLog,
+ null,
+ true,
+ new String[] {""},
+ options);
+ }
+ public void testBug547891_13() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " public static void main(String[] args) {\n"+
+ " yield[] y;\n"+
+ " }\n"+
+ "}\n"+
+ "class yield {\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " yield[] y;\n" +
+ " ^^^^^^^\n" +
+ "yield is a restricted identifier and cannot be used as type name\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 6)\n" +
+ " class yield {\n" +
+ " ^^^^^\n" +
+ "yield is a restricted identifier and cannot be used as type name\n" +
+ "----------\n");
+ }
+ public void testBug547891_14() {
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ String[] testFiles = new String[] {
+ "X.java",
+ "public class X {\n"+
+ " public static void main(String[] args) {\n"+
+ " yield[] y;\n"+
+ " Zork();\n"+
+ " }\n"+
+ "}\n"+
+ "class yield {\n" +
+ "}\n",
+ };
+ String expectedProblemLog =
+ "----------\n" +
+ "1. WARNING in X.java (at line 3)\n" +
+ " yield[] y;\n" +
+ " ^^^^^^^\n" +
+ "yield may be a restricted identifier in future and may be disallowed as a type name\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n" +
+ "3. WARNING in X.java (at line 7)\n" +
+ " class yield {\n" +
+ " ^^^^^\n" +
+ "yield may be a restricted identifier in future and may be disallowed as a type name\n" +
+ "----------\n";
+ this.runNegativeTest(
+ testFiles,
+ expectedProblemLog,
+ null,
+ true,
+ new String[] {""},
+ options);
+ }
+ public void testBug547891_15() {
+ if (this.complianceLevel < ClassFileConstants.JDK12)
+ return;
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.WARNING);
+ String message =
+ "----------\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " case 1 -> yield();\n" +
+ " ^^^^^^^\n" +
+ "restricted identifier yield not allowed here - method calls need to be qualified\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 8)\n" +
+ " case 3 -> {yield yield();}\n" +
+ " ^^^^^^^\n" +
+ "restricted identifier yield not allowed here - method calls need to be qualified\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 10)\n" +
+ " default -> { yield yield();}\n" +
+ " ^^^^^^^\n" +
+ "restricted identifier yield not allowed here - method calls need to be qualified\n" +
+ "----------\n";
+
+ this.runNegativeTest(new String[] {
+ "X.java",
+ "public class X {\n"+
+ "\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public static int foo(int i) {\n"+
+ " int r = switch(i) {\n"+
+ " case 1 -> yield();\n"+
+ " case 2 -> X.yield();\n"+
+ " case 3 -> {yield yield();}\n"+
+ " case 4 -> {yield X.yield();}\n"+
+ " default -> { yield yield();}\n"+
+ " };\n"+
+ " return r;\n"+
+ " }\n"+
+ " public static int yield() {\n"+
+ " return 0;\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(X.foo(0));\n"+
+ " }\n"+
+ "}\n"
+ },
+ message,
+ null,
+ true,
+ new String[] { "--enable-preview"},
+ options);
+ }
+ public void testBug547891_16() {
+ if (this.complianceLevel < ClassFileConstants.JDK12)
+ return;
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.WARNING);
+ String message =
+ "----------\n" +
+ "1. ERROR in X.java (at line 9)\n" +
+ " case 3 -> {yield yield();}\n" +
+ " ^^^^^^^\n" +
+ "restricted identifier yield not allowed here - method calls need to be qualified\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 11)\n" +
+ " default -> { yield yield();}\n" +
+ " ^^^^^^^\n" +
+ "restricted identifier yield not allowed here - method calls need to be qualified\n" +
+ "----------\n";
+
+ this.runNegativeTest(new String[] {
+ "X.java",
+ "public class X {\n"+
+ "\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public int foo(int i) {\n"+
+ " X x = new X();\n"+
+ " int r = switch(i) {\n"+
+ " case 1 -> this.yield();\n"+
+ " case 2 -> x.new Y().yield();\n"+
+ " case 3 -> {yield yield();}\n"+
+ " case 4 -> {yield new X().yield() + x.new Y().yield();}\n"+
+ " default -> { yield yield();}\n"+
+ " };\n"+
+ " return r;\n"+
+ " }\n"+
+ " public int yield() {\n"+
+ " return 0;\n"+
+ " }\n"+
+ " class Y {\n"+
+ " public int yield() {\n"+
+ " return 0;\n"+
+ " } \n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(new X().foo(0));\n"+
+ " }\n"+
+ "}\n"
+ },
+ message,
+ null,
+ true,
+ new String[] { "--enable-preview"},
+ options);
+ }
+ public void testBug547891_17() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ "\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public static int foo(int i) {\n"+
+ " int yield = 100;\n"+
+ " int r = switch(i) {\n"+
+ " default -> yield - 1;\n"+
+ " };\n"+
+ " return r;\n"+
+ " }\n"+
+ " public int yield() {\n"+
+ " return 0;\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(X.foo(0));\n"+
+ " }\n"+
+ "}"
+ },
+ "99");
+ }
+ public void testBug547891_18() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ "\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public static int foo(int i) {\n"+
+ " int yield = 100;\n"+
+ " int r = switch(i) {\n"+
+ " default -> {yield - 1;}\n"+
+ " };\n"+
+ " return r;\n"+
+ " }\n"+
+ " public int yield() {\n"+
+ " return 0;\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(X.foo(0));\n"+
+ " }\n"+
+ "}"
+ },
+ "-1");
+ }
+ public void testBug547891_19() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " static int yield = 100;\n"+
+ "\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public static int foo(int i) {\n"+
+ " int r = switch(i) {\n"+
+ " default -> yield - 1;\n"+
+ " };\n"+
+ " return r;\n"+
+ " }\n"+
+ " public int yield() {\n"+
+ " return 0;\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(X.foo(0));\n"+
+ " }\n"+
+ "}"
+ },
+ "99");
+ }
+ public void testBug547891_20() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " static int yield = 100;\n"+
+ "\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public static int foo(int i) {\n"+
+ " int r = switch(i) {\n"+
+ " default -> {yield - 1;}\n"+
+ " };\n"+
+ " return r;\n"+
+ " }\n"+
+ " public int yield() {\n"+
+ " return 0;\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(X.foo(0));\n"+
+ " }\n"+
+ "}"
+ },
+ "-1");
+ }
+ public void testBug547891_21() {
+ if (this.complianceLevel < ClassFileConstants.JDK12)
+ return;
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.WARNING);
+ String message =
+ "----------\n" +
+ "1. ERROR in X.java (at line 7)\n" +
+ " default -> yield - 1;\n" +
+ " ^^^^^\n" +
+ "Cannot make a static reference to the non-static field yield\n" +
+ "----------\n";
+
+ this.runNegativeTest(new String[] {
+ "X.java",
+ "public class X {\n"+
+ " int yield = 100;\n"+
+ "\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public static int foo(int i) {\n"+
+ " int r = switch(i) {\n"+
+ " default -> yield - 1;\n"+
+ " };\n"+
+ " return r;\n"+
+ " }\n"+
+ " public int yield() {\n"+
+ " return 0;\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(X.foo(0));\n"+
+ " }\n"+
+ "}"
+ },
+ message,
+ null,
+ true,
+ new String[] { "--enable-preview"},
+ options);
+ }
+ public void testBug547891_22() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ "\n"+
+ " static int yield = 100;\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public static int foo(int i) {\n"+
+ " int r = switch(i) {\n"+
+ " default -> X.yield();\n"+
+ " };\n"+
+ " return r;\n"+
+ " }\n"+
+ " public static int yield() {\n"+
+ " yield: while (X.yield == 100) {\n"+
+ " yield = 256;\n"+
+ " break yield;\n"+
+ " }\n"+
+ " return yield;\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(X.foo(0));\n"+
+ " }\n"+
+ "}\n"
+ },
+ "256");
+ }
+ public void testBug547891_23() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ "\n"+
+ " static int yield =100 ;\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public static int foo(int i) {\n"+
+ " int r = switch(i) {\n"+
+ " default -> X.yield();\n"+
+ " };\n"+
+ " return r;\n"+
+ " }\n"+
+ " public static int yield() {\n"+
+ " int yield = 500 ;\n"+
+ " yield: while (yield == 500) {\n"+
+ " yield = 1024;\n"+
+ " break yield;\n"+
+ " }\n"+
+ " return yield;\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(X.foo(0));\n"+
+ " }\n"+
+ "}\n"
+ },
+ "1024");
+ }
+ public void testBug547891_24() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ "\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public static int foo(int i) {\n"+
+ " int yield = 100;\n"+
+ " int r = switch(i) {\n"+
+ " default -> {yield yield + 1;}\n"+
+ " };\n"+
+ " return r;\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(X.foo(0));\n"+
+ " }\n"+
+ "}"
+ },
+ "101");
+ }
+ public void testBug547891_25() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ "\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public static int foo(int i) {\n"+
+ " int yield = 100;\n"+
+ " int r = switch(i) {\n"+
+ " default -> {yield yield + yield + yield * yield;}\n"+
+ " };\n"+
+ " return r;\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(X.foo(0));\n"+
+ " }\n"+
+ "}"
+ },
+ "10200");
+ }
+ public void testBug547891_26() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ "\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public static int foo(int i) {\n"+
+ " int yield = 100;\n"+
+ " int r = switch(i) {\n"+
+ " default -> {yield + yield + yield + yield * yield;}\n"+
+ " };\n"+
+ " return r;\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(X.foo(0));\n"+
+ " }\n"+
+ "}"
+ },
+ "10200");
+ }
+ public void testBug547891_27() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ "\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public static int foo(int i) {\n"+
+ " int yield = 100;\n"+
+ " int r = switch(i) {\n"+
+ " default ->0 + yield + 10;\n"+
+ " };\n"+
+ " return r;\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(X.foo(0));\n"+
+ " }\n"+
+ "}"
+ },
+ "110");
+ }
+ public void testBug547891_28() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public static int foo(int i) {\n"+
+ " int yield = 100;\n"+
+ " int r = switch(i) {\n"+
+ " case 0 : yield 100;\n"+
+ " case 1 : yield yield;\n"+
+ " default: yield 0;\n"+
+ " };\n"+
+ " return r;\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(X.foo(0));\n"+
+ " }\n"+
+ "}"
+ },
+ "100");
+ }
+ public void testBug547891_29() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public static int foo(int i) {\n"+
+ " int yield = 100;\n"+
+ " int r = switch(i) {\n"+
+ " case 0 : yield 100;\n"+
+ " case 1 : yield yield;\n"+
+ " default: yield 0;\n"+
+ " };\n"+
+ " return r > 100 ? yield + 1 : yield + 200;\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(X.foo(0));\n"+
+ " }\n"+
+ "}"
+ },
+ "300");
+ }
+ public void testBug550354_01() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " @SuppressWarnings({ \"preview\" })\n"+
+ " public static int foo(int i) throws Exception {\n"+
+ " int v = switch (i) {\n"+
+ " default -> {if (i > 0) yield 1;\n"+
+ " else yield 2;}\n"+
+ " };\n"+
+ " return v;\n"+
+ " }\n"+
+ " public static void main(String argv[]) throws Exception {\n"+
+ " System.out.println(X.foo(1));\n"+
+ " }\n"+
+ "}"
+ },
+ "1");
+ }
+ public void testBug548418_01() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " @SuppressWarnings({ \"preview\", \"unused\" })\n"+
+ " public static void main(String[] args) {\n"+
+ " int day =10;\n"+
+ " int i = switch (day) {\n"+
+ " default -> {\n"+
+ " for(int j = 0; j < 3; j++) {\n"+
+ " yield 99;\n"+
+ " }\n"+
+ " yield 0;\n"+
+ " }\n"+
+ " };\n"+
+ " System.out.println(i);\n"+
+ " }\n"+
+ "}\n"
+ },
+ "99");
+ }
+ public void testBug550853_01() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " @SuppressWarnings({ \"preview\" })\n"+
+ " public static int foo(int i) throws Exception {\n"+
+ " int v = switch (i) {\n"+
+ " default : {yield switch (i) {\n"+
+ " default -> { yield 0; } \n"+
+ " };\n"+
+ " }\n"+
+ " };\n"+
+ " return v;\n"+
+ " }\n"+
+ " public static void main(String argv[]) throws Exception {\n"+
+ " System.out.println(X.foo(1));\n"+
+ " }\n"+
+ "}\n"
+ },
+ "0");
+ }
+ public void testBug550861_01() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " @SuppressWarnings({ \"preview\" })\n"+
+ " public static void foo(int i) throws Exception {\n"+
+ " System.out.println(switch(0) {\n"+
+ " default -> {\n"+
+ " do yield 1; while(false);\n"+
+ " }\n"+
+ " });\n"+
+ " }\n"+
+ " public static void main(String argv[]) throws Exception {\n"+
+ " X.foo(1);\n"+
+ " }\n"+
+ "}\n"
+ },
+ "1");
+ }
+ public void testBug551030a() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " @SuppressWarnings(\"nls\")\n" +
+ " static final String MONDAY = \"MONDAY\";\n" +
+ " public static void main(String[] args) {\n" +
+ " int num = switch (day) {\n" +
+ " case MONDAY: \n" +
+ " // Nothing\n" +
+ " default:\n" +
+ " yield \"; \n" +
+ " }; \n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 9)\n" +
+ " yield \"; \n" +
+ " ^^^^^^^\n" +
+ "String literal is not properly closed by a double-quote\n" +
+ "----------\n");
+ }
+ public void testBug551030b() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " @SuppressWarnings(\"nls\")\n" +
+ " static final String MONDAY = \"MONDAY\";\n" +
+ " public static void main(String[] args) {\n" +
+ " int num = switch (day) {\n" +
+ " case MONDAY: \n" +
+ " // Nothing\n" +
+ " default:\n" +
+ " yield \"\"\"; \n" +
+ " }; \n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 9)\n" +
+ " yield \"\"\"; \n" +
+ " ^^^^^^^\n" +
+ "String literal is not properly closed by a double-quote\n" +
+ "----------\n");
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchTest.java
index 004768ede2..cfe6b0ddb0 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchTest.java
@@ -3114,7 +3114,7 @@ public void testBug545518() {
"1. ERROR in X.java (at line 5)\n" +
" case \"ABC\", (false ? (String) \"c\" : (String) \"d\") : break;\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
- "The preview feature Multi constant case is only available with source level 12 and above\n" +
+ "The preview feature Multi constant case is only available with source level 13 and above\n" +
"----------\n";
this.runNegativeTest(new String[] {
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java
index 0fd2a6bf58..bfa912989a 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java
@@ -184,6 +184,11 @@ public static Test suite() {
since_12.add(SwitchExpressionTest.class);
since_12.add(Unicode11Test.class);
+ // add 13 specific test here (check duplicates)
+ ArrayList since_13 = new ArrayList();
+ since_13.add(SwitchExpressionsYieldTest.class);
+ since_13.add(Unicode12_1Test.class);
+
// Build final test suite
TestSuite all = new TestSuite(TestAll.class.getName());
all.addTest(new TestSuite(StandAloneASTParserTest.class));
@@ -295,6 +300,21 @@ public static Test suite() {
TestCase.resetForgottenFilters(tests_12);
all.addTest(AbstractCompilerTest.buildComplianceTestSuite(ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_12), tests_12));
}
+ if ((possibleComplianceLevels & AbstractCompilerTest.F_13) != 0) {
+ ArrayList tests_13 = (ArrayList)standardTests.clone();
+ tests_13.addAll(since_1_4);
+ tests_13.addAll(since_1_5);
+ tests_13.addAll(since_1_6);
+ tests_13.addAll(since_1_7);
+ tests_13.addAll(since_1_8);
+ tests_13.addAll(since_9);
+ tests_13.addAll(since_10);
+ tests_13.addAll(since_11);
+ tests_13.addAll(since_12);
+ tests_13.addAll(since_13);
+ TestCase.resetForgottenFilters(tests_13);
+ all.addTest(AbstractCompilerTest.buildComplianceTestSuite(ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_13), tests_13));
+ }
all.addTest(new TestSuite(Jsr14Test.class));
return all;
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Unicode12_1Test.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Unicode12_1Test.java
new file mode 100644
index 0000000000..11f4a39819
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Unicode12_1Test.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2019 IBM Corporation and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.compiler.regression;
+
+import java.util.Map;
+
+import junit.framework.Test;
+
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+
+public class Unicode12_1Test extends AbstractRegressionTest {
+public Unicode12_1Test(String name) {
+ super(name);
+}
+public static Test suite() {
+ return buildMinimalComplianceTestSuite(testClass(), F_13);
+}
+public void test1() {
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_13);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public int a\\uA7BA; // new unicode character in unicode 12.0 \n" +
+ "}",
+ },
+ "",
+ options);
+}
+public void test2() {
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_12);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public int a\\uA7BA; // new unicode character in unicode 12.0 \n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " public int a\\uA7BA; // new unicode character in unicode 12.0 \n" +
+ " ^^^^^^\n" +
+ "Syntax error on token \"Invalid Character\", delete this token\n" +
+ "----------\n",
+ null,
+ true,
+ options);
+}
+public static Class<Unicode12_1Test> testClass() {
+ return Unicode12_1Test.class;
+}
+}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/dom/StandAloneASTParserTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/dom/StandAloneASTParserTest.java
index 170bb63642..5aac8b39e0 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/dom/StandAloneASTParserTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/dom/StandAloneASTParserTest.java
@@ -32,7 +32,6 @@ import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.ASTParser;
import org.eclipse.jdt.core.dom.Block;
-import org.eclipse.jdt.core.dom.BreakStatement;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.Expression;
import org.eclipse.jdt.core.dom.ExpressionStatement;
@@ -55,6 +54,7 @@ import org.eclipse.jdt.core.dom.Type;
import org.eclipse.jdt.core.dom.TypeDeclaration;
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
import org.eclipse.jdt.core.dom.VariableDeclarationStatement;
+import org.eclipse.jdt.core.dom.YieldStatement;
import org.eclipse.jdt.core.tests.compiler.regression.AbstractRegressionTest;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
@@ -64,7 +64,7 @@ public class StandAloneASTParserTest extends AbstractRegressionTest {
super(name);
}
- private static final int AST_JLS_LATEST = AST.JLS12;
+ private static final int AST_JLS_LATEST = AST.JLS13;
public ASTNode runConversion(
int astLevel,
@@ -1591,7 +1591,7 @@ public class StandAloneASTParserTest extends AbstractRegressionTest {
super.acceptAST(sourceFilePath, ast);
}
};
- ASTParser parser = ASTParser.newParser(AST.JLS11);
+ ASTParser parser = ASTParser.newParser(AST_JLS_LATEST);
parser.setResolveBindings(true);
parser.setStatementsRecovery(true);
parser.setBindingsRecovery(true);
@@ -1622,7 +1622,7 @@ public class StandAloneASTParserTest extends AbstractRegressionTest {
" for (var i = 0; i < 10; ++i) {}\n" +
" }\n" +
"}";
- ASTParser parser = ASTParser.newParser(AST.JLS11);
+ ASTParser parser = ASTParser.newParser(AST_JLS_LATEST);
parser.setSource(contents.toCharArray());
parser.setStatementsRecovery(true);
parser.setBindingsRecovery(true);
@@ -1758,6 +1758,7 @@ public class StandAloneASTParserTest extends AbstractRegressionTest {
SimpleName simpleName = (SimpleName) name;
assertFalse("A var", simpleName.isVar());
}
+ @Deprecated
public void testBug545383_01() throws JavaModelException {
String contents =
"class X {\n"+
@@ -1785,14 +1786,44 @@ public class StandAloneASTParserTest extends AbstractRegressionTest {
ASTNode node = parser.createAST(null);
assertTrue("Should be a compilation unit", node instanceof CompilationUnit);
CompilationUnit cu = (CompilationUnit) node;
+ IProblem[] problems = cu.getProblems();
+ assertTrue(problems.length > 0);
+ assertTrue(problems[0].toString().contains("preview"));
+ }
+ public void testBug547900_01() throws JavaModelException {
+ String contents =
+ "class X {\n"+
+ " public static int foo(int i) {\n"+
+ " int result = switch (i) {\n"+
+ " case 1 -> {yield 5;}\n"+
+ " default -> 0;\n"+
+ " };\n"+
+ " return result;\n"+
+ " }\n"+
+ "}\n";
+
+ ASTParser parser = ASTParser.newParser(AST_JLS_LATEST);
+ parser.setSource(contents.toCharArray());
+ parser.setEnvironment(null, null, null, true);
+ parser.setResolveBindings(false);
+ Map<String, String> options = getCompilerOptions();
+ options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_13);
+ options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_13);
+ options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_13);
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
+ parser.setCompilerOptions(options);
+
+ ASTNode node = parser.createAST(null);
+ assertTrue("Should be a compilation unit", node instanceof CompilationUnit);
+ CompilationUnit cu = (CompilationUnit) node;
TypeDeclaration typeDeclaration = (TypeDeclaration) cu.types().get(0);
MethodDeclaration[] methods = typeDeclaration.getMethods();
MethodDeclaration methodDeclaration = methods[0];
VariableDeclarationStatement stmt = (VariableDeclarationStatement) methodDeclaration.getBody().statements().get(0);
VariableDeclarationFragment fragment = (VariableDeclarationFragment) stmt.fragments().get(0);
SwitchExpression se = (SwitchExpression) fragment.getInitializer();
- BreakStatement breakStatement = (BreakStatement) ((Block)se.statements().get(1)).statements().get(0);
- assertNull("Unexpected Non null label", breakStatement.getLabel());
- assertNotNull("Expression null", breakStatement.getExpression());
+ YieldStatement yieldStatement = (YieldStatement) ((Block)se.statements().get(1)).statements().get(0);
+ assertNotNull("Expression null", yieldStatement.getExpression());
}
} \ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/StandardVMLauncher.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/StandardVMLauncher.java
index 80eecdce87..433f8bf239 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/StandardVMLauncher.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/StandardVMLauncher.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -112,8 +112,10 @@ public String[] getCommandLine() {
long vmVersion = Util.getMajorMinorVMVersion();
if (vmVersion != -1) {
- if (vmVersion >= ClassFileConstants.JDK1_6) {
+ if (vmVersion < ClassFileConstants.JDK13) { // FailOverToOldVerifier deprecated from 13
commandLine.addElement("-XX:-FailOverToOldVerifier");
+ }
+ if (vmVersion >= ClassFileConstants.JDK1_6) {
commandLine.addElement("-Xverify:all");
}
if (vmVersion >= ClassFileConstants.JDK1_7) {
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/AbstractCompilerTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/AbstractCompilerTest.java
index ace9a6a75a..e64a3878f8 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/AbstractCompilerTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/AbstractCompilerTest.java
@@ -44,6 +44,7 @@ public class AbstractCompilerTest extends TestCase {
public static final int F_10 = 0x80;
public static final int F_11 = 0x100;
public static final int F_12 = 0x200;
+ public static final int F_13 = 0x400;
public static final boolean RUN_JAVAC = CompilerOptions.ENABLED.equals(System.getProperty("run.javac"));
private static final int UNINITIALIZED = -1;
@@ -55,6 +56,7 @@ public class AbstractCompilerTest extends TestCase {
protected static boolean isJRE9Plus = false; // Stop gap, so tests need not be run at 9, but some tests can be adjusted for JRE 9
protected static boolean isJRE11Plus = false;
protected static boolean isJRE12Plus = false;
+ protected static boolean isJRE13Plus = false;
protected static boolean reflectNestedClassUseDollar;
/**
@@ -102,6 +104,9 @@ public class AbstractCompilerTest extends TestCase {
if ((complianceLevels & AbstractCompilerTest.F_12) != 0) {
suite.addTest(buildUniqueComplianceTestSuite(evaluationTestClass, ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_12)));
}
+ if ((complianceLevels & AbstractCompilerTest.F_13) != 0) {
+ suite.addTest(buildUniqueComplianceTestSuite(evaluationTestClass, ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_13)));
+ }
}
/**
@@ -147,6 +152,9 @@ public class AbstractCompilerTest extends TestCase {
if ((complianceLevels & AbstractCompilerTest.F_12) != 0) {
suite.addTest(buildComplianceTestSuite(testClasses, setupClass, ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_12)));
}
+ if ((complianceLevels & AbstractCompilerTest.F_13) != 0) {
+ suite.addTest(buildComplianceTestSuite(testClasses, setupClass, ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_13)));
+ }
return suite;
}
@@ -154,8 +162,9 @@ public class AbstractCompilerTest extends TestCase {
possibleComplianceLevels = complianceLevel;
int lessthan9 = F_1_3 | F_1_4 | F_1_5 | F_1_6 | F_1_7 | F_1_8;
isJRE9Plus = !isJRELevel(lessthan9);
- isJRE11Plus = isJRELevel(F_11);
- isJRE12Plus = isJRELevel(F_12);
+ isJRE13Plus = isJRELevel(F_13);
+ isJRE12Plus = isJRE13Plus || isJRELevel(F_12);
+ isJRE11Plus = isJRE12Plus || isJRELevel(F_11);
}
/**
@@ -306,6 +315,14 @@ public class AbstractCompilerTest extends TestCase {
suite.addTest(buildUniqueComplianceTestSuite(evaluationTestClass, ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_12)));
}
}
+ int level_13 = complianceLevels & AbstractCompilerTest.F_13;
+ if (level_13 != 0) {
+ if (level_13 < minimalCompliance) {
+ System.err.println("Cannot run "+evaluationTestClass.getName()+" at compliance 13!");
+ } else {
+ suite.addTest(buildUniqueComplianceTestSuite(evaluationTestClass, ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_13)));
+ }
+ }
return suite;
}
@@ -364,6 +381,9 @@ public class AbstractCompilerTest extends TestCase {
*/
public static long highestComplianceLevels() {
int complianceLevels = AbstractCompilerTest.getPossibleComplianceLevels();
+ if ((complianceLevels & AbstractCompilerTest.F_13) != 0) {
+ return ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_13);
+ }
if ((complianceLevels & AbstractCompilerTest.F_12) != 0) {
return ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_12);
}
@@ -420,7 +440,8 @@ public class AbstractCompilerTest extends TestCase {
public static int getPossibleComplianceLevels() {
if (possibleComplianceLevels == UNINITIALIZED) {
String specVersion = System.getProperty("java.specification.version");
- isJRE12Plus = CompilerOptions.VERSION_12.equals(specVersion);
+ isJRE13Plus = CompilerOptions.VERSION_13.equals(specVersion);
+ isJRE12Plus = isJRE13Plus || CompilerOptions.VERSION_12.equals(specVersion);
isJRE11Plus = isJRE12Plus || CompilerOptions.VERSION_11.equals(specVersion);
isJRE9Plus = isJRE11Plus || CompilerOptions.VERSION_9.equals(specVersion)
|| CompilerOptions.VERSION_10.equals(specVersion);
@@ -449,6 +470,8 @@ public class AbstractCompilerTest extends TestCase {
possibleComplianceLevels |= F_11;
} else if (CompilerOptions.VERSION_12.equals(compliance)) {
possibleComplianceLevels |= F_12;
+ } else if (CompilerOptions.VERSION_13.equals(compliance)) {
+ possibleComplianceLevels |= F_13;
} else {
System.out.println("Ignoring invalid compliance (" + compliance + ")");
System.out.print("Use one of ");
@@ -462,7 +485,8 @@ public class AbstractCompilerTest extends TestCase {
System.out.print(CompilerOptions.VERSION_9 + ", ");
System.out.print(CompilerOptions.VERSION_10 + ", ");
System.out.print(CompilerOptions.VERSION_11 + ", ");
- System.out.println(CompilerOptions.VERSION_12);
+ System.out.print(CompilerOptions.VERSION_12 + ", ");
+ System.out.println(CompilerOptions.VERSION_13);
}
}
if (possibleComplianceLevels == 0) {
@@ -512,6 +536,10 @@ public class AbstractCompilerTest extends TestCase {
if (canRun12) {
possibleComplianceLevels |= F_12;
}
+ boolean canRun13 = canRun12 && !CompilerOptions.VERSION_12.equals(specVersion);
+ if (canRun13) {
+ possibleComplianceLevels |= F_13;
+ }
} else if ("1.0".equals(specVersion)
|| CompilerOptions.VERSION_1_1.equals(specVersion)
|| CompilerOptions.VERSION_1_2.equals(specVersion)
@@ -534,6 +562,9 @@ public class AbstractCompilerTest extends TestCase {
possibleComplianceLevels |= F_11;
if (!CompilerOptions.VERSION_11.equals(specVersion)) {
possibleComplianceLevels |= F_12;
+ if (!CompilerOptions.VERSION_12.equals(specVersion)) {
+ possibleComplianceLevels |= F_13;
+ }
}
}
}
@@ -709,7 +740,7 @@ public class AbstractCompilerTest extends TestCase {
}
protected static String getVersionString(long compliance) {
- String version = "version 11 : 55.0";
+ String version = "version 13 : 57.0";
if (compliance < ClassFileConstants.JDK9) return "version 1.8 : 52.0";
if (compliance == ClassFileConstants.JDK9) return "version 9 : 53.0";
if (compliance == ClassFileConstants.JDK10) return "version 10 : 54.0";
@@ -718,7 +749,7 @@ public class AbstractCompilerTest extends TestCase {
int major = Integer.parseInt(ver) + ClassFileConstants.MAJOR_VERSION_0;
return "version " + ver + " : " + major + ".0";
}
- if (compliance >= ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_11)) return version; // keep this stmt for search for next bump up
+ if (compliance >= ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_13)) return version; // keep this stmt for search for next bump up
return version;
}
diff --git a/org.eclipse.jdt.core.tests.model/JCL/jclMin13.jar b/org.eclipse.jdt.core.tests.model/JCL/jclMin13.jar
new file mode 100644
index 0000000000..0f621d1524
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/JCL/jclMin13.jar
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.model/JCL/jclMin13src.zip b/org.eclipse.jdt.core.tests.model/JCL/jclMin13src.zip
new file mode 100644
index 0000000000..bf05b46301
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/JCL/jclMin13src.zip
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.model/pom.xml b/org.eclipse.jdt.core.tests.model/pom.xml
index 030204fa49..908e76d739 100644
--- a/org.eclipse.jdt.core.tests.model/pom.xml
+++ b/org.eclipse.jdt.core.tests.model/pom.xml
@@ -170,6 +170,37 @@
<tycho.surefire.argLine>--add-modules ALL-SYSTEM -Dcompliance=1.4,1.7,1.8,12</tycho.surefire.argLine>
</properties>
</profile>
+ <profile>
+ <id>test-on-javase-13</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-toolchains-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+ <execution>
+ <phase>validate</phase>
+ <goals>
+ <goal>toolchain</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <toolchains>
+ <jdk>
+ <id>JavaSE-13</id>
+ </jdk>
+ </toolchains>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <properties>
+ <!-- Overridden in https://ci.eclipse.org/jdt/job/eclipse.jdt.core-run.javac-13/configure -->
+ <tycho.surefire.argLine>--add-modules ALL-SYSTEM -Dcompliance=1.4,1.7,1.8,13</tycho.surefire.argLine>
+ </properties>
+ </profile>
</profiles>
</project>
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/RunAllJava12Tests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/RunAllJava12Tests.java
index eabf761ddc..ee41a3566d 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/RunAllJava12Tests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/RunAllJava12Tests.java
@@ -15,7 +15,6 @@ package org.eclipse.jdt.core.tests;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-import org.eclipse.jdt.core.tests.dom.ASTConverter12Test;
import org.eclipse.jdt.core.tests.dom.ConverterTestSetup;
import org.eclipse.jdt.core.tests.util.AbstractCompilerTest;
@@ -35,12 +34,6 @@ public class RunAllJava12Tests extends TestCase {
};
}
- public static Class[] getConverterTestClasses() {
- return new Class[] {
- ASTConverter12Test.class,
- };
- }
-
public static Class[] getCompilerClasses() {
return new Class[] {
org.eclipse.jdt.core.tests.eval.TestAll.class,
@@ -53,8 +46,6 @@ public class RunAllJava12Tests extends TestCase {
Class[] testClasses = getAllTestClasses();
addTestsToSuite(ts, testClasses);
- testClasses = getConverterTestClasses();
- addTestsToSuite(ts, testClasses);
AbstractCompilerTest.setpossibleComplianceLevels(AbstractCompilerTest.F_11);
addTestsToSuite(ts, getCompilerClasses());
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/RunAllJava13Tests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/RunAllJava13Tests.java
new file mode 100644
index 0000000000..bb3a1cf65c
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/RunAllJava13Tests.java
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2019 IBM Corporation and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.eclipse.jdt.core.tests.compiler.parser.ComplianceDiagnoseTest;
+import org.eclipse.jdt.core.tests.compiler.regression.SwitchExpressionsYieldTest;
+import org.eclipse.jdt.core.tests.dom.ASTConverter13Test;
+import org.eclipse.jdt.core.tests.dom.ConverterTestSetup;
+import org.eclipse.jdt.core.tests.model.JavaSearchBugs13Tests;
+import org.eclipse.jdt.core.tests.rewrite.describing.ASTRewritingTest;
+import org.eclipse.jdt.core.tests.util.AbstractCompilerTest;
+
+@SuppressWarnings({"rawtypes", "unchecked"})
+public class RunAllJava13Tests extends TestCase {
+
+ public RunAllJava13Tests(String name) {
+ super(name);
+ }
+ public static Class[] getAllTestClasses() {
+ return new Class[] {
+ JavaSearchBugs13Tests.class,
+ ComplianceDiagnoseTest.class,
+ SwitchExpressionsYieldTest.class,
+ org.eclipse.jdt.compiler.apt.tests.AllTests.class,
+ };
+ }
+
+ public static Class[] getConverterTestClasses() {
+ return new Class[] {
+ ASTConverter13Test.class,
+ ASTRewritingTest.class,
+ };
+ }
+
+ public static Class[] getCompilerClasses() {
+ return new Class[] {
+ org.eclipse.jdt.core.tests.eval.TestAll.class,
+ org.eclipse.jdt.core.tests.compiler.regression.TestAll.class,
+ };
+ }
+
+ public static Test suite() {
+ TestSuite ts = new TestSuite(RunAllJava13Tests.class.getName());
+
+ Class[] testClasses = getAllTestClasses();
+ addTestsToSuite(ts, testClasses);
+ testClasses = getConverterTestClasses();
+ addTestsToSuite(ts, testClasses);
+
+ AbstractCompilerTest.setpossibleComplianceLevels(AbstractCompilerTest.F_13);
+ addTestsToSuite(ts, getCompilerClasses());
+ // ComplianceDiagnoseTest is already added to the test suite through getTestSuite
+ ts.addTest(org.eclipse.jdt.core.tests.compiler.parser.TestAll.getTestSuite(false));
+ return ts;
+ }
+ public static void addTestsToSuite(TestSuite suite, Class[] testClasses) {
+
+ for (int i = 0; i < testClasses.length; i++) {
+ Class testClass = testClasses[i];
+ // call the suite() method and add the resulting suite to the suite
+ try {
+ Method suiteMethod = testClass.getDeclaredMethod("suite", new Class[0]); //$NON-NLS-1$
+ Test test = (Test)suiteMethod.invoke(null, new Object[0]);
+ suite.addTest(test);
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ e.getTargetException().printStackTrace();
+ } catch (NoSuchMethodException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ protected void tearDown() throws Exception {
+ ConverterTestSetup.PROJECT_SETUP = false;
+ super.tearDown();
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/RunOnlyJava12Tests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/RunOnlyJava12Tests.java
index 11bc2fa141..c1b0a66394 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/RunOnlyJava12Tests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/RunOnlyJava12Tests.java
@@ -14,10 +14,7 @@ package org.eclipse.jdt.core.tests;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Arrays;
-import org.eclipse.jdt.core.tests.dom.ASTConverter12Test;
import org.eclipse.jdt.core.tests.dom.ConverterTestSetup;
import junit.framework.Test;
@@ -36,19 +33,11 @@ public class RunOnlyJava12Tests extends TestCase {
};
}
- public static Class[] getConverterTestClasses() {
- return new Class[] {
- ASTConverter12Test.class
- };
- }
public static Test suite() {
TestSuite ts = new TestSuite(RunOnlyJava12Tests.class.getName());
Class[] testClasses = getAllTestClasses();
addTestsToSuite(ts, testClasses);
- testClasses = getConverterTestClasses();
- ConverterTestSetup.TEST_SUITES = new ArrayList(Arrays.asList(testClasses));
- addTestsToSuite(ts, testClasses);
return ts;
}
public static void addTestsToSuite(TestSuite suite, Class[] testClasses) {
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/RunOnlyJava13Tests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/RunOnlyJava13Tests.java
new file mode 100644
index 0000000000..e8ef362a92
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/RunOnlyJava13Tests.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2019 IBM Corporation and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import org.eclipse.jdt.core.tests.compiler.regression.SwitchExpressionsYieldTest;
+import org.eclipse.jdt.core.tests.dom.ASTConverter13Test;
+import org.eclipse.jdt.core.tests.dom.ConverterTestSetup;
+import org.eclipse.jdt.core.tests.model.JavaSearchBugs13Tests;
+import org.eclipse.jdt.core.tests.rewrite.describing.ASTRewritingTest;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+@SuppressWarnings({"rawtypes", "unchecked"})
+public class RunOnlyJava13Tests extends TestCase {
+
+ public RunOnlyJava13Tests(String name) {
+ super(name);
+ }
+ public static Class[] getAllTestClasses() {
+ return new Class[] {
+ JavaSearchBugs13Tests.class,
+ SwitchExpressionsYieldTest.class,
+ };
+ }
+
+ public static Class[] getConverterTestClasses() {
+ return new Class[] {
+ ASTConverter13Test.class,
+ ASTRewritingTest.class,
+ };
+ }
+ public static Test suite() {
+ TestSuite ts = new TestSuite(RunOnlyJava13Tests.class.getName());
+
+ Class[] testClasses = getAllTestClasses();
+ addTestsToSuite(ts, testClasses);
+ testClasses = getConverterTestClasses();
+ ConverterTestSetup.TEST_SUITES = new ArrayList(Arrays.asList(testClasses));
+ addTestsToSuite(ts, testClasses);
+ return ts;
+ }
+ public static void addTestsToSuite(TestSuite suite, Class[] testClasses) {
+
+ for (int i = 0; i < testClasses.length; i++) {
+ Class testClass = testClasses[i];
+ // call the suite() method and add the resulting suite to the suite
+ try {
+ Method suiteMethod = testClass.getDeclaredMethod("suite", new Class[0]); //$NON-NLS-1$
+ Test test = (Test)suiteMethod.invoke(null, new Object[0]);
+ suite.addTest(test);
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ e.getTargetException().printStackTrace();
+ } catch (NoSuchMethodException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ protected void tearDown() throws Exception {
+ ConverterTestSetup.PROJECT_SETUP = false;
+ super.tearDown();
+ }
+}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter10Test.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter10Test.java
index e3d1479c3e..21285eaed7 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter10Test.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter10Test.java
@@ -34,9 +34,10 @@ public class ASTConverter10Test extends ConverterTestSetup {
// private static final String jcl9lib = "CONVERTER_JCL9_LIB";
+ @SuppressWarnings("deprecation")
public void setUpSuite() throws Exception {
super.setUpSuite();
- this.ast = AST.newAST(AST_INTERNAL_JLS11, true);
+ this.ast = AST.newAST(AST_INTERNAL_JLS10);
}
public ASTConverter10Test(String name) {
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter11Test.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter11Test.java
index 1da181839d..8279e0b7e7 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter11Test.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter11Test.java
@@ -24,6 +24,7 @@ public class ASTConverter11Test extends ConverterTestSetup {
ICompilationUnit workingCopy;
+ @SuppressWarnings("deprecation")
public void setUpSuite() throws Exception {
super.setUpSuite();
this.ast = AST.newAST(AST_INTERNAL_JLS11, true);
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter12Test.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter13Test.java
index 9751f23fe5..867723c0b6 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter12Test.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter13Test.java
@@ -7,47 +7,55 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *Contributors:
+ * Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.core.tests.dom;
import java.util.List;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.ASTNode;
+import org.eclipse.jdt.core.dom.ASTParser;
import org.eclipse.jdt.core.dom.Block;
import org.eclipse.jdt.core.dom.BreakStatement;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.Expression;
import org.eclipse.jdt.core.dom.IBinding;
+import org.eclipse.jdt.core.dom.ITypeBinding;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.SimpleName;
import org.eclipse.jdt.core.dom.Statement;
import org.eclipse.jdt.core.dom.SwitchCase;
import org.eclipse.jdt.core.dom.SwitchExpression;
import org.eclipse.jdt.core.dom.SwitchStatement;
+import org.eclipse.jdt.core.dom.TextBlock;
import org.eclipse.jdt.core.dom.Type;
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
import org.eclipse.jdt.core.dom.VariableDeclarationStatement;
+import org.eclipse.jdt.core.dom.YieldStatement;
+import junit.framework.AssertionFailedError;
import junit.framework.Test;
@SuppressWarnings("rawtypes")
-public class ASTConverter12Test extends ConverterTestSetup {
+public class ASTConverter13Test extends ConverterTestSetup {
ICompilationUnit workingCopy;
+ private static final String jclLib = "CONVERTER_JCL9_LIB";
public void setUpSuite() throws Exception {
super.setUpSuite();
- this.ast = AST.newAST(getAST12(), true);
+ this.ast = AST.newAST(getAST13(), false);
}
- public ASTConverter12Test(String name) {
+ public ASTConverter13Test(String name) {
super(name);
}
@@ -57,11 +65,11 @@ public class ASTConverter12Test extends ConverterTestSetup {
// TESTS_NAMES = new String[] {"test0001"};
}
public static Test suite() {
- return buildModelTestSuite(ASTConverter12Test.class);
+ return buildModelTestSuite(ASTConverter13Test.class);
}
- static int getAST12() {
- return AST.JLS12;
+ static int getAST13() {
+ return AST.JLS13;
}
protected void tearDown() throws Exception {
super.tearDown();
@@ -87,15 +95,15 @@ public class ASTConverter12Test extends ConverterTestSetup {
" case MONDAY -> throw new NullPointerException();\n" +
" case TUESDAY -> 1;\n" +
"\n" +
- " case WEDNESDAY -> {break 10;}\n" +
+ " case WEDNESDAY -> {yield 10;}\n" +
" default -> {\n" +
" int g = day.toString().length();\n" +
- " break g;\n" +
+ " yield g;\n" +
" }};\n" +
" System.out.println(k);\n" +
" }\n" +
"}" ;
- this.workingCopy = getWorkingCopy("/Converter12/src/X.java", true/*resolve*/);
+ this.workingCopy = getWorkingCopy("/Converter13/src/X.java", true/*resolve*/);
IJavaProject javaProject = this.workingCopy.getJavaProject();
String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
try {
@@ -154,7 +162,7 @@ public class ASTConverter12Test extends ConverterTestSetup {
" return today;\n" +
" }\n" +
"}" ;
- this.workingCopy = getWorkingCopy("/Converter12/src/X.java", true/*resolve*/);
+ this.workingCopy = getWorkingCopy("/Converter13/src/X.java", true/*resolve*/);
IJavaProject javaProject = this.workingCopy.getJavaProject();
String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
try {
@@ -199,16 +207,16 @@ public class ASTConverter12Test extends ConverterTestSetup {
" String today = \"\";\n" +
" today = switch (day) {\n" +
" case SATURDAY,SUNDAY:\n" +
- " break \"Weekend day\";\n" +
+ " yield \"Weekend day\";\n" +
" case MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY:\n" +
- " break \"Week day\";\n" +
+ " yield \"Week day\";\n" +
" default:\n" +
- " break \"Any day\";\n" +
+ " yield \"Any day\";\n" +
" };\n" +
" return today;\n" +
" }\n" +
"}" ;
- this.workingCopy = getWorkingCopy("/Converter12/src/X.java", true/*resolve*/);
+ this.workingCopy = getWorkingCopy("/Converter13/src/X.java", true/*resolve*/);
IJavaProject javaProject = this.workingCopy.getJavaProject();
String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
try {
@@ -236,16 +244,16 @@ public class ASTConverter12Test extends ConverterTestSetup {
" String bb(Day day) throws Exception {\n" +
" String today = switch (day) {\n" +
" case SATURDAY,SUNDAY:\n" +
- " break \"Weekend day\";\n" +
+ " yield \"Weekend day\";\n" +
" case MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY:\n" +
- " break \"Week day\";\n" +
+ " yield \"Week day\";\n" +
" default:\n" +
- " break \"Any day\";\n" +
+ " yield \"Any day\";\n" +
" };\n" +
" return today;\n" +
" }\n" +
"}" ;
- this.workingCopy = getWorkingCopy("/Converter12/src/X.java", true/*resolve*/);
+ this.workingCopy = getWorkingCopy("/Converter13/src/X.java", true/*resolve*/);
IJavaProject javaProject = this.workingCopy.getJavaProject();
String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
try {
@@ -271,7 +279,7 @@ public class ASTConverter12Test extends ConverterTestSetup {
assertEquals("incorrect name", "day", ((SimpleName) expression).getFullyQualifiedName());
List statements = ((SwitchExpression) initializer).statements();
assertEquals("incorrect no of statements", 6, statements.size());
- BreakStatement brStmt = (BreakStatement) statements.get(1);
+ YieldStatement brStmt = (YieldStatement) statements.get(1);
Expression expression2 = brStmt.getExpression();
assertNotNull("should not null", expression2);
assertEquals("incorrect node type", ASTNode.STRING_LITERAL, expression2.getNodeType());
@@ -279,7 +287,7 @@ public class ASTConverter12Test extends ConverterTestSetup {
//default case:
SwitchCase caseStmt = (SwitchCase) statements.get(4);
assertTrue("not default", caseStmt.isDefault());
- brStmt = (BreakStatement) statements.get(5);
+ brStmt = (YieldStatement) statements.get(5);
expression2 = brStmt.getExpression();
assertNotNull("should not null", expression2);
assertEquals("incorrect node type", ASTNode.STRING_LITERAL, expression2.getNodeType());
@@ -288,7 +296,8 @@ public class ASTConverter12Test extends ConverterTestSetup {
javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
}
}
- public void test0005() throws JavaModelException {
+ @Deprecated
+ public void _test0005() throws JavaModelException {
String contents =
"public class X {\n" +
" public String test001() {\n" +
@@ -301,7 +310,7 @@ public class ASTConverter12Test extends ConverterTestSetup {
" return ret;\n" +
" }" +
"}" ;
- this.workingCopy = getWorkingCopy("/Converter12/src/X.java", true/*resolve*/);
+ this.workingCopy = getWorkingCopy("/Converter13/src/X.java", true/*resolve*/);
IJavaProject javaProject = this.workingCopy.getJavaProject();
String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
try {
@@ -356,7 +365,7 @@ public class ASTConverter12Test extends ConverterTestSetup {
" return ret;\n" +
" }" +
"}" ;
- this.workingCopy = getWorkingCopy("/Converter12/src/X.java", true/*resolve*/);
+ this.workingCopy = getWorkingCopy("/Converter13/src/X.java", true/*resolve*/);
IJavaProject javaProject = this.workingCopy.getJavaProject();
String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
try {
@@ -388,4 +397,255 @@ public class ASTConverter12Test extends ConverterTestSetup {
javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
}
}
+ // Moved over from ASTConverter9Test
+ public void testBug531714_015() throws CoreException {
+ // saw NPE in SwitchExpression.resolveType(SwitchExpression.java:423)
+ if (!isJRE13) {
+ System.err.println("Test "+getName()+" requires a JRE 13");
+ return;
+ }
+ IJavaProject p = createJavaProject("Foo", new String[] {"src"}, new String[] {jclLib}, "bin", "13"); // FIXME jcl12?
+ p.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
+ p.setOption(JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES, JavaCore.IGNORE);
+ try {
+ String source =
+ "import java.util.*;\n" +
+ "public class X {\n" +
+ " void testForeach1(int i, List<String> list) {\n" +
+ " for (String s : switch(i) { case 1 -> list; default -> ; }) {\n" +
+ " \n" +
+ " }\n" +
+ " Throwable t = switch (i) {\n" +
+ " case 1 -> new Exception();\n" +
+ " case 2 -> new RuntimeException();\n" + // trigger !typeUniformAcrossAllArms
+ " default -> missing;\n" +
+ " };\n" +
+ " }\n" +
+ " void testForeach0(int i, List<String> list) {\n" + // errors in first arm
+ " for (String s : switch(i) { case 1 -> ; default -> list; }) {\n" +
+ " \n" +
+ " }\n" +
+ " Throwable t = switch (i) {\n" +
+ " case 0 -> missing;\n" +
+ " case 1 -> new Exception();\n" +
+ " default -> new RuntimeException();\n" + // trigger !typeUniformAcrossAllArms
+ " };\n" +
+ " }\n" +
+ " void testForeachAll(int i) {\n" + // only erroneous arms
+ " Throwable t = switch (i) {\n" +
+ " case 0 -> missing;\n" +
+ " default -> absent;\n" +
+ " };\n" +
+ " }\n" +
+ "}\n";
+ createFile("Foo/src/X.java", source);
+ ICompilationUnit cuD = getCompilationUnit("/Foo/src/X.java");
+
+ ASTParser parser = ASTParser.newParser(AST_INTERNAL_JLS13);
+ parser.setProject(p);
+ parser.setSource(cuD);
+ parser.setResolveBindings(true);
+ parser.setStatementsRecovery(true);
+ parser.setBindingsRecovery(true);
+ org.eclipse.jdt.core.dom.CompilationUnit cuAST = (org.eclipse.jdt.core.dom.CompilationUnit) parser.createAST(null);
+ IProblem[] problems = cuAST.getProblems();
+ assertProblems("Unexpected problems",
+ "1. ERROR in /Foo/src/X.java (at line 4)\n" +
+ " for (String s : switch(i) { case 1 -> list; default -> ; }) {\n" +
+ " ^^\n" +
+ "Syntax error on token \"->\", Expression expected after this token\n" +
+ "----------\n" +
+ "2. ERROR in /Foo/src/X.java (at line 10)\n" +
+ " default -> missing;\n" +
+ " ^^^^^^^\n" +
+ "missing cannot be resolved to a variable\n" +
+ "----------\n" +
+ "3. ERROR in /Foo/src/X.java (at line 14)\n" +
+ " for (String s : switch(i) { case 1 -> ; default -> list; }) {\n" +
+ " ^^\n" +
+ "Syntax error on token \"->\", Expression expected after this token\n" +
+ "----------\n" +
+ "4. ERROR in /Foo/src/X.java (at line 18)\n" +
+ " case 0 -> missing;\n" +
+ " ^^^^^^^\n" +
+ "missing cannot be resolved to a variable\n" +
+ "----------\n" +
+ "5. ERROR in /Foo/src/X.java (at line 25)\n" +
+ " case 0 -> missing;\n" +
+ " ^^^^^^^\n" +
+ "missing cannot be resolved to a variable\n" +
+ "----------\n" +
+ "6. ERROR in /Foo/src/X.java (at line 26)\n" +
+ " default -> absent;\n" +
+ " ^^^^^^\n" +
+ "absent cannot be resolved to a variable\n" +
+ "----------\n",
+ problems, source.toCharArray());
+ } finally {
+ deleteProject(p);
+ }
+ }
+
+ public void test0007() throws JavaModelException {
+ String contents =
+ "public class X {\n" +
+ " public String test001() {\n" +
+ " String s = \"\"\"\n" +
+ " <html>\n" +
+ " <body>\n" +
+ " <p>Hello, world</p>\n" +
+ " </body>\n" +
+ " </html>\n" +
+ " \"\"\";\n" +
+ " System.out.println(s);" +
+ " return s;\n" +
+ " }" +
+ "}" ;
+ this.workingCopy = getWorkingCopy("/Converter13/src/X.java", true/*resolve*/);
+ IJavaProject javaProject = this.workingCopy.getJavaProject();
+ String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
+ try {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
+ javaProject.setOption(JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES, JavaCore.IGNORE);
+ ASTNode node = buildAST(
+ contents,
+ this.workingCopy);
+ assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType());
+ CompilationUnit compilationUnit = (CompilationUnit) node;
+ assertProblemsSize(compilationUnit, 0);
+ node = getASTNode(compilationUnit, 0, 0, 0);
+ assertEquals("Text block statement", node.getNodeType(), ASTNode.VARIABLE_DECLARATION_STATEMENT);
+ List fragments = ((VariableDeclarationStatement) node).fragments();
+ assertEquals("Incorrect no of fragments", 1, fragments.size());
+ node = (ASTNode) fragments.get(0);
+ assertEquals("Switch statement", node.getNodeType(), ASTNode.VARIABLE_DECLARATION_FRAGMENT);
+ VariableDeclarationFragment fragment = (VariableDeclarationFragment) node;
+ Expression initializer = fragment.getInitializer();
+ assertTrue("Initializer is not a TextBlock", initializer instanceof TextBlock);
+ String escapedValue = ((TextBlock) initializer).getEscapedValue();
+
+ assertTrue("String should not be empty", escapedValue.length() != 0);
+ assertTrue("String should start with \"\"\"", escapedValue.startsWith("\"\"\""));
+
+ } finally {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
+ }
+ }
+ public void test0008() throws JavaModelException {
+ String contents =
+ "public class X {\n" +
+ " public String test001() {\n" +
+ " String s = \"\"\"\n" +
+ " <html>\n" +
+ " <body>\n" +
+ " <p>Hello, world</p>\n" +
+ " </body>\n" +
+ " </html>\n" +
+ " \"\"\";\n" +
+ " System.out.println(s);" +
+ " return s;\n" +
+ " }" +
+ "}" ;
+ this.workingCopy = getWorkingCopy("/Converter13/src/X.java", true/*resolve*/);
+ IJavaProject javaProject = this.workingCopy.getJavaProject();
+ String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
+ try {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.DISABLED);
+ javaProject.setOption(JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES, JavaCore.IGNORE);
+ try {
+ buildAST(
+ contents,
+ this.workingCopy);
+ } catch(UnsupportedOperationException e) {
+ fail("Should not throw UnsupportedOperationException");
+ } catch(AssertionFailedError e) {
+ e.printStackTrace();
+ return;
+ }
+ fail("Compilation should not succeed");
+
+ } finally {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
+ }
+ }
+ public void test0009() throws JavaModelException {
+ String contents =
+ "public class X {\n" +
+ " public String test001() {\n" +
+ " String s = \"\"\"\n" +
+ " <html>\n" +
+ " <body>\n" +
+ " <p>Hello, world</p>\n" +
+ " </body>\n" +
+ " </html>\n" +
+ " \"\"\";\n" +
+ " System.out.println(s);" +
+ " return s;\n" +
+ " }" +
+ "}" ;
+ this.workingCopy = getWorkingCopy("/Converter13/src/X.java", true/*resolve*/);
+ IJavaProject javaProject = this.workingCopy.getJavaProject();
+ String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
+ try {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
+ javaProject.setOption(JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES, JavaCore.IGNORE);
+ ASTNode node = buildAST(
+ contents,
+ this.workingCopy);
+ assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType());
+ CompilationUnit compilationUnit = (CompilationUnit) node;
+ assertProblemsSize(compilationUnit, 0);
+ node = getASTNode(compilationUnit, 0, 0, 0);
+ assertEquals("Text block statement", node.getNodeType(), ASTNode.VARIABLE_DECLARATION_STATEMENT);
+ List fragments = ((VariableDeclarationStatement) node).fragments();
+ assertEquals("Incorrect no of fragments", 1, fragments.size());
+ node = (ASTNode) fragments.get(0);
+ assertEquals("Switch statement", node.getNodeType(), ASTNode.VARIABLE_DECLARATION_FRAGMENT);
+ VariableDeclarationFragment fragment = (VariableDeclarationFragment) node;
+ Expression initializer = fragment.getInitializer();
+ assertTrue("Initializer is not a TextBlock", initializer instanceof TextBlock);
+ ITypeBinding binding = initializer.resolveTypeBinding();
+ assertNotNull("No binding", binding);
+ assertEquals("Wrong qualified name", "java.lang.String", binding.getQualifiedName());
+ } finally {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
+ }
+ }
+ public void test0010() throws JavaModelException {
+ String contents =
+ "public class test13 {\n" +
+ " public static void main(String[] args) {\n" +
+ " String s = \"\"\"\n" +
+ " nadknaks vgvh \n" +
+ " \"\"\";\n" +
+ "\n" +
+ " int m = 10;\n" +
+ " m = m* 6;\n" +
+ " System.out.println(s);\n" +
+ " }\n" +
+ "}" ;
+ this.workingCopy = getWorkingCopy("/Converter13/src/test13.java", true/*resolve*/);
+ IJavaProject javaProject = this.workingCopy.getJavaProject();
+ String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
+ try {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
+ javaProject.setOption(JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES, JavaCore.IGNORE);
+ ASTNode node = buildAST(
+ contents,
+ this.workingCopy);
+ assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType());
+ CompilationUnit compilationUnit = (CompilationUnit) node;
+ assertProblemsSize(compilationUnit, 0);
+ node = getASTNode(compilationUnit, 0, 0, 0);
+ assertEquals("wrong line number", 3, compilationUnit.getLineNumber(node.getStartPosition()));
+ node = getASTNode(compilationUnit, 0, 0, 1);
+ assertEquals("wrong line number", 7, compilationUnit.getLineNumber(node.getStartPosition()));
+ node = getASTNode(compilationUnit, 0, 0, 2);
+ assertEquals("wrong line number", 8, compilationUnit.getLineNumber(node.getStartPosition()));
+ node = getASTNode(compilationUnit, 0, 0, 3);
+ assertEquals("wrong line number", 9, compilationUnit.getLineNumber(node.getStartPosition()));
+ } finally {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
+ }
+ }
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter9Test.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter9Test.java
index 74a2b6c99f..ae7f6c176b 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter9Test.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter9Test.java
@@ -1417,94 +1417,10 @@ public class ASTConverter9Test extends ConverterTestSetup {
deleteProject("Foo");
}
}
- // TODO: should probably start a new test class
- public void testBug531714_015() throws CoreException {
- // saw NPE in SwitchExpression.resolveType(SwitchExpression.java:423)
- if (!isJRE12) {
- System.err.println("Test "+getName()+" requires a JRE 12");
- return;
- }
- IJavaProject p = createJavaProject("Foo", new String[] {"src"}, new String[] {jcl9lib}, "bin", "12"); // FIXME jcl12?
- p.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
- p.setOption(JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES, JavaCore.IGNORE);
- try {
- String source =
- "import java.util.*;\n" +
- "public class X {\n" +
- " void testForeach1(int i, List<String> list) {\n" +
- " for (String s : switch(i) { case 1 -> list; default -> ; }) {\n" +
- " \n" +
- " }\n" +
- " Throwable t = switch (i) {\n" +
- " case 1 -> new Exception();\n" +
- " case 2 -> new RuntimeException();\n" + // trigger !typeUniformAcrossAllArms
- " default -> missing;\n" +
- " };\n" +
- " }\n" +
- " void testForeach0(int i, List<String> list) {\n" + // errors in first arm
- " for (String s : switch(i) { case 1 -> ; default -> list; }) {\n" +
- " \n" +
- " }\n" +
- " Throwable t = switch (i) {\n" +
- " case 0 -> missing;\n" +
- " case 1 -> new Exception();\n" +
- " default -> new RuntimeException();\n" + // trigger !typeUniformAcrossAllArms
- " };\n" +
- " }\n" +
- " void testForeachAll(int i) {\n" + // only erroneous arms
- " Throwable t = switch (i) {\n" +
- " case 0 -> missing;\n" +
- " default -> absent;\n" +
- " };\n" +
- " }\n" +
- "}\n";
- createFile("Foo/src/X.java", source);
- ICompilationUnit cuD = getCompilationUnit("/Foo/src/X.java");
-
- ASTParser parser = ASTParser.newParser(AST_INTERNAL_JLS11);
- parser.setProject(p);
- parser.setSource(cuD);
- parser.setResolveBindings(true);
- parser.setStatementsRecovery(true);
- parser.setBindingsRecovery(true);
- org.eclipse.jdt.core.dom.CompilationUnit cuAST = (org.eclipse.jdt.core.dom.CompilationUnit) parser.createAST(null);
- IProblem[] problems = cuAST.getProblems();
- assertProblems("Unexpected problems",
- "1. ERROR in /Foo/src/X.java (at line 4)\n" +
- " for (String s : switch(i) { case 1 -> list; default -> ; }) {\n" +
- " ^^\n" +
- "Syntax error on token \"->\", Expression expected after this token\n" +
- "----------\n" +
- "2. ERROR in /Foo/src/X.java (at line 10)\n" +
- " default -> missing;\n" +
- " ^^^^^^^\n" +
- "missing cannot be resolved to a variable\n" +
- "----------\n" +
- "3. ERROR in /Foo/src/X.java (at line 14)\n" +
- " for (String s : switch(i) { case 1 -> ; default -> list; }) {\n" +
- " ^^\n" +
- "Syntax error on token \"->\", Expression expected after this token\n" +
- "----------\n" +
- "4. ERROR in /Foo/src/X.java (at line 18)\n" +
- " case 0 -> missing;\n" +
- " ^^^^^^^\n" +
- "missing cannot be resolved to a variable\n" +
- "----------\n" +
- "5. ERROR in /Foo/src/X.java (at line 25)\n" +
- " case 0 -> missing;\n" +
- " ^^^^^^^\n" +
- "missing cannot be resolved to a variable\n" +
- "----------\n" +
- "6. ERROR in /Foo/src/X.java (at line 26)\n" +
- " default -> absent;\n" +
- " ^^^^^^\n" +
- "absent cannot be resolved to a variable\n" +
- "----------\n",
- problems, source.toCharArray());
- } finally {
- deleteProject(p);
- }
- }
+ /**
+ * @deprecated
+ * @throws Exception
+ */
public void testBug542795() throws Exception {
IJavaProject p = createJavaProject("Foo", new String[] {"src"}, new String[] {jcl9lib}, "bin", "11");
try {
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTStructuralPropertyTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTStructuralPropertyTest.java
index 3ed0c55983..9158ad630e 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTStructuralPropertyTest.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTStructuralPropertyTest.java
@@ -372,7 +372,7 @@ public class ASTStructuralPropertyTest extends org.eclipse.jdt.core.tests.junit.
// oops - guess that's not valid
}
}
- assertEquals("Wrong last known type", 100, hi); // last known one
+ assertEquals("Wrong last known type", 102, hi); // last known one
assertEquals("Wrong number of distinct types", hi, classes.size()); // all classes are distinct
}
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTTest.java
index 79d7bddbfa..3aac660f89 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTTest.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTTest.java
@@ -27,6 +27,7 @@ import java.util.Map;
import junit.framework.AssertionFailedError;
import junit.framework.Test;
+import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.dom.*;
// testing
@@ -1308,14 +1309,35 @@ public class ASTTest extends org.eclipse.jdt.core.tests.junit.extension.TestCase
}
+ @SuppressWarnings("deprecation")
+ private static int getApiLevel(String s) {
+ if (s == null)
+ return AST.JLS12;
+ switch (s) {
+ case JavaCore.VERSION_1_2 : return AST.JLS2;
+ case JavaCore.VERSION_1_3: return AST.JLS3;
+ case JavaCore.VERSION_1_4: return AST.JLS4;
+ case JavaCore.VERSION_1_5: return AST.JLS4;
+ case JavaCore.VERSION_1_6: return AST.JLS4;
+ case JavaCore.VERSION_1_7: return AST.JLS4;
+ case JavaCore.VERSION_1_8: return AST.JLS8;
+ case JavaCore.VERSION_9: return AST.JLS9;
+ case JavaCore.VERSION_10: return AST.JLS10;
+ case JavaCore.VERSION_11: return AST.JLS11;
+ case JavaCore.VERSION_12: return AST.JLS12;
+ case JavaCore.VERSION_13: return AST.JLS13;
+ default: return AST.JLS2;
+ }
+ }
/** @deprecated using deprecated code */
public void testAST() {
assertSame(AST.JLS2, 2);
assertSame(JLS3_INTERNAL, 3);
- AST a0 = new AST(); // deprecated, but still 2.0
- assertTrue(a0.apiLevel() == AST.JLS2);
+ AST a0 = new AST(); // deprecated, now 3 from JavaCore.defaultOptions
+ int apiLevelCal = ASTTest.getApiLevel(JavaCore.getDefaultOptions().get(JavaCore.COMPILER_SOURCE));
+ assertTrue(a0.apiLevel() == apiLevelCal);
AST a1 = new AST(new HashMap()); // deprecated, but still 2.0
assertTrue(a1.apiLevel() == AST.JLS2);
AST a2 = AST.newAST(AST.JLS2, false);
@@ -8869,6 +8891,8 @@ public class ASTTest extends org.eclipse.jdt.core.tests.junit.extension.TestCase
ASTNode.PROVIDES_DIRECTIVE,
ASTNode.MODULE_MODIFIER,
ASTNode.SWITCH_EXPRESSION,
+ ASTNode.YIELD_STATEMENT,
+ ASTNode.TEXT_BLOCK
};
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/AbstractASTTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/AbstractASTTests.java
index 65102b4e48..034a46b084 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/AbstractASTTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/AbstractASTTests.java
@@ -493,7 +493,9 @@ public class AbstractASTTests extends ModifyingResourceTests implements DefaultM
String option = cu.getJavaProject().getOption(JavaCore.COMPILER_COMPLIANCE, true);
long jdkLevel = CompilerOptions.versionToJdkLevel(option);
int JLSLevel = AST_INTERNAL_JLS3;
- if (jdkLevel >= ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_12)) {
+ if (jdkLevel >= ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_13)) {
+ JLSLevel = AST_INTERNAL_JLS13;
+ } else if (jdkLevel >= ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_12)) {
JLSLevel = AST_INTERNAL_JLS12;
} else if (jdkLevel >= ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_11)) {
JLSLevel = AST_INTERNAL_JLS11;
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ConverterTestSetup.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ConverterTestSetup.java
index 47ab610d98..b5f936605e 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ConverterTestSetup.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ConverterTestSetup.java
@@ -105,7 +105,7 @@ public abstract class ConverterTestSetup extends AbstractASTTests {
this.deleteProject("Converter9"); //$NON-NLS-1$
this.deleteProject("Converter10"); //$NON-NLS-1$
this.deleteProject("Converter11"); //$NON-NLS-1$
- this.deleteProject("Converter12"); //$NON-NLS-1$
+ this.deleteProject("Converter13"); //$NON-NLS-1$
PROJECT_SETUP = false;
} else {
TEST_SUITES.remove(getClass());
@@ -118,7 +118,7 @@ public abstract class ConverterTestSetup extends AbstractASTTests {
this.deleteProject("Converter9"); //$NON-NLS-1$
this.deleteProject("Converter10"); //$NON-NLS-1$
this.deleteProject("Converter11"); //$NON-NLS-1$
- this.deleteProject("Converter12"); //$NON-NLS-1$
+ this.deleteProject("Converter13"); //$NON-NLS-1$
PROJECT_SETUP = false;
}
}
@@ -212,7 +212,7 @@ public abstract class ConverterTestSetup extends AbstractASTTests {
setUpJavaProject("Converter9", "9"); //$NON-NLS-1$ //$NON-NLS-2$
setUpJavaProject("Converter10", "10"); //$NON-NLS-1$ //$NON-NLS-2$
setUpJavaProject("Converter11", "11"); //$NON-NLS-1$ //$NON-NLS-2$
- setUpJavaProject("Converter12", "12"); //$NON-NLS-1$ //$NON-NLS-2$
+ setUpJavaProject("Converter13", "13"); //$NON-NLS-1$ //$NON-NLS-2$
waitUntilIndexesReady(); // needed to find secondary types
PROJECT_SETUP = true;
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/RunConverterTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/RunConverterTests.java
index f12cc67bab..cdaed01aea 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/RunConverterTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/RunConverterTests.java
@@ -52,7 +52,7 @@ public static Class[] getAllTestClasses() {
TypeAnnotationsConverterTest.class,
ASTConverter18Test.class,
ASTConverter9Test.class,
- ASTConverter12Test.class,
+ ASTConverter13Test.class,
};
}
public static Test suite() {
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/TypeAnnotationsConverterTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/TypeAnnotationsConverterTest.java
index 1da23d2ee1..9d6a88214f 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/TypeAnnotationsConverterTest.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/TypeAnnotationsConverterTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -26,7 +26,7 @@ public class TypeAnnotationsConverterTest extends ConverterTestSetup {
public void setUpSuite() throws Exception {
super.setUpSuite();
- this.ast = AST.newAST(AST_INTERNAL_JLS11, false);
+ this.ast = AST.newAST(AST_INTERNAL_LATEST, false);
}
public TypeAnnotationsConverterTest(String name) {
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java
index 71ad555547..320fe9a757 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java
@@ -14850,7 +14850,7 @@ public void testBug541011g() throws JavaModelException {
* https://bugs.eclipse.org/543818 - [12] Formatter Support for Switch Expressions
*/
public void testBug543818a() throws JavaModelException {
- setComplianceLevel(CompilerOptions.VERSION_12);
+ setComplianceLevel(CompilerOptions.VERSION_13);
this.formatterPrefs.insert_space_before_comma_in_switch_case_expressions = true;
this.formatterPrefs.insert_space_before_colon_in_case = true;
this.formatterPrefs.indent_switchstatements_compare_to_switch = true;
@@ -14861,7 +14861,7 @@ public void testBug543818a() throws JavaModelException {
* https://bugs.eclipse.org/543818 - [12] Formatter Support for Switch Expressions
*/
public void testBug543818b() throws JavaModelException {
- setComplianceLevel(CompilerOptions.VERSION_12);
+ setComplianceLevel(CompilerOptions.VERSION_13);
this.formatterPrefs.insert_space_after_comma_in_switch_case_expressions = false;
this.formatterPrefs.insert_space_before_closing_paren_in_switch = true;
this.formatterPrefs.indent_switchstatements_compare_to_cases = false;
@@ -14872,7 +14872,7 @@ public void testBug543818b() throws JavaModelException {
* https://bugs.eclipse.org/543818 - [12] Formatter Support for Switch Expressions
*/
public void testBug543818c() throws JavaModelException {
- setComplianceLevel(CompilerOptions.VERSION_12);
+ setComplianceLevel(CompilerOptions.VERSION_13);
this.formatterPrefs.insert_space_before_arrow_in_switch_case = false;
this.formatterPrefs.insert_space_before_opening_paren_in_switch = false;
this.formatterPrefs.indent_breaks_compare_to_cases = false;
@@ -14883,7 +14883,7 @@ public void testBug543818c() throws JavaModelException {
* https://bugs.eclipse.org/543818 - [12] Formatter Support for Switch Expressions
*/
public void testBug543818d() throws JavaModelException {
- setComplianceLevel(CompilerOptions.VERSION_12);
+ setComplianceLevel(CompilerOptions.VERSION_13);
this.formatterPrefs.insert_space_after_arrow_in_switch_case = false;
this.formatterPrefs.insert_space_after_opening_paren_in_switch = true;
this.formatterPrefs.insert_space_before_opening_brace_in_block = false;
@@ -14895,7 +14895,7 @@ public void testBug543818d() throws JavaModelException {
* https://bugs.eclipse.org/543818 - [12] Formatter Support for Switch Expressions
*/
public void testBug543818e() throws JavaModelException {
- setComplianceLevel(CompilerOptions.VERSION_12);
+ setComplianceLevel(CompilerOptions.VERSION_13);
this.formatterPrefs.insert_space_before_arrow_in_switch_default = false;
this.formatterPrefs.insert_space_before_colon_in_default = true;
this.formatterPrefs.parenthesis_positions_in_switch_statement = DefaultCodeFormatterConstants.SEPARATE_LINES;
@@ -14906,7 +14906,7 @@ public void testBug543818e() throws JavaModelException {
* https://bugs.eclipse.org/543818 - [12] Formatter Support for Switch Expressions
*/
public void testBug543818f() throws JavaModelException {
- setComplianceLevel(CompilerOptions.VERSION_12);
+ setComplianceLevel(CompilerOptions.VERSION_13);
this.formatterPrefs.insert_space_after_arrow_in_switch_default = false;
this.formatterPrefs.insert_space_before_opening_brace_in_switch = false;
this.formatterPrefs.insert_space_before_opening_brace_in_block = false;
@@ -14917,7 +14917,7 @@ public void testBug543818f() throws JavaModelException {
* https://bugs.eclipse.org/543818 - [12] Formatter Support for Switch Expressions
*/
public void testBug543818g() throws JavaModelException {
- setComplianceLevel(CompilerOptions.VERSION_12);
+ setComplianceLevel(CompilerOptions.VERSION_13);
String input = getCompilationUnit("Formatter", "", "test543818", "in.java").getSource();
formatSource(input, getCompilationUnit("Formatter", "", "test543818", "G_out.java").getSource());
}
@@ -15230,7 +15230,7 @@ public void testBug421492d() throws JavaModelException {
* https://bugs.eclipse.org/390720 - [formatter] Add setting for blank line between case blocks (after break) for switch statement
*/
public void testBug390720a() throws JavaModelException {
- setComplianceLevel(CompilerOptions.VERSION_12);
+ setComplianceLevel(CompilerOptions.VERSION_13);
this.formatterPrefs.blank_lines_between_statement_groups_in_switch = 2;
formatSourceInWorkspace("test390720", "in.java", "A_out.java");
}
@@ -15238,7 +15238,7 @@ public void testBug390720a() throws JavaModelException {
* https://bugs.eclipse.org/390720 - [formatter] Add setting for blank line between case blocks (after break) for switch statement
*/
public void testBug390720b() throws JavaModelException {
- setComplianceLevel(CompilerOptions.VERSION_12);
+ setComplianceLevel(CompilerOptions.VERSION_13);
this.formatterPrefs.blank_lines_between_statement_groups_in_switch = ~0;
formatSourceInWorkspace("test390720", "in.java", "B_out.java");
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java
index 43d9ab94c7..cf1f469db4 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java
@@ -78,6 +78,7 @@ public abstract class AbstractJavaModelTests extends SuiteOfTestCases {
protected static boolean isJRE10 = false;
protected static boolean isJRE11 = false;
protected static boolean isJRE12 = false;
+ protected static boolean isJRE13 = false;
protected static String DEFAULT_MODULES = null;
static {
String javaVersion = System.getProperty("java.version");
@@ -91,7 +92,10 @@ public abstract class AbstractJavaModelTests extends SuiteOfTestCases {
}
}
long jdkLevel = CompilerOptions.versionToJdkLevel(javaVersion.length() > 3 ? javaVersion.substring(0, 3) : javaVersion);
- if (jdkLevel >= ClassFileConstants.getLatestJDKLevel()) {
+ if (jdkLevel >= ClassFileConstants.JDK13) {
+ isJRE13 = true;
+ }
+ if (jdkLevel >= ClassFileConstants.JDK12) {
isJRE12 = true;
}
if (jdkLevel >= ClassFileConstants.JDK11) {
@@ -144,14 +148,29 @@ public abstract class AbstractJavaModelTests extends SuiteOfTestCases {
/**
* Internal synonym for constant AST.JSL12
* to alleviate deprecation warnings once AST.JLS12 is deprecated in future.
+ * @deprecated
*/
protected static final int AST_INTERNAL_JLS12 = AST.JLS12;
+
+ /**
+ * Internal synonym for constant AST.JSL13
+ * to alleviate deprecation warnings once AST.JLS13 is deprecated in future.
+ */
+ protected static final int AST_INTERNAL_JLS13 = AST.JLS13;
/**
* Internal synonym for constant AST.JSL11
* to alleviate deprecation warnings once AST.JLS11 is deprecated in future.
+ * @deprecated
*/
protected static final int AST_INTERNAL_JLS11 = AST.JLS11;
+
+ /**
+ * Internal synonym for the latest AST level.
+ *
+ */
+ protected static final int AST_INTERNAL_LATEST = AST.JLS13;
+
public static class BasicProblemRequestor implements IProblemRequestor {
public void acceptProblem(IProblem problem) {}
public void beginReporting() {}
@@ -2082,6 +2101,12 @@ public abstract class AbstractJavaModelTests extends SuiteOfTestCases {
options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_12);
options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_12);
javaProject.setOptions(options);
+ } else if ("13".equals(compliance)) {
+ Map options = new HashMap();
+ options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_13);
+ options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_13);
+ options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_13);
+ javaProject.setOptions(options);
}
result[0] = javaProject;
}
@@ -3180,7 +3205,10 @@ public abstract class AbstractJavaModelTests extends SuiteOfTestCases {
newJclSrcString = "JCL18_SRC"; // Use the same source
}
} else {
- if (compliance.equals("12")) {
+ if (compliance.equals("13")) {
+ newJclLibString = "JCL13_LIB";
+ newJclSrcString = "JCL13_SRC";
+ } else if (compliance.equals("12")) {
newJclLibString = "JCL12_LIB";
newJclSrcString = "JCL12_SRC";
} else if (compliance.equals("11")) {
@@ -3241,10 +3269,12 @@ public abstract class AbstractJavaModelTests extends SuiteOfTestCases {
IPath jcl10Lib = new Path("JCL10_LIB");
IPath jcl11Lib = new Path("JCL11_LIB");
IPath jcl12Lib = new Path("JCL12_LIB");
+ IPath jcl13Lib = new Path("JCL13_LIB");
IPath jclFull = new Path("JCL18_FULL");
return path.equals(jclLib) || path.equals(jcl5Lib) || path.equals(jcl8Lib) || path.equals(jcl9Lib)
- || path.equals(jcl10Lib) || path.equals(jcl11Lib) || path.equals(jcl12Lib) || path.equals(jclFull);
+ || path.equals(jcl10Lib) || path.equals(jcl11Lib) || path.equals(jcl12Lib) || path.equals(jcl13Lib)
+ || path.equals(jclFull);
}
public void setUpJCLClasspathVariables(String compliance) throws JavaModelException, IOException {
setUpJCLClasspathVariables(compliance, false);
@@ -3315,6 +3345,14 @@ public abstract class AbstractJavaModelTests extends SuiteOfTestCases {
new IPath[] {getExternalJCLPath("12"), getExternalJCLSourcePath("12"), getExternalJCLRootSourcePath()},
null);
}
+ } else if ("13".equals(compliance)) {
+ if (JavaCore.getClasspathVariable("JCL13_LIB") == null) {
+ setupExternalJCL("jclMin13"); // No need for an explicit jclmin13, just use the same old one.
+ JavaCore.setClasspathVariables(
+ new String[] {"JCL13_LIB", "JCL13_SRC", "JCL_SRCROOT"},
+ new IPath[] {getExternalJCLPath("13"), getExternalJCLSourcePath("13"), getExternalJCLRootSourcePath()},
+ null);
+ }
} else {
if (JavaCore.getClasspathVariable("JCL_LIB") == null) {
setupExternalJCL("jclMin");
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AccessRestrictionsTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AccessRestrictionsTests.java
index cd8839b09a..ec59a8e6fd 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AccessRestrictionsTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AccessRestrictionsTests.java
@@ -1172,7 +1172,7 @@ public void testBug545766() throws CoreException {
createFolder("/P2/src/p2");
createFile("/P2/src/p2/Z.java", src);
- ASTParser parser = ASTParser.newParser(AST_INTERNAL_JLS12);
+ ASTParser parser = ASTParser.newParser(AST_INTERNAL_LATEST);
parser.setProject(p2);
parser.setSource((ITypeRoot)p2.findElement(new Path("p2/Z.java")));
parser.setResolveBindings(true);
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java
index 827e9f1bf6..296eb4f839 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -2656,7 +2656,7 @@ public void testBug495598_001() throws CoreException {
"public class X {}\n");
ICompilationUnit cuD = getCompilationUnit("/P/src/X.java");
- ASTParser parser = ASTParser.newParser(AST_INTERNAL_JLS11);
+ ASTParser parser = ASTParser.newParser(AST_INTERNAL_LATEST);
parser.setProject(this.testProject);
parser.setSource(cuD);
parser.setResolveBindings(true);
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java
index 03ba5f523d..5e0199ca5e 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -2684,7 +2684,7 @@ public void testBug351697() throws Exception {
proj.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null);
try {
- ASTParser parser= ASTParser.newParser(AST_INTERNAL_JLS11);
+ ASTParser parser= ASTParser.newParser(AST_INTERNAL_LATEST);
parser.setSource(unit);
parser.setResolveBindings(true);
ASTNode node = parser.createAST(null);
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs12Tests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs12Tests.java
deleted file mode 100644
index c1fced3a0f..0000000000
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs12Tests.java
+++ /dev/null
@@ -1,626 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2019 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.core.tests.model;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.WorkingCopyOwner;
-import org.eclipse.jdt.core.search.IJavaSearchScope;
-import org.eclipse.jdt.core.search.ReferenceMatch;
-import org.eclipse.jdt.core.search.SearchEngine;
-import org.eclipse.jdt.core.search.SearchMatch;
-import org.eclipse.jdt.core.search.TypeReferenceMatch;
-
-import junit.framework.Test;
-
-public class JavaSearchBugs12Tests extends AbstractJavaSearchTests {
-
- static {
-// org.eclipse.jdt.internal.core.search.BasicSearchEngine.VERBOSE = true;
-// TESTS_NUMBERS = new int[] { 19 };
-// TESTS_RANGE = new int[] { 1, -1 };
-// TESTS_NAMES = new String[] {"testBug542559_001"};
-}
-
-public JavaSearchBugs12Tests(String name) {
- super(name);
- this.endChar = "";
-}
-public static Test suite() {
- return buildModelTestSuite(JavaSearchBugs12Tests.class, BYTECODE_DECLARATION_ORDER);
-}
-class TestCollector extends JavaSearchResultCollector {
- public void acceptSearchMatch(SearchMatch searchMatch) throws CoreException {
- super.acceptSearchMatch(searchMatch);
- }
-}
-class ReferenceCollector extends JavaSearchResultCollector {
- protected void writeLine() throws CoreException {
- super.writeLine();
- ReferenceMatch refMatch = (ReferenceMatch) this.match;
- IJavaElement localElement = refMatch.getLocalElement();
- if (localElement != null) {
- this.line.append("+[");
- if (localElement.getElementType() == IJavaElement.ANNOTATION) {
- this.line.append('@');
- this.line.append(localElement.getElementName());
- this.line.append(" on ");
- this.line.append(localElement.getParent().getElementName());
- } else {
- this.line.append(localElement.getElementName());
- }
- this.line.append(']');
- }
- }
-
-}
-class TypeReferenceCollector extends ReferenceCollector {
- protected void writeLine() throws CoreException {
- super.writeLine();
- TypeReferenceMatch typeRefMatch = (TypeReferenceMatch) this.match;
- IJavaElement[] others = typeRefMatch.getOtherElements();
- int length = others==null ? 0 : others.length;
- if (length > 0) {
- this.line.append("+[");
- for (int i=0; i<length; i++) {
- IJavaElement other = others[i];
- if (i>0) this.line.append(',');
- if (other.getElementType() == IJavaElement.ANNOTATION) {
- this.line.append('@');
- this.line.append(other.getElementName());
- this.line.append(" on ");
- this.line.append(other.getParent().getElementName());
- } else {
- this.line.append(other.getElementName());
- }
- }
- this.line.append(']');
- }
- }
-}
-
-IJavaSearchScope getJavaSearchScope() {
- return SearchEngine.createJavaSearchScope(new IJavaProject[] {getJavaProject("JavaSearchBugs")});
-}
-IJavaSearchScope getJavaSearchScopeBugs(String packageName, boolean addSubpackages) throws JavaModelException {
- if (packageName == null) return getJavaSearchScope();
- return getJavaSearchPackageScope("JavaSearchBugs", packageName, addSubpackages);
-}
-public ICompilationUnit getWorkingCopy(String path, String source) throws JavaModelException {
- if (this.wcOwner == null) {
- this.wcOwner = new WorkingCopyOwner() {};
- }
- return getWorkingCopy(path, source, this.wcOwner);
-}
-@Override
-public void setUpSuite() throws Exception {
- super.setUpSuite();
- JAVA_PROJECT = setUpJavaProject("JavaSearchBugs", "12");
-}
-public void tearDownSuite() throws Exception {
- deleteProject("JavaSearchBugs");
- super.tearDownSuite();
-}
-protected void setUp () throws Exception {
- super.setUp();
- this.resultCollector = new TestCollector();
- this.resultCollector.showAccuracy(true);
-}
-
-public void testBug542559_001() throws CoreException {
- this.workingCopies = new ICompilationUnit[1];
- this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java",
- "public class X {\n" +
- " int switch_expr_field = 10;\n" +
- " int twice(int i) {\n" +
- " int tw = switch (i) {\n" +
- " case 0 -> switch_expr_field * 0;\n" +
- " case 1 -> 2;\n" +
- " default -> 3;\n" +
- " };\n" +
- " return tw;\n" +
- " }\n" +
- " public static void main(String... args) {\n" +
- " System.out.print(new X().twice(3));\n" +
- " }\n" +
- "}\n"
- );
- IJavaProject javaProject = this.workingCopies[0].getJavaProject(); //assuming single project for all working copies
- String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
- try {
- javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
- search("switch_expr_field", FIELD, REFERENCES);
- assertSearchResults("src/X.java int X.twice(int) [switch_expr_field] EXACT_MATCH");
- } finally {
- javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
- }
-}
-public void testBug542559_002() throws CoreException {
- this.workingCopies = new ICompilationUnit[1];
- this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java",
- "public class X {\n" +
- " int switch_expr_field = 10;\n" +
- " int twice(int i) {\n" +
- " int tw = switch (i) {\n" +
- " case 0 -> switch_expr_field * 0;\n" +
- " case 1 -> { break switch_expr_field; }\n" +
- " default -> 3;\n" +
- " };\n" +
- " return tw;\n" +
- " }\n" +
- " public static void main(String... args) {\n" +
- " System.out.print(new X().twice(3));\n" +
- " }\n" +
- "}\n"
- );
- IJavaProject javaProject = this.workingCopies[0].getJavaProject(); //assuming single project for all working copies
- String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
- try {
- javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
- search("switch_expr_field", FIELD, REFERENCES);
- assertSearchResults(
- "src/X.java int X.twice(int) [switch_expr_field] EXACT_MATCH\n" +
- "src/X.java int X.twice(int) [switch_expr_field] EXACT_MATCH"
- );
- } finally {
- javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
- }
-}
-public void testBug542559_003() throws CoreException {
- this.workingCopies = new ICompilationUnit[1];
- this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java",
- "public class X {\n" +
- " int switch_expr_field = 10; \n" +
- " int twice(int i) throws Exception { \n" +
- " int tw = switch (i) { \n" +
- " case 0 -> { break switch_expr_field; } \n" +
- " case 4 -> throw new MyException(); \n" +
- " default -> 3; \n" +
- " }; \n" +
- " return tw; \n" +
- " } \n" +
- " public static void main(String[] args) {\n" +
- " try {\n" +
- " System.out.print(new X().twice(3));\n" +
- " } catch (Exception e) {\n" +
- " // TODO Auto-generated catch block\n" +
- " e.printStackTrace();\n" +
- " }\n" +
- " } \n" +
- "}\n" +
- "class MyException extends Exception {\n" +
- " private static final long serialVersionUID = 3461899582505930474L;\n" +
- " \n" +
- "}\n"
- );
- IJavaProject javaProject = this.workingCopies[0].getJavaProject(); //assuming single project for all working copies
- String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
- try {
- javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
- IType type = this.workingCopies[0].getType("MyException");
- search(type, REFERENCES);
- assertSearchResults(
- "src/X.java int X.twice(int) [MyException] EXACT_MATCH"
- );
- } finally {
- javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
- }
-}
-/*
- * java search reference for an integer in default block of switch expression
- */
-public void testBug542559_004() throws CoreException {
- this.workingCopies = new ICompilationUnit[1];
- this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java",
- "public class X {\n" +
- " int switch_expr_field = 10;\n" +
- " int twice(int i) {\n" +
- " int tw = switch (i) {\n" +
- " case 0 -> switch_expr_field * 0;\n" +
- " case 1 -> 2;\n" +
- " default ->{ \n" +
- " switch_expr_field*9; \n" +
- " }};\n" +
- " return tw;\n" +
- " }\n" +
- " public static void main(String... args) {\n" +
- " System.out.print(new X().twice(3));\n" +
- " }\n" +
- "}\n"
- );
- IJavaProject javaProject = this.workingCopies[0].getJavaProject(); //assuming single project for all working copies
- String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
- try {
- javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
- search("switch_expr_field", FIELD, REFERENCES);
- assertSearchResults(
- "src/X.java int X.twice(int) [switch_expr_field] EXACT_MATCH\n" +
- "src/X.java int X.twice(int) [switch_expr_field] EXACT_MATCH"
- );
- } finally {
- javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
- }
-}
-
-/*
- * java search reference for an integer in default of switch expression
- */
-public void testBug542559_005() throws CoreException {
- this.workingCopies = new ICompilationUnit[1];
- this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java",
- "public class X {\n" +
- " int switch_expr_field = 10;\n" +
- " int twice(int i) {\n" +
- " int tw = switch (i) {\n" +
- " case 0 -> switch_expr_field * 0;\n" +
- " case 1 -> 2;\n" +
- " default -> switch_expr_field*9;\n" +
- " };\n" +
- " return tw;\n" +
- " }\n" +
- " public static void main(String... args) {\n" +
- " System.out.print(new X().twice(3));\n" +
- " }\n" +
- "}\n"
- );
- IJavaProject javaProject = this.workingCopies[0].getJavaProject(); //assuming single project for all working copies
- String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
- try {
- javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
- search("switch_expr_field", FIELD, REFERENCES);
- assertSearchResults(
- "src/X.java int X.twice(int) [switch_expr_field] EXACT_MATCH\n" +
- "src/X.java int X.twice(int) [switch_expr_field] EXACT_MATCH"
- );
- } finally {
- javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
- }
-}
-
-/*
- * java search reference for simple multi constant case statement for enum
- */
-public void testBug542559_006() throws CoreException {
- this.workingCopies = new ICompilationUnit[1];
- this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java",
- "public class X {\n" +
- "enum Day { SATURDAY, SUNDAY, MONDAY;}\n" +
- "public static void bar(Day day) {\n" +
- " switch (day) {\n" +
- " case SATURDAY, SUNDAY: \n" +
- " System.out.println(Day.SUNDAY);\n" +
- " break;\n" +
- " case MONDAY : System.out.println(Day.MONDAY);\n" +
- " break;\n" +
- " }\n" +
- " }" +
- " public static void main(String[] args) {\n" +
- " bar(Day.SATURDAY);\n" +
- " }\n"
- +
- "}\n"
- );
- IJavaProject javaProject = this.workingCopies[0].getJavaProject(); //assuming single project for all working copies
- String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
- try {
- javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
- search("SATURDAY", FIELD, REFERENCES);
- assertSearchResults(
- "src/X.java void X.bar(Day) [SATURDAY] EXACT_MATCH\n"+
- "src/X.java void X.main(String[]) [SATURDAY] EXACT_MATCH"
- );
- } finally {
- javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
- }
-}
-/*
- * java search reference for simple multi constant case statement for enum, 2nd case
- */
-public void testBug542559_007() throws CoreException {
- this.workingCopies = new ICompilationUnit[1];
- this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java",
- "public class X {\n" +
- "enum Day { SATURDAY, SUNDAY, MONDAY;}\n" +
- "public static void bar(Day day) {\n" +
- " switch (day) {\n" +
- " case SATURDAY, SUNDAY: \n" +
- " System.out.println(Day.SUNDAY);\n" +
- " break;\n" +
- " case MONDAY : System.out.println(Day.MONDAY);\n" +
- " break;\n" +
- " }\n" +
- " }" +
- " public static void main(String[] args) {\n" +
- " bar(Day.SATURDAY);\n" +
- " }\n"
- +
- "}\n"
- );
- IJavaProject javaProject = this.workingCopies[0].getJavaProject(); //assuming single project for all working copies
- String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
- try {
- javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
- search("SUNDAY", FIELD, REFERENCES);
- assertSearchResults(
- "src/X.java void X.bar(Day) [SUNDAY] EXACT_MATCH\n"+
- "src/X.java void X.bar(Day) [SUNDAY] EXACT_MATCH"
- );
- } finally {
- javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
- }
-}
-
-/*
- * java search reference for class file reference in switch expression
- */
-public void testBug542559_008() throws CoreException {
- this.workingCopies = new ICompilationUnit[1];
- this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X2.java",
- "public class X2 {\n" +
- " String s = new String(); \n" +
- " int switch_expr_field = 10;\n" +
- " int twice(int i) {\n" +
- " int tw = switch (i) {\n" +
- " case 0 -> switch_expr_field * 0;\n" +
- " case 1 -> 2;\n" +
- " default -> new X2().toString().length();\n" +
- " };\n" +
- " return tw;\n" +
- " }\n" +
- " public static void main(String... args) {\n" +
- " System.out.print(new X2().twice(3));\n" +
- " }\n" +
- "}\n"
- );
- IJavaProject javaProject = this.workingCopies[0].getJavaProject(); //assuming single project for all working copies
- String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
- try {
- javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
- search("X2", CLASS, REFERENCES);
- assertSearchResults(
- "src/X2.java int X2.twice(int) [X2] EXACT_MATCH\n"+
- "src/X2.java void X2.main(String ...) [X2] EXACT_MATCH");
- } finally {
- javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
- }
-}
-
-/*
- * java search reference for class file reference in case and default blocks
- */
-public void testBug542559_009() throws CoreException {
- this.workingCopies = new ICompilationUnit[1];
- this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java",
- "public class X {\n" +
- " Integer abcd\n" +
- " public static int foo(int i) {\n" +
- " final int k;\n" +
- "\n" +
- " int it = switch (i) { \n" +
- " case 1 -> {\n" +
- " k = 1;\n" +
- " abcd.toString();\n" +
- " break k ;\n" +
- " }\n" +
- " case 2 -> {\n" +
- " abcd.toString();\n" +
- " break k ;\n" +
- " }\n" +
- " default -> {\n" +
- " k = 3;\n" +
- " abcd.toString();\n" +
- " break k;\n" +
- " }\n" +
- " };\n" +
- " return k;\n" +
- " }\n" +
- "\n" +
- " public boolean bar() {\n" +
- " return true;\n" +
- " }\n" +
- " public static void main(String[] args) {\n" +
- " System.out.println(foo(3));\n" +
- " }\n" +
- "}\n"
- );
- IJavaProject javaProject = this.workingCopies[0].getJavaProject(); //assuming single project for all working copies
- String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
- try {
- javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
- search("abcd", FIELD, REFERENCES);
- assertSearchResults(
- "src/X.java int X.foo(int) [abcd] EXACT_MATCH\n" +
- "src/X.java int X.foo(int) [abcd] EXACT_MATCH\n" +
- "src/X.java int X.foo(int) [abcd] EXACT_MATCH"
- );
- } finally {
- javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
- }
-}
-
-/*
- * java search reference for string constant in switch expression and switch statement
- */
-public void testBug542559_0010() throws CoreException {
- this.workingCopies = new ICompilationUnit[1];
- this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java",
- "public class X {\n" +
- " static final String MONDAY = \"MONDAY\";\n" +
- " static final String TUESDAY = \"TUESDAY\";\n" +
- " static final String WEDNESDAY = \"WEDNESDAY\";\n" +
- " static final String THURSDAY = \"THURSDAY\";\n" +
- " static final String FRIDAY = \"FRIDAY\";\n" +
- " static final String SATURDAY = \"SATURDAY\";\n" +
- " static final String SUNDAY = \"SUNDAY\"; \n" +
- " @SuppressWarnings(\"preview\")\n" +
- " public static void main(String[] args) {\n" +
- " String day = \"MONDAY\";\n" +
- " switch (day) {\n" +
- " case MONDAY, FRIDAY, SUNDAY -> System.out.println(6);\n" +
- " case TUESDAY -> System.out.println(7);\n" +
- " case THURSDAY, SATURDAY -> System.out.println(8);\n" +
- " case WEDNESDAY -> System.out.println(9);\n" +
- " }\n" +
- " int k = switch (day) {\n" +
- " case SATURDAY -> throw new NullPointerException();\n" +
- " case TUESDAY -> 1;\n" +
- " case WEDNESDAY -> {break 10;}\n" +
- " default -> {\n" +
- " int g = day.h();\n" +
- " int result = f(g);\n" +
- " break result;\n" +
- " }};\n" +
- " }\n" +
- " static int f(int k) {\n" +
- " return k*k;\n" +
- " }\n" +
- "}\n"
- );
- IJavaProject javaProject = this.workingCopies[0].getJavaProject(); //assuming single project for all working copies
- String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
- try {
- javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
- search("SATURDAY", FIELD, REFERENCES);
- assertSearchResults(
- "src/X.java void X.main(String[]) [SATURDAY] EXACT_MATCH\n" +
- "src/X.java void X.main(String[]) [SATURDAY] EXACT_MATCH"
- );
- } finally {
- javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
- }
-}
-/*
- * java search a javatype reference from another java project if that is in switch expression
- */
-public void testBug542559_0011() throws CoreException {
- try {
-
- IJavaProject project1 = createJavaProject("JavaSearchBugs12", new String[] {"src"}, new String[] {"JCL12_LIB"}, "bin", "12");
- project1.open(null);
- createFolder("/JavaSearchBugs12/src/pack1");
- createFile("/JavaSearchBugs12/src/pack1/X11.java",
- "package pack1;\n" +
- "public class X11 { \n" +
- " static final String MONDAY = \"MONDAY\";\n" +
- " static final String TUESDAY = \"TUESDAY\";\n" +
- " static final String WEDNESDAY = \"WEDNESDAY\";\n" +
- " static final String THURSDAY = \"THURSDAY\";\n" +
- " static final String FRIDAY = \"FRIDAY\";\n" +
- " static final String SATURDAY = \"SATURDAY\";\n" +
- " static final String SUNDAY = \"SUNDAY\"; \n" +
- " @SuppressWarnings(\"preview\")\n" +
- " public static void main(String[] args) {\n" +
- " String day = \"MONDAY\";\n" +
- " switch (day) {\n" +
- " case MONDAY, FRIDAY, SUNDAY -> System.out.println(6);\n" +
- " case TUESDAY -> System.out.println(7);\n" +
- " case THURSDAY, SATURDAY -> System.out.println(8);\n" +
- " case WEDNESDAY -> System.out.println(9);\n" +
- " }\n" +
- " int k = switch (day) {\n" +
- " case SATURDAY -> throw new NullPointerException();\n" +
- " case TUESDAY -> 1;\n" +
- " case WEDNESDAY -> {break 10;}\n" +
- " default -> {\n" +
- " pack2.X22.a2=99;\n" +
- " int result = f(g);\n" +
- " break result;\n" +
- " }};\n" +
- " }\n" +
- " static int f(int k) {\n" +
- " return k*k;\n" +
- " }\n" +
- "}\n");
-
- IJavaProject project2 = createJavaProject("second", new String[] {"src"},new String[] {"JCL12_LIB"}, "bin", "12");
- project2.open(null);
- createFolder("/second/src/pack2");
- createFile("/second/src/pack2/X22.java",
- "package pack2;\n" +
- "public class X22 {public static int a2=9;}\n");
- addClasspathEntry(project1, JavaCore.newProjectEntry(project2.getPath()));
- project1.close(); // sync
- project2.close();
- project2.open(null);
- project1.open(null);
- IPackageFragment pkg = getPackageFragment("second", "src", "pack2");
-
- IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaProject[]
- {getJavaProject("JavaSearchBugs12")});
-
- search(
- pkg,
- ALL_OCCURRENCES,
- scope,
- this.resultCollector);
- String exp = "src/pack1/X11.java void pack1.X11.main(String[]) [pack2] EXACT_MATCH\n"
- +"src/pack2 pack2 EXACT_MATCH";
- assertSearchResults(
- exp,
- this.resultCollector);
-
- }
- finally {
- deleteProject("JavaSearchBugs12");
- deleteProject("second");
- }
-
-}
-/*
- * java search a method reference in switch expression
- */
-public void testBug542559_0012() throws CoreException {
- this.workingCopies = new ICompilationUnit[1];
- this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java",
- "import java.util.function.Supplier;\n" +
- "interface I0 { void i(); }\n" +
- "interface I1 extends I0 {}\n" +
- "interface I2 extends I0 {}\n" +
- "public class X {\n" +
- " I1 n1() { return null; }\n" +
- " <I extends I2> I n2() { return null; }\n" +
- " <M> M m(Supplier<M> m) { return m.get(); }\n" +
- " void test(int i, boolean b) {\n" +
- " m(switch (i) {\n" +
- " case 1 -> this::n1;\n" +
- " default -> this::n2;\n" +
- " }).i(); \n" +
- " }\n" +
- " public static void main(String[] args) {\n" +
- " try {\n" +
- " new X().test(1, true);\n" +
- " } catch (NullPointerException e) {\n" +
- " System.out.println(\"NPE as expected\");\n" +
- " }\n" +
- " }\n" +
- "}\n"
- );
- IJavaProject javaProject = this.workingCopies[0].getJavaProject();//assuming single project for all working copies
- String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
- try {
- javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
- search("n1", METHOD, REFERENCES);
- assertSearchResults("src/X.java void X.test(int, boolean) [n1] EXACT_MATCH");
- } finally {
- javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
- }
-}
-
-} \ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs13Tests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs13Tests.java
new file mode 100644
index 0000000000..0c932c77af
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs13Tests.java
@@ -0,0 +1,1047 @@
+/*******************************************************************************
+ * Copyright (c) 2019 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.model;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.ILocalVariable;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.WorkingCopyOwner;
+import org.eclipse.jdt.core.search.IJavaSearchScope;
+import org.eclipse.jdt.core.search.ReferenceMatch;
+import org.eclipse.jdt.core.search.SearchEngine;
+import org.eclipse.jdt.core.search.SearchMatch;
+import org.eclipse.jdt.core.search.TypeReferenceMatch;
+
+import junit.framework.Test;
+
+public class JavaSearchBugs13Tests extends AbstractJavaSearchTests {
+
+ static {
+// org.eclipse.jdt.internal.core.search.BasicSearchEngine.VERBOSE = true;
+// TESTS_NUMBERS = new int[] { 19 };
+// TESTS_RANGE = new int[] { 1, -1 };
+// TESTS_NAMES = new String[] {"testBug542559_001"};
+}
+
+public JavaSearchBugs13Tests(String name) {
+ super(name);
+ this.endChar = "";
+}
+public static Test suite() {
+ return buildModelTestSuite(JavaSearchBugs13Tests.class, BYTECODE_DECLARATION_ORDER);
+}
+class TestCollector extends JavaSearchResultCollector {
+ public void acceptSearchMatch(SearchMatch searchMatch) throws CoreException {
+ super.acceptSearchMatch(searchMatch);
+ }
+}
+class ReferenceCollector extends JavaSearchResultCollector {
+ protected void writeLine() throws CoreException {
+ super.writeLine();
+ ReferenceMatch refMatch = (ReferenceMatch) this.match;
+ IJavaElement localElement = refMatch.getLocalElement();
+ if (localElement != null) {
+ this.line.append("+[");
+ if (localElement.getElementType() == IJavaElement.ANNOTATION) {
+ this.line.append('@');
+ this.line.append(localElement.getElementName());
+ this.line.append(" on ");
+ this.line.append(localElement.getParent().getElementName());
+ } else {
+ this.line.append(localElement.getElementName());
+ }
+ this.line.append(']');
+ }
+ }
+
+}
+class TypeReferenceCollector extends ReferenceCollector {
+ protected void writeLine() throws CoreException {
+ super.writeLine();
+ TypeReferenceMatch typeRefMatch = (TypeReferenceMatch) this.match;
+ IJavaElement[] others = typeRefMatch.getOtherElements();
+ int length = others==null ? 0 : others.length;
+ if (length > 0) {
+ this.line.append("+[");
+ for (int i=0; i<length; i++) {
+ IJavaElement other = others[i];
+ if (i>0) this.line.append(',');
+ if (other.getElementType() == IJavaElement.ANNOTATION) {
+ this.line.append('@');
+ this.line.append(other.getElementName());
+ this.line.append(" on ");
+ this.line.append(other.getParent().getElementName());
+ } else {
+ this.line.append(other.getElementName());
+ }
+ }
+ this.line.append(']');
+ }
+ }
+}
+
+IJavaSearchScope getJavaSearchScope() {
+ return SearchEngine.createJavaSearchScope(new IJavaProject[] {getJavaProject("JavaSearchBugs")});
+}
+IJavaSearchScope getJavaSearchScopeBugs(String packageName, boolean addSubpackages) throws JavaModelException {
+ if (packageName == null) return getJavaSearchScope();
+ return getJavaSearchPackageScope("JavaSearchBugs", packageName, addSubpackages);
+}
+public ICompilationUnit getWorkingCopy(String path, String source) throws JavaModelException {
+ if (this.wcOwner == null) {
+ this.wcOwner = new WorkingCopyOwner() {};
+ }
+ return getWorkingCopy(path, source, this.wcOwner);
+}
+@Override
+public void setUpSuite() throws Exception {
+ super.setUpSuite();
+ JAVA_PROJECT = setUpJavaProject("JavaSearchBugs", "13");
+}
+public void tearDownSuite() throws Exception {
+ deleteProject("JavaSearchBugs");
+ super.tearDownSuite();
+}
+protected void setUp () throws Exception {
+ super.setUp();
+ this.resultCollector = new TestCollector();
+ this.resultCollector.showAccuracy(true);
+}
+
+//copy from JavaSearchBugs12Tests starts ( after deleting break with value tests since that is discarded)
+
+public void testBug542559_001() throws CoreException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java",
+ "public class X {\n" +
+ " int switch_expr_field = 10;\n" +
+ " int twice(int i) {\n" +
+ " int tw = switch (i) {\n" +
+ " case 0 -> switch_expr_field * 0;\n" +
+ " case 1 -> 2;\n" +
+ " default -> 3;\n" +
+ " };\n" +
+ " return tw;\n" +
+ " }\n" +
+ " public static void main(String... args) {\n" +
+ " System.out.print(new X().twice(3));\n" +
+ " }\n" +
+ "}\n"
+ );
+ IJavaProject javaProject = this.workingCopies[0].getJavaProject(); //assuming single project for all working copies
+ String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
+ try {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
+ search("switch_expr_field", FIELD, REFERENCES);
+ assertSearchResults("src/X.java int X.twice(int) [switch_expr_field] EXACT_MATCH");
+ } finally {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
+ }
+}
+
+
+/*
+ * java search reference for an integer in default block of switch expression
+ */
+public void testBug542559_004() throws CoreException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java",
+ "public class X {\n" +
+ " int switch_expr_field = 10;\n" +
+ " int twice(int i) {\n" +
+ " int tw = switch (i) {\n" +
+ " case 0 -> switch_expr_field * 0;\n" +
+ " case 1 -> 2;\n" +
+ " default ->{ \n" +
+ " switch_expr_field*9; \n" +
+ " }};\n" +
+ " return tw;\n" +
+ " }\n" +
+ " public static void main(String... args) {\n" +
+ " System.out.print(new X().twice(3));\n" +
+ " }\n" +
+ "}\n"
+ );
+ IJavaProject javaProject = this.workingCopies[0].getJavaProject(); //assuming single project for all working copies
+ String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
+ try {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
+ search("switch_expr_field", FIELD, REFERENCES);
+ assertSearchResults(
+ "src/X.java int X.twice(int) [switch_expr_field] EXACT_MATCH\n" +
+ "src/X.java int X.twice(int) [switch_expr_field] EXACT_MATCH"
+ );
+ } finally {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
+ }
+}
+
+/*
+ * java search reference for an integer in default of switch expression
+ */
+public void testBug542559_005() throws CoreException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java",
+ "public class X {\n" +
+ " int switch_expr_field = 10;\n" +
+ " int twice(int i) {\n" +
+ " int tw = switch (i) {\n" +
+ " case 0 -> switch_expr_field * 0;\n" +
+ " case 1 -> 2;\n" +
+ " default -> switch_expr_field*9;\n" +
+ " };\n" +
+ " return tw;\n" +
+ " }\n" +
+ " public static void main(String... args) {\n" +
+ " System.out.print(new X().twice(3));\n" +
+ " }\n" +
+ "}\n"
+ );
+ IJavaProject javaProject = this.workingCopies[0].getJavaProject(); //assuming single project for all working copies
+ String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
+ try {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
+ search("switch_expr_field", FIELD, REFERENCES);
+ assertSearchResults(
+ "src/X.java int X.twice(int) [switch_expr_field] EXACT_MATCH\n" +
+ "src/X.java int X.twice(int) [switch_expr_field] EXACT_MATCH"
+ );
+ } finally {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
+ }
+}
+
+/*
+ * java search reference for simple multi constant case statement for enum
+ */
+public void testBug542559_006() throws CoreException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java",
+ "public class X {\n" +
+ "enum Day { SATURDAY, SUNDAY, MONDAY;}\n" +
+ "public static void bar(Day day) {\n" +
+ " switch (day) {\n" +
+ " case SATURDAY, SUNDAY: \n" +
+ " System.out.println(Day.SUNDAY);\n" +
+ " break;\n" +
+ " case MONDAY : System.out.println(Day.MONDAY);\n" +
+ " break;\n" +
+ " }\n" +
+ " }" +
+ " public static void main(String[] args) {\n" +
+ " bar(Day.SATURDAY);\n" +
+ " }\n"
+ +
+ "}\n"
+ );
+ IJavaProject javaProject = this.workingCopies[0].getJavaProject(); //assuming single project for all working copies
+ String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
+ try {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
+ search("SATURDAY", FIELD, REFERENCES);
+ assertSearchResults(
+ "src/X.java void X.bar(Day) [SATURDAY] EXACT_MATCH\n"+
+ "src/X.java void X.main(String[]) [SATURDAY] EXACT_MATCH"
+ );
+ } finally {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
+ }
+}
+/*
+ * java search reference for simple multi constant case statement for enum, 2nd case
+ */
+public void testBug542559_007() throws CoreException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java",
+ "public class X {\n" +
+ "enum Day { SATURDAY, SUNDAY, MONDAY;}\n" +
+ "public static void bar(Day day) {\n" +
+ " switch (day) {\n" +
+ " case SATURDAY, SUNDAY: \n" +
+ " System.out.println(Day.SUNDAY);\n" +
+ " break;\n" +
+ " case MONDAY : System.out.println(Day.MONDAY);\n" +
+ " break;\n" +
+ " }\n" +
+ " }" +
+ " public static void main(String[] args) {\n" +
+ " bar(Day.SATURDAY);\n" +
+ " }\n"
+ +
+ "}\n"
+ );
+ IJavaProject javaProject = this.workingCopies[0].getJavaProject(); //assuming single project for all working copies
+ String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
+ try {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
+ search("SUNDAY", FIELD, REFERENCES);
+ assertSearchResults(
+ "src/X.java void X.bar(Day) [SUNDAY] EXACT_MATCH\n"+
+ "src/X.java void X.bar(Day) [SUNDAY] EXACT_MATCH"
+ );
+ } finally {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
+ }
+}
+
+/*
+ * java search reference for class file reference in switch expression
+ */
+public void testBug542559_008() throws CoreException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X2.java",
+ "public class X2 {\n" +
+ " String s = new String(); \n" +
+ " int switch_expr_field = 10;\n" +
+ " int twice(int i) {\n" +
+ " int tw = switch (i) {\n" +
+ " case 0 -> switch_expr_field * 0;\n" +
+ " case 1 -> 2;\n" +
+ " default -> new X2().toString().length();\n" +
+ " };\n" +
+ " return tw;\n" +
+ " }\n" +
+ " public static void main(String... args) {\n" +
+ " System.out.print(new X2().twice(3));\n" +
+ " }\n" +
+ "}\n"
+ );
+ IJavaProject javaProject = this.workingCopies[0].getJavaProject(); //assuming single project for all working copies
+ String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
+ try {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
+ search("X2", CLASS, REFERENCES);
+ assertSearchResults(
+ "src/X2.java int X2.twice(int) [X2] EXACT_MATCH\n"+
+ "src/X2.java void X2.main(String ...) [X2] EXACT_MATCH");
+ } finally {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
+ }
+}
+
+
+
+/*
+ * java search a method reference in switch expression
+ */
+public void testBug542559_0012() throws CoreException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java",
+ "import java.util.function.Supplier;\n" +
+ "interface I0 { void i(); }\n" +
+ "interface I1 extends I0 {}\n" +
+ "interface I2 extends I0 {}\n" +
+ "public class X {\n" +
+ " I1 n1() { return null; }\n" +
+ " <I extends I2> I n2() { return null; }\n" +
+ " <M> M m(Supplier<M> m) { return m.get(); }\n" +
+ " void test(int i, boolean b) {\n" +
+ " m(switch (i) {\n" +
+ " case 1 -> this::n1;\n" +
+ " default -> this::n2;\n" +
+ " }).i(); \n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " try {\n" +
+ " new X().test(1, true);\n" +
+ " } catch (NullPointerException e) {\n" +
+ " System.out.println(\"NPE as expected\");\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ );
+ IJavaProject javaProject = this.workingCopies[0].getJavaProject();//assuming single project for all working copies
+ String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
+ try {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
+ search("n1", METHOD, REFERENCES);
+ assertSearchResults("src/X.java void X.test(int, boolean) [n1] EXACT_MATCH");
+ } finally {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
+ }
+}
+
+// copy from JavaSearchBugs12Tests ends
+
+public void testBug549413_001() throws CoreException {
+ // field reference in yield
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java",
+ "public class X {\n" +
+ "int switch_expr_field = 10; \n" +
+ "public static int foo(int val) {\n" +
+ "int k = switch (val) {\n" +
+ "case 1 -> { yield switch_expr_field; }\n" +
+ "default -> { yield 2; }\n" +
+ "};\n" +
+ "return k;\n" +
+ "}\n" +
+ " public static void main(String... args) {\n" +
+ " System.out.println(X.foo(2));\n" +
+ " }\n" +
+ "}\n"
+ );
+ IJavaProject javaProject = this.workingCopies[0].getJavaProject(); //assuming single project for all working copies
+ String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
+ try {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
+ search("switch_expr_field", FIELD, REFERENCES);
+ assertSearchResults("src/X.java int X.foo(int) [switch_expr_field] EXACT_MATCH");
+ } finally {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
+ }
+}
+
+public void testBug549413_002() throws CoreException {
+ //field all occurrences in yield
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java",
+ "public class X {\n" +
+ "int switch_expr_field = 10; \n" +
+ "public static int foo(int val) {\n" +
+ "int k = switch (val) {\n" +
+ "case 1 -> { yield switch_expr_field; }\n" +
+ "default -> { yield 2; }\n" +
+ "};\n" +
+ "return k;\n" +
+ "}\n" +
+ " public static void main(String... args) {\n" +
+ " System.out.println(X.foo(2));\n" +
+ " }\n" +
+ "}\n"
+ );
+ IJavaProject javaProject = this.workingCopies[0].getJavaProject(); //assuming single project for all working copies
+ String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
+ try {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
+ search("switch_expr_field", FIELD, ALL_OCCURRENCES);
+ assertSearchResults("src/X.java X.switch_expr_field [switch_expr_field] EXACT_MATCH\n" +
+ "src/X.java int X.foo(int) [switch_expr_field] EXACT_MATCH");
+ } finally {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
+ }
+}
+
+
+public void testBug549413_003() throws CoreException {
+ //METHOD named yield - all occurrences in yield
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java",
+ "public class X {\n"+
+ "\n"+
+ " public static int yield() {\n"+
+ " return 1;\n"+
+ " }\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public static int foo(int val) {\n"+
+ " int k = switch (val) {\n"+
+ " case 1 -> { yield 1; }\n"+
+ " default -> { yield 2; }\n"+
+ " };\n"+
+ " return k;\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(X.foo(1));\n"+
+ " }\n"+
+ "}\n"
+ );
+ IJavaProject javaProject = this.workingCopies[0].getJavaProject(); //assuming single project for all working copies
+ String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
+ try {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
+ search("yield", METHOD, ALL_OCCURRENCES);
+ assertSearchResults("src/X.java int X.yield() [yield] EXACT_MATCH");
+ } finally {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
+ }
+}
+
+public void testBug549413_004() throws CoreException {
+ //METHOD yield - references in yield
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java",
+ "public class X {\n"+
+ "\n"+
+ " public static int yield() {\n"+
+ " return 1;\n"+
+ " }\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public static int foo(int val) {\n"+
+ " int k = switch (val) {\n"+
+ " case 1 -> { yield X.yield(); }\n"+
+ " default -> { yield 2; }\n"+
+ " };\n"+
+ " return k;\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(X.foo(1));\n"+
+ " }\n"+
+ "}\n"
+ );
+ IJavaProject javaProject = this.workingCopies[0].getJavaProject(); //assuming single project for all working copies
+ String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
+ try {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
+ search("yield", METHOD, REFERENCES);
+ assertSearchResults("src/X.java int X.foo(int) [yield()] EXACT_MATCH");
+ } finally {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
+ }
+}
+
+
+public void testBug549413_005() throws CoreException {
+ //field yield - references in yield
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java",
+ "public class X {\n"+
+ " public static int yield;\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public static int foo(int val) {\n"+
+ " int k = switch (val) {\n"+
+ " case 1 -> { yield yield; }\n"+
+ " default -> { yield 2; }\n"+
+ " };\n"+
+ " return k;\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(X.foo(1));\n"+
+ " }\n"+
+ "}\n"
+ );
+ IJavaProject javaProject = this.workingCopies[0].getJavaProject(); //assuming single project for all working copies
+ String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
+ try {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
+ search("yield", FIELD, REFERENCES);
+ assertSearchResults("src/X.java int X.foo(int) [yield] EXACT_MATCH");
+ } finally {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
+ }
+}
+
+public void testBug549413_006() throws CoreException {
+ //field yield - all occurrence in yield
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java",
+ "public class X {\n"+
+ " public static int yield;\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public static int foo(int val) {\n"+
+ " int k = switch (val) {\n"+
+ " case 1 -> { yield yield; }\n"+
+ " default -> { yield 2; }\n"+
+ " };\n"+
+ " return k;\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(X.foo(1));\n"+
+ " }\n"+
+ "}\n"
+ );
+ IJavaProject javaProject = this.workingCopies[0].getJavaProject(); //assuming single project for all working copies
+ String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
+ try {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
+ search("yield", FIELD, ALL_OCCURRENCES);
+ assertSearchResults("src/X.java X.yield [yield] EXACT_MATCH\n" +
+ "src/X.java int X.foo(int) [yield] EXACT_MATCH");
+ } finally {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
+ }
+}
+
+public void testBug549413_007() throws CoreException {
+ //field yield - all reference of identifier in yield statement
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java",
+ "public class X {\n"+
+ " public static int yield;\n"+
+ " public static int abc;\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public static int foo(int val) {\n"+
+ " int k = switch (val) {\n"+
+ " case 1 -> { abc=0;yield yield; }\n"+
+ " default -> { yield 2; }\n"+
+ " };\n"+
+ " return k;\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(X.foo(1));\n"+
+ " }\n"+
+ "}\n"
+ );
+ IJavaProject javaProject = this.workingCopies[0].getJavaProject(); //assuming single project for all working copies
+ String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
+ try {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
+ search("abc", FIELD, ALL_OCCURRENCES);
+ assertSearchResults("src/X.java X.abc [abc] EXACT_MATCH\n" +
+ "src/X.java int X.foo(int) [abc] EXACT_MATCH");
+ } finally {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
+ }
+}
+
+public void testBug549413_008() throws CoreException {
+ //field yield - all reference of identifier in yield statement ( yield -1 without braces)
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java",
+ "public class X {\n"+
+ " static int yield = 100;\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public static int foo(int i) {\n"+
+ " int r = switch(i) {\n"+
+ " default -> yield - 1;\n"+
+ " };\n"+
+ " return r;\n"+
+ " }\n"+
+ " public int yield() {\n"+
+ " return 0;\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(X.foo(0));\n"+
+ " }\n"+
+ "}\n"
+ );
+ IJavaProject javaProject = this.workingCopies[0].getJavaProject(); //assuming single project for all working copies
+ String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
+ try {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
+ search("yield", FIELD, REFERENCES);
+ assertSearchResults("src/X.java int X.foo(int) [yield] EXACT_MATCH");
+ } finally {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
+ }
+}
+
+
+public void testBug549413_009() throws CoreException {
+ //field yield - all reference of identifier in yield statement ( yield -1 with braces)
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java",
+ "public class X {\n"+
+ " int yield = 100;\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public static int foo(int i) {\n"+
+ " int r = switch(i) {\n"+
+ " default ->{ yield - 1;}\n"+
+ " };\n"+
+ " return r;\n"+
+ " }\n"+
+ " public int yield() {\n"+
+ " return 0;\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(X.foo(0));\n"+
+ " }\n"+
+ "}\n"
+ );
+ IJavaProject javaProject = this.workingCopies[0].getJavaProject(); //assuming single project for all working copies
+ String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
+ try {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
+ search("yield", FIELD, REFERENCES);
+ assertSearchResults("");
+ } finally {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
+ }
+}
+
+
+public void testBug549413_010() throws CoreException {
+ //method - break label
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java",
+ "public class X {\n"+
+ "\n"+
+ " static int yield = 100;\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public static int foo(int i) {\n"+
+ " int r = switch(i) {\n"+
+ " default -> X.yield();\n"+
+ " };\n"+
+ " return r;\n"+
+ " }\n"+
+ " public static int yield() {\n"+
+ " yield: while (X.yield == 100) {\n"+
+ " yield = 256;\n"+
+ " break yield;\n"+
+ " }\n"+
+ " return yield;\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(X.foo(0));\n"+
+ " }\n"+
+ "}\n"
+ );
+ IJavaProject javaProject = this.workingCopies[0].getJavaProject(); //assuming single project for all working copies
+ String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
+ try {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
+ search("yield", METHOD, REFERENCES);
+ assertSearchResults("src/X.java int X.foo(int) [yield()] EXACT_MATCH");
+ } finally {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
+ }
+}
+
+public void testBug549413_011() throws CoreException {
+ //break label in combination with yield field
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java",
+ "public class X {\n"+
+ "\n"+
+ " static int yield = 100;\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public static int foo(int i) {\n"+
+ " int r = switch(i) {\n"+
+ " default -> X.yield();\n"+
+ " };\n"+
+ " return r;\n"+
+ " }\n"+
+ " public static int yield() {\n"+
+ " yield: while (X.yield == 100) {\n"+
+ " yield = 256;\n"+
+ " break yield;\n"+
+ " }\n"+
+ " return yield;\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(X.foo(0));\n"+
+ " }\n"+
+ "}\n"
+ );
+ IJavaProject javaProject = this.workingCopies[0].getJavaProject(); //assuming single project for all working copies
+ String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
+ try {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
+ search("yield", FIELD, REFERENCES);
+ assertSearchResults("src/X.java int X.yield() [yield] EXACT_MATCH\n" +
+ "src/X.java int X.yield() [yield] EXACT_MATCH\n" +
+ "src/X.java int X.yield() [yield] EXACT_MATCH");
+ } finally {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
+ }
+}
+
+
+public void testBug549413_012() throws CoreException {
+ //field yield - multiple yield references
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java",
+ "public class X {\n"+
+ "\n"+
+ " static int yield = 100;\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public static int foo(int i) {\n"+
+ " int r = switch(i) {\n"+
+ " default -> {yield yield + yield + yield * yield;}\n"+
+ " };\n"+
+ " return r;\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(X.foo(0));\n"+
+ " }\n"+
+ "}\n"
+ );
+ IJavaProject javaProject = this.workingCopies[0].getJavaProject(); //assuming single project for all working copies
+ String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
+ try {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
+ search("yield", FIELD, REFERENCES);
+ assertSearchResults("src/X.java int X.foo(int) [yield] EXACT_MATCH\n" +
+ "src/X.java int X.foo(int) [yield] EXACT_MATCH\n" +
+ "src/X.java int X.foo(int) [yield] EXACT_MATCH\n" +
+ "src/X.java int X.foo(int) [yield] EXACT_MATCH");
+ } finally {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
+ }
+}
+
+
+public void testBug549413_013() throws CoreException {
+ //field yield -another yield field test
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java",
+ "public class X {\n"+
+ "\n"+
+ " static int yield = 100;\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public static int foo(int i) {\n"+
+ " int r = switch(i) {\n"+
+ " default ->0 + yield + 10;\n"+
+ " };\n"+
+ " return r;\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(X.foo(0));\n"+
+ " }\n"+
+ "}\n"
+ );
+ IJavaProject javaProject = this.workingCopies[0].getJavaProject(); //assuming single project for all working copies
+ String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
+ try {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
+ search("yield", FIELD, REFERENCES);
+ assertSearchResults("src/X.java int X.foo(int) [yield] EXACT_MATCH");
+ } finally {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
+ }
+}
+
+
+public void testBug549413_014() throws CoreException {
+ //field yield - ternary operator
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java",
+ "public class X {\n"+
+ " int yield = 100;\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public int foo(int i) {\n"+
+ " int r = switch(i) {\n"+
+ " case 0 : yield 100;\n"+
+ " case 1 : yield yield;\n"+
+ " default: yield 0;\n"+
+ " };\n"+
+ " return r > 100 ? yield + 1 : yield + 200;\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " }\n"+
+ "}\n"
+ );
+ IJavaProject javaProject = this.workingCopies[0].getJavaProject(); //assuming single project for all working copies
+ String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
+ try {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
+ search("yield", FIELD, REFERENCES);
+ assertSearchResults("src/X.java int X.foo(int) [yield] EXACT_MATCH\n" +
+ "src/X.java int X.foo(int) [yield] EXACT_MATCH\n" +
+ "src/X.java int X.foo(int) [yield] EXACT_MATCH");
+ } finally {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
+ }
+}
+
+
+public void testBug549413_015() throws CoreException {
+ //field yield - another test case
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java",
+ "public class X {\n"+
+ " int yield = 100;\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public int foo(int i) {\n"+
+ " int r = switch(i) {\n"+
+ " case 0 : yield 100;\n"+
+ " case 1 : yield yield;\n"+
+ " default: yield 0;\n"+
+ " };\n"+
+ " return r > 100 ? yield() + 1 : yield + 200;\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " }\n"+
+ " public static int yield() {\n"+
+ " return 1;\n"+
+ " }\n"+
+ "}\n"
+ );
+ IJavaProject javaProject = this.workingCopies[0].getJavaProject(); //assuming single project for all working copies
+ String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
+ try {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
+ search("yield", FIELD, REFERENCES);
+ assertSearchResults("src/X.java int X.foo(int) [yield] EXACT_MATCH\n" +
+ "src/X.java int X.foo(int) [yield] EXACT_MATCH");
+ } finally {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
+ }
+}
+
+
+public void testBug549413_016() throws CoreException {
+ //method yield -method references
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java",
+ "public class X {\n"+
+ " int yield = 100;\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public int foo(int i) {\n"+
+ " int r = switch(i) {\n"+
+ " case 0 : yield 100;\n"+
+ " case 1 : yield yield;\n"+
+ " default: yield 0;\n"+
+ " };\n"+
+ " return r > 100 ? yield() + 1 : yield + 200;\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " }\n"+
+ " public static int yield() {\n"+
+ " return 1;\n"+
+ " }\n"+
+ "}\n"
+ );
+ IJavaProject javaProject = this.workingCopies[0].getJavaProject(); //assuming single project for all working copies
+ String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
+ try {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
+ search("yield", METHOD, REFERENCES);
+ assertSearchResults("src/X.java int X.foo(int) [yield()] EXACT_MATCH");
+ } finally {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
+ }
+}
+
+public void testBug549413_017() throws CoreException {
+ //select local variable and find the declaration
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java",
+ "public class X {\n"+
+ "\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public static int foo(int i) {\n"+
+ " int yield = 100;\n"+
+ " int r = switch(i) {\n"+
+ " default -> {yield /* here*/ yield + yield + yield * yield;}\n"+
+ " };\n"+
+ " return r;\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(X.foo(0));\n"+
+ " }\n"+
+ "}\n"
+ );
+
+ String str = this.workingCopies[0].getSource();
+ String selection = "/* here*/ yield";
+ int start = str.indexOf(selection);
+ int length = selection.length();
+
+ IJavaElement[] elements = this.workingCopies[0].codeSelect(start, length);
+ ILocalVariable local = (ILocalVariable) elements[0];
+ search(local, DECLARATIONS, EXACT_RULE);
+ assertSearchResults(
+ "src/X.java int X.foo(int).yield [yield] EXACT_MATCH");
+}
+
+
+public void testBug549413_018() throws CoreException {
+ //select local variable and find the declaration
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java",
+ "public class X {\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public static int foo(int i) {\n"+
+ " int localVar = 100;\n"+
+ " int r = switch(i) {\n"+
+ " default -> {yield /* here*/ localVar + localVar + localVar * localVar;}\n"+
+ " };\n"+
+ " return r;\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(X.foo(0));\n"+
+ " }\n"+
+ "}\n"
+ );
+
+ String str = this.workingCopies[0].getSource();
+ String selection = "/* here*/ localVar";
+ int start = str.indexOf(selection);
+ int length = selection.length();
+
+ IJavaElement[] elements = this.workingCopies[0].codeSelect(start, length);
+ ILocalVariable local = (ILocalVariable) elements[0];
+ search(local, DECLARATIONS, EXACT_RULE);
+ assertSearchResults(
+ "src/X.java int X.foo(int).localVar [localVar] EXACT_MATCH");
+}
+// add non-preview stuff involving yield field and method
+
+public void testBug549413_019() throws CoreException {
+ //old style switch case without preview search for yield field.
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java",
+ "public class X {\n"+
+ " static int yield;\n"+
+ " public static int yield() { \n"+
+ " return 7; \n"+
+ " } \n"+
+ " public static void main(String[] args) { \n"+
+ " int week = 1; \n"+
+ " switch (week) { \n"+
+ " case 1: \n"+
+ " yield = 88; \n"+
+ " break; \n"+
+ " case 2: \n"+
+ " yield = yield();\n"+
+ " break; \n"+
+ " default: \n"+
+ " yield = 88; \n"+
+ " break; \n" +
+ " } \n" +
+ " System.out.println(yield); \n"+
+ " }\n"+
+ "}\n"
+);
+
+
+ try {
+ search("yield", FIELD, REFERENCES);
+ assertSearchResults("src/X.java void X.main(String[]) [yield] EXACT_MATCH\n" +
+ "src/X.java void X.main(String[]) [yield] EXACT_MATCH\n" +
+ "src/X.java void X.main(String[]) [yield] EXACT_MATCH\n" +
+ "src/X.java void X.main(String[]) [yield] EXACT_MATCH");
+ } finally {
+ }
+}
+
+public void testBug549413_020() throws CoreException {
+ //old style switch case without preview search for yield method.
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java",
+ "public class X {\n"+
+ " static int yield;\n"+
+ " public static int yield() { \n"+
+ " return 7; \n"+
+ " } \n"+
+ " public static void main(String[] args) { \n"+
+ " int week = 1; \n"+
+ " switch (week) { \n"+
+ " case 1: \n"+
+ " yield = 88; \n"+
+ " break; \n"+
+ " case 2: \n"+
+ " yield = yield();\n"+
+ " break; \n"+
+ " default: \n"+
+ " yield = 88; \n"+
+ " break; \n" +
+ " } \n" +
+ " System.out.println(yield); \n"+
+ " }\n"+
+ "}\n"
+);
+
+
+ try {
+ search("yield", METHOD, REFERENCES);
+ assertSearchResults("src/X.java void X.main(String[]) [yield()] EXACT_MATCH");
+ } finally {
+ }
+}
+
+}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/NullAnnotationModelTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/NullAnnotationModelTests.java
index 54d85a1b65..7dbfd9d928 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/NullAnnotationModelTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/NullAnnotationModelTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2016 GK Software AG and others.
+ * Copyright (c) 2011, 2019 GK Software AG and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -298,7 +298,7 @@ public class NullAnnotationModelTests extends ReconcilerTests {
"Buildpath problem: the type invalid, which is configured as a null annotation type, cannot be resolved\n" +
"----------\n");
- ASTParser parser = ASTParser.newParser(AST_INTERNAL_JLS11);
+ ASTParser parser = ASTParser.newParser(AST_INTERNAL_LATEST);
parser.setProject(p);
parser.setResolveBindings(true);
parser.setSource(unit);
@@ -361,7 +361,7 @@ public class NullAnnotationModelTests extends ReconcilerTests {
assertEquals("Should have no markers", 0, markers.length);
// Challenge CompilationUnitResolver:
- ASTParser parser = ASTParser.newParser(AST_INTERNAL_JLS11);
+ ASTParser parser = ASTParser.newParser(AST_INTERNAL_LATEST);
parser.setProject(p);
parser.setResolveBindings(true);
parser.setSource(unit);
@@ -432,7 +432,7 @@ public class NullAnnotationModelTests extends ReconcilerTests {
assertEquals("Unexpected marker path", "/P/p1/C1.java", markers[0].getResource().getFullPath().toString());
// Challenge CompilationUnitResolver:
- ASTParser parser = ASTParser.newParser(AST_INTERNAL_JLS11);
+ ASTParser parser = ASTParser.newParser(AST_INTERNAL_LATEST);
parser.setProject(p);
parser.setResolveBindings(true);
parser.setSource(unit);
@@ -485,7 +485,7 @@ public class NullAnnotationModelTests extends ReconcilerTests {
final ICompilationUnit unit = getCompilationUnit("/P/p1/C1.java").getWorkingCopy(this.wcOwner, null);
assertNoProblem(c1SourceString.toCharArray(), unit);
- ASTParser parser = ASTParser.newParser(AST_INTERNAL_JLS11);
+ ASTParser parser = ASTParser.newParser(AST_INTERNAL_LATEST);
parser.setProject(p);
parser.setResolveBindings(true);
parser.setSource(unit);
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java
index 91ebdb5913..42c7614638 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -79,7 +79,7 @@ public class ReconcilerTests extends ModifyingResourceTests {
}
}
- /*package*/ static final int JLS_LATEST = AST.JLS11;
+ /*package*/ static final int JLS_LATEST = AST.JLS13;
static class ReconcileParticipant extends CompilationParticipant {
IJavaElementDelta delta;
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests9.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests9.java
index 4f85147bfc..02e1bd6089 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests9.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests9.java
@@ -43,7 +43,7 @@ public class ReconcilerTests9 extends ModifyingResourceTests {
protected ICompilationUnit workingCopy;
protected ProblemRequestor problemRequestor;
- /*package*/ static final int JLS_LATEST = AST.JLS11;
+ /*package*/ static final int JLS_LATEST = AST.JLS13;
/**
*/
@@ -436,7 +436,7 @@ public void testBug540541() throws CoreException, IOException {
"}\n");
this.workingCopy = getCompilationUnit("client/src/p/X.java").getWorkingCopy(this.wcOwner, null);
this.problemRequestor.initialize(this.workingCopy.getSource().toCharArray());
- this.workingCopy.reconcile(AST_INTERNAL_JLS11, true, this.wcOwner, null);
+ this.workingCopy.reconcile(JLS_LATEST, true, this.wcOwner, null);
assertProblems("Expecting no problems",
"----------\n" +
"----------\n",
@@ -501,7 +501,7 @@ public void testBug543092() throws Exception {
this.workingCopy = getCompilationUnit("p/src/test/Test.java").getWorkingCopy(this.wcOwner, null);
this.problemRequestor.initialize(this.workingCopy.getSource().toCharArray());
- this.workingCopy.reconcile(AST_INTERNAL_JLS11, true, this.wcOwner, null);
+ this.workingCopy.reconcile(JLS_LATEST, true, this.wcOwner, null);
assertProblems("Expecting no problems",
"----------\n" +
"----------\n",
@@ -560,7 +560,7 @@ public void testBug543092b() throws Exception {
this.workingCopy = getCompilationUnit("p/src/test/Test.java").getWorkingCopy(this.wcOwner, null);
this.problemRequestor.initialize(this.workingCopy.getSource().toCharArray());
- this.workingCopy.reconcile(AST_INTERNAL_JLS11, true, this.wcOwner, null);
+ this.workingCopy.reconcile(JLS_LATEST, true, this.wcOwner, null);
assertProblems("Expecting no problems",
"----------\n" +
"1. ERROR in /p/src/test/Test.java (at line 3)\n" +
@@ -641,7 +641,7 @@ public void testBug544017() throws CoreException {
ICompilationUnit wc = getCompilationUnit(pathExample).getWorkingCopy(this.wcOwner, null);
wc.getBuffer().append(" ");
this.problemRequestor.initialize((sourceExample+" ").toCharArray());
- wc.reconcile(AST_INTERNAL_JLS11, true, this.wcOwner, null);
+ wc.reconcile(JLS_LATEST, true, this.wcOwner, null);
assertProblems("Expecting no problems",
"----------\n" +
"----------\n",
@@ -676,7 +676,7 @@ public void testBug545687() throws CoreException, IOException {
this.problemRequestor.initialize(testSrc.toCharArray());
this.workingCopy = getCompilationUnit("testproj/src/test/Test.java").getWorkingCopy(this.wcOwner, null);
this.problemRequestor.initialize(this.workingCopy.getSource().toCharArray());
- this.workingCopy.reconcile(AST_INTERNAL_JLS11, true, this.wcOwner, null);
+ this.workingCopy.reconcile(JLS_LATEST, true, this.wcOwner, null);
assertProblems("Expecting no problems", "----------\n" + "----------\n", this.problemRequestor);
IMarker[] markers = p.getProject().findMarkers(null, true, IResource.DEPTH_INFINITE);
@@ -792,7 +792,7 @@ public void testBug546315() throws Exception {
this.problemRequestor.initialize(testSource.toCharArray());
this.workingCopy = getCompilationUnit("p/src-test/test/Test.java").getWorkingCopy(this.wcOwner, null);
this.problemRequestor.initialize(this.workingCopy.getSource().toCharArray());
- this.workingCopy.reconcile(AST_INTERNAL_JLS11, true, this.wcOwner, null);
+ this.workingCopy.reconcile(JLS_LATEST, true, this.wcOwner, null);
assertProblems("Expecting no problems", "----------\n" + "----------\n", this.problemRequestor);
markers = p.getProject().findMarkers(null, true, IResource.DEPTH_INFINITE);
@@ -843,7 +843,7 @@ public void testBug544306() throws Exception {
this.workingCopy.discardWorkingCopy();
this.workingCopy = getCompilationUnit("p2/src-test/p2/Test.java").getWorkingCopy(this.wcOwner, null);
this.problemRequestor.initialize(testSource.toCharArray());
- this.workingCopy.reconcile(AST_INTERNAL_JLS11, true, this.wcOwner, null);
+ this.workingCopy.reconcile(JLS_LATEST, true, this.wcOwner, null);
assertProblems("Expecting no problems", "----------\n" + "----------\n", this.problemRequestor);
this.workingCopy.discardWorkingCopy();
} finally {
@@ -934,7 +934,7 @@ public void testBug547113() throws CoreException {
this.problemRequestor.initialize(cSource.toCharArray());
this.workingCopy = getCompilationUnit("c/src/com/example/c/C.java").getWorkingCopy(this.wcOwner, null);
this.problemRequestor.initialize(this.workingCopy.getSource().toCharArray());
- this.workingCopy.reconcile(AST_INTERNAL_JLS11, true, this.wcOwner, null);
+ this.workingCopy.reconcile(AST_INTERNAL_JLS13, true, this.wcOwner, null);
assertProblems("Expecting no problems",
"----------\n" +
"----------\n",
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/RunCompletionModelTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/RunCompletionModelTests.java
index 348ad9ccb1..992ad6f1bb 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/RunCompletionModelTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/RunCompletionModelTests.java
@@ -41,7 +41,6 @@ public class RunCompletionModelTests extends junit.framework.TestCase {
COMPLETION_SUITES.add(CompletionTests9.class);
COMPLETION_SUITES.add(CompletionTests10.class);
COMPLETION_SUITES.add(CompletionTests11.class);
- COMPLETION_SUITES.add(CompletionTests12.class);
COMPLETION_SUITES.add(CompletionContextTests.class);
COMPLETION_SUITES.add(CompletionContextTests_1_5.class);
COMPLETION_SUITES.add(CompletionWithMissingTypesTests.class);
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingStatementsTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingStatementsTest.java
index ae8f5e505d..26fe652407 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingStatementsTest.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingStatementsTest.java
@@ -104,10 +104,10 @@ public class ASTRewritingStatementsTest extends ASTRewritingTest {
return createSuite(ASTRewritingStatementsTest.class);
}
- @Override
+ @Override
protected void setUp() throws Exception {
super.setUp();
- if (this.apiLevel == AST.JLS12 ) {
+ if (this.apiLevel == AST.JLS13 ) {
this.project1.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
this.project1.setOption(JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES, JavaCore.IGNORE);
}
@@ -3615,7 +3615,7 @@ public class ASTRewritingStatementsTest extends ASTRewritingTest {
assertTrue("Number of statements not 0", statements.size() == 0);
SwitchCase caseStatement1= ast.newSwitchCase();
- if (this.apiLevel < AST.JLS12) {
+ if (this.apiLevel < AST.JLS13) {
caseStatement1.setExpression(ast.newNumberLiteral("1"));
}
else {
@@ -3625,7 +3625,7 @@ public class ASTRewritingStatementsTest extends ASTRewritingTest {
Statement statement1= ast.newReturnStatement();
SwitchCase caseStatement2= ast.newSwitchCase(); // default
- if (this.apiLevel < AST.JLS12) {
+ if (this.apiLevel < AST.JLS13) {
caseStatement2.setExpression(null);
}
@@ -3650,7 +3650,7 @@ public class ASTRewritingStatementsTest extends ASTRewritingTest {
// change case statement
SwitchCase caseStatement= (SwitchCase) statements.get(3);
Expression newCaseExpression= ast.newNumberLiteral("10");
- if (this.apiLevel != AST.JLS12) {
+ if (this.apiLevel < AST.JLS13) {
rewrite.replace(caseStatement.getExpression(), newCaseExpression, null);
} else {
List expressions = caseStatement.expressions();
@@ -3663,7 +3663,7 @@ public class ASTRewritingStatementsTest extends ASTRewritingTest {
{
// insert case statement
SwitchCase caseStatement2= ast.newSwitchCase();
- if (this.apiLevel < AST.JLS12) {
+ if (this.apiLevel < AST.JLS13) {
caseStatement2.setExpression(ast.newNumberLiteral("11"));
}
else {
@@ -3679,7 +3679,7 @@ public class ASTRewritingStatementsTest extends ASTRewritingTest {
{
// insert case statement
SwitchCase caseStatement2= ast.newSwitchCase();
- if (this.apiLevel < AST.JLS12) {
+ if (this.apiLevel < AST.JLS13) {
caseStatement2.setExpression(ast.newNumberLiteral("12"));
}
else {
@@ -3774,7 +3774,7 @@ public class ASTRewritingStatementsTest extends ASTRewritingTest {
assertTrue("Number of statements not 0", statements.size() == 0);
SwitchCase caseStatement1= ast.newSwitchCase();
- if (this.apiLevel < AST.JLS12) {
+ if (this.apiLevel < AST.JLS13) {
caseStatement1.setExpression(ast.newNumberLiteral("1"));
}
else {
@@ -3784,7 +3784,7 @@ public class ASTRewritingStatementsTest extends ASTRewritingTest {
Statement statement1= ast.newReturnStatement();
SwitchCase caseStatement2= ast.newSwitchCase(); // default
- if (this.apiLevel < AST.JLS12) {
+ if (this.apiLevel < AST.JLS13) {
caseStatement2.setExpression(null);
}
@@ -3809,7 +3809,7 @@ public class ASTRewritingStatementsTest extends ASTRewritingTest {
// change case statement
SwitchCase caseStatement= (SwitchCase) statements.get(3);
Expression newCaseExpression= ast.newNumberLiteral("10");
- if (this.apiLevel < AST.JLS12) {
+ if (this.apiLevel < AST.JLS13) {
rewrite.replace(caseStatement.getExpression(), newCaseExpression, null);
} else {
List expressions = caseStatement.expressions();
@@ -3822,7 +3822,7 @@ public class ASTRewritingStatementsTest extends ASTRewritingTest {
{
// insert case statement
SwitchCase caseStatement2= ast.newSwitchCase();
- if (this.apiLevel < AST.JLS12) {
+ if (this.apiLevel < AST.JLS13) {
caseStatement2.setExpression(ast.newNumberLiteral("11"));
}
else {
@@ -3839,7 +3839,7 @@ public class ASTRewritingStatementsTest extends ASTRewritingTest {
{
// insert case statement
SwitchCase caseStatement2= ast.newSwitchCase();
- if (this.apiLevel < AST.JLS12) {
+ if (this.apiLevel < AST.JLS13) {
caseStatement2.setExpression(ast.newNumberLiteral("12"));
}
else {
@@ -4150,7 +4150,7 @@ public class ASTRewritingStatementsTest extends ASTRewritingTest {
ExpressionStatement assignment = (ExpressionStatement)statements.get(1); // i= 1;:
SwitchCase switchCase = ast.newSwitchCase();
- if (this.apiLevel < AST.JLS12) {
+ if (this.apiLevel < AST.JLS13) {
switchCase.setExpression(ast.newNumberLiteral("2"));
}
else {
@@ -4298,7 +4298,7 @@ public class ASTRewritingStatementsTest extends ASTRewritingTest {
ExpressionStatement assignment = (ExpressionStatement)statements.get(1); // i= 1;
SwitchCase switchCase = ast.newSwitchCase();
- if (this.apiLevel < AST.JLS12) {
+ if (this.apiLevel < AST.JLS13) {
switchCase.setExpression(ast.newNumberLiteral("2"));
}
else {
@@ -4622,7 +4622,7 @@ public class ASTRewritingStatementsTest extends ASTRewritingTest {
SwitchStatement switchStmt = (SwitchStatement) blockStatements.get(1);
SwitchCase caseStatement1= ast.newSwitchCase();
- if (this.apiLevel < AST.JLS12) {
+ if (this.apiLevel < AST.JLS13) {
caseStatement1.setExpression(ast.newNumberLiteral("100"));
} else {
caseStatement1.expressions().add(ast.newNumberLiteral("100"));
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingSwitchExpressionsTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingSwitchExpressionsTest.java
index 17754814ab..228b8872b4 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingSwitchExpressionsTest.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingSwitchExpressionsTest.java
@@ -54,15 +54,15 @@ public class ASTRewritingSwitchExpressionsTest extends ASTRewritingTest {
return createSuite(ASTRewritingSwitchExpressionsTest.class);
}
- @Override
+ @Override
protected void setUp() throws Exception {
super.setUp();
- if (this.apiLevel == AST.JLS12 ) {
+ if (this.apiLevel == AST.JLS13 ) {
this.project1.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
this.project1.setOption(JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES, JavaCore.IGNORE);
- this.project1.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_12);
- this.project1.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_12);
- this.project1.setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_12);
+ this.project1.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_13);
+ this.project1.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_13);
+ this.project1.setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_13);
}
}
@@ -169,8 +169,9 @@ public class ASTRewritingSwitchExpressionsTest extends ASTRewritingTest {
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
+ @Deprecated
@SuppressWarnings("rawtypes")
- public void testSwitchExpressions_02_since_12() throws Exception {
+ public void _testSwitchExpressions_02_since_12() throws Exception {
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
@@ -228,8 +229,9 @@ public class ASTRewritingSwitchExpressionsTest extends ASTRewritingTest {
assertEqualString(preview, buf.toString());
}
+ @Deprecated
@SuppressWarnings("rawtypes")
- public void testSwitchExpressions_03_since_12() throws Exception {
+ public void _testSwitchExpressions_03_since_12() throws Exception {
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null);
String s =
"package test1;\n"+
@@ -315,7 +317,7 @@ public class ASTRewritingSwitchExpressionsTest extends ASTRewritingTest {
}
@SuppressWarnings("rawtypes")
- public void testSwitchStatement_Bug543720_since_12() throws Exception {
+ public void _testSwitchStatement_Bug543720_since_12() throws Exception {
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null);
String s =
"package test1;\n"+
@@ -396,7 +398,7 @@ public class ASTRewritingSwitchExpressionsTest extends ASTRewritingTest {
assertEqualString(preview, buf.toString());
}
@SuppressWarnings("rawtypes")
- public void testSwitchExpressions_04_since_12() throws Exception {
+ public void _testSwitchExpressions_04_since_12() throws Exception {
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null);
String s = "package test1;\n"+
"public class X {\n"+
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingTest.java
index 5437dbb065..4a2fb22113 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingTest.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingTest.java
@@ -83,9 +83,9 @@ public class ASTRewritingTest extends AbstractJavaModelTests {
/** @deprecated using deprecated code */
private final static int JLS10_INTERNAL = AST.JLS10;
- private final static int JLS12_INTERNAL = AST.JLS12;
+ private final static int JLS13_INTERNAL = AST.JLS13;
- private final static int[] JLS_LEVELS = { JLS2_INTERNAL, JLS3_INTERNAL, JLS4_INTERNAL, JLS8_INTERNAL, JLS9_INTERNAL, JLS10_INTERNAL, JLS12_INTERNAL };
+ private final static int[] JLS_LEVELS = { JLS2_INTERNAL, JLS3_INTERNAL, JLS4_INTERNAL, JLS8_INTERNAL, JLS9_INTERNAL, JLS10_INTERNAL, JLS13_INTERNAL };
private static final String ONLY_AST_STRING = "_only";
private static final String SINCE_AST_STRING = "_since";
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ImportRewriteTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ImportRewriteTest.java
index ecf0daa3ce..d0eb23b11b 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ImportRewriteTest.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ImportRewriteTest.java
@@ -4959,7 +4959,7 @@ public class ImportRewriteTest extends AbstractJavaModelTests {
"}\n";
ICompilationUnit cu = pack1.createCompilationUnit("X.java", contents, false, null);
- ASTParser parser = ASTParser.newParser(AST_INTERNAL_JLS11);
+ ASTParser parser = ASTParser.newParser(AST_INTERNAL_LATEST);
parser.setSource(cu);
parser.setResolveBindings(true);
parser.setStatementsRecovery(true);
@@ -4984,7 +4984,7 @@ public class ImportRewriteTest extends AbstractJavaModelTests {
"}\n";
ICompilationUnit cu = pack1.createCompilationUnit("X.java", contents, false, null);
- ASTParser parser = ASTParser.newParser(AST_INTERNAL_JLS11);
+ ASTParser parser = ASTParser.newParser(AST_INTERNAL_LATEST);
parser.setSource(cu);
parser.setResolveBindings(true);
parser.setStatementsRecovery(true);
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter12/.classpath b/org.eclipse.jdt.core.tests.model/workspace/Converter13/.classpath
index 3522bc0c3f..3522bc0c3f 100644
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter12/.classpath
+++ b/org.eclipse.jdt.core.tests.model/workspace/Converter13/.classpath
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter12/.project b/org.eclipse.jdt.core.tests.model/workspace/Converter13/.project
index 663fb8d747..663fb8d747 100644
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter12/.project
+++ b/org.eclipse.jdt.core.tests.model/workspace/Converter13/.project
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter12/src/X.java b/org.eclipse.jdt.core.tests.model/workspace/Converter13/src/X.java
index 5a1a8880f1..5a1a8880f1 100644
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter12/src/X.java
+++ b/org.eclipse.jdt.core.tests.model/workspace/Converter13/src/X.java
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test390720/A_out.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test390720/A_out.java
index 683eafb167..f1db906b13 100644
--- a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test390720/A_out.java
+++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test390720/A_out.java
@@ -16,7 +16,7 @@ public class MyTest {
case 4: {
- // break missing, oh well...
+ // yield missing, oh well...
}
@@ -33,13 +33,13 @@ public class MyTest {
int c = switch (b) {
case 444:
- break a + b;
+ yield a + b;
case 555:
case 666:
doSoemthing();
- break 777;
+ yield 777;
default:
@@ -52,7 +52,7 @@ public class MyTest {
case 1 -> 6;
case 2 -> {
int f = a + b;
- break f * f;
+ yield f * f;
}
default -> 55;
};
@@ -79,32 +79,32 @@ public class MyTest {
doSomething(switch (a * b * c * d) {
case 888:
aaa();
- break bbb();
+ yield bbb();
// comment
case 999:
aaa();
- break bbb();
+ yield bbb();
// comment
case 101010:
aaa();
- break bbb();
+ yield bbb();
// comment
case 111111:
aaa();
- break bbb();
+ yield bbb();
// comment
case 121212:
aaa();
- break bbb();
+ yield bbb();
// comment
@@ -113,14 +113,14 @@ public class MyTest {
case 131313:
aaa();
- break bbb();
+ yield bbb();
// comment
// comment
default:
aaa();
- break bbb();
+ yield bbb();
});
}
}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test390720/B_out.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test390720/B_out.java
index b428dfcccd..68d73ba84b 100644
--- a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test390720/B_out.java
+++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test390720/B_out.java
@@ -12,7 +12,7 @@ public class MyTest {
doSomeOtherThing();
break;
case 4: {
- // break missing, oh well...
+ // yield missing, oh well...
}
case 5: {
doSomething(55);
@@ -25,11 +25,11 @@ public class MyTest {
int c = switch (b) {
case 444:
- break a + b;
+ yield a + b;
case 555:
case 666:
doSoemthing();
- break 777;
+ yield 777;
default:
doSomeOtherSomething();
return;
@@ -40,7 +40,7 @@ public class MyTest {
case 1 -> 6;
case 2 -> {
int f = a + b;
- break f * f;
+ yield f * f;
}
default -> 55;
};
@@ -63,37 +63,37 @@ public class MyTest {
doSomething(switch (a * b * c * d) {
case 888:
aaa();
- break bbb();
+ yield bbb();
// comment
case 999:
aaa();
- break bbb();
+ yield bbb();
// comment
case 101010:
aaa();
- break bbb();
+ yield bbb();
// comment
case 111111:
aaa();
- break bbb();
+ yield bbb();
// comment
case 121212:
aaa();
- break bbb();
+ yield bbb();
// comment
// comment
case 131313:
aaa();
- break bbb();
+ yield bbb();
// comment
// comment
default:
aaa();
- break bbb();
+ yield bbb();
});
}
}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test390720/in.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test390720/in.java
index 6072466362..967b5c9b78 100644
--- a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test390720/in.java
+++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test390720/in.java
@@ -13,7 +13,7 @@ public class MyTest {
doSomeOtherThing();
break;
case 4: {
- // break missing, oh well...
+ // yield missing, oh well...
}
case 5: {
@@ -27,12 +27,12 @@ public class MyTest {
int c = switch (b) {
case 444:
- break a + b;
+ yield a + b;
case 555:
case 666:
doSoemthing();
- break 777;
+ yield 777;
default:
doSomeOtherSomething();
return;
@@ -43,7 +43,7 @@ public class MyTest {
case 1 -> 6;
case 2 -> {
int f = a + b;
- break f * f;
+ yield f * f;
}
default -> 55;
};
@@ -66,27 +66,27 @@ public class MyTest {
doSomething(switch (a * b * c * d) {
case 888:
aaa();
- break bbb();
+ yield bbb();
// comment
case 999:
aaa();
- break bbb();
+ yield bbb();
// comment
case 101010:
aaa();
- break bbb();
+ yield bbb();
// comment
case 111111:
aaa();
- break bbb();
+ yield bbb();
// comment
case 121212:
aaa();
- break bbb();
+ yield bbb();
// comment
@@ -94,12 +94,12 @@ public class MyTest {
case 131313:
aaa();
- break bbb();
+ yield bbb();
// comment
// comment
default:
aaa();
- break bbb();
+ yield bbb();
});
}
}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test543818/A_out.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test543818/A_out.java
index 89ab5633ba..2e4f19b2bf 100644
--- a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test543818/A_out.java
+++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test543818/A_out.java
@@ -31,7 +31,7 @@ public class C {
int value = switch (ABC) {
case A :
- break 1;
+ yield 1;
case B :
System.out.println("!!!");
return;
@@ -40,16 +40,16 @@ public class C {
case C , D , E , F , G :
case H , I , J : {
System.out.println("@@@");
- break 3454366;
+ yield 3454366;
}
default:
- break 6;
+ yield 6;
};
Object value2 = switch (a.b.c.d(e.f.g.h())) {
case a -> {
System.out.println("aaaaaaa");
- break "";
+ yield "";
}
case b + c , d.e , f("aaaaaaaaaaaa"//
+ //
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test543818/B_out.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test543818/B_out.java
index 30ba3b5be8..9800b28ae7 100644
--- a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test543818/B_out.java
+++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test543818/B_out.java
@@ -31,7 +31,7 @@ public class C {
int value = switch (ABC ) {
case A:
- break 1;
+ yield 1;
case B:
System.out.println("!!!");
return;
@@ -40,16 +40,16 @@ public class C {
case C,D,E,F,G:
case H,I,J: {
System.out.println("@@@");
- break 3454366;
+ yield 3454366;
}
default:
- break 6;
+ yield 6;
};
Object value2 = switch (a.b.c.d(e.f.g.h()) ) {
case a -> {
System.out.println("aaaaaaa");
- break "";
+ yield "";
}
case b + c,d.e,f("aaaaaaaaaaaa"//
+ //
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test543818/C_out.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test543818/C_out.java
index b98e85a4d6..f7928100c0 100644
--- a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test543818/C_out.java
+++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test543818/C_out.java
@@ -31,7 +31,7 @@ public class C {
int value = switch(ABC) {
case A:
- break 1;
+ yield 1;
case B:
System.out.println("!!!");
return;
@@ -40,16 +40,16 @@ public class C {
case C, D, E, F, G:
case H, I, J: {
System.out.println("@@@");
- break 3454366;
+ yield 3454366;
}
default:
- break 6;
+ yield 6;
};
Object value2 = switch(a.b.c.d(e.f.g.h())) {
case a-> {
System.out.println("aaaaaaa");
- break "";
+ yield "";
}
case b + c, d.e, f("aaaaaaaaaaaa"//
+ //
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test543818/D_out.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test543818/D_out.java
index 49e0db739e..c9715995d5 100644
--- a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test543818/D_out.java
+++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test543818/D_out.java
@@ -34,7 +34,7 @@ public class C {
int value = switch ( ABC)
{
case A:
- break 1;
+ yield 1;
case B:
System.out.println("!!!");
return;
@@ -43,17 +43,17 @@ public class C {
case C, D, E, F, G:
case H, I, J:{
System.out.println("@@@");
- break 3454366;
+ yield 3454366;
}
default:
- break 6;
+ yield 6;
};
Object value2 = switch ( a.b.c.d(e.f.g.h()))
{
case a ->{
System.out.println("aaaaaaa");
- break "";
+ yield "";
}
case b + c, d.e, f("aaaaaaaaaaaa"//
+ //
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test543818/E_out.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test543818/E_out.java
index d8bbd1a1f4..25f85e2c00 100644
--- a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test543818/E_out.java
+++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test543818/E_out.java
@@ -37,7 +37,7 @@ public class C {
ABC
) {
case A:
- break 1;
+ yield 1;
case B:
System.out.println("!!!");
return;
@@ -46,10 +46,10 @@ public class C {
case C, D, E, F, G:
case H, I, J: {
System.out.println("@@@");
- break 3454366;
+ yield 3454366;
}
default :
- break 6;
+ yield 6;
};
Object value2 = switch (
@@ -57,7 +57,7 @@ public class C {
) {
case a -> {
System.out.println("aaaaaaa");
- break "";
+ yield "";
}
case b + c, d.e, f("aaaaaaaaaaaa"//
+ //
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test543818/F_out.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test543818/F_out.java
index 6ad72c331f..27b34bdad4 100644
--- a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test543818/F_out.java
+++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test543818/F_out.java
@@ -31,7 +31,7 @@ public class C {
int value = switch (ABC){
case A:
- break 1;
+ yield 1;
case B:
System.out.println("!!!");
return;
@@ -40,16 +40,16 @@ public class C {
case C, D, E, F, G:
case H, I, J:{
System.out.println("@@@");
- break 3454366;
+ yield 3454366;
}
default:
- break 6;
+ yield 6;
};
Object value2 = switch (a.b.c.d(e.f.g.h())){
case a -> {
System.out.println("aaaaaaa");
- break "";
+ yield "";
}
case b + c, d.e, f("aaaaaaaaaaaa"//
+ //
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test543818/G_out.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test543818/G_out.java
index aa05baad51..5a06a59163 100644
--- a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test543818/G_out.java
+++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test543818/G_out.java
@@ -31,7 +31,7 @@ public class C {
int value = switch (ABC) {
case A:
- break 1;
+ yield 1;
case B:
System.out.println("!!!");
return;
@@ -40,16 +40,16 @@ public class C {
case C, D, E, F, G:
case H, I, J: {
System.out.println("@@@");
- break 3454366;
+ yield 3454366;
}
default:
- break 6;
+ yield 6;
};
Object value2 = switch (a.b.c.d(e.f.g.h())) {
case a -> {
System.out.println("aaaaaaa");
- break "";
+ yield "";
}
case b + c, d.e, f("aaaaaaaaaaaa"//
+ //
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test543818/in.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test543818/in.java
index 7dfd080e19..96f93ec985 100644
--- a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test543818/in.java
+++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test543818/in.java
@@ -30,7 +30,7 @@ public class C {
int value = switch(ABC) {
case A:
- break 1;
+ yield 1;
case B:
System.out.println("!!!");
return;
@@ -38,15 +38,15 @@ public class C {
case C, D, E, F, G:
case H, I, J: {
System.out.println("@@@");
- break 3454366;
+ yield 3454366;
}
- default: break 6;
+ default: yield 6;
};
Object value2 = switch(a.b.c.d(e.f.g.h())) {
case a -> {
System.out.println("aaaaaaa");
- break "";
+ yield "";
}
case b + c, d.e, f("aaaaaaaaaaaa"//
+//
diff --git a/org.eclipse.jdt.core.tests.performance/META-INF/MANIFEST.MF b/org.eclipse.jdt.core.tests.performance/META-INF/MANIFEST.MF
index 539f46b01b..9b5cad8454 100644
--- a/org.eclipse.jdt.core.tests.performance/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.core.tests.performance/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jdt.core.tests.performance
-Bundle-Version: 3.10.600.qualifier
+Bundle-Version: 3.10.650.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package: org.eclipse.jdt.core.tests.performance,
diff --git a/org.eclipse.jdt.core.tests.performance/pom.xml b/org.eclipse.jdt.core.tests.performance/pom.xml
index e7be08995b..1aa7656e5f 100644
--- a/org.eclipse.jdt.core.tests.performance/pom.xml
+++ b/org.eclipse.jdt.core.tests.performance/pom.xml
@@ -20,7 +20,7 @@
</parent>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.core.tests.performance</artifactId>
- <version>3.10.600-SNAPSHOT</version>
+ <version>3.10.650-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<properties>
<testSuite>${project.artifactId}</testSuite>
diff --git a/org.eclipse.jdt.core.tests.performance/src/org/eclipse/jdt/core/tests/performance/SecondaryTypesPerformanceTest.java b/org.eclipse.jdt.core.tests.performance/src/org/eclipse/jdt/core/tests/performance/SecondaryTypesPerformanceTest.java
index fa5a8a2d8e..b4c03cd1c9 100644
--- a/org.eclipse.jdt.core.tests.performance/src/org/eclipse/jdt/core/tests/performance/SecondaryTypesPerformanceTest.java
+++ b/org.eclipse.jdt.core.tests.performance/src/org/eclipse/jdt/core/tests/performance/SecondaryTypesPerformanceTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2016 Sven Strohschein and others.
+ * Copyright (c) 2016, 2019 Sven Strohschein and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -84,7 +84,7 @@ public class SecondaryTypesPerformanceTest extends PerformanceTestCase {
classpathList.add(testScratchArea);
for (int i = 0; i<10; ++i) {
- ASTParser parser = ASTParser.newParser(AST.JLS11);
+ ASTParser parser = ASTParser.newParser(AST.JLS13);
parser.setResolveBindings(true);
parser.setStatementsRecovery(true);
parser.setBindingsRecovery(true);
diff --git a/org.eclipse.jdt.core/.settings/.api_filters b/org.eclipse.jdt.core/.settings/.api_filters
index 26e4f57056..f5f3fac15f 100644
--- a/org.eclipse.jdt.core/.settings/.api_filters
+++ b/org.eclipse.jdt.core/.settings/.api_filters
@@ -1,49 +1,105 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<component id="org.eclipse.jdt.core" version="2">
<resource path="compiler/org/eclipse/jdt/core/compiler/CategorizedProblem.java" type="org.eclipse.jdt.core.compiler.CategorizedProblem">
- <filter comment="To be addressed while merging 12" id="336658481">
+ <filter comment="PREVIEW RELATED" id="336658481">
<message_arguments>
<message_argument value="org.eclipse.jdt.core.compiler.CategorizedProblem"/>
- <message_argument value="CAT_COMPLIANCE"/>
+ <message_argument value="CAT_PREVIEW_RELATED"/>
</message_arguments>
</filter>
</resource>
<resource path="compiler/org/eclipse/jdt/core/compiler/IProblem.java" type="org.eclipse.jdt.core.compiler.IProblem">
- <filter id="388194388">
+ <filter comment="BETA_JAVA13 addition of preview related base" id="388194388">
<message_arguments>
<message_argument value="org.eclipse.jdt.core.compiler.IProblem"/>
<message_argument value="IgnoreCategoriesMask"/>
- <message_argument value="8388607"/>
+ <message_argument value="4194303"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="dom/org/eclipse/jdt/core/dom/ASTVisitor.java" type="org.eclipse.jdt.core.dom.ASTVisitor">
+ <filter comment="Not required as it is a part of preview feature" id="338944126">
+ <message_arguments>
+ <message_argument value="org.eclipse.jdt.core.dom.ASTVisitor"/>
+ <message_argument value="visit(SwitchExpression)"/>
</message_arguments>
</filter>
</resource>
<resource path="dom/org/eclipse/jdt/core/dom/BreakStatement.java" type="org.eclipse.jdt.core.dom.BreakStatement">
- <filter comment="For Java 12 support." id="336658481">
+ <filter comment="No more an API as part of preview feature" id="338944126">
+ <message_arguments>
+ <message_argument value="org.eclipse.jdt.core.dom.BreakStatement"/>
+ <message_argument value="getExpression()"/>
+ </message_arguments>
+ </filter>
+ <filter comment="No more an API as part of preview feature" id="338944126">
+ <message_arguments>
+ <message_argument value="org.eclipse.jdt.core.dom.BreakStatement"/>
+ <message_argument value="isImplicit()"/>
+ </message_arguments>
+ </filter>
+ <filter comment="preview feature - transient" id="338944126">
+ <message_arguments>
+ <message_argument value="org.eclipse.jdt.core.dom.BreakStatement"/>
+ <message_argument value="propertyDescriptors(int, boolean)"/>
+ </message_arguments>
+ </filter>
+ <filter comment="Not valid for Java 13" id="338944126">
<message_arguments>
<message_argument value="org.eclipse.jdt.core.dom.BreakStatement"/>
- <message_argument value="EXPRESSION_PROPERTY"/>
+ <message_argument value="setExpression(Expression)"/>
</message_arguments>
</filter>
</resource>
<resource path="dom/org/eclipse/jdt/core/dom/SwitchCase.java" type="org.eclipse.jdt.core.dom.SwitchCase">
- <filter comment="For Java 12" id="336658481">
+ <filter comment="No more an API as part of preview feature" id="338944126">
<message_arguments>
<message_argument value="org.eclipse.jdt.core.dom.SwitchCase"/>
- <message_argument value="EXPRESSIONS2_PROPERTY"/>
+ <message_argument value="expressions()"/>
</message_arguments>
</filter>
- <filter comment="For Java 12 Support - case -&gt;" id="336658481">
+ <filter comment="No more an API as part of preview feature" id="338944126">
<message_arguments>
<message_argument value="org.eclipse.jdt.core.dom.SwitchCase"/>
- <message_argument value="SWITCH_LABELED_RULE_PROPERTY"/>
+ <message_argument value="isSwitchLabeledRule()"/>
+ </message_arguments>
+ </filter>
+ <filter comment="No more an API as part of preview feature" id="338944126">
+ <message_arguments>
+ <message_argument value="org.eclipse.jdt.core.dom.SwitchCase"/>
+ <message_argument value="setSwitchLabeledRule(boolean)"/>
</message_arguments>
</filter>
</resource>
- <resource path="model/org/eclipse/jdt/core/util/IClassFileReader.java" type="org.eclipse.jdt.core.util.IClassFileReader">
- <filter comment="default method added for getting nest members" id="404000815">
+ <resource path="dom/org/eclipse/jdt/core/dom/SwitchExpression.java" type="org.eclipse.jdt.core.dom.SwitchExpression">
+ <filter comment="No more an API as part of preview feature" id="338944126">
+ <message_arguments>
+ <message_argument value="org.eclipse.jdt.core.dom.SwitchExpression"/>
+ <message_argument value="getExpression()"/>
+ </message_arguments>
+ </filter>
+ <filter comment="No more an API as part of preview feature" id="338944126">
+ <message_arguments>
+ <message_argument value="org.eclipse.jdt.core.dom.SwitchExpression"/>
+ <message_argument value="propertyDescriptors(int)"/>
+ </message_arguments>
+ </filter>
+ <filter comment="preview feature - transient" id="338944126">
+ <message_arguments>
+ <message_argument value="org.eclipse.jdt.core.dom.SwitchExpression"/>
+ <message_argument value="propertyDescriptors(int, boolean)"/>
+ </message_arguments>
+ </filter>
+ <filter comment="No more an API as part of preview feature" id="338944126">
+ <message_arguments>
+ <message_argument value="org.eclipse.jdt.core.dom.SwitchExpression"/>
+ <message_argument value="setExpression(Expression)"/>
+ </message_arguments>
+ </filter>
+ <filter comment="Only for Java 13" id="338944126">
<message_arguments>
- <message_argument value="org.eclipse.jdt.core.util.IClassFileReader"/>
- <message_argument value="getNestMembersAttribute()"/>
+ <message_argument value="org.eclipse.jdt.core.dom.SwitchExpression"/>
+ <message_argument value="statements()"/>
</message_arguments>
</filter>
</resource>
diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java
index 43131531bc..daf0b505bd 100644
--- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java
+++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java
@@ -2195,6 +2195,16 @@ public void configure(String[] argv) {
mode = DEFAULT;
continue;
}
+ if (currentArg.equals("-13") || currentArg.equals("-13.0")) { //$NON-NLS-1$ //$NON-NLS-2$
+ if (didSpecifyCompliance) {
+ throw new IllegalArgumentException(
+ this.bind("configure.duplicateCompliance", currentArg)); //$NON-NLS-1$
+ }
+ didSpecifyCompliance = true;
+ this.options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_13);
+ mode = DEFAULT;
+ continue;
+ }
if (currentArg.equals("-d")) { //$NON-NLS-1$
if (this.destinationPath != null) {
StringBuffer errorMessage = new StringBuffer();
@@ -2753,6 +2763,8 @@ public void configure(String[] argv) {
this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_11);
} else if (currentArg.equals("12") || currentArg.equals("12.0")) { //$NON-NLS-1$//$NON-NLS-2$
this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_12);
+ } else if (currentArg.equals("13") || currentArg.equals("13.0")) { //$NON-NLS-1$//$NON-NLS-2$
+ this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_13);
}
else if (currentArg.equals("jsr14")) { //$NON-NLS-1$
this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_JSR14);
@@ -2844,6 +2856,8 @@ public void configure(String[] argv) {
this.options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_11);
} else if (currentArg.equals("12") || currentArg.equals("12.0")) { //$NON-NLS-1$//$NON-NLS-2$
this.options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_12);
+ } else if (currentArg.equals("13") || currentArg.equals("13.0")) { //$NON-NLS-1$//$NON-NLS-2$
+ this.options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_13);
} else {
throw new IllegalArgumentException(this.bind("configure.source", currentArg)); //$NON-NLS-1$
}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java
index 38eaad8ce3..9a0c3d312a 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Stephan Herrmann - Contribution for
@@ -99,6 +99,7 @@ public class CompletionParser extends AssistParser {
protected static final int K_AFTER_NAME_IN_PROVIDES_STATEMENT = COMPLETION_PARSER + 49;
protected static final int K_AFTER_WITH_IN_PROVIDES_STATEMENT = COMPLETION_PARSER + 50;
protected static final int K_INSIDE_OPENS_STATEMENT = COMPLETION_PARSER + 51;
+ protected static final int K_YIELD_KEYWORD = COMPLETION_PARSER + 52;
public final static char[] FAKE_TYPE_NAME = new char[]{' '};
@@ -1675,6 +1676,14 @@ private boolean checkInstanceofKeyword() {
}
return false;
}
+private boolean checkYieldKeyword() {
+ // Clients to ensure that we are already inside a method
+ char[] id = this.scanner.getCurrentIdentifierSource();
+ if(id.length > 0 && CharOperation.prefixEquals(id, Keywords.YIELD)) {
+ return true;
+ }
+ return false;
+}
/**
* Checks if the completion is inside a method invocation or a constructor invocation.
* Returns whether we found a completion node.
@@ -3798,6 +3807,12 @@ protected void consumePushPosition() {
}
}
@Override
+protected void consumeSwitchLabeledBlock() {
+ popUntilElement(K_SWITCH_LABEL);
+ popElement(K_SWITCH_LABEL);
+ concatNodeLists();
+}
+@Override
protected void consumeToken(int token) {
if(this.isFirst) {
super.consumeToken(token);
@@ -3826,6 +3841,10 @@ protected void consumeToken(int token) {
break;
case TokenNameLBRACE:
popElement(K_BETWEEN_NEW_AND_LEFT_BRACKET);
+ if(topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) == K_SWITCH_LABEL
+ && previous == TokenNameARROW) {
+ pushOnElementStack(K_SWITCH_EXPRESSION_DELIMITTER);
+ }
break;
case TokenNameLBRACKET:
if(topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) == K_BETWEEN_NEW_AND_LEFT_BRACKET) {
@@ -3916,6 +3935,16 @@ protected void consumeToken(int token) {
case TokenNameIdentifier:
if (this.inReferenceExpression)
break;
+ if (this.scanner.previewEnabled && isInsideSwitch() && checkYieldKeyword()) {
+ pushOnElementStack(K_YIELD_KEYWORD);
+ // Take the short cut here.
+ // Instead of injecting the TokenNameRestrictedIdentifierYield, totally ignore it
+ // and let completion take it course. We will not be constructing the
+ // YieldStatement and thus not producing accurate completion, but completion doesn't have
+ // enough information anyway about the LHS anyway.
+ token = this.currentToken = this.getNextToken();
+ super.consumeToken(this.currentToken);
+ }
if (previous == TokenNameDOT) { // e.g. foo().[fred]()
if (this.invocationType != SUPER_RECEIVER // e.g. not super.[fred]()
&& this.invocationType != NAME_RECEIVER // e.g. not bar.[fred]()
@@ -4321,6 +4350,7 @@ protected void consumeToken(int token) {
pushOnElementStack(K_BETWEEN_FOR_AND_RIGHT_PAREN, this.bracketDepth);
break;
case TokenNameswitch:
+ popElement(K_LOCAL_INITIALIZER_DELIMITER);
pushOnElementStack(K_BETWEEN_SWITCH_AND_RIGHT_PAREN, this.bracketDepth);
break;
case TokenNamesynchronized:
@@ -4864,7 +4894,8 @@ public NameReference createSingleAssistNameReference(char[] assistName, long pos
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=269493: Keywords are not proposed in a for
// loop without block. Completion while at K_CONTROL_STATEMENT_DELIMITER case needs to handled
// similar to the K_BLOCK_DELIMITER with minor differences.
- if(kind == K_BLOCK_DELIMITER || kind == K_CONTROL_STATEMENT_DELIMITER || kind == K_LAMBDA_EXPRESSION_DELIMITER) {
+ if(kind == K_BLOCK_DELIMITER || kind == K_CONTROL_STATEMENT_DELIMITER || kind == K_LAMBDA_EXPRESSION_DELIMITER
+ || kind == K_SWITCH_EXPRESSION_DELIMITTER) {
if(this.canBeExplicitConstructor == YES) {
canBeExplicitConstructorCall = true;
}
@@ -4906,6 +4937,9 @@ public NameReference createSingleAssistNameReference(char[] assistName, long pos
if(isInsideBreakable()) {
keywords[count++]= Keywords.BREAK;
}
+ if(isInsideSwitch()) {
+ keywords[count++]= Keywords.YIELD;
+ }
} else if (kind == K_BETWEEN_FOR_AND_RIGHT_PAREN) {
if (this.options.complianceLevel >= ClassFileConstants.JDK10) {
keywords[count++]= Keywords.VAR;
@@ -4920,13 +4954,16 @@ public NameReference createSingleAssistNameReference(char[] assistName, long pos
keywords[count++]= Keywords.TRUE;
keywords[count++]= Keywords.FALSE;
keywords[count++]= Keywords.NULL;
-
+ if (kind == K_YIELD_KEYWORD) {
+ keywords[count++]= Keywords.YIELD;
+ }
if(kind == K_SWITCH_LABEL) {
if(topKnownElementInfo(COMPLETION_OR_ASSIST_PARSER) != DEFAULT) {
keywords[count++]= Keywords.DEFAULT;
}
keywords[count++]= Keywords.BREAK;
keywords[count++]= Keywords.CASE;
+ keywords[count++]= Keywords.YIELD;
if (this.options.complianceLevel >= ClassFileConstants.JDK1_4) {
keywords[count++]= Keywords.ASSERT;
}
@@ -5124,9 +5161,7 @@ protected NameReference getUnspecifiedReference(boolean rejectTypeAnnotations) {
@Override
protected void consumePostfixExpression() {
// PostfixExpression ::= Name
- if(this.topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) == K_INSIDE_BREAK_STATEMENT) {
- // Do nothing, just let checkLabelStatement() do the job
- } else {
+ if (topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) != K_YIELD_KEYWORD) {
super.consumePostfixExpression();
}
}
@@ -5231,24 +5266,11 @@ protected boolean isInsideAnnotation() {
return false;
}
-protected boolean isIndirectlyInsideBlock(){
- int i = this.elementPtr;
- while(i > -1) {
- if(this.elementKindStack[i] == K_BLOCK_DELIMITER)
- return true;
- i--;
- }
- return false;
-}
-
-protected boolean isInsideBlock(){
+protected boolean isInsideSwitch(){
int i = this.elementPtr;
while(i > -1) {
switch (this.elementKindStack[i]) {
- case K_TYPE_DELIMITER : return false;
- case K_METHOD_DELIMITER : return false;
- case K_FIELD_INITIALIZER_DELIMITER : return false;
- case K_BLOCK_DELIMITER : return true;
+ case K_SWITCH_LABEL : return true;
}
i--;
}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistParser.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistParser.java
index 99804638db..7d5db3e78f 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistParser.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistParser.java
@@ -104,6 +104,7 @@ public abstract class AssistParser extends Parser {
protected static final int K_ENUM_CONSTANT_DELIMITER = ASSIST_PARSER + 6; // whether we are inside a field initializer
protected static final int K_LAMBDA_EXPRESSION_DELIMITER = ASSIST_PARSER + 7; // whether we are inside a lambda expression
protected static final int K_MODULE_INFO_DELIMITER = ASSIST_PARSER + 8; // whether we are inside a module info declaration
+ protected static final int K_SWITCH_EXPRESSION_DELIMITTER = ASSIST_PARSER + 9; // whether we are inside a switch expression
// selector constants
protected static final int THIS_CONSTRUCTOR = -1;
@@ -1281,11 +1282,8 @@ private void adjustBracket(int token) {
break;
}
}
-private boolean lastArrowAssociatedWithCase = false;
@Override
protected void consumeToken(int token) {
- if (TokenNameARROW == token)
- this.lastArrowAssociatedWithCase = this.caseFlagSet; // remember the arrow association before reset.
super.consumeToken(token);
if(this.isFirst) {
@@ -1318,9 +1316,10 @@ protected void consumeToken(int token) {
}
break;
case TokenNameLBRACE:
- if (this.previousToken == TokenNameARROW && !this.lastArrowAssociatedWithCase) {
+ if (this.previousToken == TokenNameARROW) {
popElement(K_LAMBDA_EXPRESSION_DELIMITER);
- pushOnElementStack(K_LAMBDA_EXPRESSION_DELIMITER, BLOCK_BODY, this.previousObjectInfo);
+ if (topKnownElementKind(ASSIST_PARSER, 1) != K_SWITCH_EXPRESSION_DELIMITTER)
+ pushOnElementStack(K_LAMBDA_EXPRESSION_DELIMITER, BLOCK_BODY, this.previousObjectInfo);
}
break;
}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/Keywords.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/Keywords.java
index 2fb6ab568b..cf7836fbb2 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/Keywords.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/Keywords.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Jesper Steen Møller - Contributions for
@@ -22,6 +22,7 @@ public interface Keywords {
char[] ASSERT = "assert".toCharArray(); //$NON-NLS-1$
char[] BREAK = "break".toCharArray(); //$NON-NLS-1$
char[] CASE = "case".toCharArray(); //$NON-NLS-1$
+ char[] YIELD = "yield".toCharArray(); //$NON-NLS-1$
char[] CATCH = "catch".toCharArray(); //$NON-NLS-1$
char[] CLASS = "class".toCharArray(); //$NON-NLS-1$
char[] CONTINUE = "continue".toCharArray(); //$NON-NLS-1$
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/CategorizedProblem.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/CategorizedProblem.java
index 41add2dcf4..c162e3ec7a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/CategorizedProblem.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/CategorizedProblem.java
@@ -107,6 +107,9 @@ public abstract class CategorizedProblem implements IProblem {
* @since 3.18
*/
public static final int CAT_COMPLIANCE = 170;
+ /** Category for problems related to preview features
+ * @since 3.20*/
+ public static final int CAT_PREVIEW_RELATED = 180;
/**
* Returns an integer identifying the category of this problem. Categories, like problem IDs are
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java
index d253f404a8..79fc84d4e3 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java
@@ -375,11 +375,13 @@ void setSourceStart(int sourceStart);
int ModuleRelated = 0x00800000;
/** @since 3.18 */
int Compliance = 0x00400000;
+ /** @since 3.20 */
+ int PreviewRelated = 0x00200000;
/**
* Mask to use in order to filter out the category portion of the problem ID.
*/
- int IgnoreCategoriesMask = 0x3FFFFF;
+ int IgnoreCategoriesMask = 0x1FFFFF;
/*
* Below are listed all available problem IDs. Note that this list could be augmented in the future,
@@ -774,7 +776,9 @@ void setSourceStart(int sourceStart);
/** @since 3.10 */
int MissingTypeInLambda = MethodRelated + 271;
-
+ /** @since 3.20
+ * @noreference preview related error */
+ int UnterminatedTextBlock = PreviewRelated + 272;
// type related problems
/** @since 3.1 */
int DiscouragedReference = TypeRelated + 280;
@@ -2063,7 +2067,9 @@ void setSourceStart(int sourceStart);
int PreviewFeatureUsed = Compliance + 1104;
/** @since 3.18 */
int PreviewFeatureNotSupported = Compliance + 1105;
-
+ /** @since 3.20*/
+ int PreviewFeaturesNotAllowed = PreviewRelated + 1106;
+
/** @since 3.13 */
int UnlikelyCollectionMethodArgumentType = 1200;
/** @since 3.13 */
@@ -2096,26 +2102,105 @@ void setSourceStart(int sourceStart);
int VarIsNotAllowedHere = Syntax + 1511; // ''var'' is not allowed here
/** @since 3.16 */
int VarCannotBeMixedWithNonVarParams = Syntax + 1512; // ''var'' cannot be mixed with explicit or implicit parameters
- /** @since 3.18 */
+ /** @since 3.18
+ * @deprecated preview related error - will be removed
+ * @noreference preview related error */
int SwitchExpressionsIncompatibleResultExpressionTypes = TypeRelated + 1600;
- /** @since 3.18 */
+ /** @since 3.18
+ * @deprecated preview related error - will be removed
+ * @noreference preview related error */
int SwitchExpressionsEmptySwitchBlock = Internal + 1601;
- /** @since 3.18 */
+ /** @since 3.18
+ * @deprecated preview related error - will be removed
+ * @noreference preview related error */
int SwitchExpressionsNoResultExpression = TypeRelated + 1602;
- /** @since 3.18 */
+ /** @since 3.18
+ * @deprecated preview related error - will be removed
+ * @noreference preview related error */
int SwitchExpressionSwitchLabeledBlockCompletesNormally = Internal + 1603;
- /** @since 3.18 */
+ /** @since 3.18
+ * @deprecated preview related error - will be removed
+ * @noreference preview related error */
int SwitchExpressionLastStatementCompletesNormally = Internal + 1604;
- /** @since 3.18 */
+ /** @since 3.18
+ * @deprecated preview related error - will be removed
+ * @noreference preview related error */
int SwitchExpressionTrailingSwitchLabels = Internal + 1605;
- /** @since 3.18 */
+ /** @since 3.18
+ * @deprecated preview related error - will be removed
+ * @noreference preview related error */
int switchMixedCase = Syntax + 1606;
- /** @since 3.18 */
+ /** @since 3.18
+ * @deprecated preview related error - will be removed
+ * @noreference preview related error */
int SwitchExpressionMissingDefaultCase = Internal + 1607;
- /** @since 3.18 */
+ /** @since 3.18
+ * @deprecated preview related error - will be removed
+ * @noreference preview related error */
int SwitchExpressionBreakMissingValue = Internal + 1610;
- /** @since 3.18 */
+ /** @since 3.18
+ * @deprecated preview related error - will be removed
+ * @noreference preview related error */
int SwitchExpressionMissingEnumConstantCase = Internal + 1611;
- /** @since 3.18 */
+ /** @since 3.18
+ * @deprecated preview related error - will be removed
+ * @noreference preview related error */
int SwitchExpressionIllegalLastStatement = Internal + 1612;
+ /** @since 3.20
+ * @noreference preview related error */
+ int SwitchExpressionsYieldIncompatibleResultExpressionTypes = PreviewRelated + 1700;
+ /** @since 3.20
+ * @noreference preview related error */
+ int SwitchExpressionsYieldEmptySwitchBlock = PreviewRelated + 1701;
+ /** @since 3.20
+ * @noreference preview related error */
+ int SwitchExpressionsYieldNoResultExpression = PreviewRelated + 1702;
+ /** @since 3.20
+ * @noreference preview related error */
+ int SwitchExpressionaYieldSwitchLabeledBlockCompletesNormally = PreviewRelated + 1703;
+ /** @since 3.20
+ * @noreference preview related error */
+ int SwitchExpressionsYieldLastStatementCompletesNormally = PreviewRelated + 1704;
+ /** @since 3.20
+ * @noreference preview related error */
+ int SwitchExpressionsYieldTrailingSwitchLabels = PreviewRelated + 1705;
+ /** @since 3.20
+ * @noreference preview related error */
+ int SwitchPreviewMixedCase = PreviewRelated + 1706;
+ /** @since 3.20
+ * @noreference preview related error */
+ int SwitchExpressionsYieldMissingDefaultCase = PreviewRelated + 1707;
+ /** @since 3.20
+ * @noreference preview related error */
+ int SwitchExpressionsYieldMissingValue = PreviewRelated + 1708;
+ /** @since 3.20
+ * @noreference preview related error */
+ int SwitchExpressionsYieldMissingEnumConstantCase = PreviewRelated + 1709;
+ /** @since 3.20
+ * @noreference preview related error */
+ int SwitchExpressionsYieldIllegalLastStatement = PreviewRelated + 1710;
+ /** @since 3.20
+ * @noreference preview related error */
+ int SwitchExpressionsYieldBreakNotAllowed = PreviewRelated + 1711;
+ /** @since 3.20
+ * @noreference preview related error */
+ int SwitchExpressionsYieldUnqualifiedMethodWarning = PreviewRelated + 1712;
+ /** @since 3.20
+ * @noreference preview related error */
+ int SwitchExpressionsYieldUnqualifiedMethodError = PreviewRelated + 1713;
+ /** @since 3.20
+ * @noreference preview related error */
+ int SwitchExpressionsYieldOutsideSwitchExpression = PreviewRelated + 1714;
+ /** @since 3.20
+ * @noreference preview related error */
+ int SwitchExpressionsYieldRestrictedGeneralWarning = PreviewRelated + 1715;
+ /** @since 3.20
+ * @noreference preview related error */
+ int SwitchExpressionsYieldIllegalStatement = PreviewRelated + 1716;
+ /** @since 3.20
+ * @noreference preview related error */
+ int SwitchExpressionsYieldTypeDeclarationWarning = PreviewRelated + 1717;
+ /** @since 3.20
+ * @noreference preview related error */
+ int SwitchExpressionsYieldTypeDeclarationError = PreviewRelated + 1718;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ASTVisitor.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ASTVisitor.java
index b515f77b43..8665c8a986 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ASTVisitor.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ASTVisitor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -487,6 +487,9 @@ public abstract class ASTVisitor {
ClassScope scope) {
// do nothing by default
}
+ public void endVisit(YieldStatement yieldStatement, BlockScope scope) {
+ // do nothing by default
+ }
public void endVisit(WhileStatement whileStatement, BlockScope scope) {
// do nothing by default
}
@@ -981,6 +984,9 @@ public abstract class ASTVisitor {
ClassScope scope) {
return true; // do nothing by default, keep traversing
}
+ public boolean visit(YieldStatement yieldStatement, BlockScope scope) {
+ return true; // do nothing by default, keep traversing
+ }
public boolean visit(WhileStatement whileStatement, BlockScope scope) {
return true; // do nothing by default, keep traversing
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/Compiler.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/Compiler.java
index 7584092b3a..7065f43c2c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/Compiler.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/Compiler.java
@@ -803,14 +803,29 @@ public class Compiler implements ITypeRequestor, ProblemSeverities {
this.parser = new Parser(this.problemReporter, this.options.parseLiteralExpressionsAsConstants);
}
+ private void abortIfPreviewNotAllowed(ICompilationUnit[] sourceUnits, int maxUnits) {
+ if (!this.options.enablePreviewFeatures)
+ return;
+ try {
+ if (this.options.sourceLevel != ClassFileConstants.getLatestJDKLevel()) {
+ this.problemReporter.abortDueToPreviewEnablingNotAllowed(CompilerOptions.versionFromJdkLevel(this.options.sourceLevel), CompilerOptions.getLatestVersion());
+ }
+ } catch (AbortCompilation a) {
+ // best effort to find a way for reporting this problem: report on the first source
+ if (a.compilationResult == null) {
+ a.compilationResult = new CompilationResult(sourceUnits[0], 0, maxUnits, this.options.maxProblemsPerUnit);
+ }
+ throw a;
+ }
+ }
/**
* Add the initial set of compilation units into the loop
* -> build compilation unit declarations, their bindings and record their results.
*/
protected void internalBeginToCompile(ICompilationUnit[] sourceUnits, int maxUnits) {
+ abortIfPreviewNotAllowed(sourceUnits,maxUnits);
if (!this.useSingleThread && maxUnits >= ReadManager.THRESHOLD)
this.parser.readManager = new ReadManager(sourceUnits, maxUnits);
-
// Switch the current policy and compilation result for this unit to the requested one.
for (int i = 0; i < maxUnits; i++) {
CompilationResult unitResult = null;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/BreakStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/BreakStatement.java
index ada2ae6b26..e12cfc4d61 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/BreakStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/BreakStatement.java
@@ -16,16 +16,11 @@
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
-import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
import org.eclipse.jdt.internal.compiler.flow.*;
import org.eclipse.jdt.internal.compiler.lookup.*;
public class BreakStatement extends BranchStatement {
- public Expression expression;
- public SwitchExpression switchExpression;
- public boolean isImplicit;
-
public BreakStatement(char[] label, int sourceStart, int e) {
super(label, sourceStart, e);
}
@@ -40,23 +35,20 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl
? flowContext.getTargetContextForDefaultBreak()
: flowContext.getTargetContextForBreakLabel(this.label);
+ // JLS 13 14.15
+ if (targetContext instanceof SwitchFlowContext &&
+ targetContext.associatedNode instanceof SwitchExpression) {
+ currentScope.problemReporter().switchExpressionBreakNotAllowed(this);
+ }
if (targetContext == null) {
if (this.label == null) {
currentScope.problemReporter().invalidBreak(this);
} else {
- if (this.switchExpression == null)
- currentScope.problemReporter().undefinedLabel(this);
+ currentScope.problemReporter().undefinedLabel(this);
}
return flowInfo; // pretend it did not break since no actual target
}
- if ((this.isImplicit || this.switchExpression != null) && this.expression != null) {
- flowInfo = this.expression.analyseCode(currentScope, flowContext, flowInfo);
- this.expression.checkNPEbyUnboxing(currentScope, flowContext, flowInfo);
- if (flowInfo.reachMode() == FlowInfo.REACHABLE && currentScope.compilerOptions().isAnnotationBasedNullAnalysisEnabled)
- checkAgainstNullAnnotation(currentScope, flowContext, flowInfo, this.expression);
- }
-
targetContext.recordAbruptExit();
targetContext.expireNullCheckedFieldInfo();
@@ -101,72 +93,17 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl
}
return FlowInfo.DEAD_END;
}
-@Override
-protected void generateExpressionResultCode(BlockScope currentScope, CodeStream codeStream) {
- if (this.label == null && this.expression != null) {
- this.expression.generateCode(currentScope, codeStream, this.switchExpression != null);
- }
-}
-@Override
-protected void adjustStackSize(BlockScope currentScope, CodeStream codeStream) {
- if (this.label == null && this.expression != null && this.switchExpression != null) {
- TypeBinding postConversionType = this.expression.postConversionType(currentScope);
- switch(postConversionType.id) {
- case TypeIds.T_long :
- case TypeIds.T_double :
- codeStream.decrStackSize(2);
- break;
- case TypeIds.T_void :
- break;
- default :
- codeStream.decrStackSize(1);
- break;
- }
- }
-}
-@Override
-public void resolve(BlockScope scope) {
- super.resolve(scope);
- if (this.expression != null && (this.switchExpression != null || this.isImplicit)) {
- if (this.switchExpression == null && this.isImplicit && !this.expression.statementExpression()) {
- if (scope.compilerOptions().enablePreviewFeatures) {
- /* JLS 12 14.11.2
- Switch labeled rules in switch statements differ from those in switch expressions (15.28).
- In switch statements they must be switch labeled statement expressions, ... */
- scope.problemReporter().invalidExpressionAsStatement(this.expression);
- return;
- }
- }
- this.expression.resolveType(scope);
- } else if (this.expression == null && this.switchExpression != null) {
- scope.problemReporter().switchExpressionBreakMissingValue(this);
- }
-}
-
-@Override
-public TypeBinding resolveExpressionType(BlockScope scope) {
- return this.expression != null ? this.expression.resolveType(scope) : null;
-}
@Override
public StringBuffer printStatement(int tab, StringBuffer output) {
- if (!this.isImplicit) // implicit for SwitchLabeledExpressions
- printIndent(tab, output).append("break"); //$NON-NLS-1$
- if (this.label != null)
- output.append(' ').append(this.label);
- if (this.expression != null) {
- output.append(' ');
- this.expression.printExpression(tab, output);
- }
+ printIndent(tab, output).append("break"); //$NON-NLS-1$
+ if (this.label != null) output.append(' ').append(this.label);
return output.append(';');
}
@Override
public void traverse(ASTVisitor visitor, BlockScope blockscope) {
- if (visitor.visit(this, blockscope)) {
- if (this.expression != null)
- this.expression.traverse(visitor, blockscope);
- }
+ visitor.visit(this, blockscope);
visitor.endVisit(this, blockscope);
}
@Override
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java
index b605963daf..290f5cc15e 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java
@@ -146,6 +146,7 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl
boolean wasInsideAssert = ((flowContext.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) != 0);
flowInfo = this.receiver.analyseCode(currentScope, flowContext, flowInfo, nonStatic).unconditionalInits();
+ yieldQualifiedCheck(currentScope);
// recording the closing of AutoCloseable resources:
CompilerOptions compilerOptions = currentScope.compilerOptions();
boolean analyseResources = compilerOptions.analyseResourceLeaks;
@@ -243,6 +244,18 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl
flowContext.expireNullCheckedFieldInfo(); // no longer trust this info after any message send
return flowInfo;
}
+private void yieldQualifiedCheck(BlockScope currentScope) {
+ long sourceLevel = currentScope.compilerOptions().sourceLevel;
+ if (sourceLevel < ClassFileConstants.JDK13 || !this.receiverIsImplicitThis())
+ return;
+ if (this.selector == null || !("yield".equals(new String(this.selector)))) //$NON-NLS-1$
+ return;
+ if (sourceLevel == ClassFileConstants.JDK13 && currentScope.compilerOptions().enablePreviewFeatures) {
+ currentScope.problemReporter().switchExpressionsYieldUnqualifiedMethodError(this);
+ } else {
+ currentScope.problemReporter().switchExpressionsYieldUnqualifiedMethodWarning(this);
+ }
+}
private void recordCallingClose(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo, Expression closeTarget) {
FakedTrackingVariable trackingVariable = FakedTrackingVariable.getCloseTrackingVariable(closeTarget, flowInfo, flowContext);
if (trackingVariable != null) { // null happens if target is not a local variable or not an AutoCloseable
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Statement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Statement.java
index 091157bbd4..9d386d58a5 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Statement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Statement.java
@@ -305,7 +305,10 @@ public boolean breaksOut(final char[] label) {
this.breaksOut = true;
return false;
}
-
+ @Override
+ public boolean visit(YieldStatement yieldStatement, BlockScope skope) {
+ return false;
+ }
public boolean breaksOut() {
Statement.this.traverse(this, null);
return this.breaksOut;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchExpression.java
index 78c8e64d20..b5244486bb 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchExpression.java
@@ -292,14 +292,14 @@ public class SwitchExpression extends SwitchStatement implements IPolyExpression
resolve(upperScope);
if (this.statements == null || this.statements.length == 0) {
- // Report Error JLS 12 15.28.1 The switch block must not be empty.
+ // Report Error JLS 13 15.28.1 The switch block must not be empty.
upperScope.problemReporter().switchExpressionEmptySwitchBlock(this);
return null;
}
resultExpressionsCount = this.resultExpressions != null ? this.resultExpressions.size() : 0;
if (resultExpressionsCount == 0) {
- // Report Error JLS 12 15.28.1
+ // Report Error JLS 13 15.28.1
// It is a compile-time error if a switch expression has no result expressions.
upperScope.problemReporter().switchExpressionNoResultExpressions(this);
return null;
@@ -390,10 +390,11 @@ public class SwitchExpression extends SwitchStatement implements IPolyExpression
boolean typeNumeric = true;
TypeBinding resultNumeric = null;
HashSet<TypeBinding> typeSet = new HashSet<>();
- /* JLS 12 5.6.3 Switch Numeric Promotion
- * When a switch expression applies numeric promotion to a set of result expressions, each of which
- * must denote a value that is convertible to a numeric type, the following rules apply, in order:
- * If any result expression is of a reference type, it is subjected to unboxing conversion (5.1.8).
+ /* JLS 13 5.6 Numeric Contexts
+ * An expression appears in a numeric context if it is one of:....
+ * ...8. a result expression of a standalone switch expression (15.28.1),
+ * where all the result expressions are convertible to a numeric type
+ * If any expression is of a reference type, it is subjected to unboxing conversion (5.1.8).
*/
for (int i = 0; i < resultExpressionsCount; ++i) {
TypeBinding originalType = this.originalValueResultExpressionTypes[i];
@@ -413,7 +414,7 @@ public class SwitchExpression extends SwitchStatement implements IPolyExpression
* Otherwise, if any result expression is of type long, then other result expressions that are not of
* type long are widened to long.
*/
- TypeBinding[] dfl = new TypeBinding[]{// do not change the order JLS 12 5.6.3
+ TypeBinding[] dfl = new TypeBinding[]{// do not change the order JLS 13 5.6
TypeBinding.DOUBLE,
TypeBinding.FLOAT,
TypeBinding.LONG};
@@ -424,6 +425,13 @@ public class SwitchExpression extends SwitchStatement implements IPolyExpression
}
}
+ /* Otherwise, if any expression appears in a numeric array context or a numeric arithmetic context,
+ * rather than a numeric choice context, then the promoted type is int and other expressions that are
+ * not of type int undergo widening primitive conversion to int. - not applicable since numeric choice context.
+ * [Note: A numeric choice context is a numeric context that is either a numeric conditional expression or
+ * a standalone switch expression where all the result expressions are convertible to a numeric type.]
+ */
+
/* Otherwise, if any result expression is of type int and is not a constant expression, the other
* result expressions that are not of type int are widened to int.
*/
@@ -433,7 +441,6 @@ public class SwitchExpression extends SwitchStatement implements IPolyExpression
getResultNumeric(typeSet, this.originalValueResultExpressionTypes); // check the rest
typeSet = null; // hey gc!
for (int i = 0; i < resultExpressionsCount; ++i) {
- // auto-unboxing and/or widening/narrrowing JLS 12 5.6.3
this.resultExpressions.get(i).computeConversion(this.scope,
resultNumeric, this.originalValueResultExpressionTypes[i]);
this.finalValueResultExpressionTypes[i] = resultNumeric;
@@ -517,24 +524,25 @@ public class SwitchExpression extends SwitchStatement implements IPolyExpression
// note: if an expression has a type integer, then it will be a constant
// since non-constant integers are already processed before reaching here.
- /*
- * Otherwise, if any result expression is of type char, and every other result expression is either of
- * type char, or of type byte, or a constant expression of type int with a value that is representable
- * in the type char, then the byte results are widened to char and the int results are narrowed to char.
- */
-
- /* Otherwise, if any result expression is of type short, and every other result expression is either of
- * type short, or of type byte, or a constant expression of type int with a value that is representable
- * in the type short, then the byte results are widened to short and the int results are narrowed to
- * short.
- */
- /* Otherwise, if any result expression is of type byte, and every other result expression is either of
- * type byte or a constant expression of type int with a value that is representable in the type byte,
- * then the int results are narrowed to byte.
+ /* Otherwise, if any expression is of type short, and every other expression is either of type short,
+ * or of type byte, or a constant expression of type int with a value that is representable in the
+ * type short, then T is short, the byte expressions undergo widening primitive conversion to short,
+ * and the int expressions undergo narrowing primitive conversion to short.\
+ *
+ * Otherwise, if any expression is of type byte, and every other expression is either of type byte or a
+ * constant expression of type int with a value that is representable in the type byte, then T is byte
+ * and the int expressions undergo narrowing primitive conversion to byte.
+ *
+ * Otherwise, if any expression is of type char, and every other expression is either of type char or a
+ * constant expression of type int with a value that is representable in the type char, then T is char
+ * and the int expressions undergo narrowing primitive conversion to char.
+ *
+ * Otherwise, T is int and all the expressions that are not of type int undergo widening
+ * primitive conversion to int.
*/
- // DO NOT Change the order below [as per JLS 12 5.6.3 item 2, sub-items 5,6 and 7].
- TypeBinding[] csb = new TypeBinding[] {TypeBinding.CHAR, TypeBinding.SHORT, TypeBinding.BYTE};
+ // DO NOT Change the order below [as per JLS 13 5.6 ].
+ TypeBinding[] csb = new TypeBinding[] {TypeBinding.SHORT, TypeBinding.BYTE, TypeBinding.CHAR};
for (TypeBinding c : csb) {
TypeBinding result = check_csb(typeSet, c);
if (result != null)
@@ -547,7 +555,7 @@ public class SwitchExpression extends SwitchStatement implements IPolyExpression
public boolean isPolyExpression() {
if (this.isPolyExpression)
return true;
- // JLS 12 15.28.1 A switch expression is a poly expression if it appears in an assignment context or
+ // JLS 13 15.28.1 A switch expression is a poly expression if it appears in an assignment context or
// an invocation context (5.2, 5.3). Otherwise, it is a standalone expression.
return this.isPolyExpression = this.expressionContext == ASSIGNMENT_CONTEXT ||
this.expressionContext == INVOCATION_CONTEXT;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java
index f32a048ec9..3fe7de0bec 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java
@@ -92,7 +92,6 @@ public class SwitchStatement extends Expression {
}
// else add an implicit break
BreakStatement breakStatement = new BreakStatement(null, block.sourceEnd -1, block.sourceEnd);
- breakStatement.isImplicit = true;
int l = block.statements == null ? 0 : block.statements.length;
if (l == 0) {
@@ -126,6 +125,7 @@ public class SwitchStatement extends Expression {
}
SwitchFlowContext switchContext =
new SwitchFlowContext(flowContext, this, (this.breakLabel = new BranchLabel()), true, true);
+ switchContext.isExpression = this instanceof SwitchExpression;
// analyse the block by considering specially the case/default statements (need to bind them
// to the entry point)
@@ -159,6 +159,19 @@ public class SwitchStatement extends Expression {
complaintLevel = initialComplaintLevel; // reset complaint
fallThroughState = CASE;
} else {
+ if (!(this instanceof SwitchExpression) &&
+ currentScope.compilerOptions().complianceLevel >= ClassFileConstants.JDK13 &&
+ statement instanceof YieldStatement &&
+ ((YieldStatement) statement).isImplicit) {
+ YieldStatement y = (YieldStatement) statement;
+ Expression e = ((YieldStatement) statement).expression;
+ /* JLS 13 14.11.2
+ Switch labeled rules in switch statements differ from those in switch expressions (15.28).
+ In switch statements they must be switch labeled statement expressions, ... */
+ if (!y.expression.statementExpression()) {
+ this.scope.problemReporter().invalidExpressionAsStatement(e);
+ }
+ }
fallThroughState = getFallThroughState(statement, currentScope); // reset below if needed
}
if ((complaintLevel = statement.complainIfUnreachable(caseInits, this.scope, complaintLevel, true)) < Statement.COMPLAINED_UNREACHABLE) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TextBlock.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TextBlock.java
new file mode 100644
index 0000000000..a4e8a571a6
--- /dev/null
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TextBlock.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2019 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.compiler.ast;
+
+public class TextBlock extends StringLiteral {
+
+ public TextBlock(char[] token, int start, int end, int lineNumber) {
+ super(token, start,end, lineNumber);
+ }
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java
index 34bc92b70f..f8cb33f1c4 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Stephan Herrmann - Contributions for
@@ -658,6 +658,7 @@ public boolean hasErrors() {
* Common flow analysis for all types
*/
private void internalAnalyseCode(FlowContext flowContext, FlowInfo flowInfo) {
+ checkYieldUsage();
if (!this.binding.isUsed() && this.binding.isOrEnclosedByPrivateType()) {
if (!this.scope.referenceCompilationUnit().compilationResult.hasSyntaxError) {
this.scope.problemReporter().unusedPrivateType(this);
@@ -780,6 +781,18 @@ private void internalAnalyseCode(FlowContext flowContext, FlowInfo flowInfo) {
}
}
+private void checkYieldUsage() {
+ long sourceLevel = this.scope.compilerOptions().sourceLevel;
+ if (sourceLevel < ClassFileConstants.JDK13 || this.name == null ||
+ !("yield".equals(new String(this.name)))) //$NON-NLS-1$
+ return;
+ if (sourceLevel == ClassFileConstants.JDK13 && this.scope.compilerOptions().enablePreviewFeatures) {
+ this.scope.problemReporter().switchExpressionsYieldTypeDeclarationError(this);
+ } else {
+ this.scope.problemReporter().switchExpressionsYieldTypeDeclarationWarning(this);
+ }
+}
+
private SimpleSetOfCharArray getJUnitMethodSourceValues() {
SimpleSetOfCharArray junitMethodSourceValues = new SimpleSetOfCharArray();
for (AbstractMethodDeclaration methodDeclaration : this.methods) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java
index 11c9aec060..04c5e9a5f4 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Stephan Herrmann - Contribution for
@@ -350,6 +350,19 @@ public Annotation[][] annotations = null;
public void aboutToResolve(Scope scope) {
// default implementation: do nothing
}
+private void checkYieldUsage(Scope currentScope) {
+ char [][] qName = getTypeName();
+ String name = qName != null && qName[0] != null ? new String(qName[0]) : null;
+ long sourceLevel = currentScope.compilerOptions().sourceLevel;
+ if (sourceLevel < ClassFileConstants.JDK13 || name == null ||
+ !("yield".equals(new String(name)))) //$NON-NLS-1$
+ return;
+ if (sourceLevel == ClassFileConstants.JDK13 && currentScope.compilerOptions().enablePreviewFeatures) {
+ currentScope.problemReporter().switchExpressionsYieldTypeDeclarationError(this);
+ } else {
+ currentScope.problemReporter().switchExpressionsYieldTypeDeclarationWarning(this);
+ }
+}
@Override
public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
return flowInfo;
@@ -494,6 +507,7 @@ public abstract char [][] getTypeName() ;
protected TypeBinding internalResolveType(Scope scope, int location) {
// handle the error here
this.constant = Constant.NotAConstant;
+ checkYieldUsage(scope);
if (this.resolvedType != null) { // is a shared type reference which was already resolved
if (this.resolvedType.isValidBinding()) {
return this.resolvedType;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/YieldStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/YieldStatement.java
new file mode 100644
index 0000000000..3479ca681f
--- /dev/null
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/YieldStatement.java
@@ -0,0 +1,182 @@
+/*******************************************************************************
+ * Copyright (c) 2019 IBM Corporation and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.compiler.ast;
+
+import org.eclipse.jdt.internal.compiler.ASTVisitor;
+import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
+import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
+import org.eclipse.jdt.internal.compiler.flow.*;
+import org.eclipse.jdt.internal.compiler.lookup.*;
+
+public class YieldStatement extends BranchStatement {
+
+ public Expression expression;
+ public SwitchExpression switchExpression;
+ /**
+ * @noreference This field is not intended to be referenced by clients.
+ */
+ public boolean isImplicit;
+
+public YieldStatement(Expression exp, int sourceStart, int sourceEnd) {
+ super(null, sourceStart, sourceEnd);
+ this.expression = exp;
+}
+@Override
+public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
+ // this.switchExpression != null && this.expression != null true here.
+
+ // here requires to generate a sequence of finally blocks invocations depending corresponding
+ // to each of the traversed try statements, so that execution will terminate properly.
+
+
+ // lookup the null label, this should answer the returnContext - for implicit yields, the nesting
+ // doesn't occur since it immediately follow '->' and hence identical to default break - ie the
+ // immediate breakable context is guaranteed to be the one intended;
+ // while explicit yield should move up the parent to the switch expression.
+ FlowContext targetContext = this.isImplicit ? flowContext.getTargetContextForDefaultBreak() :
+ flowContext.getTargetContextForDefaultYield();
+
+ flowInfo = this.expression.analyseCode(currentScope, flowContext, flowInfo);
+ this.expression.checkNPEbyUnboxing(currentScope, flowContext, flowInfo);
+ if (flowInfo.reachMode() == FlowInfo.REACHABLE && currentScope.compilerOptions().isAnnotationBasedNullAnalysisEnabled)
+ checkAgainstNullAnnotation(currentScope, flowContext, flowInfo, this.expression);
+
+ targetContext.recordAbruptExit();
+ targetContext.expireNullCheckedFieldInfo();
+
+ this.initStateIndex =
+ currentScope.methodScope().recordInitializationStates(flowInfo);
+
+ this.targetLabel = targetContext.breakLabel();
+ FlowContext traversedContext = flowContext;
+ int subCount = 0;
+ this.subroutines = new SubRoutineStatement[5];
+
+ do {
+ SubRoutineStatement sub;
+ if ((sub = traversedContext.subroutine()) != null) {
+ if (subCount == this.subroutines.length) {
+ System.arraycopy(this.subroutines, 0, (this.subroutines = new SubRoutineStatement[subCount*2]), 0, subCount); // grow
+ }
+ this.subroutines[subCount++] = sub;
+ if (sub.isSubRoutineEscaping()) {
+ break;
+ }
+ }
+ traversedContext.recordReturnFrom(flowInfo.unconditionalInits());
+ traversedContext.recordBreakTo(targetContext);
+
+ if (traversedContext instanceof InsideSubRoutineFlowContext) {
+ ASTNode node = traversedContext.associatedNode;
+ if (node instanceof TryStatement) {
+ TryStatement tryStatement = (TryStatement) node;
+ flowInfo.addInitializationsFrom(tryStatement.subRoutineInits); // collect inits
+ }
+ } else if (traversedContext == targetContext) {
+ // only record break info once accumulated through subroutines, and only against target context
+ targetContext.recordBreakFrom(flowInfo);
+ break;
+ }
+ } while ((traversedContext = traversedContext.getLocalParent()) != null);
+
+ // resize subroutines
+ if (subCount != this.subroutines.length) {
+ System.arraycopy(this.subroutines, 0, (this.subroutines = new SubRoutineStatement[subCount]), 0, subCount);
+ }
+ return FlowInfo.DEAD_END;
+}
+@Override
+protected void generateExpressionResultCode(BlockScope currentScope, CodeStream codeStream) {
+ this.expression.generateCode(currentScope, codeStream, this.switchExpression != null);
+}
+@Override
+protected void adjustStackSize(BlockScope currentScope, CodeStream codeStream) {
+ if (this.label == null && this.expression != null && this.switchExpression != null) {
+ TypeBinding postConversionType = this.expression.postConversionType(currentScope);
+ switch(postConversionType.id) {
+ case TypeIds.T_long :
+ case TypeIds.T_double :
+ codeStream.decrStackSize(2);
+ break;
+ case TypeIds.T_void :
+ break;
+ default :
+ codeStream.decrStackSize(1);
+ break;
+ }
+ }
+}
+@Override
+public void resolve(BlockScope scope) {
+ // METHOD IN WORKS - INCOMPLETE
+ super.resolve(scope);
+ if (this.expression == null) {
+ //currentScope.problemReporter().switchExpressionYieldMissingExpression(this);
+ return;
+
+ }
+ if (this.switchExpression != null || this.isImplicit) {
+ if (this.switchExpression == null && this.isImplicit && !this.expression.statementExpression()) {
+ if (scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK12 && scope.compilerOptions().enablePreviewFeatures) {
+ /* JLS 13 14.11.2
+ Switch labeled rules in switch statements differ from those in switch expressions (15.28).
+ In switch statements they must be switch labeled statement expressions, ... */
+ scope.problemReporter().invalidExpressionAsStatement(this.expression);
+ return;
+ }
+ }
+ } else {
+ if (scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK13) {
+ if (scope.compilerOptions().enablePreviewFeatures) {
+ scope.problemReporter().switchExpressionsYieldOutsideSwitchExpression(this);
+ } else {
+ scope.problemReporter().switchExpressionsYieldIllegalStatement(this);
+ }
+ }
+ }
+ this.expression.resolveType(scope);
+// if (this.expression != null) {
+// this.expression.resolveType(scope);
+// }
+}
+
+@Override
+public TypeBinding resolveExpressionType(BlockScope scope) {
+ return this.expression != null ? this.expression.resolveType(scope) : null;
+}
+
+@Override
+public StringBuffer printStatement(int tab, StringBuffer output) {
+ if (!this.isImplicit)
+ printIndent(tab, output).append("yield"); //$NON-NLS-1$
+ if (this.expression != null) {
+ output.append(' ');
+ this.expression.printExpression(tab, output);
+ }
+ return output.append(';');
+}
+
+@Override
+public void traverse(ASTVisitor visitor, BlockScope blockscope) {
+ if (visitor.visit(this, blockscope)) {
+ if (this.expression != null)
+ this.expression.traverse(visitor, blockscope);
+ }
+ visitor.endVisit(this, blockscope);
+}
+@Override
+public boolean doesNotCompleteNormally() {
+ return true;
+}
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileConstants.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileConstants.java
index 6ab938c1e0..dde2308286 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileConstants.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileConstants.java
@@ -129,9 +129,10 @@ public interface ClassFileConstants {
int MAJOR_VERSION_10 = 54;
int MAJOR_VERSION_11 = 55;
int MAJOR_VERSION_12 = 56;
+ int MAJOR_VERSION_13 = 57;
int MAJOR_VERSION_0 = 44;
- int MAJOR_LATEST_VERSION = MAJOR_VERSION_12;
+ int MAJOR_LATEST_VERSION = MAJOR_VERSION_13;
int MINOR_VERSION_0 = 0;
int MINOR_VERSION_1 = 1;
@@ -154,6 +155,7 @@ public interface ClassFileConstants {
long JDK10 = ((long)ClassFileConstants.MAJOR_VERSION_10 << 16) + ClassFileConstants.MINOR_VERSION_0;
long JDK11 = ((long)ClassFileConstants.MAJOR_VERSION_11 << 16) + ClassFileConstants.MINOR_VERSION_0;
long JDK12 = ((long)ClassFileConstants.MAJOR_VERSION_12 << 16) + ClassFileConstants.MINOR_VERSION_0;
+ long JDK13 = ((long)ClassFileConstants.MAJOR_VERSION_13 << 16) + ClassFileConstants.MINOR_VERSION_0;
public static long getLatestJDKLevel() {
return ((long)ClassFileConstants.MAJOR_LATEST_VERSION << 16) + ClassFileConstants.MINOR_VERSION_0;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowContext.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowContext.java
index 4d99f72598..3d73bad904 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowContext.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowContext.java
@@ -616,6 +616,24 @@ public FlowContext getTargetContextForDefaultBreak() {
// not found
return null;
}
+/*
+ * lookup a default yield through switch expression locations
+ */
+public FlowContext getTargetContextForDefaultYield() {
+ FlowContext current = this, lastNonReturningSubRoutine = null;
+ while (current != null) {
+ if (current.isNonReturningContext()) {
+ lastNonReturningSubRoutine = current;
+ }
+ if (current.isBreakable() && current.labelName() == null && ((SwitchFlowContext) current).isExpression){
+ if (lastNonReturningSubRoutine == null) return current;
+ return lastNonReturningSubRoutine;
+ }
+ current = current.getLocalParent();
+ }
+ // not found
+ return null;
+}
/*
* lookup a default continue amongst continuable locations
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/SwitchFlowContext.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/SwitchFlowContext.java
index 363c863543..fb2bfa9841 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/SwitchFlowContext.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/SwitchFlowContext.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -26,6 +26,7 @@ public class SwitchFlowContext extends FlowContext {
public BranchLabel breakLabel;
public UnconditionalFlowInfo initsOnBreak = FlowInfo.DEAD_END;
+ public boolean isExpression = false;
public SwitchFlowContext(FlowContext parent, ASTNode associatedNode, BranchLabel breakLabel, boolean isPreTest, boolean inheritNullFieldChecks) {
super(parent, associatedNode, inheritNullFieldChecks);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java
index b7c7458b75..aeb5409f5d 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java
@@ -231,6 +231,7 @@ public class CompilerOptions {
public static final String VERSION_10 = "10"; //$NON-NLS-1$
public static final String VERSION_11 = "11"; //$NON-NLS-1$
public static final String VERSION_12 = "12"; //$NON-NLS-1$
+ public static final String VERSION_13 = "13"; //$NON-NLS-1$
/*
* Note: Whenever a new version is added, make sure getLatestVersion()
* is updated with it.
@@ -600,7 +601,7 @@ public class CompilerOptions {
* Return the latest Java language version supported by the Eclipse compiler
*/
public static String getLatestVersion() {
- return VERSION_12;
+ return VERSION_13;
}
/**
* Return the most specific option key controlling this irritant. Note that in some case, some irritant is controlled by
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/messages.properties b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/messages.properties
index 7b28fe3140..a56d61af06 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/messages.properties
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/messages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2016 IBM Corporation and others.
+# Copyright (c) 2000, 2019 IBM Corporation and others.
#
# This program and the accompanying materials
# are made available under the terms of the Eclipse Public License 2.0
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java
index aa8f9770e2..4f7a7b95b6 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -1082,6 +1082,9 @@ public abstract class AbstractCommentParser implements JavadocTagConstants {
consumeToken();
break;
+ case TerminalTokens.TokenNameRestrictedIdentifierYield:
+ throw new InvalidInputException(); // unexpected.
+
case TerminalTokens.TokenNameDOT :
if ((iToken & 1) == 0) { // dots must be even tokens
throw new InvalidInputException();
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/ConflictedParser.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/ConflictedParser.java
index d9fe4e3f08..96b25b8603 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/ConflictedParser.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/ConflictedParser.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
@@ -27,4 +27,5 @@ public interface ConflictedParser {
* appear as terminals in ModuleDeclaration, and are identifiers everywhere else)
*/
boolean isParsingModuleDeclaration();
+ boolean isParsingJava13();
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/JavadocTagConstants.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/JavadocTagConstants.java
index f952c7169d..60d40587ad 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/JavadocTagConstants.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/JavadocTagConstants.java
@@ -194,6 +194,8 @@ public interface JavadocTagConstants {
// since 11
{},
//since 12
+ {},
+ //since 12
{}
};
public static final char[][][] INLINE_TAGS = {
@@ -222,7 +224,9 @@ public interface JavadocTagConstants {
// since 11
{},
//since 12
- {TAG_SYSTEM_PROPERTY}
+ {TAG_SYSTEM_PROPERTY},
+ //since 12
+ {}
};
public final static int INLINE_TAGS_LENGTH = INLINE_TAGS.length;
public final static int BLOCK_TAGS_LENGTH = BLOCK_TAGS.length;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
index f930920dbb..db0af41079 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
@@ -215,6 +215,14 @@ public class Parser implements TerminalTokens, ParserBasicInformation, Conflicte
compliance = ClassFileConstants.JDK1_8;
} else if("9".equals(token)) { //$NON-NLS-1$
compliance = ClassFileConstants.JDK9;
+ } else if("10".equals(token)) { //$NON-NLS-1$
+ compliance = ClassFileConstants.JDK10;
+ } else if("11".equals(token)) { //$NON-NLS-1$
+ compliance = ClassFileConstants.JDK11;
+ } else if("12".equals(token)) { //$NON-NLS-1$
+ compliance = ClassFileConstants.JDK12;
+ } else if("13".equals(token)) { //$NON-NLS-1$
+ compliance = ClassFileConstants.JDK13;
} else if("recovery".equals(token)) { //$NON-NLS-1$
compliance = ClassFileConstants.JDK_DEFERRED;
}
@@ -545,8 +553,8 @@ public class Parser implements TerminalTokens, ParserBasicInformation, Conflicte
buildFileOfIntFor(prefix + (++i) + ".rsc", "in_symb", tokens); //$NON-NLS-2$ //$NON-NLS-1$
byte[] newRhs = buildFileOfByteFor(prefix + (++i) + ".rsc", "rhs", tokens); //$NON-NLS-2$ //$NON-NLS-1$
- buildFileOfByteFor(prefix + (++i) + ".rsc", "term_check", tokens); //$NON-NLS-2$ //$NON-NLS-1$
- buildFileOfByteFor(prefix + (++i) + ".rsc", "scope_la", tokens); //$NON-NLS-2$ //$NON-NLS-1$
+ buildFileOfIntFor(prefix + (++i) + ".rsc", "term_check", tokens); //$NON-NLS-2$ //$NON-NLS-1$
+ buildFileOfIntFor(prefix + (++i) + ".rsc", "scope_la", tokens); //$NON-NLS-2$ //$NON-NLS-1$
String[] newName = buildFileForName(prefix + (++i) + ".rsc", new String(contents)); //$NON-NLS-1$
@@ -944,6 +952,7 @@ private int stateStackLengthStack[] = new int[0];
protected boolean parsingJava8Plus;
protected boolean parsingJava9Plus;
protected boolean parsingJava12Plus;
+protected boolean parsingJava13Plus;
protected boolean parsingJava11Plus;
protected int unstackedAct = ERROR_ACTION;
private boolean haltOnSyntaxError = false;
@@ -963,6 +972,7 @@ public Parser(ProblemReporter problemReporter, boolean optimizeStringLiterals) {
initializeScanner();
this.parsingJava8Plus = this.options.sourceLevel >= ClassFileConstants.JDK1_8;
this.parsingJava9Plus = this.options.sourceLevel >= ClassFileConstants.JDK9;
+ this.parsingJava13Plus = this.options.sourceLevel >= ClassFileConstants.JDK13;
this.parsingJava12Plus = this.options.sourceLevel >= ClassFileConstants.JDK12;
this.parsingJava11Plus = this.options.sourceLevel >= ClassFileConstants.JDK11;
this.astLengthStack = new int[50];
@@ -2226,7 +2236,7 @@ protected void consumeCaseLabel() {
}
CaseStatement caseStatement = new CaseStatement(constantExpressions[0], constantExpressions[length - 1].sourceEnd, this.intStack[this.intPtr--]);
if (constantExpressions.length > 1) {
- if (this.parsingJava12Plus) {
+ if (this.parsingJava13Plus) {
if (this.options.enablePreviewFeatures) {
if (this.options.isAnyEnabled(IrritantSet.PREVIEW) && constantExpressions.length > 1) {
problemReporter().previewFeatureUsed(caseStatement.sourceStart, caseStatement.sourceEnd);
@@ -2235,7 +2245,7 @@ protected void consumeCaseLabel() {
problemReporter().previewFeatureNotEnabled(caseStatement.sourceStart, caseStatement.sourceEnd, "Multi constant case"); //$NON-NLS-1$
}
} else {
- problemReporter().previewFeatureNotSupported(caseStatement.sourceStart, caseStatement.sourceEnd, "Multi constant case", CompilerOptions.VERSION_12); //$NON-NLS-1$
+ problemReporter().previewFeatureNotSupported(caseStatement.sourceStart, caseStatement.sourceEnd, "Multi constant case", CompilerOptions.VERSION_13); //$NON-NLS-1$
}
}
caseStatement.constantExpressions = constantExpressions;
@@ -6450,2122 +6460,2118 @@ protected void consumeZeroTypeAnnotations() {
// This method is part of an automatic generation : do NOT edit-modify
protected void consumeRule(int act) {
switch ( act ) {
- case 35 : if (DEBUG) { System.out.println("Type ::= PrimitiveType"); } //$NON-NLS-1$
+ case 37 : if (DEBUG) { System.out.println("Type ::= PrimitiveType"); } //$NON-NLS-1$
consumePrimitiveType();
break;
- case 49 : if (DEBUG) { System.out.println("ReferenceType ::= ClassOrInterfaceType"); } //$NON-NLS-1$
+ case 51 : if (DEBUG) { System.out.println("ReferenceType ::= ClassOrInterfaceType"); } //$NON-NLS-1$
consumeReferenceType();
break;
- case 53 : if (DEBUG) { System.out.println("ClassOrInterface ::= Name"); } //$NON-NLS-1$
+ case 55 : if (DEBUG) { System.out.println("ClassOrInterface ::= Name"); } //$NON-NLS-1$
consumeClassOrInterfaceName();
break;
- case 54 : if (DEBUG) { System.out.println("ClassOrInterface ::= GenericType DOT Name"); } //$NON-NLS-1$
+ case 56 : if (DEBUG) { System.out.println("ClassOrInterface ::= GenericType DOT Name"); } //$NON-NLS-1$
consumeClassOrInterface();
break;
- case 55 : if (DEBUG) { System.out.println("GenericType ::= ClassOrInterface TypeArguments"); } //$NON-NLS-1$
+ case 57 : if (DEBUG) { System.out.println("GenericType ::= ClassOrInterface TypeArguments"); } //$NON-NLS-1$
consumeGenericType();
break;
- case 56 : if (DEBUG) { System.out.println("GenericType ::= ClassOrInterface LESS GREATER"); } //$NON-NLS-1$
+ case 58 : if (DEBUG) { System.out.println("GenericType ::= ClassOrInterface LESS GREATER"); } //$NON-NLS-1$
consumeGenericTypeWithDiamond();
break;
- case 57 : if (DEBUG) { System.out.println("ArrayTypeWithTypeArgumentsName ::= GenericType DOT Name"); } //$NON-NLS-1$
+ case 59 : if (DEBUG) { System.out.println("ArrayTypeWithTypeArgumentsName ::= GenericType DOT Name"); } //$NON-NLS-1$
consumeArrayTypeWithTypeArgumentsName();
break;
- case 58 : if (DEBUG) { System.out.println("ArrayType ::= PrimitiveType Dims"); } //$NON-NLS-1$
+ case 60 : if (DEBUG) { System.out.println("ArrayType ::= PrimitiveType Dims"); } //$NON-NLS-1$
consumePrimitiveArrayType();
break;
- case 59 : if (DEBUG) { System.out.println("ArrayType ::= Name Dims"); } //$NON-NLS-1$
+ case 61 : if (DEBUG) { System.out.println("ArrayType ::= Name Dims"); } //$NON-NLS-1$
consumeNameArrayType();
break;
- case 60 : if (DEBUG) { System.out.println("ArrayType ::= ArrayTypeWithTypeArgumentsName Dims"); } //$NON-NLS-1$
+ case 62 : if (DEBUG) { System.out.println("ArrayType ::= ArrayTypeWithTypeArgumentsName Dims"); } //$NON-NLS-1$
consumeGenericTypeNameArrayType();
break;
- case 61 : if (DEBUG) { System.out.println("ArrayType ::= GenericType Dims"); } //$NON-NLS-1$
+ case 63 : if (DEBUG) { System.out.println("ArrayType ::= GenericType Dims"); } //$NON-NLS-1$
consumeGenericTypeArrayType();
break;
- case 63 : if (DEBUG) { System.out.println("Name ::= SimpleName"); } //$NON-NLS-1$
+ case 65 : if (DEBUG) { System.out.println("Name ::= SimpleName"); } //$NON-NLS-1$
consumeZeroTypeAnnotations();
break;
- case 68 : if (DEBUG) { System.out.println("UnannotatableName ::= UnannotatableName DOT SimpleName"); } //$NON-NLS-1$
+ case 70 : if (DEBUG) { System.out.println("UnannotatableName ::= UnannotatableName DOT SimpleName"); } //$NON-NLS-1$
consumeUnannotatableQualifiedName();
break;
- case 69 : if (DEBUG) { System.out.println("QualifiedName ::= Name DOT SimpleName"); } //$NON-NLS-1$
+ case 71 : if (DEBUG) { System.out.println("QualifiedName ::= Name DOT SimpleName"); } //$NON-NLS-1$
consumeQualifiedName(false);
break;
- case 70 : if (DEBUG) { System.out.println("QualifiedName ::= Name DOT TypeAnnotations SimpleName"); } //$NON-NLS-1$
+ case 72 : if (DEBUG) { System.out.println("QualifiedName ::= Name DOT TypeAnnotations SimpleName"); } //$NON-NLS-1$
consumeQualifiedName(true);
break;
- case 71 : if (DEBUG) { System.out.println("TypeAnnotationsopt ::="); } //$NON-NLS-1$
+ case 73 : if (DEBUG) { System.out.println("TypeAnnotationsopt ::="); } //$NON-NLS-1$
consumeZeroTypeAnnotations();
break;
- case 75 : if (DEBUG) { System.out.println("TypeAnnotations0 ::= TypeAnnotations0 TypeAnnotation"); } //$NON-NLS-1$
+ case 77 : if (DEBUG) { System.out.println("TypeAnnotations0 ::= TypeAnnotations0 TypeAnnotation"); } //$NON-NLS-1$
consumeOneMoreTypeAnnotation();
break;
- case 76 : if (DEBUG) { System.out.println("TypeAnnotation ::= NormalTypeAnnotation"); } //$NON-NLS-1$
+ case 78 : if (DEBUG) { System.out.println("TypeAnnotation ::= NormalTypeAnnotation"); } //$NON-NLS-1$
consumeTypeAnnotation();
break;
- case 77 : if (DEBUG) { System.out.println("TypeAnnotation ::= MarkerTypeAnnotation"); } //$NON-NLS-1$
+ case 79 : if (DEBUG) { System.out.println("TypeAnnotation ::= MarkerTypeAnnotation"); } //$NON-NLS-1$
consumeTypeAnnotation();
break;
- case 78 : if (DEBUG) { System.out.println("TypeAnnotation ::= SingleMemberTypeAnnotation"); } //$NON-NLS-1$
+ case 80 : if (DEBUG) { System.out.println("TypeAnnotation ::= SingleMemberTypeAnnotation"); } //$NON-NLS-1$
consumeTypeAnnotation();
break;
- case 79 : if (DEBUG) { System.out.println("TypeAnnotationName ::= AT308 UnannotatableName"); } //$NON-NLS-1$
+ case 81 : if (DEBUG) { System.out.println("TypeAnnotationName ::= AT308 UnannotatableName"); } //$NON-NLS-1$
consumeAnnotationName() ;
break;
- case 80 : if (DEBUG) { System.out.println("NormalTypeAnnotation ::= TypeAnnotationName LPAREN..."); } //$NON-NLS-1$
+ case 82 : if (DEBUG) { System.out.println("NormalTypeAnnotation ::= TypeAnnotationName LPAREN..."); } //$NON-NLS-1$
consumeNormalAnnotation(true) ;
break;
- case 81 : if (DEBUG) { System.out.println("MarkerTypeAnnotation ::= TypeAnnotationName"); } //$NON-NLS-1$
+ case 83 : if (DEBUG) { System.out.println("MarkerTypeAnnotation ::= TypeAnnotationName"); } //$NON-NLS-1$
consumeMarkerAnnotation(true) ;
break;
- case 82 : if (DEBUG) { System.out.println("SingleMemberTypeAnnotation ::= TypeAnnotationName LPAREN"); } //$NON-NLS-1$
+ case 84 : if (DEBUG) { System.out.println("SingleMemberTypeAnnotation ::= TypeAnnotationName LPAREN"); } //$NON-NLS-1$
consumeSingleMemberAnnotation(true) ;
break;
- case 83 : if (DEBUG) { System.out.println("RejectTypeAnnotations ::="); } //$NON-NLS-1$
+ case 85 : if (DEBUG) { System.out.println("RejectTypeAnnotations ::="); } //$NON-NLS-1$
consumeNonTypeUseName();
break;
- case 84 : if (DEBUG) { System.out.println("PushZeroTypeAnnotations ::="); } //$NON-NLS-1$
+ case 86 : if (DEBUG) { System.out.println("PushZeroTypeAnnotations ::="); } //$NON-NLS-1$
consumeZeroTypeAnnotations();
break;
- case 85 : if (DEBUG) { System.out.println("VariableDeclaratorIdOrThis ::= this"); } //$NON-NLS-1$
+ case 87 : if (DEBUG) { System.out.println("VariableDeclaratorIdOrThis ::= this"); } //$NON-NLS-1$
consumeExplicitThisParameter(false);
break;
- case 86 : if (DEBUG) { System.out.println("VariableDeclaratorIdOrThis ::= UnannotatableName DOT this"); } //$NON-NLS-1$
+ case 88 : if (DEBUG) { System.out.println("VariableDeclaratorIdOrThis ::= UnannotatableName DOT this"); } //$NON-NLS-1$
consumeExplicitThisParameter(true);
break;
- case 87 : if (DEBUG) { System.out.println("VariableDeclaratorIdOrThis ::= VariableDeclaratorId"); } //$NON-NLS-1$
+ case 89 : if (DEBUG) { System.out.println("VariableDeclaratorIdOrThis ::= VariableDeclaratorId"); } //$NON-NLS-1$
consumeVariableDeclaratorIdParameter();
break;
- case 88 : if (DEBUG) { System.out.println("CompilationUnit ::= EnterCompilationUnit..."); } //$NON-NLS-1$
+ case 90 : if (DEBUG) { System.out.println("CompilationUnit ::= EnterCompilationUnit..."); } //$NON-NLS-1$
consumeCompilationUnit();
break;
- case 89 : if (DEBUG) { System.out.println("InternalCompilationUnit ::= PackageDeclaration"); } //$NON-NLS-1$
+ case 91 : if (DEBUG) { System.out.println("InternalCompilationUnit ::= PackageDeclaration"); } //$NON-NLS-1$
consumeInternalCompilationUnit();
break;
- case 90 : if (DEBUG) { System.out.println("InternalCompilationUnit ::= PackageDeclaration..."); } //$NON-NLS-1$
+ case 92 : if (DEBUG) { System.out.println("InternalCompilationUnit ::= PackageDeclaration..."); } //$NON-NLS-1$
consumeInternalCompilationUnit();
break;
- case 91 : if (DEBUG) { System.out.println("InternalCompilationUnit ::= PackageDeclaration..."); } //$NON-NLS-1$
+ case 93 : if (DEBUG) { System.out.println("InternalCompilationUnit ::= PackageDeclaration..."); } //$NON-NLS-1$
consumeInternalCompilationUnitWithTypes();
break;
- case 92 : if (DEBUG) { System.out.println("InternalCompilationUnit ::= PackageDeclaration..."); } //$NON-NLS-1$
+ case 94 : if (DEBUG) { System.out.println("InternalCompilationUnit ::= PackageDeclaration..."); } //$NON-NLS-1$
consumeInternalCompilationUnitWithTypes();
break;
- case 93 : if (DEBUG) { System.out.println("InternalCompilationUnit ::= ImportDeclarations..."); } //$NON-NLS-1$
+ case 95 : if (DEBUG) { System.out.println("InternalCompilationUnit ::= ImportDeclarations..."); } //$NON-NLS-1$
consumeInternalCompilationUnit();
break;
- case 94 : if (DEBUG) { System.out.println("InternalCompilationUnit ::= TypeDeclarations"); } //$NON-NLS-1$
+ case 96 : if (DEBUG) { System.out.println("InternalCompilationUnit ::= TypeDeclarations"); } //$NON-NLS-1$
consumeInternalCompilationUnitWithTypes();
break;
- case 95 : if (DEBUG) { System.out.println("InternalCompilationUnit ::= ImportDeclarations..."); } //$NON-NLS-1$
+ case 97 : if (DEBUG) { System.out.println("InternalCompilationUnit ::= ImportDeclarations..."); } //$NON-NLS-1$
consumeInternalCompilationUnitWithTypes();
break;
- case 96 : if (DEBUG) { System.out.println("InternalCompilationUnit ::="); } //$NON-NLS-1$
+ case 98 : if (DEBUG) { System.out.println("InternalCompilationUnit ::="); } //$NON-NLS-1$
consumeEmptyInternalCompilationUnit();
break;
- case 97 : if (DEBUG) { System.out.println("InternalCompilationUnit ::= ImportDeclarations..."); } //$NON-NLS-1$
+ case 99 : if (DEBUG) { System.out.println("InternalCompilationUnit ::= ImportDeclarations..."); } //$NON-NLS-1$
consumeInternalCompilationUnitWithModuleDeclaration();
break;
- case 98 : if (DEBUG) { System.out.println("InternalCompilationUnit ::= ModuleDeclaration"); } //$NON-NLS-1$
+ case 100 : if (DEBUG) { System.out.println("InternalCompilationUnit ::= ModuleDeclaration"); } //$NON-NLS-1$
consumeInternalCompilationUnitWithModuleDeclaration();
break;
- case 99 : if (DEBUG) { System.out.println("ModuleDeclaration ::= ModuleHeader ModuleBody"); } //$NON-NLS-1$
+ case 101 : if (DEBUG) { System.out.println("ModuleDeclaration ::= ModuleHeader ModuleBody"); } //$NON-NLS-1$
consumeModuleDeclaration();
break;
- case 100 : if (DEBUG) { System.out.println("ModuleHeader ::= Modifiersopt ModuleModifieropt module"); } //$NON-NLS-1$
+ case 102 : if (DEBUG) { System.out.println("ModuleHeader ::= Modifiersopt ModuleModifieropt module"); } //$NON-NLS-1$
consumeModuleHeader();
break;
- case 102 : if (DEBUG) { System.out.println("ModuleModifieropt ::= ModuleModifier"); } //$NON-NLS-1$
+ case 104 : if (DEBUG) { System.out.println("ModuleModifieropt ::= ModuleModifier"); } //$NON-NLS-1$
consumeModuleModifiers();
break;
- case 105 : if (DEBUG) { System.out.println("ModuleStatementsOpt ::="); } //$NON-NLS-1$
+ case 107 : if (DEBUG) { System.out.println("ModuleStatementsOpt ::="); } //$NON-NLS-1$
consumeEmptyModuleStatementsOpt();
break;
- case 108 : if (DEBUG) { System.out.println("ModuleStatements ::= ModuleStatements ModuleStatement"); } //$NON-NLS-1$
+ case 110 : if (DEBUG) { System.out.println("ModuleStatements ::= ModuleStatements ModuleStatement"); } //$NON-NLS-1$
consumeModuleStatements();
break;
- case 114 : if (DEBUG) { System.out.println("RequiresStatement ::= SingleRequiresModuleName SEMICOLON"); } //$NON-NLS-1$
+ case 116 : if (DEBUG) { System.out.println("RequiresStatement ::= SingleRequiresModuleName SEMICOLON"); } //$NON-NLS-1$
consumeRequiresStatement();
break;
- case 115 : if (DEBUG) { System.out.println("SingleRequiresModuleName ::= requires..."); } //$NON-NLS-1$
+ case 117 : if (DEBUG) { System.out.println("SingleRequiresModuleName ::= requires..."); } //$NON-NLS-1$
consumeSingleRequiresModuleName();
break;
- case 116 : if (DEBUG) { System.out.println("RequiresModifiersopt ::= RequiresModifiers"); } //$NON-NLS-1$
+ case 118 : if (DEBUG) { System.out.println("RequiresModifiersopt ::= RequiresModifiers"); } //$NON-NLS-1$
consumeModifiers();
break;
- case 117 : if (DEBUG) { System.out.println("RequiresModifiersopt ::="); } //$NON-NLS-1$
+ case 119 : if (DEBUG) { System.out.println("RequiresModifiersopt ::="); } //$NON-NLS-1$
consumeDefaultModifiers();
break;
- case 119 : if (DEBUG) { System.out.println("RequiresModifiers ::= RequiresModifiers RequiresModifier"); } //$NON-NLS-1$
+ case 121 : if (DEBUG) { System.out.println("RequiresModifiers ::= RequiresModifiers RequiresModifier"); } //$NON-NLS-1$
consumeModifiers2();
break;
- case 122 : if (DEBUG) { System.out.println("ExportsStatement ::= ExportsHeader TargetModuleListopt"); } //$NON-NLS-1$
+ case 124 : if (DEBUG) { System.out.println("ExportsStatement ::= ExportsHeader TargetModuleListopt"); } //$NON-NLS-1$
consumeExportsStatement();
break;
- case 123 : if (DEBUG) { System.out.println("ExportsHeader ::= exports SinglePkgName"); } //$NON-NLS-1$
+ case 125 : if (DEBUG) { System.out.println("ExportsHeader ::= exports SinglePkgName"); } //$NON-NLS-1$
consumeExportsHeader();
break;
- case 125 : if (DEBUG) { System.out.println("TargetModuleListopt ::= to TargetModuleNameList"); } //$NON-NLS-1$
+ case 127 : if (DEBUG) { System.out.println("TargetModuleListopt ::= to TargetModuleNameList"); } //$NON-NLS-1$
consumeTargetModuleList();
break;
- case 126 : if (DEBUG) { System.out.println("TargetModuleName ::= UnannotatableName"); } //$NON-NLS-1$
+ case 128 : if (DEBUG) { System.out.println("TargetModuleName ::= UnannotatableName"); } //$NON-NLS-1$
consumeSingleTargetModuleName();
break;
- case 128 : if (DEBUG) { System.out.println("TargetModuleNameList ::= TargetModuleNameList COMMA..."); } //$NON-NLS-1$
+ case 130 : if (DEBUG) { System.out.println("TargetModuleNameList ::= TargetModuleNameList COMMA..."); } //$NON-NLS-1$
consumeTargetModuleNameList();
break;
- case 129 : if (DEBUG) { System.out.println("SinglePkgName ::= UnannotatableName"); } //$NON-NLS-1$
+ case 131 : if (DEBUG) { System.out.println("SinglePkgName ::= UnannotatableName"); } //$NON-NLS-1$
consumeSinglePkgName();
break;
- case 130 : if (DEBUG) { System.out.println("OpensStatement ::= OpensHeader TargetModuleListopt..."); } //$NON-NLS-1$
+ case 132 : if (DEBUG) { System.out.println("OpensStatement ::= OpensHeader TargetModuleListopt..."); } //$NON-NLS-1$
consumeOpensStatement();
break;
- case 131 : if (DEBUG) { System.out.println("OpensHeader ::= opens SinglePkgName"); } //$NON-NLS-1$
+ case 133 : if (DEBUG) { System.out.println("OpensHeader ::= opens SinglePkgName"); } //$NON-NLS-1$
consumeOpensHeader();
break;
- case 132 : if (DEBUG) { System.out.println("UsesStatement ::= UsesHeader SEMICOLON"); } //$NON-NLS-1$
+ case 134 : if (DEBUG) { System.out.println("UsesStatement ::= UsesHeader SEMICOLON"); } //$NON-NLS-1$
consumeUsesStatement();
break;
- case 133 : if (DEBUG) { System.out.println("UsesHeader ::= uses Name"); } //$NON-NLS-1$
+ case 135 : if (DEBUG) { System.out.println("UsesHeader ::= uses Name"); } //$NON-NLS-1$
consumeUsesHeader();
break;
- case 134 : if (DEBUG) { System.out.println("ProvidesStatement ::= ProvidesInterface WithClause..."); } //$NON-NLS-1$
+ case 136 : if (DEBUG) { System.out.println("ProvidesStatement ::= ProvidesInterface WithClause..."); } //$NON-NLS-1$
consumeProvidesStatement();
break;
- case 135 : if (DEBUG) { System.out.println("ProvidesInterface ::= provides Name"); } //$NON-NLS-1$
+ case 137 : if (DEBUG) { System.out.println("ProvidesInterface ::= provides Name"); } //$NON-NLS-1$
consumeProvidesInterface();
break;
- case 136 : if (DEBUG) { System.out.println("ServiceImplName ::= Name"); } //$NON-NLS-1$
+ case 138 : if (DEBUG) { System.out.println("ServiceImplName ::= Name"); } //$NON-NLS-1$
consumeSingleServiceImplName();
break;
- case 138 : if (DEBUG) { System.out.println("ServiceImplNameList ::= ServiceImplNameList COMMA..."); } //$NON-NLS-1$
+ case 140 : if (DEBUG) { System.out.println("ServiceImplNameList ::= ServiceImplNameList COMMA..."); } //$NON-NLS-1$
consumeServiceImplNameList();
break;
- case 139 : if (DEBUG) { System.out.println("WithClause ::= with ServiceImplNameList"); } //$NON-NLS-1$
+ case 141 : if (DEBUG) { System.out.println("WithClause ::= with ServiceImplNameList"); } //$NON-NLS-1$
consumeWithClause();
break;
- case 140 : if (DEBUG) { System.out.println("ReduceImports ::="); } //$NON-NLS-1$
+ case 142 : if (DEBUG) { System.out.println("ReduceImports ::="); } //$NON-NLS-1$
consumeReduceImports();
break;
- case 141 : if (DEBUG) { System.out.println("EnterCompilationUnit ::="); } //$NON-NLS-1$
+ case 143 : if (DEBUG) { System.out.println("EnterCompilationUnit ::="); } //$NON-NLS-1$
consumeEnterCompilationUnit();
break;
- case 163 : if (DEBUG) { System.out.println("CatchHeader ::= catch LPAREN CatchFormalParameter RPAREN"); } //$NON-NLS-1$
+ case 165 : if (DEBUG) { System.out.println("CatchHeader ::= catch LPAREN CatchFormalParameter RPAREN"); } //$NON-NLS-1$
consumeCatchHeader();
break;
- case 165 : if (DEBUG) { System.out.println("ImportDeclarations ::= ImportDeclarations..."); } //$NON-NLS-1$
+ case 167 : if (DEBUG) { System.out.println("ImportDeclarations ::= ImportDeclarations..."); } //$NON-NLS-1$
consumeImportDeclarations();
break;
- case 167 : if (DEBUG) { System.out.println("TypeDeclarations ::= TypeDeclarations TypeDeclaration"); } //$NON-NLS-1$
+ case 169 : if (DEBUG) { System.out.println("TypeDeclarations ::= TypeDeclarations TypeDeclaration"); } //$NON-NLS-1$
consumeTypeDeclarations();
break;
- case 168 : if (DEBUG) { System.out.println("PackageDeclaration ::= PackageDeclarationName SEMICOLON"); } //$NON-NLS-1$
+ case 170 : if (DEBUG) { System.out.println("PackageDeclaration ::= PackageDeclarationName SEMICOLON"); } //$NON-NLS-1$
consumePackageDeclaration();
break;
- case 169 : if (DEBUG) { System.out.println("PackageDeclarationName ::= Modifiers package..."); } //$NON-NLS-1$
+ case 171 : if (DEBUG) { System.out.println("PackageDeclarationName ::= Modifiers package..."); } //$NON-NLS-1$
consumePackageDeclarationNameWithModifiers();
break;
- case 170 : if (DEBUG) { System.out.println("PackageDeclarationName ::= PackageComment package Name"); } //$NON-NLS-1$
+ case 172 : if (DEBUG) { System.out.println("PackageDeclarationName ::= PackageComment package Name"); } //$NON-NLS-1$
consumePackageDeclarationName();
break;
- case 171 : if (DEBUG) { System.out.println("PackageComment ::="); } //$NON-NLS-1$
+ case 173 : if (DEBUG) { System.out.println("PackageComment ::="); } //$NON-NLS-1$
consumePackageComment();
break;
- case 176 : if (DEBUG) { System.out.println("SingleTypeImportDeclaration ::=..."); } //$NON-NLS-1$
+ case 178 : if (DEBUG) { System.out.println("SingleTypeImportDeclaration ::=..."); } //$NON-NLS-1$
consumeImportDeclaration();
break;
- case 177 : if (DEBUG) { System.out.println("SingleTypeImportDeclarationName ::= import Name..."); } //$NON-NLS-1$
+ case 179 : if (DEBUG) { System.out.println("SingleTypeImportDeclarationName ::= import Name..."); } //$NON-NLS-1$
consumeSingleTypeImportDeclarationName();
break;
- case 178 : if (DEBUG) { System.out.println("TypeImportOnDemandDeclaration ::=..."); } //$NON-NLS-1$
+ case 180 : if (DEBUG) { System.out.println("TypeImportOnDemandDeclaration ::=..."); } //$NON-NLS-1$
consumeImportDeclaration();
break;
- case 179 : if (DEBUG) { System.out.println("TypeImportOnDemandDeclarationName ::= import Name DOT..."); } //$NON-NLS-1$
+ case 181 : if (DEBUG) { System.out.println("TypeImportOnDemandDeclarationName ::= import Name DOT..."); } //$NON-NLS-1$
consumeTypeImportOnDemandDeclarationName();
break;
- case 182 : if (DEBUG) { System.out.println("TypeDeclaration ::= SEMICOLON"); } //$NON-NLS-1$
+ case 184 : if (DEBUG) { System.out.println("TypeDeclaration ::= SEMICOLON"); } //$NON-NLS-1$
consumeEmptyTypeDeclaration();
break;
- case 186 : if (DEBUG) { System.out.println("Modifiers ::= Modifiers Modifier"); } //$NON-NLS-1$
+ case 188 : if (DEBUG) { System.out.println("Modifiers ::= Modifiers Modifier"); } //$NON-NLS-1$
consumeModifiers2();
break;
- case 198 : if (DEBUG) { System.out.println("Modifier ::= Annotation"); } //$NON-NLS-1$
+ case 200 : if (DEBUG) { System.out.println("Modifier ::= Annotation"); } //$NON-NLS-1$
consumeAnnotationAsModifier();
break;
- case 199 : if (DEBUG) { System.out.println("ClassDeclaration ::= ClassHeader ClassBody"); } //$NON-NLS-1$
+ case 201 : if (DEBUG) { System.out.println("ClassDeclaration ::= ClassHeader ClassBody"); } //$NON-NLS-1$
consumeClassDeclaration();
break;
- case 200 : if (DEBUG) { System.out.println("ClassHeader ::= ClassHeaderName ClassHeaderExtendsopt..."); } //$NON-NLS-1$
+ case 202 : if (DEBUG) { System.out.println("ClassHeader ::= ClassHeaderName ClassHeaderExtendsopt..."); } //$NON-NLS-1$
consumeClassHeader();
break;
- case 201 : if (DEBUG) { System.out.println("ClassHeaderName ::= ClassHeaderName1 TypeParameters"); } //$NON-NLS-1$
+ case 203 : if (DEBUG) { System.out.println("ClassHeaderName ::= ClassHeaderName1 TypeParameters"); } //$NON-NLS-1$
consumeTypeHeaderNameWithTypeParameters();
break;
- case 203 : if (DEBUG) { System.out.println("ClassHeaderName1 ::= Modifiersopt class Identifier"); } //$NON-NLS-1$
+ case 205 : if (DEBUG) { System.out.println("ClassHeaderName1 ::= Modifiersopt class Identifier"); } //$NON-NLS-1$
consumeClassHeaderName1();
break;
- case 204 : if (DEBUG) { System.out.println("ClassHeaderExtends ::= extends ClassType"); } //$NON-NLS-1$
+ case 206 : if (DEBUG) { System.out.println("ClassHeaderExtends ::= extends ClassType"); } //$NON-NLS-1$
consumeClassHeaderExtends();
break;
- case 205 : if (DEBUG) { System.out.println("ClassHeaderImplements ::= implements InterfaceTypeList"); } //$NON-NLS-1$
+ case 207 : if (DEBUG) { System.out.println("ClassHeaderImplements ::= implements InterfaceTypeList"); } //$NON-NLS-1$
consumeClassHeaderImplements();
break;
- case 207 : if (DEBUG) { System.out.println("InterfaceTypeList ::= InterfaceTypeList COMMA..."); } //$NON-NLS-1$
+ case 209 : if (DEBUG) { System.out.println("InterfaceTypeList ::= InterfaceTypeList COMMA..."); } //$NON-NLS-1$
consumeInterfaceTypeList();
break;
- case 208 : if (DEBUG) { System.out.println("InterfaceType ::= ClassOrInterfaceType"); } //$NON-NLS-1$
+ case 210 : if (DEBUG) { System.out.println("InterfaceType ::= ClassOrInterfaceType"); } //$NON-NLS-1$
consumeInterfaceType();
break;
- case 211 : if (DEBUG) { System.out.println("ClassBodyDeclarations ::= ClassBodyDeclarations..."); } //$NON-NLS-1$
+ case 213 : if (DEBUG) { System.out.println("ClassBodyDeclarations ::= ClassBodyDeclarations..."); } //$NON-NLS-1$
consumeClassBodyDeclarations();
break;
- case 215 : if (DEBUG) { System.out.println("ClassBodyDeclaration ::= Diet NestedMethod..."); } //$NON-NLS-1$
+ case 217 : if (DEBUG) { System.out.println("ClassBodyDeclaration ::= Diet NestedMethod..."); } //$NON-NLS-1$
consumeClassBodyDeclaration();
break;
- case 216 : if (DEBUG) { System.out.println("Diet ::="); } //$NON-NLS-1$
+ case 218 : if (DEBUG) { System.out.println("Diet ::="); } //$NON-NLS-1$
consumeDiet();
break;
- case 217 : if (DEBUG) { System.out.println("Initializer ::= Diet NestedMethod CreateInitializer..."); } //$NON-NLS-1$
+ case 219 : if (DEBUG) { System.out.println("Initializer ::= Diet NestedMethod CreateInitializer..."); } //$NON-NLS-1$
consumeClassBodyDeclaration();
break;
- case 218 : if (DEBUG) { System.out.println("CreateInitializer ::="); } //$NON-NLS-1$
+ case 220 : if (DEBUG) { System.out.println("CreateInitializer ::="); } //$NON-NLS-1$
consumeCreateInitializer();
break;
- case 225 : if (DEBUG) { System.out.println("ClassMemberDeclaration ::= SEMICOLON"); } //$NON-NLS-1$
+ case 227 : if (DEBUG) { System.out.println("ClassMemberDeclaration ::= SEMICOLON"); } //$NON-NLS-1$
consumeEmptyTypeDeclaration();
break;
- case 228 : if (DEBUG) { System.out.println("FieldDeclaration ::= Modifiersopt Type..."); } //$NON-NLS-1$
+ case 230 : if (DEBUG) { System.out.println("FieldDeclaration ::= Modifiersopt Type..."); } //$NON-NLS-1$
consumeFieldDeclaration();
break;
- case 230 : if (DEBUG) { System.out.println("VariableDeclarators ::= VariableDeclarators COMMA..."); } //$NON-NLS-1$
+ case 232 : if (DEBUG) { System.out.println("VariableDeclarators ::= VariableDeclarators COMMA..."); } //$NON-NLS-1$
consumeVariableDeclarators();
break;
- case 233 : if (DEBUG) { System.out.println("EnterVariable ::="); } //$NON-NLS-1$
+ case 235 : if (DEBUG) { System.out.println("EnterVariable ::="); } //$NON-NLS-1$
consumeEnterVariable();
break;
- case 234 : if (DEBUG) { System.out.println("ExitVariableWithInitialization ::="); } //$NON-NLS-1$
+ case 236 : if (DEBUG) { System.out.println("ExitVariableWithInitialization ::="); } //$NON-NLS-1$
consumeExitVariableWithInitialization();
break;
- case 235 : if (DEBUG) { System.out.println("ExitVariableWithoutInitialization ::="); } //$NON-NLS-1$
+ case 237 : if (DEBUG) { System.out.println("ExitVariableWithoutInitialization ::="); } //$NON-NLS-1$
consumeExitVariableWithoutInitialization();
break;
- case 236 : if (DEBUG) { System.out.println("ForceNoDiet ::="); } //$NON-NLS-1$
+ case 238 : if (DEBUG) { System.out.println("ForceNoDiet ::="); } //$NON-NLS-1$
consumeForceNoDiet();
break;
- case 237 : if (DEBUG) { System.out.println("RestoreDiet ::="); } //$NON-NLS-1$
+ case 239 : if (DEBUG) { System.out.println("RestoreDiet ::="); } //$NON-NLS-1$
consumeRestoreDiet();
break;
- case 242 : if (DEBUG) { System.out.println("MethodDeclaration ::= MethodHeader MethodBody"); } //$NON-NLS-1$
+ case 244 : if (DEBUG) { System.out.println("MethodDeclaration ::= MethodHeader MethodBody"); } //$NON-NLS-1$
// set to true to consume a method with a body
consumeMethodDeclaration(true, false);
break;
- case 243 : if (DEBUG) { System.out.println("MethodDeclaration ::= DefaultMethodHeader MethodBody"); } //$NON-NLS-1$
+ case 245 : if (DEBUG) { System.out.println("MethodDeclaration ::= DefaultMethodHeader MethodBody"); } //$NON-NLS-1$
// set to true to consume a method with a body
consumeMethodDeclaration(true, true);
break;
- case 244 : if (DEBUG) { System.out.println("AbstractMethodDeclaration ::= MethodHeader SEMICOLON"); } //$NON-NLS-1$
+ case 246 : if (DEBUG) { System.out.println("AbstractMethodDeclaration ::= MethodHeader SEMICOLON"); } //$NON-NLS-1$
// set to false to consume a method without body
consumeMethodDeclaration(false, false);
break;
- case 245 : if (DEBUG) { System.out.println("MethodHeader ::= MethodHeaderName FormalParameterListopt"); } //$NON-NLS-1$
+ case 247 : if (DEBUG) { System.out.println("MethodHeader ::= MethodHeaderName FormalParameterListopt"); } //$NON-NLS-1$
consumeMethodHeader();
break;
- case 246 : if (DEBUG) { System.out.println("DefaultMethodHeader ::= DefaultMethodHeaderName..."); } //$NON-NLS-1$
+ case 248 : if (DEBUG) { System.out.println("DefaultMethodHeader ::= DefaultMethodHeaderName..."); } //$NON-NLS-1$
consumeMethodHeader();
break;
- case 247 : if (DEBUG) { System.out.println("MethodHeaderName ::= Modifiersopt TypeParameters Type..."); } //$NON-NLS-1$
+ case 249 : if (DEBUG) { System.out.println("MethodHeaderName ::= Modifiersopt TypeParameters Type..."); } //$NON-NLS-1$
consumeMethodHeaderNameWithTypeParameters(false);
break;
- case 248 : if (DEBUG) { System.out.println("MethodHeaderName ::= Modifiersopt Type Identifier LPAREN"); } //$NON-NLS-1$
+ case 250 : if (DEBUG) { System.out.println("MethodHeaderName ::= Modifiersopt Type Identifier LPAREN"); } //$NON-NLS-1$
consumeMethodHeaderName(false);
break;
- case 249 : if (DEBUG) { System.out.println("DefaultMethodHeaderName ::= ModifiersWithDefault..."); } //$NON-NLS-1$
+ case 251 : if (DEBUG) { System.out.println("DefaultMethodHeaderName ::= ModifiersWithDefault..."); } //$NON-NLS-1$
consumeMethodHeaderNameWithTypeParameters(false);
break;
- case 250 : if (DEBUG) { System.out.println("DefaultMethodHeaderName ::= ModifiersWithDefault Type..."); } //$NON-NLS-1$
+ case 252 : if (DEBUG) { System.out.println("DefaultMethodHeaderName ::= ModifiersWithDefault Type..."); } //$NON-NLS-1$
consumeMethodHeaderName(false);
break;
- case 251 : if (DEBUG) { System.out.println("ModifiersWithDefault ::= Modifiersopt default..."); } //$NON-NLS-1$
+ case 253 : if (DEBUG) { System.out.println("ModifiersWithDefault ::= Modifiersopt default..."); } //$NON-NLS-1$
consumePushCombineModifiers();
break;
- case 252 : if (DEBUG) { System.out.println("MethodHeaderRightParen ::= RPAREN"); } //$NON-NLS-1$
+ case 254 : if (DEBUG) { System.out.println("MethodHeaderRightParen ::= RPAREN"); } //$NON-NLS-1$
consumeMethodHeaderRightParen();
break;
- case 253 : if (DEBUG) { System.out.println("MethodHeaderExtendedDims ::= Dimsopt"); } //$NON-NLS-1$
+ case 255 : if (DEBUG) { System.out.println("MethodHeaderExtendedDims ::= Dimsopt"); } //$NON-NLS-1$
consumeMethodHeaderExtendedDims();
break;
- case 254 : if (DEBUG) { System.out.println("MethodHeaderThrowsClause ::= throws ClassTypeList"); } //$NON-NLS-1$
+ case 256 : if (DEBUG) { System.out.println("MethodHeaderThrowsClause ::= throws ClassTypeList"); } //$NON-NLS-1$
consumeMethodHeaderThrowsClause();
break;
- case 255 : if (DEBUG) { System.out.println("ConstructorHeader ::= ConstructorHeaderName..."); } //$NON-NLS-1$
+ case 257 : if (DEBUG) { System.out.println("ConstructorHeader ::= ConstructorHeaderName..."); } //$NON-NLS-1$
consumeConstructorHeader();
break;
- case 256 : if (DEBUG) { System.out.println("ConstructorHeaderName ::= Modifiersopt TypeParameters..."); } //$NON-NLS-1$
+ case 258 : if (DEBUG) { System.out.println("ConstructorHeaderName ::= Modifiersopt TypeParameters..."); } //$NON-NLS-1$
consumeConstructorHeaderNameWithTypeParameters();
break;
- case 257 : if (DEBUG) { System.out.println("ConstructorHeaderName ::= Modifiersopt Identifier LPAREN"); } //$NON-NLS-1$
+ case 259 : if (DEBUG) { System.out.println("ConstructorHeaderName ::= Modifiersopt Identifier LPAREN"); } //$NON-NLS-1$
consumeConstructorHeaderName();
break;
- case 259 : if (DEBUG) { System.out.println("FormalParameterList ::= FormalParameterList COMMA..."); } //$NON-NLS-1$
+ case 261 : if (DEBUG) { System.out.println("FormalParameterList ::= FormalParameterList COMMA..."); } //$NON-NLS-1$
consumeFormalParameterList();
break;
- case 260 : if (DEBUG) { System.out.println("FormalParameter ::= Modifiersopt Type..."); } //$NON-NLS-1$
+ case 262 : if (DEBUG) { System.out.println("FormalParameter ::= Modifiersopt Type..."); } //$NON-NLS-1$
consumeFormalParameter(false);
break;
- case 261 : if (DEBUG) { System.out.println("FormalParameter ::= Modifiersopt Type..."); } //$NON-NLS-1$
+ case 263 : if (DEBUG) { System.out.println("FormalParameter ::= Modifiersopt Type..."); } //$NON-NLS-1$
consumeFormalParameter(true);
break;
- case 262 : if (DEBUG) { System.out.println("FormalParameter ::= Modifiersopt Type AT308DOTDOTDOT..."); } //$NON-NLS-1$
+ case 264 : if (DEBUG) { System.out.println("FormalParameter ::= Modifiersopt Type AT308DOTDOTDOT..."); } //$NON-NLS-1$
consumeFormalParameter(true);
break;
- case 263 : if (DEBUG) { System.out.println("CatchFormalParameter ::= Modifiersopt CatchType..."); } //$NON-NLS-1$
+ case 265 : if (DEBUG) { System.out.println("CatchFormalParameter ::= Modifiersopt CatchType..."); } //$NON-NLS-1$
consumeCatchFormalParameter();
break;
- case 264 : if (DEBUG) { System.out.println("CatchType ::= UnionType"); } //$NON-NLS-1$
+ case 266 : if (DEBUG) { System.out.println("CatchType ::= UnionType"); } //$NON-NLS-1$
consumeCatchType();
break;
- case 265 : if (DEBUG) { System.out.println("UnionType ::= Type"); } //$NON-NLS-1$
+ case 267 : if (DEBUG) { System.out.println("UnionType ::= Type"); } //$NON-NLS-1$
consumeUnionTypeAsClassType();
break;
- case 266 : if (DEBUG) { System.out.println("UnionType ::= UnionType OR Type"); } //$NON-NLS-1$
+ case 268 : if (DEBUG) { System.out.println("UnionType ::= UnionType OR Type"); } //$NON-NLS-1$
consumeUnionType();
break;
- case 268 : if (DEBUG) { System.out.println("ClassTypeList ::= ClassTypeList COMMA ClassTypeElt"); } //$NON-NLS-1$
+ case 270 : if (DEBUG) { System.out.println("ClassTypeList ::= ClassTypeList COMMA ClassTypeElt"); } //$NON-NLS-1$
consumeClassTypeList();
break;
- case 269 : if (DEBUG) { System.out.println("ClassTypeElt ::= ClassType"); } //$NON-NLS-1$
+ case 271 : if (DEBUG) { System.out.println("ClassTypeElt ::= ClassType"); } //$NON-NLS-1$
consumeClassTypeElt();
break;
- case 270 : if (DEBUG) { System.out.println("MethodBody ::= NestedMethod LBRACE BlockStatementsopt..."); } //$NON-NLS-1$
+ case 272 : if (DEBUG) { System.out.println("MethodBody ::= NestedMethod LBRACE BlockStatementsopt..."); } //$NON-NLS-1$
consumeMethodBody();
break;
- case 271 : if (DEBUG) { System.out.println("NestedMethod ::="); } //$NON-NLS-1$
+ case 273 : if (DEBUG) { System.out.println("NestedMethod ::="); } //$NON-NLS-1$
consumeNestedMethod();
break;
- case 272 : if (DEBUG) { System.out.println("StaticInitializer ::= StaticOnly Block"); } //$NON-NLS-1$
+ case 274 : if (DEBUG) { System.out.println("StaticInitializer ::= StaticOnly Block"); } //$NON-NLS-1$
consumeStaticInitializer();
break;
- case 273 : if (DEBUG) { System.out.println("StaticOnly ::= static"); } //$NON-NLS-1$
+ case 275 : if (DEBUG) { System.out.println("StaticOnly ::= static"); } //$NON-NLS-1$
consumeStaticOnly();
break;
- case 274 : if (DEBUG) { System.out.println("ConstructorDeclaration ::= ConstructorHeader MethodBody"); } //$NON-NLS-1$
+ case 276 : if (DEBUG) { System.out.println("ConstructorDeclaration ::= ConstructorHeader MethodBody"); } //$NON-NLS-1$
consumeConstructorDeclaration() ;
break;
- case 275 : if (DEBUG) { System.out.println("ConstructorDeclaration ::= ConstructorHeader SEMICOLON"); } //$NON-NLS-1$
+ case 277 : if (DEBUG) { System.out.println("ConstructorDeclaration ::= ConstructorHeader SEMICOLON"); } //$NON-NLS-1$
consumeInvalidConstructorDeclaration() ;
break;
- case 276 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= this LPAREN..."); } //$NON-NLS-1$
+ case 278 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= this LPAREN..."); } //$NON-NLS-1$
consumeExplicitConstructorInvocation(0, THIS_CALL);
break;
- case 277 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= OnlyTypeArguments this"); } //$NON-NLS-1$
+ case 279 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= OnlyTypeArguments this"); } //$NON-NLS-1$
consumeExplicitConstructorInvocationWithTypeArguments(0,THIS_CALL);
break;
- case 278 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= super LPAREN..."); } //$NON-NLS-1$
+ case 280 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= super LPAREN..."); } //$NON-NLS-1$
consumeExplicitConstructorInvocation(0,SUPER_CALL);
break;
- case 279 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= OnlyTypeArguments..."); } //$NON-NLS-1$
+ case 281 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= OnlyTypeArguments..."); } //$NON-NLS-1$
consumeExplicitConstructorInvocationWithTypeArguments(0,SUPER_CALL);
break;
- case 280 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= Primary DOT super..."); } //$NON-NLS-1$
+ case 282 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= Primary DOT super..."); } //$NON-NLS-1$
consumeExplicitConstructorInvocation(1, SUPER_CALL);
break;
- case 281 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= Primary DOT..."); } //$NON-NLS-1$
+ case 283 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= Primary DOT..."); } //$NON-NLS-1$
consumeExplicitConstructorInvocationWithTypeArguments(1, SUPER_CALL);
break;
- case 282 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= Name DOT super LPAREN"); } //$NON-NLS-1$
+ case 284 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= Name DOT super LPAREN"); } //$NON-NLS-1$
consumeExplicitConstructorInvocation(2, SUPER_CALL);
break;
- case 283 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= Name DOT..."); } //$NON-NLS-1$
+ case 285 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= Name DOT..."); } //$NON-NLS-1$
consumeExplicitConstructorInvocationWithTypeArguments(2, SUPER_CALL);
break;
- case 284 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= Primary DOT this..."); } //$NON-NLS-1$
+ case 286 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= Primary DOT this..."); } //$NON-NLS-1$
consumeExplicitConstructorInvocation(1, THIS_CALL);
break;
- case 285 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= Primary DOT..."); } //$NON-NLS-1$
+ case 287 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= Primary DOT..."); } //$NON-NLS-1$
consumeExplicitConstructorInvocationWithTypeArguments(1, THIS_CALL);
break;
- case 286 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= Name DOT this LPAREN"); } //$NON-NLS-1$
+ case 288 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= Name DOT this LPAREN"); } //$NON-NLS-1$
consumeExplicitConstructorInvocation(2, THIS_CALL);
break;
- case 287 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= Name DOT..."); } //$NON-NLS-1$
+ case 289 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= Name DOT..."); } //$NON-NLS-1$
consumeExplicitConstructorInvocationWithTypeArguments(2, THIS_CALL);
break;
- case 288 : if (DEBUG) { System.out.println("InterfaceDeclaration ::= InterfaceHeader InterfaceBody"); } //$NON-NLS-1$
+ case 290 : if (DEBUG) { System.out.println("InterfaceDeclaration ::= InterfaceHeader InterfaceBody"); } //$NON-NLS-1$
consumeInterfaceDeclaration();
break;
- case 289 : if (DEBUG) { System.out.println("InterfaceHeader ::= InterfaceHeaderName..."); } //$NON-NLS-1$
+ case 291 : if (DEBUG) { System.out.println("InterfaceHeader ::= InterfaceHeaderName..."); } //$NON-NLS-1$
consumeInterfaceHeader();
break;
- case 290 : if (DEBUG) { System.out.println("InterfaceHeaderName ::= InterfaceHeaderName1..."); } //$NON-NLS-1$
+ case 292 : if (DEBUG) { System.out.println("InterfaceHeaderName ::= InterfaceHeaderName1..."); } //$NON-NLS-1$
consumeTypeHeaderNameWithTypeParameters();
break;
- case 292 : if (DEBUG) { System.out.println("InterfaceHeaderName1 ::= Modifiersopt interface..."); } //$NON-NLS-1$
+ case 294 : if (DEBUG) { System.out.println("InterfaceHeaderName1 ::= Modifiersopt interface..."); } //$NON-NLS-1$
consumeInterfaceHeaderName1();
break;
- case 293 : if (DEBUG) { System.out.println("InterfaceHeaderExtends ::= extends InterfaceTypeList"); } //$NON-NLS-1$
+ case 295 : if (DEBUG) { System.out.println("InterfaceHeaderExtends ::= extends InterfaceTypeList"); } //$NON-NLS-1$
consumeInterfaceHeaderExtends();
break;
- case 296 : if (DEBUG) { System.out.println("InterfaceMemberDeclarations ::=..."); } //$NON-NLS-1$
+ case 298 : if (DEBUG) { System.out.println("InterfaceMemberDeclarations ::=..."); } //$NON-NLS-1$
consumeInterfaceMemberDeclarations();
break;
- case 297 : if (DEBUG) { System.out.println("InterfaceMemberDeclaration ::= SEMICOLON"); } //$NON-NLS-1$
+ case 299 : if (DEBUG) { System.out.println("InterfaceMemberDeclaration ::= SEMICOLON"); } //$NON-NLS-1$
consumeEmptyTypeDeclaration();
break;
- case 299 : if (DEBUG) { System.out.println("InterfaceMemberDeclaration ::= DefaultMethodHeader..."); } //$NON-NLS-1$
+ case 301 : if (DEBUG) { System.out.println("InterfaceMemberDeclaration ::= DefaultMethodHeader..."); } //$NON-NLS-1$
consumeInterfaceMethodDeclaration(false);
break;
- case 300 : if (DEBUG) { System.out.println("InterfaceMemberDeclaration ::= MethodHeader MethodBody"); } //$NON-NLS-1$
+ case 302 : if (DEBUG) { System.out.println("InterfaceMemberDeclaration ::= MethodHeader MethodBody"); } //$NON-NLS-1$
consumeInterfaceMethodDeclaration(false);
break;
- case 301 : if (DEBUG) { System.out.println("InterfaceMemberDeclaration ::= DefaultMethodHeader..."); } //$NON-NLS-1$
+ case 303 : if (DEBUG) { System.out.println("InterfaceMemberDeclaration ::= DefaultMethodHeader..."); } //$NON-NLS-1$
consumeInterfaceMethodDeclaration(true);
break;
- case 302 : if (DEBUG) { System.out.println("InvalidConstructorDeclaration ::= ConstructorHeader..."); } //$NON-NLS-1$
+ case 304 : if (DEBUG) { System.out.println("InvalidConstructorDeclaration ::= ConstructorHeader..."); } //$NON-NLS-1$
consumeInvalidConstructorDeclaration(true);
break;
- case 303 : if (DEBUG) { System.out.println("InvalidConstructorDeclaration ::= ConstructorHeader..."); } //$NON-NLS-1$
+ case 305 : if (DEBUG) { System.out.println("InvalidConstructorDeclaration ::= ConstructorHeader..."); } //$NON-NLS-1$
consumeInvalidConstructorDeclaration(false);
break;
- case 314 : if (DEBUG) { System.out.println("PushLeftBrace ::="); } //$NON-NLS-1$
+ case 316 : if (DEBUG) { System.out.println("PushLeftBrace ::="); } //$NON-NLS-1$
consumePushLeftBrace();
break;
- case 315 : if (DEBUG) { System.out.println("ArrayInitializer ::= LBRACE PushLeftBrace ,opt RBRACE"); } //$NON-NLS-1$
+ case 317 : if (DEBUG) { System.out.println("ArrayInitializer ::= LBRACE PushLeftBrace ,opt RBRACE"); } //$NON-NLS-1$
consumeEmptyArrayInitializer();
break;
- case 316 : if (DEBUG) { System.out.println("ArrayInitializer ::= LBRACE PushLeftBrace..."); } //$NON-NLS-1$
+ case 318 : if (DEBUG) { System.out.println("ArrayInitializer ::= LBRACE PushLeftBrace..."); } //$NON-NLS-1$
consumeArrayInitializer();
break;
- case 317 : if (DEBUG) { System.out.println("ArrayInitializer ::= LBRACE PushLeftBrace..."); } //$NON-NLS-1$
+ case 319 : if (DEBUG) { System.out.println("ArrayInitializer ::= LBRACE PushLeftBrace..."); } //$NON-NLS-1$
consumeArrayInitializer();
break;
- case 319 : if (DEBUG) { System.out.println("VariableInitializers ::= VariableInitializers COMMA..."); } //$NON-NLS-1$
+ case 321 : if (DEBUG) { System.out.println("VariableInitializers ::= VariableInitializers COMMA..."); } //$NON-NLS-1$
consumeVariableInitializers();
break;
- case 320 : if (DEBUG) { System.out.println("Block ::= OpenBlock LBRACE BlockStatementsopt RBRACE"); } //$NON-NLS-1$
+ case 322 : if (DEBUG) { System.out.println("Block ::= OpenBlock LBRACE BlockStatementsopt RBRACE"); } //$NON-NLS-1$
consumeBlock();
break;
- case 321 : if (DEBUG) { System.out.println("OpenBlock ::="); } //$NON-NLS-1$
+ case 323 : if (DEBUG) { System.out.println("OpenBlock ::="); } //$NON-NLS-1$
consumeOpenBlock() ;
break;
- case 322 : if (DEBUG) { System.out.println("BlockStatements ::= BlockStatement"); } //$NON-NLS-1$
+ case 324 : if (DEBUG) { System.out.println("BlockStatements ::= BlockStatement"); } //$NON-NLS-1$
consumeBlockStatement() ;
break;
- case 323 : if (DEBUG) { System.out.println("BlockStatements ::= BlockStatements BlockStatement"); } //$NON-NLS-1$
+ case 325 : if (DEBUG) { System.out.println("BlockStatements ::= BlockStatements BlockStatement"); } //$NON-NLS-1$
consumeBlockStatements() ;
break;
- case 330 : if (DEBUG) { System.out.println("BlockStatement ::= InterfaceDeclaration"); } //$NON-NLS-1$
+ case 332 : if (DEBUG) { System.out.println("BlockStatement ::= InterfaceDeclaration"); } //$NON-NLS-1$
consumeInvalidInterfaceDeclaration();
break;
- case 331 : if (DEBUG) { System.out.println("BlockStatement ::= AnnotationTypeDeclaration"); } //$NON-NLS-1$
+ case 333 : if (DEBUG) { System.out.println("BlockStatement ::= AnnotationTypeDeclaration"); } //$NON-NLS-1$
consumeInvalidAnnotationTypeDeclaration();
break;
- case 332 : if (DEBUG) { System.out.println("BlockStatement ::= EnumDeclaration"); } //$NON-NLS-1$
+ case 334 : if (DEBUG) { System.out.println("BlockStatement ::= EnumDeclaration"); } //$NON-NLS-1$
consumeInvalidEnumDeclaration();
break;
- case 333 : if (DEBUG) { System.out.println("LocalVariableDeclarationStatement ::=..."); } //$NON-NLS-1$
+ case 335 : if (DEBUG) { System.out.println("LocalVariableDeclarationStatement ::=..."); } //$NON-NLS-1$
consumeLocalVariableDeclarationStatement();
break;
- case 334 : if (DEBUG) { System.out.println("LocalVariableDeclaration ::= Type PushModifiers..."); } //$NON-NLS-1$
+ case 336 : if (DEBUG) { System.out.println("LocalVariableDeclaration ::= Type PushModifiers..."); } //$NON-NLS-1$
consumeLocalVariableDeclaration();
break;
- case 335 : if (DEBUG) { System.out.println("LocalVariableDeclaration ::= Modifiers Type..."); } //$NON-NLS-1$
+ case 337 : if (DEBUG) { System.out.println("LocalVariableDeclaration ::= Modifiers Type..."); } //$NON-NLS-1$
consumeLocalVariableDeclaration();
break;
- case 336 : if (DEBUG) { System.out.println("PushModifiers ::="); } //$NON-NLS-1$
+ case 338 : if (DEBUG) { System.out.println("PushModifiers ::="); } //$NON-NLS-1$
consumePushModifiers();
break;
- case 337 : if (DEBUG) { System.out.println("PushModifiersForHeader ::="); } //$NON-NLS-1$
+ case 339 : if (DEBUG) { System.out.println("PushModifiersForHeader ::="); } //$NON-NLS-1$
consumePushModifiersForHeader();
break;
- case 338 : if (DEBUG) { System.out.println("PushRealModifiers ::="); } //$NON-NLS-1$
+ case 340 : if (DEBUG) { System.out.println("PushRealModifiers ::="); } //$NON-NLS-1$
consumePushRealModifiers();
break;
- case 365 : if (DEBUG) { System.out.println("EmptyStatement ::= SEMICOLON"); } //$NON-NLS-1$
+ case 368 : if (DEBUG) { System.out.println("EmptyStatement ::= SEMICOLON"); } //$NON-NLS-1$
consumeEmptyStatement();
break;
- case 366 : if (DEBUG) { System.out.println("LabeledStatement ::= Label COLON Statement"); } //$NON-NLS-1$
+ case 369 : if (DEBUG) { System.out.println("LabeledStatement ::= Label COLON Statement"); } //$NON-NLS-1$
consumeStatementLabel() ;
break;
- case 367 : if (DEBUG) { System.out.println("LabeledStatementNoShortIf ::= Label COLON..."); } //$NON-NLS-1$
+ case 370 : if (DEBUG) { System.out.println("LabeledStatementNoShortIf ::= Label COLON..."); } //$NON-NLS-1$
consumeStatementLabel() ;
break;
- case 368 : if (DEBUG) { System.out.println("Label ::= Identifier"); } //$NON-NLS-1$
+ case 371 : if (DEBUG) { System.out.println("Label ::= Identifier"); } //$NON-NLS-1$
consumeLabel() ;
break;
- case 369 : if (DEBUG) { System.out.println("ExpressionStatement ::= StatementExpression SEMICOLON"); } //$NON-NLS-1$
+ case 372 : if (DEBUG) { System.out.println("ExpressionStatement ::= StatementExpression SEMICOLON"); } //$NON-NLS-1$
consumeExpressionStatement();
break;
- case 378 : if (DEBUG) { System.out.println("IfThenStatement ::= if LPAREN Expression RPAREN..."); } //$NON-NLS-1$
+ case 381 : if (DEBUG) { System.out.println("IfThenStatement ::= if LPAREN Expression RPAREN..."); } //$NON-NLS-1$
consumeStatementIfNoElse();
break;
- case 379 : if (DEBUG) { System.out.println("IfThenElseStatement ::= if LPAREN Expression RPAREN..."); } //$NON-NLS-1$
+ case 382 : if (DEBUG) { System.out.println("IfThenElseStatement ::= if LPAREN Expression RPAREN..."); } //$NON-NLS-1$
consumeStatementIfWithElse();
break;
- case 380 : if (DEBUG) { System.out.println("IfThenElseStatementNoShortIf ::= if LPAREN Expression..."); } //$NON-NLS-1$
+ case 383 : if (DEBUG) { System.out.println("IfThenElseStatementNoShortIf ::= if LPAREN Expression..."); } //$NON-NLS-1$
consumeStatementIfWithElse();
break;
- case 381 : if (DEBUG) { System.out.println("SwitchStatement ::= switch LPAREN Expression RPAREN..."); } //$NON-NLS-1$
+ case 384 : if (DEBUG) { System.out.println("SwitchStatement ::= switch LPAREN Expression RPAREN..."); } //$NON-NLS-1$
consumeStatementSwitch() ;
break;
- case 382 : if (DEBUG) { System.out.println("SwitchBlock ::= LBRACE RBRACE"); } //$NON-NLS-1$
+ case 385 : if (DEBUG) { System.out.println("SwitchBlock ::= LBRACE RBRACE"); } //$NON-NLS-1$
consumeEmptySwitchBlock() ;
break;
- case 385 : if (DEBUG) { System.out.println("SwitchBlock ::= LBRACE SwitchBlockStatements..."); } //$NON-NLS-1$
+ case 388 : if (DEBUG) { System.out.println("SwitchBlock ::= LBRACE SwitchBlockStatements..."); } //$NON-NLS-1$
consumeSwitchBlock() ;
break;
- case 387 : if (DEBUG) { System.out.println("SwitchBlockStatements ::= SwitchBlockStatements..."); } //$NON-NLS-1$
+ case 390 : if (DEBUG) { System.out.println("SwitchBlockStatements ::= SwitchBlockStatements..."); } //$NON-NLS-1$
consumeSwitchBlockStatements() ;
break;
- case 389 : if (DEBUG) { System.out.println("SwitchBlockStatement ::= SwitchLabels BlockStatements"); } //$NON-NLS-1$
+ case 392 : if (DEBUG) { System.out.println("SwitchBlockStatement ::= SwitchLabels BlockStatements"); } //$NON-NLS-1$
consumeSwitchBlockStatement() ;
break;
- case 391 : if (DEBUG) { System.out.println("SwitchLabels ::= SwitchLabels SwitchLabel"); } //$NON-NLS-1$
+ case 394 : if (DEBUG) { System.out.println("SwitchLabels ::= SwitchLabels SwitchLabel"); } //$NON-NLS-1$
consumeSwitchLabels() ;
break;
- case 392 : if (DEBUG) { System.out.println("SwitchLabel ::= SwitchLabelCaseLhs COLON"); } //$NON-NLS-1$
+ case 395 : if (DEBUG) { System.out.println("SwitchLabel ::= SwitchLabelCaseLhs COLON"); } //$NON-NLS-1$
consumeCaseLabel();
break;
- case 393 : if (DEBUG) { System.out.println("SwitchLabel ::= default COLON"); } //$NON-NLS-1$
+ case 396 : if (DEBUG) { System.out.println("SwitchLabel ::= default COLON"); } //$NON-NLS-1$
consumeDefaultLabel();
break;
- case 396 : if (DEBUG) { System.out.println("SwitchExpression ::= switch LPAREN Expression RPAREN..."); } //$NON-NLS-1$
+ case 399 : if (DEBUG) { System.out.println("SwitchExpression ::= switch LPAREN Expression RPAREN..."); } //$NON-NLS-1$
consumeSwitchExpression() ;
break;
- case 399 : if (DEBUG) { System.out.println("SwitchLabeledRule ::= SwitchLabeledThrowStatement"); } //$NON-NLS-1$
+ case 402 : if (DEBUG) { System.out.println("SwitchLabeledRule ::= SwitchLabeledThrowStatement"); } //$NON-NLS-1$
consumeSwitchLabeledRule();
break;
- case 400 : if (DEBUG) { System.out.println("SwitchLabeledExpression ::= SwitchLabelExpr Expression"); } //$NON-NLS-1$
+ case 403 : if (DEBUG) { System.out.println("SwitchLabeledExpression ::= SwitchLabelExpr Expression"); } //$NON-NLS-1$
consumeSwitchLabeledExpression();
break;
- case 401 : if (DEBUG) { System.out.println("SwitchLabeledBlock ::= SwitchLabelExpr Block"); } //$NON-NLS-1$
+ case 404 : if (DEBUG) { System.out.println("SwitchLabeledBlock ::= SwitchLabelExpr Block"); } //$NON-NLS-1$
consumeSwitchLabeledBlock();
break;
- case 402 : if (DEBUG) { System.out.println("SwitchLabeledThrowStatement ::= SwitchLabelExpr..."); } //$NON-NLS-1$
+ case 405 : if (DEBUG) { System.out.println("SwitchLabeledThrowStatement ::= SwitchLabelExpr..."); } //$NON-NLS-1$
consumeSwitchLabeledThrowStatement();
break;
- case 403 : if (DEBUG) { System.out.println("SwitchLabelExpr ::= default ARROW"); } //$NON-NLS-1$
+ case 406 : if (DEBUG) { System.out.println("SwitchLabelExpr ::= default ARROW"); } //$NON-NLS-1$
consumeDefaultLabelExpr();
break;
- case 404 : if (DEBUG) { System.out.println("SwitchLabelExpr ::= SwitchLabelCaseLhs BeginCaseExpr..."); } //$NON-NLS-1$
+ case 407 : if (DEBUG) { System.out.println("SwitchLabelExpr ::= SwitchLabelCaseLhs BeginCaseExpr..."); } //$NON-NLS-1$
consumeCaseLabelExpr();
break;
- case 405 : if (DEBUG) { System.out.println("SwitchLabelCaseLhs ::= case ConstantExpressions"); } //$NON-NLS-1$
+ case 408 : if (DEBUG) { System.out.println("SwitchLabelCaseLhs ::= case ConstantExpressions"); } //$NON-NLS-1$
consumeSwitchLabelCaseLhs();
break;
- case 406 : if (DEBUG) { System.out.println("WhileStatement ::= while LPAREN Expression RPAREN..."); } //$NON-NLS-1$
+ case 409 : if (DEBUG) { System.out.println("YieldStatement ::= RestrictedIdentifierYield Expression"); } //$NON-NLS-1$
+ consumeStatementYield() ;
+ break;
+
+ case 410 : if (DEBUG) { System.out.println("WhileStatement ::= while LPAREN Expression RPAREN..."); } //$NON-NLS-1$
consumeStatementWhile() ;
break;
- case 407 : if (DEBUG) { System.out.println("WhileStatementNoShortIf ::= while LPAREN Expression..."); } //$NON-NLS-1$
+ case 411 : if (DEBUG) { System.out.println("WhileStatementNoShortIf ::= while LPAREN Expression..."); } //$NON-NLS-1$
consumeStatementWhile() ;
break;
- case 408 : if (DEBUG) { System.out.println("DoStatement ::= do Statement while LPAREN Expression..."); } //$NON-NLS-1$
+ case 412 : if (DEBUG) { System.out.println("DoStatement ::= do Statement while LPAREN Expression..."); } //$NON-NLS-1$
consumeStatementDo() ;
break;
- case 409 : if (DEBUG) { System.out.println("ForStatement ::= for LPAREN ForInitopt SEMICOLON..."); } //$NON-NLS-1$
+ case 413 : if (DEBUG) { System.out.println("ForStatement ::= for LPAREN ForInitopt SEMICOLON..."); } //$NON-NLS-1$
consumeStatementFor() ;
break;
- case 410 : if (DEBUG) { System.out.println("ForStatementNoShortIf ::= for LPAREN ForInitopt..."); } //$NON-NLS-1$
+ case 414 : if (DEBUG) { System.out.println("ForStatementNoShortIf ::= for LPAREN ForInitopt..."); } //$NON-NLS-1$
consumeStatementFor() ;
break;
- case 411 : if (DEBUG) { System.out.println("ForInit ::= StatementExpressionList"); } //$NON-NLS-1$
+ case 415 : if (DEBUG) { System.out.println("ForInit ::= StatementExpressionList"); } //$NON-NLS-1$
consumeForInit() ;
break;
- case 415 : if (DEBUG) { System.out.println("StatementExpressionList ::= StatementExpressionList..."); } //$NON-NLS-1$
+ case 419 : if (DEBUG) { System.out.println("StatementExpressionList ::= StatementExpressionList..."); } //$NON-NLS-1$
consumeStatementExpressionList() ;
break;
- case 416 : if (DEBUG) { System.out.println("AssertStatement ::= assert Expression SEMICOLON"); } //$NON-NLS-1$
+ case 420 : if (DEBUG) { System.out.println("AssertStatement ::= assert Expression SEMICOLON"); } //$NON-NLS-1$
consumeSimpleAssertStatement() ;
break;
- case 417 : if (DEBUG) { System.out.println("AssertStatement ::= assert Expression COLON Expression"); } //$NON-NLS-1$
+ case 421 : if (DEBUG) { System.out.println("AssertStatement ::= assert Expression COLON Expression"); } //$NON-NLS-1$
consumeAssertStatement() ;
break;
- case 418 : if (DEBUG) { System.out.println("BreakStatement ::= break SEMICOLON"); } //$NON-NLS-1$
+ case 422 : if (DEBUG) { System.out.println("BreakStatement ::= break SEMICOLON"); } //$NON-NLS-1$
consumeStatementBreak() ;
break;
- case 419 : if (DEBUG) { System.out.println("BreakStatement ::= break Identifier SEMICOLON"); } //$NON-NLS-1$
+ case 423 : if (DEBUG) { System.out.println("BreakStatement ::= break Identifier SEMICOLON"); } //$NON-NLS-1$
consumeStatementBreakWithLabel() ;
break;
- case 420 : if (DEBUG) { System.out.println("BreakStatement ::= break BreakPreviewMarker SEMICOLON"); } //$NON-NLS-1$
- consumeStatementBreak() ;
- break;
-
- case 421 : if (DEBUG) { System.out.println("BreakStatement ::= break BreakPreviewMarker Expression"); } //$NON-NLS-1$
- consumeStatementBreakWithExpressionOrLabel() ;
- break;
-
- case 422 : if (DEBUG) { System.out.println("ContinueStatement ::= continue SEMICOLON"); } //$NON-NLS-1$
+ case 424 : if (DEBUG) { System.out.println("ContinueStatement ::= continue SEMICOLON"); } //$NON-NLS-1$
consumeStatementContinue() ;
break;
- case 423 : if (DEBUG) { System.out.println("ContinueStatement ::= continue Identifier SEMICOLON"); } //$NON-NLS-1$
+ case 425 : if (DEBUG) { System.out.println("ContinueStatement ::= continue Identifier SEMICOLON"); } //$NON-NLS-1$
consumeStatementContinueWithLabel() ;
break;
- case 424 : if (DEBUG) { System.out.println("ReturnStatement ::= return Expressionopt SEMICOLON"); } //$NON-NLS-1$
+ case 426 : if (DEBUG) { System.out.println("ReturnStatement ::= return Expressionopt SEMICOLON"); } //$NON-NLS-1$
consumeStatementReturn() ;
break;
- case 425 : if (DEBUG) { System.out.println("ThrowStatement ::= throw Expression SEMICOLON"); } //$NON-NLS-1$
+ case 427 : if (DEBUG) { System.out.println("ThrowStatement ::= throw Expression SEMICOLON"); } //$NON-NLS-1$
consumeStatementThrow();
break;
- case 426 : if (DEBUG) { System.out.println("ThrowExpression ::= throw Expression"); } //$NON-NLS-1$
+ case 428 : if (DEBUG) { System.out.println("ThrowExpression ::= throw Expression"); } //$NON-NLS-1$
consumeThrowExpression() ;
break;
- case 427 : if (DEBUG) { System.out.println("SynchronizedStatement ::= OnlySynchronized LPAREN..."); } //$NON-NLS-1$
+ case 429 : if (DEBUG) { System.out.println("SynchronizedStatement ::= OnlySynchronized LPAREN..."); } //$NON-NLS-1$
consumeStatementSynchronized();
break;
- case 428 : if (DEBUG) { System.out.println("OnlySynchronized ::= synchronized"); } //$NON-NLS-1$
+ case 430 : if (DEBUG) { System.out.println("OnlySynchronized ::= synchronized"); } //$NON-NLS-1$
consumeOnlySynchronized();
break;
- case 429 : if (DEBUG) { System.out.println("TryStatement ::= try TryBlock Catches"); } //$NON-NLS-1$
+ case 431 : if (DEBUG) { System.out.println("TryStatement ::= try TryBlock Catches"); } //$NON-NLS-1$
consumeStatementTry(false, false);
break;
- case 430 : if (DEBUG) { System.out.println("TryStatement ::= try TryBlock Catchesopt Finally"); } //$NON-NLS-1$
+ case 432 : if (DEBUG) { System.out.println("TryStatement ::= try TryBlock Catchesopt Finally"); } //$NON-NLS-1$
consumeStatementTry(true, false);
break;
- case 431 : if (DEBUG) { System.out.println("TryStatementWithResources ::= try ResourceSpecification"); } //$NON-NLS-1$
+ case 433 : if (DEBUG) { System.out.println("TryStatementWithResources ::= try ResourceSpecification"); } //$NON-NLS-1$
consumeStatementTry(false, true);
break;
- case 432 : if (DEBUG) { System.out.println("TryStatementWithResources ::= try ResourceSpecification"); } //$NON-NLS-1$
+ case 434 : if (DEBUG) { System.out.println("TryStatementWithResources ::= try ResourceSpecification"); } //$NON-NLS-1$
consumeStatementTry(true, true);
break;
- case 433 : if (DEBUG) { System.out.println("ResourceSpecification ::= LPAREN Resources ;opt RPAREN"); } //$NON-NLS-1$
+ case 435 : if (DEBUG) { System.out.println("ResourceSpecification ::= LPAREN Resources ;opt RPAREN"); } //$NON-NLS-1$
consumeResourceSpecification();
break;
- case 434 : if (DEBUG) { System.out.println(";opt ::="); } //$NON-NLS-1$
+ case 436 : if (DEBUG) { System.out.println(";opt ::="); } //$NON-NLS-1$
consumeResourceOptionalTrailingSemiColon(false);
break;
- case 435 : if (DEBUG) { System.out.println(";opt ::= SEMICOLON"); } //$NON-NLS-1$
+ case 437 : if (DEBUG) { System.out.println(";opt ::= SEMICOLON"); } //$NON-NLS-1$
consumeResourceOptionalTrailingSemiColon(true);
break;
- case 436 : if (DEBUG) { System.out.println("Resources ::= Resource"); } //$NON-NLS-1$
+ case 438 : if (DEBUG) { System.out.println("Resources ::= Resource"); } //$NON-NLS-1$
consumeSingleResource();
break;
- case 437 : if (DEBUG) { System.out.println("Resources ::= Resources TrailingSemiColon Resource"); } //$NON-NLS-1$
+ case 439 : if (DEBUG) { System.out.println("Resources ::= Resources TrailingSemiColon Resource"); } //$NON-NLS-1$
consumeMultipleResources();
break;
- case 438 : if (DEBUG) { System.out.println("TrailingSemiColon ::= SEMICOLON"); } //$NON-NLS-1$
+ case 440 : if (DEBUG) { System.out.println("TrailingSemiColon ::= SEMICOLON"); } //$NON-NLS-1$
consumeResourceOptionalTrailingSemiColon(true);
break;
- case 439 : if (DEBUG) { System.out.println("Resource ::= Type PushModifiers VariableDeclaratorId..."); } //$NON-NLS-1$
+ case 441 : if (DEBUG) { System.out.println("Resource ::= Type PushModifiers VariableDeclaratorId..."); } //$NON-NLS-1$
consumeResourceAsLocalVariableDeclaration();
break;
- case 440 : if (DEBUG) { System.out.println("Resource ::= Modifiers Type PushRealModifiers..."); } //$NON-NLS-1$
+ case 442 : if (DEBUG) { System.out.println("Resource ::= Modifiers Type PushRealModifiers..."); } //$NON-NLS-1$
consumeResourceAsLocalVariableDeclaration();
break;
- case 441 : if (DEBUG) { System.out.println("Resource ::= Name"); } //$NON-NLS-1$
+ case 443 : if (DEBUG) { System.out.println("Resource ::= Name"); } //$NON-NLS-1$
consumeResourceAsLocalVariable();
break;
- case 442 : if (DEBUG) { System.out.println("Resource ::= FieldAccess"); } //$NON-NLS-1$
+ case 444 : if (DEBUG) { System.out.println("Resource ::= FieldAccess"); } //$NON-NLS-1$
consumeResourceAsFieldAccess();
break;
- case 444 : if (DEBUG) { System.out.println("ExitTryBlock ::="); } //$NON-NLS-1$
+ case 446 : if (DEBUG) { System.out.println("ExitTryBlock ::="); } //$NON-NLS-1$
consumeExitTryBlock();
break;
- case 446 : if (DEBUG) { System.out.println("Catches ::= Catches CatchClause"); } //$NON-NLS-1$
+ case 448 : if (DEBUG) { System.out.println("Catches ::= Catches CatchClause"); } //$NON-NLS-1$
consumeCatches();
break;
- case 447 : if (DEBUG) { System.out.println("CatchClause ::= catch LPAREN CatchFormalParameter RPAREN"); } //$NON-NLS-1$
+ case 449 : if (DEBUG) { System.out.println("CatchClause ::= catch LPAREN CatchFormalParameter RPAREN"); } //$NON-NLS-1$
consumeStatementCatch() ;
break;
- case 449 : if (DEBUG) { System.out.println("PushLPAREN ::= LPAREN"); } //$NON-NLS-1$
+ case 451 : if (DEBUG) { System.out.println("PushLPAREN ::= LPAREN"); } //$NON-NLS-1$
consumeLeftParen();
break;
- case 450 : if (DEBUG) { System.out.println("PushRPAREN ::= RPAREN"); } //$NON-NLS-1$
+ case 452 : if (DEBUG) { System.out.println("PushRPAREN ::= RPAREN"); } //$NON-NLS-1$
consumeRightParen();
break;
- case 455 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= this"); } //$NON-NLS-1$
+ case 457 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= this"); } //$NON-NLS-1$
consumePrimaryNoNewArrayThis();
break;
- case 456 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= PushLPAREN Expression_NotName..."); } //$NON-NLS-1$
+ case 458 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= PushLPAREN Expression_NotName..."); } //$NON-NLS-1$
consumePrimaryNoNewArray();
break;
- case 457 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= PushLPAREN Name PushRPAREN"); } //$NON-NLS-1$
+ case 459 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= PushLPAREN Name PushRPAREN"); } //$NON-NLS-1$
consumePrimaryNoNewArrayWithName();
break;
- case 460 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= Name DOT this"); } //$NON-NLS-1$
+ case 462 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= Name DOT this"); } //$NON-NLS-1$
consumePrimaryNoNewArrayNameThis();
break;
- case 461 : if (DEBUG) { System.out.println("QualifiedSuperReceiver ::= Name DOT super"); } //$NON-NLS-1$
+ case 463 : if (DEBUG) { System.out.println("QualifiedSuperReceiver ::= Name DOT super"); } //$NON-NLS-1$
consumeQualifiedSuperReceiver();
break;
- case 462 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= Name DOT class"); } //$NON-NLS-1$
+ case 464 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= Name DOT class"); } //$NON-NLS-1$
consumePrimaryNoNewArrayName();
break;
- case 463 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= Name Dims DOT class"); } //$NON-NLS-1$
+ case 465 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= Name Dims DOT class"); } //$NON-NLS-1$
consumePrimaryNoNewArrayArrayType();
break;
- case 464 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= PrimitiveType Dims DOT class"); } //$NON-NLS-1$
+ case 466 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= PrimitiveType Dims DOT class"); } //$NON-NLS-1$
consumePrimaryNoNewArrayPrimitiveArrayType();
break;
- case 465 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= PrimitiveType DOT class"); } //$NON-NLS-1$
+ case 467 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= PrimitiveType DOT class"); } //$NON-NLS-1$
consumePrimaryNoNewArrayPrimitiveType();
break;
- case 471 : if (DEBUG) { System.out.println("ReferenceExpressionTypeArgumentsAndTrunk0 ::=..."); } //$NON-NLS-1$
+ case 473 : if (DEBUG) { System.out.println("ReferenceExpressionTypeArgumentsAndTrunk0 ::=..."); } //$NON-NLS-1$
consumeReferenceExpressionTypeArgumentsAndTrunk(false);
break;
- case 472 : if (DEBUG) { System.out.println("ReferenceExpressionTypeArgumentsAndTrunk0 ::=..."); } //$NON-NLS-1$
+ case 474 : if (DEBUG) { System.out.println("ReferenceExpressionTypeArgumentsAndTrunk0 ::=..."); } //$NON-NLS-1$
consumeReferenceExpressionTypeArgumentsAndTrunk(true);
break;
- case 473 : if (DEBUG) { System.out.println("ReferenceExpression ::= PrimitiveType Dims COLON_COLON"); } //$NON-NLS-1$
+ case 475 : if (DEBUG) { System.out.println("ReferenceExpression ::= PrimitiveType Dims COLON_COLON"); } //$NON-NLS-1$
consumeReferenceExpressionTypeForm(true);
break;
- case 474 : if (DEBUG) { System.out.println("ReferenceExpression ::= Name Dimsopt COLON_COLON..."); } //$NON-NLS-1$
+ case 476 : if (DEBUG) { System.out.println("ReferenceExpression ::= Name Dimsopt COLON_COLON..."); } //$NON-NLS-1$
consumeReferenceExpressionTypeForm(false);
break;
- case 475 : if (DEBUG) { System.out.println("ReferenceExpression ::= Name BeginTypeArguments..."); } //$NON-NLS-1$
+ case 477 : if (DEBUG) { System.out.println("ReferenceExpression ::= Name BeginTypeArguments..."); } //$NON-NLS-1$
consumeReferenceExpressionGenericTypeForm();
break;
- case 476 : if (DEBUG) { System.out.println("ReferenceExpression ::= Primary COLON_COLON..."); } //$NON-NLS-1$
+ case 478 : if (DEBUG) { System.out.println("ReferenceExpression ::= Primary COLON_COLON..."); } //$NON-NLS-1$
consumeReferenceExpressionPrimaryForm();
break;
- case 477 : if (DEBUG) { System.out.println("ReferenceExpression ::= QualifiedSuperReceiver..."); } //$NON-NLS-1$
+ case 479 : if (DEBUG) { System.out.println("ReferenceExpression ::= QualifiedSuperReceiver..."); } //$NON-NLS-1$
consumeReferenceExpressionPrimaryForm();
break;
- case 478 : if (DEBUG) { System.out.println("ReferenceExpression ::= super COLON_COLON..."); } //$NON-NLS-1$
+ case 480 : if (DEBUG) { System.out.println("ReferenceExpression ::= super COLON_COLON..."); } //$NON-NLS-1$
consumeReferenceExpressionSuperForm();
break;
- case 479 : if (DEBUG) { System.out.println("NonWildTypeArgumentsopt ::="); } //$NON-NLS-1$
+ case 481 : if (DEBUG) { System.out.println("NonWildTypeArgumentsopt ::="); } //$NON-NLS-1$
consumeEmptyTypeArguments();
break;
- case 481 : if (DEBUG) { System.out.println("IdentifierOrNew ::= Identifier"); } //$NON-NLS-1$
+ case 483 : if (DEBUG) { System.out.println("IdentifierOrNew ::= Identifier"); } //$NON-NLS-1$
consumeIdentifierOrNew(false);
break;
- case 482 : if (DEBUG) { System.out.println("IdentifierOrNew ::= new"); } //$NON-NLS-1$
+ case 484 : if (DEBUG) { System.out.println("IdentifierOrNew ::= new"); } //$NON-NLS-1$
consumeIdentifierOrNew(true);
break;
- case 483 : if (DEBUG) { System.out.println("LambdaExpression ::= LambdaParameters ARROW LambdaBody"); } //$NON-NLS-1$
+ case 485 : if (DEBUG) { System.out.println("LambdaExpression ::= LambdaParameters ARROW LambdaBody"); } //$NON-NLS-1$
consumeLambdaExpression();
break;
- case 484 : if (DEBUG) { System.out.println("NestedLambda ::="); } //$NON-NLS-1$
+ case 486 : if (DEBUG) { System.out.println("NestedLambda ::="); } //$NON-NLS-1$
consumeNestedLambda();
break;
- case 485 : if (DEBUG) { System.out.println("LambdaParameters ::= Identifier NestedLambda"); } //$NON-NLS-1$
+ case 487 : if (DEBUG) { System.out.println("LambdaParameters ::= Identifier NestedLambda"); } //$NON-NLS-1$
consumeTypeElidedLambdaParameter(false);
break;
- case 491 : if (DEBUG) { System.out.println("TypeElidedFormalParameterList ::=..."); } //$NON-NLS-1$
+ case 493 : if (DEBUG) { System.out.println("TypeElidedFormalParameterList ::=..."); } //$NON-NLS-1$
consumeFormalParameterList();
break;
- case 492 : if (DEBUG) { System.out.println("TypeElidedFormalParameter ::= Modifiersopt Identifier"); } //$NON-NLS-1$
+ case 494 : if (DEBUG) { System.out.println("TypeElidedFormalParameter ::= Modifiersopt Identifier"); } //$NON-NLS-1$
consumeTypeElidedLambdaParameter(true);
break;
- case 495 : if (DEBUG) { System.out.println("ElidedLeftBraceAndReturn ::="); } //$NON-NLS-1$
+ case 497 : if (DEBUG) { System.out.println("ElidedLeftBraceAndReturn ::="); } //$NON-NLS-1$
consumeElidedLeftBraceAndReturn();
break;
- case 496 : if (DEBUG) { System.out.println("AllocationHeader ::= new ClassType LPAREN..."); } //$NON-NLS-1$
+ case 498 : if (DEBUG) { System.out.println("AllocationHeader ::= new ClassType LPAREN..."); } //$NON-NLS-1$
consumeAllocationHeader();
break;
- case 497 : if (DEBUG) { System.out.println("ClassInstanceCreationExpression ::= new..."); } //$NON-NLS-1$
+ case 499 : if (DEBUG) { System.out.println("ClassInstanceCreationExpression ::= new..."); } //$NON-NLS-1$
consumeClassInstanceCreationExpressionWithTypeArguments();
break;
- case 498 : if (DEBUG) { System.out.println("ClassInstanceCreationExpression ::= new ClassType..."); } //$NON-NLS-1$
+ case 500 : if (DEBUG) { System.out.println("ClassInstanceCreationExpression ::= new ClassType..."); } //$NON-NLS-1$
consumeClassInstanceCreationExpression();
break;
- case 499 : if (DEBUG) { System.out.println("ClassInstanceCreationExpression ::= Primary DOT new..."); } //$NON-NLS-1$
+ case 501 : if (DEBUG) { System.out.println("ClassInstanceCreationExpression ::= Primary DOT new..."); } //$NON-NLS-1$
consumeClassInstanceCreationExpressionQualifiedWithTypeArguments() ;
break;
- case 500 : if (DEBUG) { System.out.println("ClassInstanceCreationExpression ::= Primary DOT new..."); } //$NON-NLS-1$
+ case 502 : if (DEBUG) { System.out.println("ClassInstanceCreationExpression ::= Primary DOT new..."); } //$NON-NLS-1$
consumeClassInstanceCreationExpressionQualified() ;
break;
- case 501 : if (DEBUG) { System.out.println("ClassInstanceCreationExpression ::=..."); } //$NON-NLS-1$
+ case 503 : if (DEBUG) { System.out.println("ClassInstanceCreationExpression ::=..."); } //$NON-NLS-1$
consumeClassInstanceCreationExpressionQualified() ;
break;
- case 502 : if (DEBUG) { System.out.println("ClassInstanceCreationExpression ::=..."); } //$NON-NLS-1$
+ case 504 : if (DEBUG) { System.out.println("ClassInstanceCreationExpression ::=..."); } //$NON-NLS-1$
consumeClassInstanceCreationExpressionQualifiedWithTypeArguments() ;
break;
- case 503 : if (DEBUG) { System.out.println("EnterInstanceCreationArgumentList ::="); } //$NON-NLS-1$
+ case 505 : if (DEBUG) { System.out.println("EnterInstanceCreationArgumentList ::="); } //$NON-NLS-1$
consumeEnterInstanceCreationArgumentList();
break;
- case 504 : if (DEBUG) { System.out.println("ClassInstanceCreationExpressionName ::= Name DOT new"); } //$NON-NLS-1$
+ case 506 : if (DEBUG) { System.out.println("ClassInstanceCreationExpressionName ::= Name DOT new"); } //$NON-NLS-1$
consumeClassInstanceCreationExpressionName() ;
break;
- case 505 : if (DEBUG) { System.out.println("UnqualifiedClassBodyopt ::="); } //$NON-NLS-1$
+ case 507 : if (DEBUG) { System.out.println("UnqualifiedClassBodyopt ::="); } //$NON-NLS-1$
consumeClassBodyopt();
break;
- case 507 : if (DEBUG) { System.out.println("UnqualifiedEnterAnonymousClassBody ::="); } //$NON-NLS-1$
+ case 509 : if (DEBUG) { System.out.println("UnqualifiedEnterAnonymousClassBody ::="); } //$NON-NLS-1$
consumeEnterAnonymousClassBody(false);
break;
- case 508 : if (DEBUG) { System.out.println("QualifiedClassBodyopt ::="); } //$NON-NLS-1$
+ case 510 : if (DEBUG) { System.out.println("QualifiedClassBodyopt ::="); } //$NON-NLS-1$
consumeClassBodyopt();
break;
- case 510 : if (DEBUG) { System.out.println("QualifiedEnterAnonymousClassBody ::="); } //$NON-NLS-1$
+ case 512 : if (DEBUG) { System.out.println("QualifiedEnterAnonymousClassBody ::="); } //$NON-NLS-1$
consumeEnterAnonymousClassBody(true);
break;
- case 512 : if (DEBUG) { System.out.println("ArgumentList ::= ArgumentList COMMA Expression"); } //$NON-NLS-1$
+ case 514 : if (DEBUG) { System.out.println("ArgumentList ::= ArgumentList COMMA Expression"); } //$NON-NLS-1$
consumeArgumentList();
break;
- case 513 : if (DEBUG) { System.out.println("ArrayCreationHeader ::= new PrimitiveType..."); } //$NON-NLS-1$
+ case 515 : if (DEBUG) { System.out.println("ArrayCreationHeader ::= new PrimitiveType..."); } //$NON-NLS-1$
consumeArrayCreationHeader();
break;
- case 514 : if (DEBUG) { System.out.println("ArrayCreationHeader ::= new ClassOrInterfaceType..."); } //$NON-NLS-1$
+ case 516 : if (DEBUG) { System.out.println("ArrayCreationHeader ::= new ClassOrInterfaceType..."); } //$NON-NLS-1$
consumeArrayCreationHeader();
break;
- case 515 : if (DEBUG) { System.out.println("ArrayCreationWithoutArrayInitializer ::= new..."); } //$NON-NLS-1$
+ case 517 : if (DEBUG) { System.out.println("ArrayCreationWithoutArrayInitializer ::= new..."); } //$NON-NLS-1$
consumeArrayCreationExpressionWithoutInitializer();
break;
- case 516 : if (DEBUG) { System.out.println("ArrayCreationWithArrayInitializer ::= new PrimitiveType"); } //$NON-NLS-1$
+ case 518 : if (DEBUG) { System.out.println("ArrayCreationWithArrayInitializer ::= new PrimitiveType"); } //$NON-NLS-1$
consumeArrayCreationExpressionWithInitializer();
break;
- case 517 : if (DEBUG) { System.out.println("ArrayCreationWithoutArrayInitializer ::= new..."); } //$NON-NLS-1$
+ case 519 : if (DEBUG) { System.out.println("ArrayCreationWithoutArrayInitializer ::= new..."); } //$NON-NLS-1$
consumeArrayCreationExpressionWithoutInitializer();
break;
- case 518 : if (DEBUG) { System.out.println("ArrayCreationWithArrayInitializer ::= new..."); } //$NON-NLS-1$
+ case 520 : if (DEBUG) { System.out.println("ArrayCreationWithArrayInitializer ::= new..."); } //$NON-NLS-1$
consumeArrayCreationExpressionWithInitializer();
break;
- case 520 : if (DEBUG) { System.out.println("DimWithOrWithOutExprs ::= DimWithOrWithOutExprs..."); } //$NON-NLS-1$
+ case 522 : if (DEBUG) { System.out.println("DimWithOrWithOutExprs ::= DimWithOrWithOutExprs..."); } //$NON-NLS-1$
consumeDimWithOrWithOutExprs();
break;
- case 522 : if (DEBUG) { System.out.println("DimWithOrWithOutExpr ::= TypeAnnotationsopt LBRACKET..."); } //$NON-NLS-1$
+ case 524 : if (DEBUG) { System.out.println("DimWithOrWithOutExpr ::= TypeAnnotationsopt LBRACKET..."); } //$NON-NLS-1$
consumeDimWithOrWithOutExpr();
break;
- case 523 : if (DEBUG) { System.out.println("Dims ::= DimsLoop"); } //$NON-NLS-1$
+ case 525 : if (DEBUG) { System.out.println("Dims ::= DimsLoop"); } //$NON-NLS-1$
consumeDims();
break;
- case 526 : if (DEBUG) { System.out.println("OneDimLoop ::= LBRACKET RBRACKET"); } //$NON-NLS-1$
+ case 528 : if (DEBUG) { System.out.println("OneDimLoop ::= LBRACKET RBRACKET"); } //$NON-NLS-1$
consumeOneDimLoop(false);
break;
- case 527 : if (DEBUG) { System.out.println("OneDimLoop ::= TypeAnnotations LBRACKET RBRACKET"); } //$NON-NLS-1$
+ case 529 : if (DEBUG) { System.out.println("OneDimLoop ::= TypeAnnotations LBRACKET RBRACKET"); } //$NON-NLS-1$
consumeOneDimLoop(true);
break;
- case 528 : if (DEBUG) { System.out.println("FieldAccess ::= Primary DOT Identifier"); } //$NON-NLS-1$
+ case 530 : if (DEBUG) { System.out.println("FieldAccess ::= Primary DOT Identifier"); } //$NON-NLS-1$
consumeFieldAccess(false);
break;
- case 529 : if (DEBUG) { System.out.println("FieldAccess ::= super DOT Identifier"); } //$NON-NLS-1$
+ case 531 : if (DEBUG) { System.out.println("FieldAccess ::= super DOT Identifier"); } //$NON-NLS-1$
consumeFieldAccess(true);
break;
- case 530 : if (DEBUG) { System.out.println("FieldAccess ::= QualifiedSuperReceiver DOT Identifier"); } //$NON-NLS-1$
+ case 532 : if (DEBUG) { System.out.println("FieldAccess ::= QualifiedSuperReceiver DOT Identifier"); } //$NON-NLS-1$
consumeFieldAccess(false);
break;
- case 531 : if (DEBUG) { System.out.println("MethodInvocation ::= Name LPAREN ArgumentListopt RPAREN"); } //$NON-NLS-1$
+ case 533 : if (DEBUG) { System.out.println("MethodInvocation ::= Name LPAREN ArgumentListopt RPAREN"); } //$NON-NLS-1$
consumeMethodInvocationName();
break;
- case 532 : if (DEBUG) { System.out.println("MethodInvocation ::= Name DOT OnlyTypeArguments..."); } //$NON-NLS-1$
+ case 534 : if (DEBUG) { System.out.println("MethodInvocation ::= Name DOT OnlyTypeArguments..."); } //$NON-NLS-1$
consumeMethodInvocationNameWithTypeArguments();
break;
- case 533 : if (DEBUG) { System.out.println("MethodInvocation ::= Primary DOT OnlyTypeArguments..."); } //$NON-NLS-1$
+ case 535 : if (DEBUG) { System.out.println("MethodInvocation ::= Primary DOT OnlyTypeArguments..."); } //$NON-NLS-1$
consumeMethodInvocationPrimaryWithTypeArguments();
break;
- case 534 : if (DEBUG) { System.out.println("MethodInvocation ::= Primary DOT Identifier LPAREN..."); } //$NON-NLS-1$
+ case 536 : if (DEBUG) { System.out.println("MethodInvocation ::= Primary DOT Identifier LPAREN..."); } //$NON-NLS-1$
consumeMethodInvocationPrimary();
break;
- case 535 : if (DEBUG) { System.out.println("MethodInvocation ::= QualifiedSuperReceiver DOT..."); } //$NON-NLS-1$
+ case 537 : if (DEBUG) { System.out.println("MethodInvocation ::= QualifiedSuperReceiver DOT..."); } //$NON-NLS-1$
consumeMethodInvocationPrimary();
break;
- case 536 : if (DEBUG) { System.out.println("MethodInvocation ::= QualifiedSuperReceiver DOT..."); } //$NON-NLS-1$
+ case 538 : if (DEBUG) { System.out.println("MethodInvocation ::= QualifiedSuperReceiver DOT..."); } //$NON-NLS-1$
consumeMethodInvocationPrimaryWithTypeArguments();
break;
- case 537 : if (DEBUG) { System.out.println("MethodInvocation ::= super DOT OnlyTypeArguments..."); } //$NON-NLS-1$
+ case 539 : if (DEBUG) { System.out.println("MethodInvocation ::= super DOT OnlyTypeArguments..."); } //$NON-NLS-1$
consumeMethodInvocationSuperWithTypeArguments();
break;
- case 538 : if (DEBUG) { System.out.println("MethodInvocation ::= super DOT Identifier LPAREN..."); } //$NON-NLS-1$
+ case 540 : if (DEBUG) { System.out.println("MethodInvocation ::= super DOT Identifier LPAREN..."); } //$NON-NLS-1$
consumeMethodInvocationSuper();
break;
- case 539 : if (DEBUG) { System.out.println("ArrayAccess ::= Name LBRACKET Expression RBRACKET"); } //$NON-NLS-1$
+ case 541 : if (DEBUG) { System.out.println("ArrayAccess ::= Name LBRACKET Expression RBRACKET"); } //$NON-NLS-1$
consumeArrayAccess(true);
break;
- case 540 : if (DEBUG) { System.out.println("ArrayAccess ::= PrimaryNoNewArray LBRACKET Expression..."); } //$NON-NLS-1$
+ case 542 : if (DEBUG) { System.out.println("ArrayAccess ::= PrimaryNoNewArray LBRACKET Expression..."); } //$NON-NLS-1$
consumeArrayAccess(false);
break;
- case 541 : if (DEBUG) { System.out.println("ArrayAccess ::= ArrayCreationWithArrayInitializer..."); } //$NON-NLS-1$
+ case 543 : if (DEBUG) { System.out.println("ArrayAccess ::= ArrayCreationWithArrayInitializer..."); } //$NON-NLS-1$
consumeArrayAccess(false);
break;
- case 543 : if (DEBUG) { System.out.println("PostfixExpression ::= Name"); } //$NON-NLS-1$
+ case 545 : if (DEBUG) { System.out.println("PostfixExpression ::= Name"); } //$NON-NLS-1$
consumePostfixExpression();
break;
- case 546 : if (DEBUG) { System.out.println("PostIncrementExpression ::= PostfixExpression PLUS_PLUS"); } //$NON-NLS-1$
+ case 548 : if (DEBUG) { System.out.println("PostIncrementExpression ::= PostfixExpression PLUS_PLUS"); } //$NON-NLS-1$
consumeUnaryExpression(OperatorIds.PLUS,true);
break;
- case 547 : if (DEBUG) { System.out.println("PostDecrementExpression ::= PostfixExpression..."); } //$NON-NLS-1$
+ case 549 : if (DEBUG) { System.out.println("PostDecrementExpression ::= PostfixExpression..."); } //$NON-NLS-1$
consumeUnaryExpression(OperatorIds.MINUS,true);
break;
- case 548 : if (DEBUG) { System.out.println("PushPosition ::="); } //$NON-NLS-1$
+ case 550 : if (DEBUG) { System.out.println("PushPosition ::="); } //$NON-NLS-1$
consumePushPosition();
break;
- case 551 : if (DEBUG) { System.out.println("UnaryExpression ::= PLUS PushPosition UnaryExpression"); } //$NON-NLS-1$
+ case 553 : if (DEBUG) { System.out.println("UnaryExpression ::= PLUS PushPosition UnaryExpression"); } //$NON-NLS-1$
consumeUnaryExpression(OperatorIds.PLUS);
break;
- case 552 : if (DEBUG) { System.out.println("UnaryExpression ::= MINUS PushPosition UnaryExpression"); } //$NON-NLS-1$
+ case 554 : if (DEBUG) { System.out.println("UnaryExpression ::= MINUS PushPosition UnaryExpression"); } //$NON-NLS-1$
consumeUnaryExpression(OperatorIds.MINUS);
break;
- case 554 : if (DEBUG) { System.out.println("PreIncrementExpression ::= PLUS_PLUS PushPosition..."); } //$NON-NLS-1$
+ case 556 : if (DEBUG) { System.out.println("PreIncrementExpression ::= PLUS_PLUS PushPosition..."); } //$NON-NLS-1$
consumeUnaryExpression(OperatorIds.PLUS,false);
break;
- case 555 : if (DEBUG) { System.out.println("PreDecrementExpression ::= MINUS_MINUS PushPosition..."); } //$NON-NLS-1$
+ case 557 : if (DEBUG) { System.out.println("PreDecrementExpression ::= MINUS_MINUS PushPosition..."); } //$NON-NLS-1$
consumeUnaryExpression(OperatorIds.MINUS,false);
break;
- case 557 : if (DEBUG) { System.out.println("UnaryExpressionNotPlusMinus ::= TWIDDLE PushPosition..."); } //$NON-NLS-1$
+ case 559 : if (DEBUG) { System.out.println("UnaryExpressionNotPlusMinus ::= TWIDDLE PushPosition..."); } //$NON-NLS-1$
consumeUnaryExpression(OperatorIds.TWIDDLE);
break;
- case 558 : if (DEBUG) { System.out.println("UnaryExpressionNotPlusMinus ::= NOT PushPosition..."); } //$NON-NLS-1$
+ case 560 : if (DEBUG) { System.out.println("UnaryExpressionNotPlusMinus ::= NOT PushPosition..."); } //$NON-NLS-1$
consumeUnaryExpression(OperatorIds.NOT);
break;
- case 560 : if (DEBUG) { System.out.println("CastExpression ::= PushLPAREN PrimitiveType Dimsopt..."); } //$NON-NLS-1$
+ case 562 : if (DEBUG) { System.out.println("CastExpression ::= PushLPAREN PrimitiveType Dimsopt..."); } //$NON-NLS-1$
consumeCastExpressionWithPrimitiveType();
break;
- case 561 : if (DEBUG) { System.out.println("CastExpression ::= PushLPAREN Name..."); } //$NON-NLS-1$
+ case 563 : if (DEBUG) { System.out.println("CastExpression ::= PushLPAREN Name..."); } //$NON-NLS-1$
consumeCastExpressionWithGenericsArray();
break;
- case 562 : if (DEBUG) { System.out.println("CastExpression ::= PushLPAREN Name..."); } //$NON-NLS-1$
+ case 564 : if (DEBUG) { System.out.println("CastExpression ::= PushLPAREN Name..."); } //$NON-NLS-1$
consumeCastExpressionWithQualifiedGenericsArray();
break;
- case 563 : if (DEBUG) { System.out.println("CastExpression ::= PushLPAREN Name PushRPAREN..."); } //$NON-NLS-1$
+ case 565 : if (DEBUG) { System.out.println("CastExpression ::= PushLPAREN Name PushRPAREN..."); } //$NON-NLS-1$
consumeCastExpressionLL1();
break;
- case 564 : if (DEBUG) { System.out.println("CastExpression ::= BeginIntersectionCast PushLPAREN..."); } //$NON-NLS-1$
+ case 566 : if (DEBUG) { System.out.println("CastExpression ::= BeginIntersectionCast PushLPAREN..."); } //$NON-NLS-1$
consumeCastExpressionLL1WithBounds();
break;
- case 565 : if (DEBUG) { System.out.println("CastExpression ::= PushLPAREN Name Dims..."); } //$NON-NLS-1$
+ case 567 : if (DEBUG) { System.out.println("CastExpression ::= PushLPAREN Name Dims..."); } //$NON-NLS-1$
consumeCastExpressionWithNameArray();
break;
- case 566 : if (DEBUG) { System.out.println("AdditionalBoundsListOpt ::="); } //$NON-NLS-1$
+ case 568 : if (DEBUG) { System.out.println("AdditionalBoundsListOpt ::="); } //$NON-NLS-1$
consumeZeroAdditionalBounds();
break;
- case 570 : if (DEBUG) { System.out.println("OnlyTypeArgumentsForCastExpression ::= OnlyTypeArguments"); } //$NON-NLS-1$
+ case 572 : if (DEBUG) { System.out.println("OnlyTypeArgumentsForCastExpression ::= OnlyTypeArguments"); } //$NON-NLS-1$
consumeOnlyTypeArgumentsForCastExpression();
break;
- case 571 : if (DEBUG) { System.out.println("InsideCastExpression ::="); } //$NON-NLS-1$
+ case 573 : if (DEBUG) { System.out.println("InsideCastExpression ::="); } //$NON-NLS-1$
consumeInsideCastExpression();
break;
- case 572 : if (DEBUG) { System.out.println("InsideCastExpressionLL1 ::="); } //$NON-NLS-1$
+ case 574 : if (DEBUG) { System.out.println("InsideCastExpressionLL1 ::="); } //$NON-NLS-1$
consumeInsideCastExpressionLL1();
break;
- case 573 : if (DEBUG) { System.out.println("InsideCastExpressionLL1WithBounds ::="); } //$NON-NLS-1$
+ case 575 : if (DEBUG) { System.out.println("InsideCastExpressionLL1WithBounds ::="); } //$NON-NLS-1$
consumeInsideCastExpressionLL1WithBounds ();
break;
- case 574 : if (DEBUG) { System.out.println("InsideCastExpressionWithQualifiedGenerics ::="); } //$NON-NLS-1$
+ case 576 : if (DEBUG) { System.out.println("InsideCastExpressionWithQualifiedGenerics ::="); } //$NON-NLS-1$
consumeInsideCastExpressionWithQualifiedGenerics();
break;
- case 576 : if (DEBUG) { System.out.println("MultiplicativeExpression ::= MultiplicativeExpression..."); } //$NON-NLS-1$
+ case 578 : if (DEBUG) { System.out.println("MultiplicativeExpression ::= MultiplicativeExpression..."); } //$NON-NLS-1$
consumeBinaryExpression(OperatorIds.MULTIPLY);
break;
- case 577 : if (DEBUG) { System.out.println("MultiplicativeExpression ::= MultiplicativeExpression..."); } //$NON-NLS-1$
+ case 579 : if (DEBUG) { System.out.println("MultiplicativeExpression ::= MultiplicativeExpression..."); } //$NON-NLS-1$
consumeBinaryExpression(OperatorIds.DIVIDE);
break;
- case 578 : if (DEBUG) { System.out.println("MultiplicativeExpression ::= MultiplicativeExpression..."); } //$NON-NLS-1$
+ case 580 : if (DEBUG) { System.out.println("MultiplicativeExpression ::= MultiplicativeExpression..."); } //$NON-NLS-1$
consumeBinaryExpression(OperatorIds.REMAINDER);
break;
- case 580 : if (DEBUG) { System.out.println("AdditiveExpression ::= AdditiveExpression PLUS..."); } //$NON-NLS-1$
+ case 582 : if (DEBUG) { System.out.println("AdditiveExpression ::= AdditiveExpression PLUS..."); } //$NON-NLS-1$
consumeBinaryExpression(OperatorIds.PLUS);
break;
- case 581 : if (DEBUG) { System.out.println("AdditiveExpression ::= AdditiveExpression MINUS..."); } //$NON-NLS-1$
+ case 583 : if (DEBUG) { System.out.println("AdditiveExpression ::= AdditiveExpression MINUS..."); } //$NON-NLS-1$
consumeBinaryExpression(OperatorIds.MINUS);
break;
- case 583 : if (DEBUG) { System.out.println("ShiftExpression ::= ShiftExpression LEFT_SHIFT..."); } //$NON-NLS-1$
+ case 585 : if (DEBUG) { System.out.println("ShiftExpression ::= ShiftExpression LEFT_SHIFT..."); } //$NON-NLS-1$
consumeBinaryExpression(OperatorIds.LEFT_SHIFT);
break;
- case 584 : if (DEBUG) { System.out.println("ShiftExpression ::= ShiftExpression RIGHT_SHIFT..."); } //$NON-NLS-1$
+ case 586 : if (DEBUG) { System.out.println("ShiftExpression ::= ShiftExpression RIGHT_SHIFT..."); } //$NON-NLS-1$
consumeBinaryExpression(OperatorIds.RIGHT_SHIFT);
break;
- case 585 : if (DEBUG) { System.out.println("ShiftExpression ::= ShiftExpression UNSIGNED_RIGHT_SHIFT"); } //$NON-NLS-1$
+ case 587 : if (DEBUG) { System.out.println("ShiftExpression ::= ShiftExpression UNSIGNED_RIGHT_SHIFT"); } //$NON-NLS-1$
consumeBinaryExpression(OperatorIds.UNSIGNED_RIGHT_SHIFT);
break;
- case 587 : if (DEBUG) { System.out.println("RelationalExpression ::= RelationalExpression LESS..."); } //$NON-NLS-1$
+ case 589 : if (DEBUG) { System.out.println("RelationalExpression ::= RelationalExpression LESS..."); } //$NON-NLS-1$
consumeBinaryExpression(OperatorIds.LESS);
break;
- case 588 : if (DEBUG) { System.out.println("RelationalExpression ::= RelationalExpression GREATER..."); } //$NON-NLS-1$
+ case 590 : if (DEBUG) { System.out.println("RelationalExpression ::= RelationalExpression GREATER..."); } //$NON-NLS-1$
consumeBinaryExpression(OperatorIds.GREATER);
break;
- case 589 : if (DEBUG) { System.out.println("RelationalExpression ::= RelationalExpression LESS_EQUAL"); } //$NON-NLS-1$
+ case 591 : if (DEBUG) { System.out.println("RelationalExpression ::= RelationalExpression LESS_EQUAL"); } //$NON-NLS-1$
consumeBinaryExpression(OperatorIds.LESS_EQUAL);
break;
- case 590 : if (DEBUG) { System.out.println("RelationalExpression ::= RelationalExpression..."); } //$NON-NLS-1$
+ case 592 : if (DEBUG) { System.out.println("RelationalExpression ::= RelationalExpression..."); } //$NON-NLS-1$
consumeBinaryExpression(OperatorIds.GREATER_EQUAL);
break;
- case 592 : if (DEBUG) { System.out.println("InstanceofExpression ::= InstanceofExpression instanceof"); } //$NON-NLS-1$
+ case 594 : if (DEBUG) { System.out.println("InstanceofExpression ::= InstanceofExpression instanceof"); } //$NON-NLS-1$
consumeInstanceOfExpression();
break;
- case 594 : if (DEBUG) { System.out.println("EqualityExpression ::= EqualityExpression EQUAL_EQUAL..."); } //$NON-NLS-1$
+ case 596 : if (DEBUG) { System.out.println("EqualityExpression ::= EqualityExpression EQUAL_EQUAL..."); } //$NON-NLS-1$
consumeEqualityExpression(OperatorIds.EQUAL_EQUAL);
break;
- case 595 : if (DEBUG) { System.out.println("EqualityExpression ::= EqualityExpression NOT_EQUAL..."); } //$NON-NLS-1$
+ case 597 : if (DEBUG) { System.out.println("EqualityExpression ::= EqualityExpression NOT_EQUAL..."); } //$NON-NLS-1$
consumeEqualityExpression(OperatorIds.NOT_EQUAL);
break;
- case 597 : if (DEBUG) { System.out.println("AndExpression ::= AndExpression AND EqualityExpression"); } //$NON-NLS-1$
+ case 599 : if (DEBUG) { System.out.println("AndExpression ::= AndExpression AND EqualityExpression"); } //$NON-NLS-1$
consumeBinaryExpression(OperatorIds.AND);
break;
- case 599 : if (DEBUG) { System.out.println("ExclusiveOrExpression ::= ExclusiveOrExpression XOR..."); } //$NON-NLS-1$
+ case 601 : if (DEBUG) { System.out.println("ExclusiveOrExpression ::= ExclusiveOrExpression XOR..."); } //$NON-NLS-1$
consumeBinaryExpression(OperatorIds.XOR);
break;
- case 601 : if (DEBUG) { System.out.println("InclusiveOrExpression ::= InclusiveOrExpression OR..."); } //$NON-NLS-1$
+ case 603 : if (DEBUG) { System.out.println("InclusiveOrExpression ::= InclusiveOrExpression OR..."); } //$NON-NLS-1$
consumeBinaryExpression(OperatorIds.OR);
break;
- case 603 : if (DEBUG) { System.out.println("ConditionalAndExpression ::= ConditionalAndExpression..."); } //$NON-NLS-1$
+ case 605 : if (DEBUG) { System.out.println("ConditionalAndExpression ::= ConditionalAndExpression..."); } //$NON-NLS-1$
consumeBinaryExpression(OperatorIds.AND_AND);
break;
- case 605 : if (DEBUG) { System.out.println("ConditionalOrExpression ::= ConditionalOrExpression..."); } //$NON-NLS-1$
+ case 607 : if (DEBUG) { System.out.println("ConditionalOrExpression ::= ConditionalOrExpression..."); } //$NON-NLS-1$
consumeBinaryExpression(OperatorIds.OR_OR);
break;
- case 607 : if (DEBUG) { System.out.println("ConditionalExpression ::= ConditionalOrExpression..."); } //$NON-NLS-1$
+ case 609 : if (DEBUG) { System.out.println("ConditionalExpression ::= ConditionalOrExpression..."); } //$NON-NLS-1$
consumeConditionalExpression(OperatorIds.QUESTIONCOLON) ;
break;
- case 610 : if (DEBUG) { System.out.println("Assignment ::= PostfixExpression AssignmentOperator..."); } //$NON-NLS-1$
+ case 612 : if (DEBUG) { System.out.println("Assignment ::= PostfixExpression AssignmentOperator..."); } //$NON-NLS-1$
consumeAssignment();
break;
- case 612 : if (DEBUG) { System.out.println("Assignment ::= InvalidArrayInitializerAssignement"); } //$NON-NLS-1$
+ case 614 : if (DEBUG) { System.out.println("Assignment ::= InvalidArrayInitializerAssignement"); } //$NON-NLS-1$
ignoreExpressionAssignment();
break;
- case 613 : if (DEBUG) { System.out.println("AssignmentOperator ::= EQUAL"); } //$NON-NLS-1$
+ case 615 : if (DEBUG) { System.out.println("AssignmentOperator ::= EQUAL"); } //$NON-NLS-1$
consumeAssignmentOperator(EQUAL);
break;
- case 614 : if (DEBUG) { System.out.println("AssignmentOperator ::= MULTIPLY_EQUAL"); } //$NON-NLS-1$
+ case 616 : if (DEBUG) { System.out.println("AssignmentOperator ::= MULTIPLY_EQUAL"); } //$NON-NLS-1$
consumeAssignmentOperator(MULTIPLY);
break;
- case 615 : if (DEBUG) { System.out.println("AssignmentOperator ::= DIVIDE_EQUAL"); } //$NON-NLS-1$
+ case 617 : if (DEBUG) { System.out.println("AssignmentOperator ::= DIVIDE_EQUAL"); } //$NON-NLS-1$
consumeAssignmentOperator(DIVIDE);
break;
- case 616 : if (DEBUG) { System.out.println("AssignmentOperator ::= REMAINDER_EQUAL"); } //$NON-NLS-1$
+ case 618 : if (DEBUG) { System.out.println("AssignmentOperator ::= REMAINDER_EQUAL"); } //$NON-NLS-1$
consumeAssignmentOperator(REMAINDER);
break;
- case 617 : if (DEBUG) { System.out.println("AssignmentOperator ::= PLUS_EQUAL"); } //$NON-NLS-1$
+ case 619 : if (DEBUG) { System.out.println("AssignmentOperator ::= PLUS_EQUAL"); } //$NON-NLS-1$
consumeAssignmentOperator(PLUS);
break;
- case 618 : if (DEBUG) { System.out.println("AssignmentOperator ::= MINUS_EQUAL"); } //$NON-NLS-1$
+ case 620 : if (DEBUG) { System.out.println("AssignmentOperator ::= MINUS_EQUAL"); } //$NON-NLS-1$
consumeAssignmentOperator(MINUS);
break;
- case 619 : if (DEBUG) { System.out.println("AssignmentOperator ::= LEFT_SHIFT_EQUAL"); } //$NON-NLS-1$
+ case 621 : if (DEBUG) { System.out.println("AssignmentOperator ::= LEFT_SHIFT_EQUAL"); } //$NON-NLS-1$
consumeAssignmentOperator(LEFT_SHIFT);
break;
- case 620 : if (DEBUG) { System.out.println("AssignmentOperator ::= RIGHT_SHIFT_EQUAL"); } //$NON-NLS-1$
+ case 622 : if (DEBUG) { System.out.println("AssignmentOperator ::= RIGHT_SHIFT_EQUAL"); } //$NON-NLS-1$
consumeAssignmentOperator(RIGHT_SHIFT);
break;
- case 621 : if (DEBUG) { System.out.println("AssignmentOperator ::= UNSIGNED_RIGHT_SHIFT_EQUAL"); } //$NON-NLS-1$
+ case 623 : if (DEBUG) { System.out.println("AssignmentOperator ::= UNSIGNED_RIGHT_SHIFT_EQUAL"); } //$NON-NLS-1$
consumeAssignmentOperator(UNSIGNED_RIGHT_SHIFT);
break;
- case 622 : if (DEBUG) { System.out.println("AssignmentOperator ::= AND_EQUAL"); } //$NON-NLS-1$
+ case 624 : if (DEBUG) { System.out.println("AssignmentOperator ::= AND_EQUAL"); } //$NON-NLS-1$
consumeAssignmentOperator(AND);
break;
- case 623 : if (DEBUG) { System.out.println("AssignmentOperator ::= XOR_EQUAL"); } //$NON-NLS-1$
+ case 625 : if (DEBUG) { System.out.println("AssignmentOperator ::= XOR_EQUAL"); } //$NON-NLS-1$
consumeAssignmentOperator(XOR);
break;
- case 624 : if (DEBUG) { System.out.println("AssignmentOperator ::= OR_EQUAL"); } //$NON-NLS-1$
+ case 626 : if (DEBUG) { System.out.println("AssignmentOperator ::= OR_EQUAL"); } //$NON-NLS-1$
consumeAssignmentOperator(OR);
break;
- case 625 : if (DEBUG) { System.out.println("Expression ::= AssignmentExpression"); } //$NON-NLS-1$
+ case 627 : if (DEBUG) { System.out.println("Expression ::= AssignmentExpression"); } //$NON-NLS-1$
consumeExpression();
break;
- case 628 : if (DEBUG) { System.out.println("Expressionopt ::="); } //$NON-NLS-1$
+ case 630 : if (DEBUG) { System.out.println("Expressionopt ::="); } //$NON-NLS-1$
consumeEmptyExpression();
break;
- case 631 : if (DEBUG) { System.out.println("ConstantExpressions ::= ConstantExpressions COMMA..."); } //$NON-NLS-1$
+ case 633 : if (DEBUG) { System.out.println("ConstantExpressions ::= ConstantExpressions COMMA..."); } //$NON-NLS-1$
consumeConstantExpressions();
break;
- case 635 : if (DEBUG) { System.out.println("ClassBodyDeclarationsopt ::="); } //$NON-NLS-1$
+ case 637 : if (DEBUG) { System.out.println("ClassBodyDeclarationsopt ::="); } //$NON-NLS-1$
consumeEmptyClassBodyDeclarationsopt();
break;
- case 636 : if (DEBUG) { System.out.println("ClassBodyDeclarationsopt ::= NestedType..."); } //$NON-NLS-1$
+ case 638 : if (DEBUG) { System.out.println("ClassBodyDeclarationsopt ::= NestedType..."); } //$NON-NLS-1$
consumeClassBodyDeclarationsopt();
break;
- case 637 : if (DEBUG) { System.out.println("Modifiersopt ::="); } //$NON-NLS-1$
+ case 639 : if (DEBUG) { System.out.println("Modifiersopt ::="); } //$NON-NLS-1$
consumeDefaultModifiers();
break;
- case 638 : if (DEBUG) { System.out.println("Modifiersopt ::= Modifiers"); } //$NON-NLS-1$
+ case 640 : if (DEBUG) { System.out.println("Modifiersopt ::= Modifiers"); } //$NON-NLS-1$
consumeModifiers();
break;
- case 639 : if (DEBUG) { System.out.println("BlockStatementsopt ::="); } //$NON-NLS-1$
+ case 641 : if (DEBUG) { System.out.println("BlockStatementsopt ::="); } //$NON-NLS-1$
consumeEmptyBlockStatementsopt();
break;
- case 641 : if (DEBUG) { System.out.println("Dimsopt ::="); } //$NON-NLS-1$
+ case 643 : if (DEBUG) { System.out.println("Dimsopt ::="); } //$NON-NLS-1$
consumeEmptyDimsopt();
break;
- case 643 : if (DEBUG) { System.out.println("ArgumentListopt ::="); } //$NON-NLS-1$
+ case 645 : if (DEBUG) { System.out.println("ArgumentListopt ::="); } //$NON-NLS-1$
consumeEmptyArgumentListopt();
break;
- case 647 : if (DEBUG) { System.out.println("FormalParameterListopt ::="); } //$NON-NLS-1$
+ case 649 : if (DEBUG) { System.out.println("FormalParameterListopt ::="); } //$NON-NLS-1$
consumeFormalParameterListopt();
break;
- case 651 : if (DEBUG) { System.out.println("InterfaceMemberDeclarationsopt ::="); } //$NON-NLS-1$
+ case 653 : if (DEBUG) { System.out.println("InterfaceMemberDeclarationsopt ::="); } //$NON-NLS-1$
consumeEmptyInterfaceMemberDeclarationsopt();
break;
- case 652 : if (DEBUG) { System.out.println("InterfaceMemberDeclarationsopt ::= NestedType..."); } //$NON-NLS-1$
+ case 654 : if (DEBUG) { System.out.println("InterfaceMemberDeclarationsopt ::= NestedType..."); } //$NON-NLS-1$
consumeInterfaceMemberDeclarationsopt();
break;
- case 653 : if (DEBUG) { System.out.println("NestedType ::="); } //$NON-NLS-1$
+ case 655 : if (DEBUG) { System.out.println("NestedType ::="); } //$NON-NLS-1$
consumeNestedType();
break;
- case 654 : if (DEBUG) { System.out.println("ForInitopt ::="); } //$NON-NLS-1$
+ case 656 : if (DEBUG) { System.out.println("ForInitopt ::="); } //$NON-NLS-1$
consumeEmptyForInitopt();
break;
- case 656 : if (DEBUG) { System.out.println("ForUpdateopt ::="); } //$NON-NLS-1$
+ case 658 : if (DEBUG) { System.out.println("ForUpdateopt ::="); } //$NON-NLS-1$
consumeEmptyForUpdateopt();
break;
- case 660 : if (DEBUG) { System.out.println("Catchesopt ::="); } //$NON-NLS-1$
+ case 662 : if (DEBUG) { System.out.println("Catchesopt ::="); } //$NON-NLS-1$
consumeEmptyCatchesopt();
break;
- case 662 : if (DEBUG) { System.out.println("EnumDeclaration ::= EnumHeader EnumBody"); } //$NON-NLS-1$
+ case 664 : if (DEBUG) { System.out.println("EnumDeclaration ::= EnumHeader EnumBody"); } //$NON-NLS-1$
consumeEnumDeclaration();
break;
- case 663 : if (DEBUG) { System.out.println("EnumHeader ::= EnumHeaderName ClassHeaderImplementsopt"); } //$NON-NLS-1$
+ case 665 : if (DEBUG) { System.out.println("EnumHeader ::= EnumHeaderName ClassHeaderImplementsopt"); } //$NON-NLS-1$
consumeEnumHeader();
break;
- case 664 : if (DEBUG) { System.out.println("EnumHeaderName ::= Modifiersopt enum Identifier"); } //$NON-NLS-1$
+ case 666 : if (DEBUG) { System.out.println("EnumHeaderName ::= Modifiersopt enum Identifier"); } //$NON-NLS-1$
consumeEnumHeaderName();
break;
- case 665 : if (DEBUG) { System.out.println("EnumHeaderName ::= Modifiersopt enum Identifier..."); } //$NON-NLS-1$
+ case 667 : if (DEBUG) { System.out.println("EnumHeaderName ::= Modifiersopt enum Identifier..."); } //$NON-NLS-1$
consumeEnumHeaderNameWithTypeParameters();
break;
- case 666 : if (DEBUG) { System.out.println("EnumBody ::= LBRACE EnumBodyDeclarationsopt RBRACE"); } //$NON-NLS-1$
+ case 668 : if (DEBUG) { System.out.println("EnumBody ::= LBRACE EnumBodyDeclarationsopt RBRACE"); } //$NON-NLS-1$
consumeEnumBodyNoConstants();
break;
- case 667 : if (DEBUG) { System.out.println("EnumBody ::= LBRACE COMMA EnumBodyDeclarationsopt..."); } //$NON-NLS-1$
+ case 669 : if (DEBUG) { System.out.println("EnumBody ::= LBRACE COMMA EnumBodyDeclarationsopt..."); } //$NON-NLS-1$
consumeEnumBodyNoConstants();
break;
- case 668 : if (DEBUG) { System.out.println("EnumBody ::= LBRACE EnumConstants COMMA..."); } //$NON-NLS-1$
+ case 670 : if (DEBUG) { System.out.println("EnumBody ::= LBRACE EnumConstants COMMA..."); } //$NON-NLS-1$
consumeEnumBodyWithConstants();
break;
- case 669 : if (DEBUG) { System.out.println("EnumBody ::= LBRACE EnumConstants..."); } //$NON-NLS-1$
+ case 671 : if (DEBUG) { System.out.println("EnumBody ::= LBRACE EnumConstants..."); } //$NON-NLS-1$
consumeEnumBodyWithConstants();
break;
- case 671 : if (DEBUG) { System.out.println("EnumConstants ::= EnumConstants COMMA EnumConstant"); } //$NON-NLS-1$
+ case 673 : if (DEBUG) { System.out.println("EnumConstants ::= EnumConstants COMMA EnumConstant"); } //$NON-NLS-1$
consumeEnumConstants();
break;
- case 672 : if (DEBUG) { System.out.println("EnumConstantHeaderName ::= Modifiersopt Identifier"); } //$NON-NLS-1$
+ case 674 : if (DEBUG) { System.out.println("EnumConstantHeaderName ::= Modifiersopt Identifier"); } //$NON-NLS-1$
consumeEnumConstantHeaderName();
break;
- case 673 : if (DEBUG) { System.out.println("EnumConstantHeader ::= EnumConstantHeaderName..."); } //$NON-NLS-1$
+ case 675 : if (DEBUG) { System.out.println("EnumConstantHeader ::= EnumConstantHeaderName..."); } //$NON-NLS-1$
consumeEnumConstantHeader();
break;
- case 674 : if (DEBUG) { System.out.println("EnumConstant ::= EnumConstantHeader ForceNoDiet..."); } //$NON-NLS-1$
+ case 676 : if (DEBUG) { System.out.println("EnumConstant ::= EnumConstantHeader ForceNoDiet..."); } //$NON-NLS-1$
consumeEnumConstantWithClassBody();
break;
- case 675 : if (DEBUG) { System.out.println("EnumConstant ::= EnumConstantHeader"); } //$NON-NLS-1$
+ case 677 : if (DEBUG) { System.out.println("EnumConstant ::= EnumConstantHeader"); } //$NON-NLS-1$
consumeEnumConstantNoClassBody();
break;
- case 676 : if (DEBUG) { System.out.println("Arguments ::= LPAREN ArgumentListopt RPAREN"); } //$NON-NLS-1$
+ case 678 : if (DEBUG) { System.out.println("Arguments ::= LPAREN ArgumentListopt RPAREN"); } //$NON-NLS-1$
consumeArguments();
break;
- case 677 : if (DEBUG) { System.out.println("Argumentsopt ::="); } //$NON-NLS-1$
+ case 679 : if (DEBUG) { System.out.println("Argumentsopt ::="); } //$NON-NLS-1$
consumeEmptyArguments();
break;
- case 679 : if (DEBUG) { System.out.println("EnumDeclarations ::= SEMICOLON ClassBodyDeclarationsopt"); } //$NON-NLS-1$
+ case 681 : if (DEBUG) { System.out.println("EnumDeclarations ::= SEMICOLON ClassBodyDeclarationsopt"); } //$NON-NLS-1$
consumeEnumDeclarations();
break;
- case 680 : if (DEBUG) { System.out.println("EnumBodyDeclarationsopt ::="); } //$NON-NLS-1$
+ case 682 : if (DEBUG) { System.out.println("EnumBodyDeclarationsopt ::="); } //$NON-NLS-1$
consumeEmptyEnumDeclarations();
break;
- case 682 : if (DEBUG) { System.out.println("EnhancedForStatement ::= EnhancedForStatementHeader..."); } //$NON-NLS-1$
+ case 684 : if (DEBUG) { System.out.println("EnhancedForStatement ::= EnhancedForStatementHeader..."); } //$NON-NLS-1$
consumeEnhancedForStatement();
break;
- case 683 : if (DEBUG) { System.out.println("EnhancedForStatementNoShortIf ::=..."); } //$NON-NLS-1$
+ case 685 : if (DEBUG) { System.out.println("EnhancedForStatementNoShortIf ::=..."); } //$NON-NLS-1$
consumeEnhancedForStatement();
break;
- case 684 : if (DEBUG) { System.out.println("EnhancedForStatementHeaderInit ::= for LPAREN Type..."); } //$NON-NLS-1$
+ case 686 : if (DEBUG) { System.out.println("EnhancedForStatementHeaderInit ::= for LPAREN Type..."); } //$NON-NLS-1$
consumeEnhancedForStatementHeaderInit(false);
break;
- case 685 : if (DEBUG) { System.out.println("EnhancedForStatementHeaderInit ::= for LPAREN Modifiers"); } //$NON-NLS-1$
+ case 687 : if (DEBUG) { System.out.println("EnhancedForStatementHeaderInit ::= for LPAREN Modifiers"); } //$NON-NLS-1$
consumeEnhancedForStatementHeaderInit(true);
break;
- case 686 : if (DEBUG) { System.out.println("EnhancedForStatementHeader ::=..."); } //$NON-NLS-1$
+ case 688 : if (DEBUG) { System.out.println("EnhancedForStatementHeader ::=..."); } //$NON-NLS-1$
consumeEnhancedForStatementHeader();
break;
- case 687 : if (DEBUG) { System.out.println("SingleStaticImportDeclaration ::=..."); } //$NON-NLS-1$
+ case 689 : if (DEBUG) { System.out.println("SingleStaticImportDeclaration ::=..."); } //$NON-NLS-1$
consumeImportDeclaration();
break;
- case 688 : if (DEBUG) { System.out.println("SingleStaticImportDeclarationName ::= import static Name"); } //$NON-NLS-1$
+ case 690 : if (DEBUG) { System.out.println("SingleStaticImportDeclarationName ::= import static Name"); } //$NON-NLS-1$
consumeSingleStaticImportDeclarationName();
break;
- case 689 : if (DEBUG) { System.out.println("StaticImportOnDemandDeclaration ::=..."); } //$NON-NLS-1$
+ case 691 : if (DEBUG) { System.out.println("StaticImportOnDemandDeclaration ::=..."); } //$NON-NLS-1$
consumeImportDeclaration();
break;
- case 690 : if (DEBUG) { System.out.println("StaticImportOnDemandDeclarationName ::= import static..."); } //$NON-NLS-1$
+ case 692 : if (DEBUG) { System.out.println("StaticImportOnDemandDeclarationName ::= import static..."); } //$NON-NLS-1$
consumeStaticImportOnDemandDeclarationName();
break;
- case 691 : if (DEBUG) { System.out.println("TypeArguments ::= LESS TypeArgumentList1"); } //$NON-NLS-1$
+ case 693 : if (DEBUG) { System.out.println("TypeArguments ::= LESS TypeArgumentList1"); } //$NON-NLS-1$
consumeTypeArguments();
break;
- case 692 : if (DEBUG) { System.out.println("OnlyTypeArguments ::= LESS TypeArgumentList1"); } //$NON-NLS-1$
+ case 694 : if (DEBUG) { System.out.println("OnlyTypeArguments ::= LESS TypeArgumentList1"); } //$NON-NLS-1$
consumeOnlyTypeArguments();
break;
- case 694 : if (DEBUG) { System.out.println("TypeArgumentList1 ::= TypeArgumentList COMMA..."); } //$NON-NLS-1$
+ case 696 : if (DEBUG) { System.out.println("TypeArgumentList1 ::= TypeArgumentList COMMA..."); } //$NON-NLS-1$
consumeTypeArgumentList1();
break;
- case 696 : if (DEBUG) { System.out.println("TypeArgumentList ::= TypeArgumentList COMMA TypeArgument"); } //$NON-NLS-1$
+ case 698 : if (DEBUG) { System.out.println("TypeArgumentList ::= TypeArgumentList COMMA TypeArgument"); } //$NON-NLS-1$
consumeTypeArgumentList();
break;
- case 697 : if (DEBUG) { System.out.println("TypeArgument ::= ReferenceType"); } //$NON-NLS-1$
+ case 699 : if (DEBUG) { System.out.println("TypeArgument ::= ReferenceType"); } //$NON-NLS-1$
consumeTypeArgument();
break;
- case 701 : if (DEBUG) { System.out.println("ReferenceType1 ::= ReferenceType GREATER"); } //$NON-NLS-1$
+ case 703 : if (DEBUG) { System.out.println("ReferenceType1 ::= ReferenceType GREATER"); } //$NON-NLS-1$
consumeReferenceType1();
break;
- case 702 : if (DEBUG) { System.out.println("ReferenceType1 ::= ClassOrInterface LESS..."); } //$NON-NLS-1$
+ case 704 : if (DEBUG) { System.out.println("ReferenceType1 ::= ClassOrInterface LESS..."); } //$NON-NLS-1$
consumeTypeArgumentReferenceType1();
break;
- case 704 : if (DEBUG) { System.out.println("TypeArgumentList2 ::= TypeArgumentList COMMA..."); } //$NON-NLS-1$
+ case 706 : if (DEBUG) { System.out.println("TypeArgumentList2 ::= TypeArgumentList COMMA..."); } //$NON-NLS-1$
consumeTypeArgumentList2();
break;
- case 707 : if (DEBUG) { System.out.println("ReferenceType2 ::= ReferenceType RIGHT_SHIFT"); } //$NON-NLS-1$
+ case 709 : if (DEBUG) { System.out.println("ReferenceType2 ::= ReferenceType RIGHT_SHIFT"); } //$NON-NLS-1$
consumeReferenceType2();
break;
- case 708 : if (DEBUG) { System.out.println("ReferenceType2 ::= ClassOrInterface LESS..."); } //$NON-NLS-1$
+ case 710 : if (DEBUG) { System.out.println("ReferenceType2 ::= ClassOrInterface LESS..."); } //$NON-NLS-1$
consumeTypeArgumentReferenceType2();
break;
- case 710 : if (DEBUG) { System.out.println("TypeArgumentList3 ::= TypeArgumentList COMMA..."); } //$NON-NLS-1$
+ case 712 : if (DEBUG) { System.out.println("TypeArgumentList3 ::= TypeArgumentList COMMA..."); } //$NON-NLS-1$
consumeTypeArgumentList3();
break;
- case 713 : if (DEBUG) { System.out.println("ReferenceType3 ::= ReferenceType UNSIGNED_RIGHT_SHIFT"); } //$NON-NLS-1$
+ case 715 : if (DEBUG) { System.out.println("ReferenceType3 ::= ReferenceType UNSIGNED_RIGHT_SHIFT"); } //$NON-NLS-1$
consumeReferenceType3();
break;
- case 714 : if (DEBUG) { System.out.println("Wildcard ::= TypeAnnotationsopt QUESTION"); } //$NON-NLS-1$
+ case 716 : if (DEBUG) { System.out.println("Wildcard ::= TypeAnnotationsopt QUESTION"); } //$NON-NLS-1$
consumeWildcard();
break;
- case 715 : if (DEBUG) { System.out.println("Wildcard ::= TypeAnnotationsopt QUESTION WildcardBounds"); } //$NON-NLS-1$
+ case 717 : if (DEBUG) { System.out.println("Wildcard ::= TypeAnnotationsopt QUESTION WildcardBounds"); } //$NON-NLS-1$
consumeWildcardWithBounds();
break;
- case 716 : if (DEBUG) { System.out.println("WildcardBounds ::= extends ReferenceType"); } //$NON-NLS-1$
+ case 718 : if (DEBUG) { System.out.println("WildcardBounds ::= extends ReferenceType"); } //$NON-NLS-1$
consumeWildcardBoundsExtends();
break;
- case 717 : if (DEBUG) { System.out.println("WildcardBounds ::= super ReferenceType"); } //$NON-NLS-1$
+ case 719 : if (DEBUG) { System.out.println("WildcardBounds ::= super ReferenceType"); } //$NON-NLS-1$
consumeWildcardBoundsSuper();
break;
- case 718 : if (DEBUG) { System.out.println("Wildcard1 ::= TypeAnnotationsopt QUESTION GREATER"); } //$NON-NLS-1$
+ case 720 : if (DEBUG) { System.out.println("Wildcard1 ::= TypeAnnotationsopt QUESTION GREATER"); } //$NON-NLS-1$
consumeWildcard1();
break;
- case 719 : if (DEBUG) { System.out.println("Wildcard1 ::= TypeAnnotationsopt QUESTION..."); } //$NON-NLS-1$
+ case 721 : if (DEBUG) { System.out.println("Wildcard1 ::= TypeAnnotationsopt QUESTION..."); } //$NON-NLS-1$
consumeWildcard1WithBounds();
break;
- case 720 : if (DEBUG) { System.out.println("WildcardBounds1 ::= extends ReferenceType1"); } //$NON-NLS-1$
+ case 722 : if (DEBUG) { System.out.println("WildcardBounds1 ::= extends ReferenceType1"); } //$NON-NLS-1$
consumeWildcardBounds1Extends();
break;
- case 721 : if (DEBUG) { System.out.println("WildcardBounds1 ::= super ReferenceType1"); } //$NON-NLS-1$
+ case 723 : if (DEBUG) { System.out.println("WildcardBounds1 ::= super ReferenceType1"); } //$NON-NLS-1$
consumeWildcardBounds1Super();
break;
- case 722 : if (DEBUG) { System.out.println("Wildcard2 ::= TypeAnnotationsopt QUESTION RIGHT_SHIFT"); } //$NON-NLS-1$
+ case 724 : if (DEBUG) { System.out.println("Wildcard2 ::= TypeAnnotationsopt QUESTION RIGHT_SHIFT"); } //$NON-NLS-1$
consumeWildcard2();
break;
- case 723 : if (DEBUG) { System.out.println("Wildcard2 ::= TypeAnnotationsopt QUESTION..."); } //$NON-NLS-1$
+ case 725 : if (DEBUG) { System.out.println("Wildcard2 ::= TypeAnnotationsopt QUESTION..."); } //$NON-NLS-1$
consumeWildcard2WithBounds();
break;
- case 724 : if (DEBUG) { System.out.println("WildcardBounds2 ::= extends ReferenceType2"); } //$NON-NLS-1$
+ case 726 : if (DEBUG) { System.out.println("WildcardBounds2 ::= extends ReferenceType2"); } //$NON-NLS-1$
consumeWildcardBounds2Extends();
break;
- case 725 : if (DEBUG) { System.out.println("WildcardBounds2 ::= super ReferenceType2"); } //$NON-NLS-1$
+ case 727 : if (DEBUG) { System.out.println("WildcardBounds2 ::= super ReferenceType2"); } //$NON-NLS-1$
consumeWildcardBounds2Super();
break;
- case 726 : if (DEBUG) { System.out.println("Wildcard3 ::= TypeAnnotationsopt QUESTION..."); } //$NON-NLS-1$
+ case 728 : if (DEBUG) { System.out.println("Wildcard3 ::= TypeAnnotationsopt QUESTION..."); } //$NON-NLS-1$
consumeWildcard3();
break;
- case 727 : if (DEBUG) { System.out.println("Wildcard3 ::= TypeAnnotationsopt QUESTION..."); } //$NON-NLS-1$
+ case 729 : if (DEBUG) { System.out.println("Wildcard3 ::= TypeAnnotationsopt QUESTION..."); } //$NON-NLS-1$
consumeWildcard3WithBounds();
break;
- case 728 : if (DEBUG) { System.out.println("WildcardBounds3 ::= extends ReferenceType3"); } //$NON-NLS-1$
+ case 730 : if (DEBUG) { System.out.println("WildcardBounds3 ::= extends ReferenceType3"); } //$NON-NLS-1$
consumeWildcardBounds3Extends();
break;
- case 729 : if (DEBUG) { System.out.println("WildcardBounds3 ::= super ReferenceType3"); } //$NON-NLS-1$
+ case 731 : if (DEBUG) { System.out.println("WildcardBounds3 ::= super ReferenceType3"); } //$NON-NLS-1$
consumeWildcardBounds3Super();
break;
- case 730 : if (DEBUG) { System.out.println("TypeParameterHeader ::= TypeAnnotationsopt Identifier"); } //$NON-NLS-1$
+ case 732 : if (DEBUG) { System.out.println("TypeParameterHeader ::= TypeAnnotationsopt Identifier"); } //$NON-NLS-1$
consumeTypeParameterHeader();
break;
- case 731 : if (DEBUG) { System.out.println("TypeParameters ::= LESS TypeParameterList1"); } //$NON-NLS-1$
+ case 733 : if (DEBUG) { System.out.println("TypeParameters ::= LESS TypeParameterList1"); } //$NON-NLS-1$
consumeTypeParameters();
break;
- case 733 : if (DEBUG) { System.out.println("TypeParameterList ::= TypeParameterList COMMA..."); } //$NON-NLS-1$
+ case 735 : if (DEBUG) { System.out.println("TypeParameterList ::= TypeParameterList COMMA..."); } //$NON-NLS-1$
consumeTypeParameterList();
break;
- case 735 : if (DEBUG) { System.out.println("TypeParameter ::= TypeParameterHeader extends..."); } //$NON-NLS-1$
+ case 737 : if (DEBUG) { System.out.println("TypeParameter ::= TypeParameterHeader extends..."); } //$NON-NLS-1$
consumeTypeParameterWithExtends();
break;
- case 736 : if (DEBUG) { System.out.println("TypeParameter ::= TypeParameterHeader extends..."); } //$NON-NLS-1$
+ case 738 : if (DEBUG) { System.out.println("TypeParameter ::= TypeParameterHeader extends..."); } //$NON-NLS-1$
consumeTypeParameterWithExtendsAndBounds();
break;
- case 738 : if (DEBUG) { System.out.println("AdditionalBoundList ::= AdditionalBoundList..."); } //$NON-NLS-1$
+ case 740 : if (DEBUG) { System.out.println("AdditionalBoundList ::= AdditionalBoundList..."); } //$NON-NLS-1$
consumeAdditionalBoundList();
break;
- case 739 : if (DEBUG) { System.out.println("AdditionalBound ::= AND ReferenceType"); } //$NON-NLS-1$
+ case 741 : if (DEBUG) { System.out.println("AdditionalBound ::= AND ReferenceType"); } //$NON-NLS-1$
consumeAdditionalBound();
break;
- case 741 : if (DEBUG) { System.out.println("TypeParameterList1 ::= TypeParameterList COMMA..."); } //$NON-NLS-1$
+ case 743 : if (DEBUG) { System.out.println("TypeParameterList1 ::= TypeParameterList COMMA..."); } //$NON-NLS-1$
consumeTypeParameterList1();
break;
- case 742 : if (DEBUG) { System.out.println("TypeParameter1 ::= TypeParameterHeader GREATER"); } //$NON-NLS-1$
+ case 744 : if (DEBUG) { System.out.println("TypeParameter1 ::= TypeParameterHeader GREATER"); } //$NON-NLS-1$
consumeTypeParameter1();
break;
- case 743 : if (DEBUG) { System.out.println("TypeParameter1 ::= TypeParameterHeader extends..."); } //$NON-NLS-1$
+ case 745 : if (DEBUG) { System.out.println("TypeParameter1 ::= TypeParameterHeader extends..."); } //$NON-NLS-1$
consumeTypeParameter1WithExtends();
break;
- case 744 : if (DEBUG) { System.out.println("TypeParameter1 ::= TypeParameterHeader extends..."); } //$NON-NLS-1$
+ case 746 : if (DEBUG) { System.out.println("TypeParameter1 ::= TypeParameterHeader extends..."); } //$NON-NLS-1$
consumeTypeParameter1WithExtendsAndBounds();
break;
- case 746 : if (DEBUG) { System.out.println("AdditionalBoundList1 ::= AdditionalBoundList..."); } //$NON-NLS-1$
+ case 748 : if (DEBUG) { System.out.println("AdditionalBoundList1 ::= AdditionalBoundList..."); } //$NON-NLS-1$
consumeAdditionalBoundList1();
break;
- case 747 : if (DEBUG) { System.out.println("AdditionalBound1 ::= AND ReferenceType1"); } //$NON-NLS-1$
+ case 749 : if (DEBUG) { System.out.println("AdditionalBound1 ::= AND ReferenceType1"); } //$NON-NLS-1$
consumeAdditionalBound1();
break;
- case 753 : if (DEBUG) { System.out.println("UnaryExpression_NotName ::= PLUS PushPosition..."); } //$NON-NLS-1$
+ case 755 : if (DEBUG) { System.out.println("UnaryExpression_NotName ::= PLUS PushPosition..."); } //$NON-NLS-1$
consumeUnaryExpression(OperatorIds.PLUS);
break;
- case 754 : if (DEBUG) { System.out.println("UnaryExpression_NotName ::= MINUS PushPosition..."); } //$NON-NLS-1$
+ case 756 : if (DEBUG) { System.out.println("UnaryExpression_NotName ::= MINUS PushPosition..."); } //$NON-NLS-1$
consumeUnaryExpression(OperatorIds.MINUS);
break;
- case 757 : if (DEBUG) { System.out.println("UnaryExpressionNotPlusMinus_NotName ::= TWIDDLE..."); } //$NON-NLS-1$
+ case 759 : if (DEBUG) { System.out.println("UnaryExpressionNotPlusMinus_NotName ::= TWIDDLE..."); } //$NON-NLS-1$
consumeUnaryExpression(OperatorIds.TWIDDLE);
break;
- case 758 : if (DEBUG) { System.out.println("UnaryExpressionNotPlusMinus_NotName ::= NOT PushPosition"); } //$NON-NLS-1$
+ case 760 : if (DEBUG) { System.out.println("UnaryExpressionNotPlusMinus_NotName ::= NOT PushPosition"); } //$NON-NLS-1$
consumeUnaryExpression(OperatorIds.NOT);
break;
- case 761 : if (DEBUG) { System.out.println("MultiplicativeExpression_NotName ::=..."); } //$NON-NLS-1$
+ case 763 : if (DEBUG) { System.out.println("MultiplicativeExpression_NotName ::=..."); } //$NON-NLS-1$
consumeBinaryExpression(OperatorIds.MULTIPLY);
break;
- case 762 : if (DEBUG) { System.out.println("MultiplicativeExpression_NotName ::= Name MULTIPLY..."); } //$NON-NLS-1$
+ case 764 : if (DEBUG) { System.out.println("MultiplicativeExpression_NotName ::= Name MULTIPLY..."); } //$NON-NLS-1$
consumeBinaryExpressionWithName(OperatorIds.MULTIPLY);
break;
- case 763 : if (DEBUG) { System.out.println("MultiplicativeExpression_NotName ::=..."); } //$NON-NLS-1$
+ case 765 : if (DEBUG) { System.out.println("MultiplicativeExpression_NotName ::=..."); } //$NON-NLS-1$
consumeBinaryExpression(OperatorIds.DIVIDE);
break;
- case 764 : if (DEBUG) { System.out.println("MultiplicativeExpression_NotName ::= Name DIVIDE..."); } //$NON-NLS-1$
+ case 766 : if (DEBUG) { System.out.println("MultiplicativeExpression_NotName ::= Name DIVIDE..."); } //$NON-NLS-1$
consumeBinaryExpressionWithName(OperatorIds.DIVIDE);
break;
- case 765 : if (DEBUG) { System.out.println("MultiplicativeExpression_NotName ::=..."); } //$NON-NLS-1$
+ case 767 : if (DEBUG) { System.out.println("MultiplicativeExpression_NotName ::=..."); } //$NON-NLS-1$
consumeBinaryExpression(OperatorIds.REMAINDER);
break;
- case 766 : if (DEBUG) { System.out.println("MultiplicativeExpression_NotName ::= Name REMAINDER..."); } //$NON-NLS-1$
+ case 768 : if (DEBUG) { System.out.println("MultiplicativeExpression_NotName ::= Name REMAINDER..."); } //$NON-NLS-1$
consumeBinaryExpressionWithName(OperatorIds.REMAINDER);
break;
- case 768 : if (DEBUG) { System.out.println("AdditiveExpression_NotName ::=..."); } //$NON-NLS-1$
+ case 770 : if (DEBUG) { System.out.println("AdditiveExpression_NotName ::=..."); } //$NON-NLS-1$
consumeBinaryExpression(OperatorIds.PLUS);
break;
- case 769 : if (DEBUG) { System.out.println("AdditiveExpression_NotName ::= Name PLUS..."); } //$NON-NLS-1$
+ case 771 : if (DEBUG) { System.out.println("AdditiveExpression_NotName ::= Name PLUS..."); } //$NON-NLS-1$
consumeBinaryExpressionWithName(OperatorIds.PLUS);
break;
- case 770 : if (DEBUG) { System.out.println("AdditiveExpression_NotName ::=..."); } //$NON-NLS-1$
+ case 772 : if (DEBUG) { System.out.println("AdditiveExpression_NotName ::=..."); } //$NON-NLS-1$
consumeBinaryExpression(OperatorIds.MINUS);
break;
- case 771 : if (DEBUG) { System.out.println("AdditiveExpression_NotName ::= Name MINUS..."); } //$NON-NLS-1$
+ case 773 : if (DEBUG) { System.out.println("AdditiveExpression_NotName ::= Name MINUS..."); } //$NON-NLS-1$
consumeBinaryExpressionWithName(OperatorIds.MINUS);
break;
- case 773 : if (DEBUG) { System.out.println("ShiftExpression_NotName ::= ShiftExpression_NotName..."); } //$NON-NLS-1$
+ case 775 : if (DEBUG) { System.out.println("ShiftExpression_NotName ::= ShiftExpression_NotName..."); } //$NON-NLS-1$
consumeBinaryExpression(OperatorIds.LEFT_SHIFT);
break;
- case 774 : if (DEBUG) { System.out.println("ShiftExpression_NotName ::= Name LEFT_SHIFT..."); } //$NON-NLS-1$
+ case 776 : if (DEBUG) { System.out.println("ShiftExpression_NotName ::= Name LEFT_SHIFT..."); } //$NON-NLS-1$
consumeBinaryExpressionWithName(OperatorIds.LEFT_SHIFT);
break;
- case 775 : if (DEBUG) { System.out.println("ShiftExpression_NotName ::= ShiftExpression_NotName..."); } //$NON-NLS-1$
+ case 777 : if (DEBUG) { System.out.println("ShiftExpression_NotName ::= ShiftExpression_NotName..."); } //$NON-NLS-1$
consumeBinaryExpression(OperatorIds.RIGHT_SHIFT);
break;
- case 776 : if (DEBUG) { System.out.println("ShiftExpression_NotName ::= Name RIGHT_SHIFT..."); } //$NON-NLS-1$
+ case 778 : if (DEBUG) { System.out.println("ShiftExpression_NotName ::= Name RIGHT_SHIFT..."); } //$NON-NLS-1$
consumeBinaryExpressionWithName(OperatorIds.RIGHT_SHIFT);
break;
- case 777 : if (DEBUG) { System.out.println("ShiftExpression_NotName ::= ShiftExpression_NotName..."); } //$NON-NLS-1$
+ case 779 : if (DEBUG) { System.out.println("ShiftExpression_NotName ::= ShiftExpression_NotName..."); } //$NON-NLS-1$
consumeBinaryExpression(OperatorIds.UNSIGNED_RIGHT_SHIFT);
break;
- case 778 : if (DEBUG) { System.out.println("ShiftExpression_NotName ::= Name UNSIGNED_RIGHT_SHIFT..."); } //$NON-NLS-1$
+ case 780 : if (DEBUG) { System.out.println("ShiftExpression_NotName ::= Name UNSIGNED_RIGHT_SHIFT..."); } //$NON-NLS-1$
consumeBinaryExpressionWithName(OperatorIds.UNSIGNED_RIGHT_SHIFT);
break;
- case 780 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::= ShiftExpression_NotName"); } //$NON-NLS-1$
+ case 782 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::= ShiftExpression_NotName"); } //$NON-NLS-1$
consumeBinaryExpression(OperatorIds.LESS);
break;
- case 781 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::= Name LESS..."); } //$NON-NLS-1$
+ case 783 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::= Name LESS..."); } //$NON-NLS-1$
consumeBinaryExpressionWithName(OperatorIds.LESS);
break;
- case 782 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::= ShiftExpression_NotName"); } //$NON-NLS-1$
+ case 784 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::= ShiftExpression_NotName"); } //$NON-NLS-1$
consumeBinaryExpression(OperatorIds.GREATER);
break;
- case 783 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::= Name GREATER..."); } //$NON-NLS-1$
+ case 785 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::= Name GREATER..."); } //$NON-NLS-1$
consumeBinaryExpressionWithName(OperatorIds.GREATER);
break;
- case 784 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::=..."); } //$NON-NLS-1$
+ case 786 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::=..."); } //$NON-NLS-1$
consumeBinaryExpression(OperatorIds.LESS_EQUAL);
break;
- case 785 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::= Name LESS_EQUAL..."); } //$NON-NLS-1$
+ case 787 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::= Name LESS_EQUAL..."); } //$NON-NLS-1$
consumeBinaryExpressionWithName(OperatorIds.LESS_EQUAL);
break;
- case 786 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::=..."); } //$NON-NLS-1$
+ case 788 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::=..."); } //$NON-NLS-1$
consumeBinaryExpression(OperatorIds.GREATER_EQUAL);
break;
- case 787 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::= Name GREATER_EQUAL..."); } //$NON-NLS-1$
+ case 789 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::= Name GREATER_EQUAL..."); } //$NON-NLS-1$
consumeBinaryExpressionWithName(OperatorIds.GREATER_EQUAL);
break;
- case 789 : if (DEBUG) { System.out.println("InstanceofExpression_NotName ::= Name instanceof..."); } //$NON-NLS-1$
+ case 791 : if (DEBUG) { System.out.println("InstanceofExpression_NotName ::= Name instanceof..."); } //$NON-NLS-1$
consumeInstanceOfExpressionWithName();
break;
- case 790 : if (DEBUG) { System.out.println("InstanceofExpression_NotName ::=..."); } //$NON-NLS-1$
+ case 792 : if (DEBUG) { System.out.println("InstanceofExpression_NotName ::=..."); } //$NON-NLS-1$
consumeInstanceOfExpression();
break;
- case 792 : if (DEBUG) { System.out.println("EqualityExpression_NotName ::=..."); } //$NON-NLS-1$
+ case 794 : if (DEBUG) { System.out.println("EqualityExpression_NotName ::=..."); } //$NON-NLS-1$
consumeEqualityExpression(OperatorIds.EQUAL_EQUAL);
break;
- case 793 : if (DEBUG) { System.out.println("EqualityExpression_NotName ::= Name EQUAL_EQUAL..."); } //$NON-NLS-1$
+ case 795 : if (DEBUG) { System.out.println("EqualityExpression_NotName ::= Name EQUAL_EQUAL..."); } //$NON-NLS-1$
consumeEqualityExpressionWithName(OperatorIds.EQUAL_EQUAL);
break;
- case 794 : if (DEBUG) { System.out.println("EqualityExpression_NotName ::=..."); } //$NON-NLS-1$
+ case 796 : if (DEBUG) { System.out.println("EqualityExpression_NotName ::=..."); } //$NON-NLS-1$
consumeEqualityExpression(OperatorIds.NOT_EQUAL);
break;
- case 795 : if (DEBUG) { System.out.println("EqualityExpression_NotName ::= Name NOT_EQUAL..."); } //$NON-NLS-1$
+ case 797 : if (DEBUG) { System.out.println("EqualityExpression_NotName ::= Name NOT_EQUAL..."); } //$NON-NLS-1$
consumeEqualityExpressionWithName(OperatorIds.NOT_EQUAL);
break;
- case 797 : if (DEBUG) { System.out.println("AndExpression_NotName ::= AndExpression_NotName AND..."); } //$NON-NLS-1$
+ case 799 : if (DEBUG) { System.out.println("AndExpression_NotName ::= AndExpression_NotName AND..."); } //$NON-NLS-1$
consumeBinaryExpression(OperatorIds.AND);
break;
- case 798 : if (DEBUG) { System.out.println("AndExpression_NotName ::= Name AND EqualityExpression"); } //$NON-NLS-1$
+ case 800 : if (DEBUG) { System.out.println("AndExpression_NotName ::= Name AND EqualityExpression"); } //$NON-NLS-1$
consumeBinaryExpressionWithName(OperatorIds.AND);
break;
- case 800 : if (DEBUG) { System.out.println("ExclusiveOrExpression_NotName ::=..."); } //$NON-NLS-1$
+ case 802 : if (DEBUG) { System.out.println("ExclusiveOrExpression_NotName ::=..."); } //$NON-NLS-1$
consumeBinaryExpression(OperatorIds.XOR);
break;
- case 801 : if (DEBUG) { System.out.println("ExclusiveOrExpression_NotName ::= Name XOR AndExpression"); } //$NON-NLS-1$
+ case 803 : if (DEBUG) { System.out.println("ExclusiveOrExpression_NotName ::= Name XOR AndExpression"); } //$NON-NLS-1$
consumeBinaryExpressionWithName(OperatorIds.XOR);
break;
- case 803 : if (DEBUG) { System.out.println("InclusiveOrExpression_NotName ::=..."); } //$NON-NLS-1$
+ case 805 : if (DEBUG) { System.out.println("InclusiveOrExpression_NotName ::=..."); } //$NON-NLS-1$
consumeBinaryExpression(OperatorIds.OR);
break;
- case 804 : if (DEBUG) { System.out.println("InclusiveOrExpression_NotName ::= Name OR..."); } //$NON-NLS-1$
+ case 806 : if (DEBUG) { System.out.println("InclusiveOrExpression_NotName ::= Name OR..."); } //$NON-NLS-1$
consumeBinaryExpressionWithName(OperatorIds.OR);
break;
- case 806 : if (DEBUG) { System.out.println("ConditionalAndExpression_NotName ::=..."); } //$NON-NLS-1$
+ case 808 : if (DEBUG) { System.out.println("ConditionalAndExpression_NotName ::=..."); } //$NON-NLS-1$
consumeBinaryExpression(OperatorIds.AND_AND);
break;
- case 807 : if (DEBUG) { System.out.println("ConditionalAndExpression_NotName ::= Name AND_AND..."); } //$NON-NLS-1$
+ case 809 : if (DEBUG) { System.out.println("ConditionalAndExpression_NotName ::= Name AND_AND..."); } //$NON-NLS-1$
consumeBinaryExpressionWithName(OperatorIds.AND_AND);
break;
- case 809 : if (DEBUG) { System.out.println("ConditionalOrExpression_NotName ::=..."); } //$NON-NLS-1$
+ case 811 : if (DEBUG) { System.out.println("ConditionalOrExpression_NotName ::=..."); } //$NON-NLS-1$
consumeBinaryExpression(OperatorIds.OR_OR);
break;
- case 810 : if (DEBUG) { System.out.println("ConditionalOrExpression_NotName ::= Name OR_OR..."); } //$NON-NLS-1$
+ case 812 : if (DEBUG) { System.out.println("ConditionalOrExpression_NotName ::= Name OR_OR..."); } //$NON-NLS-1$
consumeBinaryExpressionWithName(OperatorIds.OR_OR);
break;
- case 812 : if (DEBUG) { System.out.println("ConditionalExpression_NotName ::=..."); } //$NON-NLS-1$
+ case 814 : if (DEBUG) { System.out.println("ConditionalExpression_NotName ::=..."); } //$NON-NLS-1$
consumeConditionalExpression(OperatorIds.QUESTIONCOLON) ;
break;
- case 813 : if (DEBUG) { System.out.println("ConditionalExpression_NotName ::= Name QUESTION..."); } //$NON-NLS-1$
+ case 815 : if (DEBUG) { System.out.println("ConditionalExpression_NotName ::= Name QUESTION..."); } //$NON-NLS-1$
consumeConditionalExpressionWithName(OperatorIds.QUESTIONCOLON) ;
break;
- case 817 : if (DEBUG) { System.out.println("AnnotationTypeDeclarationHeaderName ::= Modifiers AT..."); } //$NON-NLS-1$
+ case 819 : if (DEBUG) { System.out.println("AnnotationTypeDeclarationHeaderName ::= Modifiers AT..."); } //$NON-NLS-1$
consumeAnnotationTypeDeclarationHeaderName() ;
break;
- case 818 : if (DEBUG) { System.out.println("AnnotationTypeDeclarationHeaderName ::= Modifiers AT..."); } //$NON-NLS-1$
+ case 820 : if (DEBUG) { System.out.println("AnnotationTypeDeclarationHeaderName ::= Modifiers AT..."); } //$NON-NLS-1$
consumeAnnotationTypeDeclarationHeaderNameWithTypeParameters() ;
break;
- case 819 : if (DEBUG) { System.out.println("AnnotationTypeDeclarationHeaderName ::= AT..."); } //$NON-NLS-1$
+ case 821 : if (DEBUG) { System.out.println("AnnotationTypeDeclarationHeaderName ::= AT..."); } //$NON-NLS-1$
consumeAnnotationTypeDeclarationHeaderNameWithTypeParameters() ;
break;
- case 820 : if (DEBUG) { System.out.println("AnnotationTypeDeclarationHeaderName ::= AT..."); } //$NON-NLS-1$
+ case 822 : if (DEBUG) { System.out.println("AnnotationTypeDeclarationHeaderName ::= AT..."); } //$NON-NLS-1$
consumeAnnotationTypeDeclarationHeaderName() ;
break;
- case 821 : if (DEBUG) { System.out.println("AnnotationTypeDeclarationHeader ::=..."); } //$NON-NLS-1$
+ case 823 : if (DEBUG) { System.out.println("AnnotationTypeDeclarationHeader ::=..."); } //$NON-NLS-1$
consumeAnnotationTypeDeclarationHeader() ;
break;
- case 822 : if (DEBUG) { System.out.println("AnnotationTypeDeclaration ::=..."); } //$NON-NLS-1$
+ case 824 : if (DEBUG) { System.out.println("AnnotationTypeDeclaration ::=..."); } //$NON-NLS-1$
consumeAnnotationTypeDeclaration() ;
break;
- case 824 : if (DEBUG) { System.out.println("AnnotationTypeMemberDeclarationsopt ::="); } //$NON-NLS-1$
+ case 826 : if (DEBUG) { System.out.println("AnnotationTypeMemberDeclarationsopt ::="); } //$NON-NLS-1$
consumeEmptyAnnotationTypeMemberDeclarationsopt() ;
break;
- case 825 : if (DEBUG) { System.out.println("AnnotationTypeMemberDeclarationsopt ::= NestedType..."); } //$NON-NLS-1$
+ case 827 : if (DEBUG) { System.out.println("AnnotationTypeMemberDeclarationsopt ::= NestedType..."); } //$NON-NLS-1$
consumeAnnotationTypeMemberDeclarationsopt() ;
break;
- case 827 : if (DEBUG) { System.out.println("AnnotationTypeMemberDeclarations ::=..."); } //$NON-NLS-1$
+ case 829 : if (DEBUG) { System.out.println("AnnotationTypeMemberDeclarations ::=..."); } //$NON-NLS-1$
consumeAnnotationTypeMemberDeclarations() ;
break;
- case 828 : if (DEBUG) { System.out.println("AnnotationMethodHeaderName ::= Modifiersopt..."); } //$NON-NLS-1$
+ case 830 : if (DEBUG) { System.out.println("AnnotationMethodHeaderName ::= Modifiersopt..."); } //$NON-NLS-1$
consumeMethodHeaderNameWithTypeParameters(true);
break;
- case 829 : if (DEBUG) { System.out.println("AnnotationMethodHeaderName ::= Modifiersopt Type..."); } //$NON-NLS-1$
+ case 831 : if (DEBUG) { System.out.println("AnnotationMethodHeaderName ::= Modifiersopt Type..."); } //$NON-NLS-1$
consumeMethodHeaderName(true);
break;
- case 830 : if (DEBUG) { System.out.println("AnnotationMethodHeaderDefaultValueopt ::="); } //$NON-NLS-1$
+ case 832 : if (DEBUG) { System.out.println("AnnotationMethodHeaderDefaultValueopt ::="); } //$NON-NLS-1$
consumeEmptyMethodHeaderDefaultValue() ;
break;
- case 831 : if (DEBUG) { System.out.println("AnnotationMethodHeaderDefaultValueopt ::= DefaultValue"); } //$NON-NLS-1$
+ case 833 : if (DEBUG) { System.out.println("AnnotationMethodHeaderDefaultValueopt ::= DefaultValue"); } //$NON-NLS-1$
consumeMethodHeaderDefaultValue();
break;
- case 832 : if (DEBUG) { System.out.println("AnnotationMethodHeader ::= AnnotationMethodHeaderName..."); } //$NON-NLS-1$
+ case 834 : if (DEBUG) { System.out.println("AnnotationMethodHeader ::= AnnotationMethodHeaderName..."); } //$NON-NLS-1$
consumeMethodHeader();
break;
- case 833 : if (DEBUG) { System.out.println("AnnotationTypeMemberDeclaration ::=..."); } //$NON-NLS-1$
+ case 835 : if (DEBUG) { System.out.println("AnnotationTypeMemberDeclaration ::=..."); } //$NON-NLS-1$
consumeAnnotationTypeMemberDeclaration() ;
break;
- case 841 : if (DEBUG) { System.out.println("AnnotationName ::= AT UnannotatableName"); } //$NON-NLS-1$
+ case 843 : if (DEBUG) { System.out.println("AnnotationName ::= AT UnannotatableName"); } //$NON-NLS-1$
consumeAnnotationName() ;
break;
- case 842 : if (DEBUG) { System.out.println("NormalAnnotation ::= AnnotationName LPAREN..."); } //$NON-NLS-1$
+ case 844 : if (DEBUG) { System.out.println("NormalAnnotation ::= AnnotationName LPAREN..."); } //$NON-NLS-1$
consumeNormalAnnotation(false) ;
break;
- case 843 : if (DEBUG) { System.out.println("MemberValuePairsopt ::="); } //$NON-NLS-1$
+ case 845 : if (DEBUG) { System.out.println("MemberValuePairsopt ::="); } //$NON-NLS-1$
consumeEmptyMemberValuePairsopt() ;
break;
- case 846 : if (DEBUG) { System.out.println("MemberValuePairs ::= MemberValuePairs COMMA..."); } //$NON-NLS-1$
+ case 848 : if (DEBUG) { System.out.println("MemberValuePairs ::= MemberValuePairs COMMA..."); } //$NON-NLS-1$
consumeMemberValuePairs() ;
break;
- case 847 : if (DEBUG) { System.out.println("MemberValuePair ::= SimpleName EQUAL EnterMemberValue..."); } //$NON-NLS-1$
+ case 849 : if (DEBUG) { System.out.println("MemberValuePair ::= SimpleName EQUAL EnterMemberValue..."); } //$NON-NLS-1$
consumeMemberValuePair() ;
break;
- case 848 : if (DEBUG) { System.out.println("EnterMemberValue ::="); } //$NON-NLS-1$
+ case 850 : if (DEBUG) { System.out.println("EnterMemberValue ::="); } //$NON-NLS-1$
consumeEnterMemberValue() ;
break;
- case 849 : if (DEBUG) { System.out.println("ExitMemberValue ::="); } //$NON-NLS-1$
+ case 851 : if (DEBUG) { System.out.println("ExitMemberValue ::="); } //$NON-NLS-1$
consumeExitMemberValue() ;
break;
- case 851 : if (DEBUG) { System.out.println("MemberValue ::= Name"); } //$NON-NLS-1$
+ case 853 : if (DEBUG) { System.out.println("MemberValue ::= Name"); } //$NON-NLS-1$
consumeMemberValueAsName() ;
break;
- case 854 : if (DEBUG) { System.out.println("MemberValueArrayInitializer ::=..."); } //$NON-NLS-1$
+ case 856 : if (DEBUG) { System.out.println("MemberValueArrayInitializer ::=..."); } //$NON-NLS-1$
consumeMemberValueArrayInitializer() ;
break;
- case 855 : if (DEBUG) { System.out.println("MemberValueArrayInitializer ::=..."); } //$NON-NLS-1$
+ case 857 : if (DEBUG) { System.out.println("MemberValueArrayInitializer ::=..."); } //$NON-NLS-1$
consumeMemberValueArrayInitializer() ;
break;
- case 856 : if (DEBUG) { System.out.println("MemberValueArrayInitializer ::=..."); } //$NON-NLS-1$
+ case 858 : if (DEBUG) { System.out.println("MemberValueArrayInitializer ::=..."); } //$NON-NLS-1$
consumeEmptyMemberValueArrayInitializer() ;
break;
- case 857 : if (DEBUG) { System.out.println("MemberValueArrayInitializer ::=..."); } //$NON-NLS-1$
+ case 859 : if (DEBUG) { System.out.println("MemberValueArrayInitializer ::=..."); } //$NON-NLS-1$
consumeEmptyMemberValueArrayInitializer() ;
break;
- case 858 : if (DEBUG) { System.out.println("EnterMemberValueArrayInitializer ::="); } //$NON-NLS-1$
+ case 860 : if (DEBUG) { System.out.println("EnterMemberValueArrayInitializer ::="); } //$NON-NLS-1$
consumeEnterMemberValueArrayInitializer() ;
break;
- case 860 : if (DEBUG) { System.out.println("MemberValues ::= MemberValues COMMA MemberValue"); } //$NON-NLS-1$
+ case 862 : if (DEBUG) { System.out.println("MemberValues ::= MemberValues COMMA MemberValue"); } //$NON-NLS-1$
consumeMemberValues() ;
break;
- case 861 : if (DEBUG) { System.out.println("MarkerAnnotation ::= AnnotationName"); } //$NON-NLS-1$
+ case 863 : if (DEBUG) { System.out.println("MarkerAnnotation ::= AnnotationName"); } //$NON-NLS-1$
consumeMarkerAnnotation(false) ;
break;
- case 862 : if (DEBUG) { System.out.println("SingleMemberAnnotationMemberValue ::= MemberValue"); } //$NON-NLS-1$
+ case 864 : if (DEBUG) { System.out.println("SingleMemberAnnotationMemberValue ::= MemberValue"); } //$NON-NLS-1$
consumeSingleMemberAnnotationMemberValue() ;
break;
- case 863 : if (DEBUG) { System.out.println("SingleMemberAnnotation ::= AnnotationName LPAREN..."); } //$NON-NLS-1$
+ case 865 : if (DEBUG) { System.out.println("SingleMemberAnnotation ::= AnnotationName LPAREN..."); } //$NON-NLS-1$
consumeSingleMemberAnnotation(false) ;
break;
- case 864 : if (DEBUG) { System.out.println("RecoveryMethodHeaderName ::= Modifiersopt TypeParameters"); } //$NON-NLS-1$
+ case 866 : if (DEBUG) { System.out.println("RecoveryMethodHeaderName ::= Modifiersopt TypeParameters"); } //$NON-NLS-1$
consumeRecoveryMethodHeaderNameWithTypeParameters();
break;
- case 865 : if (DEBUG) { System.out.println("RecoveryMethodHeaderName ::= Modifiersopt Type..."); } //$NON-NLS-1$
+ case 867 : if (DEBUG) { System.out.println("RecoveryMethodHeaderName ::= Modifiersopt Type..."); } //$NON-NLS-1$
consumeRecoveryMethodHeaderName();
break;
- case 866 : if (DEBUG) { System.out.println("RecoveryMethodHeaderName ::= ModifiersWithDefault..."); } //$NON-NLS-1$
+ case 868 : if (DEBUG) { System.out.println("RecoveryMethodHeaderName ::= ModifiersWithDefault..."); } //$NON-NLS-1$
consumeRecoveryMethodHeaderNameWithTypeParameters();
break;
- case 867 : if (DEBUG) { System.out.println("RecoveryMethodHeaderName ::= ModifiersWithDefault Type"); } //$NON-NLS-1$
+ case 869 : if (DEBUG) { System.out.println("RecoveryMethodHeaderName ::= ModifiersWithDefault Type"); } //$NON-NLS-1$
consumeRecoveryMethodHeaderName();
break;
- case 868 : if (DEBUG) { System.out.println("RecoveryMethodHeader ::= RecoveryMethodHeaderName..."); } //$NON-NLS-1$
+ case 870 : if (DEBUG) { System.out.println("RecoveryMethodHeader ::= RecoveryMethodHeaderName..."); } //$NON-NLS-1$
consumeMethodHeader();
break;
- case 869 : if (DEBUG) { System.out.println("RecoveryMethodHeader ::= RecoveryMethodHeaderName..."); } //$NON-NLS-1$
+ case 871 : if (DEBUG) { System.out.println("RecoveryMethodHeader ::= RecoveryMethodHeaderName..."); } //$NON-NLS-1$
consumeMethodHeader();
break;
@@ -9108,22 +9114,18 @@ protected void consumeStatementBreakWithLabel() {
this.endStatementPosition));
this.identifierLengthPtr--;
}
-protected void consumeStatementBreakWithExpressionOrLabel() {
-// add the compliance check
- if (this.expressionLengthStack[this.expressionLengthPtr--] != 0) {
- Expression expr = this.expressionStack[this.expressionPtr--];
- char[] labelOrExpr = expr instanceof Literal ?
- ((Literal) expr).source() : expr instanceof SingleNameReference ? ((SingleNameReference) expr).token : null;
- BreakStatement breakStatement = new BreakStatement(
- labelOrExpr,
- this.intStack[this.intPtr--],
- this.endStatementPosition);
- pushOnAstStack(breakStatement);
- breakStatement.expression = expr; // need to figure out later whether this is a label or an expression.
- if (expr instanceof SingleNameReference) {
- ((SingleNameReference) expr).isLabel = true;
+protected void consumeStatementYield() {
+ // YieldStatement ::= RestrictedIdentifierYield Expression ';'
+
+ // add the compliance check
+ if (this.expressionLengthStack[this.expressionLengthPtr--] != 0) {
+ Expression expr = this.expressionStack[this.expressionPtr--];
+ YieldStatement yieldStatement = new YieldStatement(
+ expr,
+ this.intStack[this.intPtr--],
+ this.endStatementPosition);
+ pushOnAstStack(yieldStatement);
}
- }
}
protected void consumeStatementCatch() {
// CatchClause ::= 'catch' '(' FormalParameter ')' Block
@@ -9301,8 +9303,8 @@ protected void consumeStatementReturn() {
pushOnAstStack(new ReturnStatement(null, this.intStack[this.intPtr--], this.endStatementPosition));
}
}
-private void createSwitchStatementOrExpression(boolean isStmt) {
-
+private SwitchStatement createSwitchStatementOrExpression(boolean isStmt) {
+
//OpenBlock just makes the semantic action blockStart()
//the block is inlined but a scope need to be created
//if some declaration occurs.
@@ -9329,7 +9331,8 @@ private void createSwitchStatementOrExpression(boolean isStmt) {
switchStatement.sourceEnd = this.endStatementPosition;
if (length == 0 && !containsComment(switchStatement.blockStart, switchStatement.sourceEnd)) {
switchStatement.bits |= ASTNode.UndocumentedEmptyBlock;
- }
+ }
+ return switchStatement;
}
protected void consumeStatementSwitch() {
// SwitchStatement ::= 'switch' OpenBlock '(' Expression ')' SwitchBlock
@@ -9527,6 +9530,41 @@ protected void consumeStaticOnly() {
this.recoveredStaticInitializerStart = this.intStack[this.intPtr]; // remember start position only for static initializers
}
}
+protected void consumeTextBlock() {
+ if (!this.parsingJava13Plus) {
+ problemReporter().previewFeatureNotSupported(this.scanner.startPosition, this.scanner.currentPosition - 1, "Text Blocks", CompilerOptions.VERSION_13); //$NON-NLS-1$
+ } else if (!this.options.enablePreviewFeatures){
+ problemReporter().previewFeatureNotEnabled(this.scanner.startPosition, this.scanner.currentPosition - 1, "Text Blocks"); //$NON-NLS-1$
+ } else {
+ if (this.options.isAnyEnabled(IrritantSet.PREVIEW)) {
+ problemReporter().previewFeatureUsed(this.scanner.startPosition, this.scanner.currentPosition - 1);
+ }
+ }
+ char[] textBlock2 = this.scanner.getCurrentTextBlock();
+ TextBlock textBlock;
+ if (this.recordStringLiterals &&
+ !this.reparsingLambdaExpression &&
+ this.checkExternalizeStrings &&
+ this.lastPosistion < this.scanner.currentPosition &&
+ !this.statementRecoveryActivated) {
+ textBlock =
+ new TextBlock(
+ textBlock2,
+ this.scanner.startPosition,
+ this.scanner.currentPosition - 1,
+ Util.getLineNumber(this.scanner.startPosition, this.scanner.lineEnds, 0, this.scanner.linePtr));
+ // TODO
+ //this.compilationUnit.recordStringLiteral(stringLiteral, this.currentElement != null);
+ } else {
+ textBlock = new TextBlock(
+ textBlock2,
+ this.scanner.startPosition,
+ this.scanner.currentPosition - 1,
+ 0);
+ }
+ pushOnExpressionStack(textBlock);
+ // Regardless of the error reported above, we have to push the ast node accordingly
+}
protected void consumeSwitchBlock() {
// SwitchBlock ::= '{' SwitchBlockStatements SwitchLabels '}'
concatNodeLists();
@@ -9545,14 +9583,15 @@ protected void consumeSwitchLabels() {
optimizedConcatNodeLists();
}
protected void consumeSwitchLabelCaseLhs() {
-// System.out.println("consumeSwitchLabelCaseLhs");
+ if (this.scanner.lookBack[1] == TerminalTokens.TokenNameCOLON) // kludge for yield :(
+ this.scanner.yieldColons = 1;
}
protected void consumeCaseLabelExpr() {
// SwitchLabelExpr ::= SwitchLabelCaseLhs BeginCaseExpr '->'
consumeCaseLabel();
CaseStatement caseStatement = (CaseStatement) this.astStack[this.astPtr];
- if (!this.parsingJava12Plus) {
- problemReporter().previewFeatureNotSupported(caseStatement.sourceStart, caseStatement.sourceEnd, "Case Labels with '->'", CompilerOptions.VERSION_12); //$NON-NLS-1$
+ if (!this.parsingJava13Plus) {
+ problemReporter().previewFeatureNotSupported(caseStatement.sourceStart, caseStatement.sourceEnd, "Case Labels with '->'", CompilerOptions.VERSION_13); //$NON-NLS-1$
} else if (!this.options.enablePreviewFeatures){
problemReporter().previewFeatureNotEnabled(caseStatement.sourceStart, caseStatement.sourceEnd, "Case Labels with '->'"); //$NON-NLS-1$
} else {
@@ -9566,8 +9605,8 @@ protected void consumeDefaultLabelExpr() {
// SwitchLabelDefaultExpr ::= 'default' '->'
consumeDefaultLabel();
CaseStatement defaultStatement = (CaseStatement) this.astStack[this.astPtr];
- if (!this.parsingJava12Plus) {
- problemReporter().previewFeatureNotSupported(defaultStatement.sourceStart, defaultStatement.sourceEnd, "Case Labels with '->'", CompilerOptions.VERSION_12); //$NON-NLS-1$
+ if (!this.parsingJava13Plus) {
+ problemReporter().previewFeatureNotSupported(defaultStatement.sourceStart, defaultStatement.sourceEnd, "Case Labels with '->'", CompilerOptions.VERSION_13); //$NON-NLS-1$
} else if (!this.options.enablePreviewFeatures){
problemReporter().previewFeatureNotEnabled(defaultStatement.sourceStart, defaultStatement.sourceEnd, "Case Labels with '->'"); //$NON-NLS-1$
} else {
@@ -9577,7 +9616,7 @@ protected void consumeDefaultLabelExpr() {
}
defaultStatement.isExpr = true;
}
-/* package */ void collectResultExpressions(SwitchExpression s) {
+/* package */ void collectResultExpressionsYield(SwitchExpression s) {
if (s.resultExpressions != null)
return; // already calculated.
@@ -9600,34 +9639,18 @@ protected void consumeDefaultLabelExpr() {
this.targetSwitchExpressions.pop();
}
@Override
- public boolean visit(BreakStatement breakStatement, BlockScope blockScope) {
+ public boolean visit(YieldStatement yieldStatement, BlockScope blockScope) {
SwitchExpression targetSwitchExpression = this.targetSwitchExpressions.peek();
- if (breakStatement.expression != null) {
- targetSwitchExpression.resultExpressions.add(breakStatement.expression);
- breakStatement.switchExpression = this.targetSwitchExpressions.peek();
- breakStatement.label = null; // not a label, but an expression
- if (breakStatement.expression instanceof SingleNameReference) {
- ((SingleNameReference) breakStatement.expression).isLabel = false;
- }
+ if (yieldStatement.expression != null) {
+ targetSwitchExpression.resultExpressions.add(yieldStatement.expression);
+ yieldStatement.switchExpression = this.targetSwitchExpressions.peek();
} else {
// flag an error while resolving
- breakStatement.switchExpression = targetSwitchExpression;
+ yieldStatement.switchExpression = targetSwitchExpression;
}
return true;
}
@Override
- public boolean visit(DoStatement stmt, BlockScope blockScope) {
- return false;
- }
- @Override
- public boolean visit(ForStatement stmt, BlockScope blockScope) {
- return false;
- }
- @Override
- public boolean visit(ForeachStatement stmt, BlockScope blockScope) {
- return false;
- }
- @Override
public boolean visit(SwitchStatement stmt, BlockScope blockScope) {
return false;
}
@@ -9635,14 +9658,6 @@ protected void consumeDefaultLabelExpr() {
public boolean visit(TypeDeclaration stmt, BlockScope blockScope) {
return false;
}
- @Override
- public boolean visit(WhileStatement stmt, BlockScope blockScope) {
- return false;
- }
- @Override
- public boolean visit(CaseStatement caseStatement, BlockScope blockScope) {
- return true; // do nothing by default, keep traversing
- }
}
s.resultExpressions = new ArrayList<>(0); // indicates processed
int l = s.statements == null ? 0 : s.statements.length;
@@ -9671,8 +9686,8 @@ protected void consumeSwitchExpression() {
if (this.astLengthStack[this.astLengthPtr--] != 0) {
SwitchExpression s = (SwitchExpression) this.astStack[this.astPtr--];
- if (!this.parsingJava12Plus) {
- problemReporter().previewFeatureNotSupported(s.sourceStart, s.sourceEnd, "Switch Expressions", CompilerOptions.VERSION_12); //$NON-NLS-1$
+ if (!this.parsingJava13Plus) {
+ problemReporter().previewFeatureNotSupported(s.sourceStart, s.sourceEnd, "Switch Expressions", CompilerOptions.VERSION_13); //$NON-NLS-1$
} else if (!this.options.enablePreviewFeatures) {
problemReporter().previewFeatureNotEnabled(s.sourceStart, s.sourceEnd, "Switch Expressions"); //$NON-NLS-1$
} else {
@@ -9680,7 +9695,7 @@ protected void consumeSwitchExpression() {
problemReporter().previewFeatureUsed(s.sourceStart, s.sourceEnd);
}
}
- collectResultExpressions(s);
+ collectResultExpressionsYield(s);
pushOnExpressionStack(s);
}
}
@@ -9712,13 +9727,12 @@ protected void consumeSwitchLabeledRuleToBlockStatement() {
protected void consumeSwitchLabeledExpression() {
consumeExpressionStatement();
Expression expr = (Expression) this.astStack[this.astPtr];
- BreakStatement breakStatement = new BreakStatement(
- null,
+ YieldStatement yieldStatement = new YieldStatement(
+ expr,
expr.sourceStart,
this.endStatementPosition);
- breakStatement.isImplicit = true;
- breakStatement.expression = expr;
- this.astStack[this.astPtr] = breakStatement;
+ yieldStatement.isImplicit = true;
+ this.astStack[this.astPtr] = yieldStatement;
concatNodeLists();
}
protected void consumeSwitchLabeledBlock() {
@@ -9756,7 +9770,7 @@ protected void consumeToken(int type) {
//System.out.println(this.scanner.toStringAction(type));
switch (type) {
case TokenNameARROW:
- if (!this.caseFlagSet && this.scanner.lookBack[0] != TokenNamedefault)
+ if (!this.caseFlagSet && this.scanner.lookBack[0] != TokenNamedefault)
consumeLambdaHeader();
this.caseFlagSet = false;
break;
@@ -9950,6 +9964,9 @@ protected void consumeToken(int type) {
}
pushOnExpressionStack(stringLiteral);
break;
+ case TokenNameTextBlock :
+ consumeTextBlock();
+ break;
case TokenNamefalse :
pushOnExpressionStack(
new FalseLiteral(this.scanner.startPosition, this.scanner.currentPosition - 1));
@@ -9989,6 +10006,7 @@ protected void consumeToken(int type) {
case TokenNameopens:
case TokenNameuses:
case TokenNameprovides:
+ case TokenNameRestrictedIdentifierYield:
pushOnIntStack(this.scanner.startPosition);
break;
case TokenNameswitch :
@@ -13561,6 +13579,10 @@ public boolean automatonWillShift(int token, int lastAction) {
}
}
@Override
+public boolean isParsingJava13() {
+ return this.parsingJava13Plus;
+}
+@Override
public boolean isParsingModuleDeclaration() {
// It can be a null in case of a Vanguard parser, which means no module to be dealt with.
return (this.parsingJava9Plus && this.compilationUnit != null && this.compilationUnit.isModuleInfo());
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/ParserBasicInformation.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/ParserBasicInformation.java
index d8d8f26579..bf9a555f9e 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/ParserBasicInformation.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/ParserBasicInformation.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -19,22 +19,22 @@ public interface ParserBasicInformation {
public final static int
- ERROR_SYMBOL = 130,
+ ERROR_SYMBOL = 131,
MAX_NAME_LENGTH = 41,
NUM_STATES = 1168,
- NT_OFFSET = 130,
+ NT_OFFSET = 131,
SCOPE_UBOUND = 297,
SCOPE_SIZE = 298,
- LA_STATE_OFFSET = 16968,
+ LA_STATE_OFFSET = 16962,
MAX_LA = 1,
- NUM_RULES = 869,
- NUM_TERMINALS = 130,
- NUM_NON_TERMINALS = 397,
- NUM_SYMBOLS = 527,
- START_STATE = 1126,
- EOFT_SYMBOL = 61,
- EOLT_SYMBOL = 61,
- ACCEPT_ACTION = 16967,
- ERROR_ACTION = 16968;
+ NUM_RULES = 871,
+ NUM_TERMINALS = 131,
+ NUM_NON_TERMINALS = 398,
+ NUM_SYMBOLS = 529,
+ START_STATE = 1026,
+ EOFT_SYMBOL = 62,
+ EOLT_SYMBOL = 62,
+ ACCEPT_ACTION = 16961,
+ ERROR_ACTION = 16962;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java
index 883f9385ca..3963baab18 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -15,6 +15,9 @@
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.parser;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.compiler.InvalidInputException;
import org.eclipse.jdt.internal.compiler.CompilationResult;
@@ -108,6 +111,7 @@ public class Scanner implements TerminalTokens {
public boolean fakeInModule = false;
boolean inCase = false;
+ /* package */ int yieldColons = -1;
boolean breakPreviewAllowed = false;
/**
* The current context of the scanner w.r.t restricted keywords
@@ -118,7 +122,6 @@ public class Scanner implements TerminalTokens {
}
protected ScanContext scanContext = null;
protected boolean insideModuleInfo = false;
-
public static final String END_OF_SOURCE = "End_Of_Source"; //$NON-NLS-1$
public static final String INVALID_HEXA = "Invalid_Hexa_Literal"; //$NON-NLS-1$
@@ -126,6 +129,7 @@ public class Scanner implements TerminalTokens {
public static final String INVALID_CHARACTER_CONSTANT = "Invalid_Character_Constant"; //$NON-NLS-1$
public static final String INVALID_ESCAPE = "Invalid_Escape"; //$NON-NLS-1$
public static final String INVALID_INPUT = "Invalid_Input"; //$NON-NLS-1$
+ public static final String INVALID_TEXTBLOCK = "Invalid_Textblock"; //$NON-NLS-1$
public static final String INVALID_UNICODE_ESCAPE = "Invalid_Unicode_Escape"; //$NON-NLS-1$
public static final String INVALID_FLOAT = "Invalid_Float_Literal"; //$NON-NLS-1$
public static final String INVALID_LOW_SURROGATE = "Invalid_Low_Surrogate"; //$NON-NLS-1$
@@ -133,6 +137,7 @@ public class Scanner implements TerminalTokens {
public static final String NULL_SOURCE_STRING = "Null_Source_String"; //$NON-NLS-1$
public static final String UNTERMINATED_STRING = "Unterminated_String"; //$NON-NLS-1$
+ public static final String UNTERMINATED_TEXT_BLOCK = "Unterminated_Text_Block"; //$NON-NLS-1$
public static final String UNTERMINATED_COMMENT = "Unterminated_Comment"; //$NON-NLS-1$
public static final String INVALID_CHAR_IN_STRING = "Invalid_Char_In_String"; //$NON-NLS-1$
public static final String INVALID_DIGIT = "Invalid_Digit"; //$NON-NLS-1$
@@ -142,7 +147,7 @@ public class Scanner implements TerminalTokens {
public static final String BINARY_LITERAL_NOT_BELOW_17 = "Binary_Literal_Not_Below_17"; //$NON-NLS-1$
public static final String ILLEGAL_HEXA_LITERAL = "Illegal_Hexa_Literal"; //$NON-NLS-1$
public static final String INVALID_UNDERSCORE = "Invalid_Underscore"; //$NON-NLS-1$
- public static final String UNDERSCORES_IN_LITERALS_NOT_BELOW_17 = "Underscores_In_Literals_Not_Below_17"; //$NON-NLS-1$`
+ public static final String UNDERSCORES_IN_LITERALS_NOT_BELOW_17 = "Underscores_In_Literals_Not_Below_17"; //$NON-NLS-1$
//----------------optimized identifier managment------------------
static final char[] charArray_a = new char[] {'a'},
@@ -232,6 +237,9 @@ public class Scanner implements TerminalTokens {
public static final int HIGH_SURROGATE_MAX_VALUE = 0xDBFF;
public static final int LOW_SURROGATE_MAX_VALUE = 0xDFFF;
+ // raw string support - 11
+ /* package */ int rawStart = -1;
+
public Scanner() {
this(false /*comment*/, false /*whitespace*/, false /*nls*/, ClassFileConstants.JDK1_3 /*sourceLevel*/, null/*taskTag*/, null/*taskPriorities*/, true /*taskCaseSensitive*/);
}
@@ -567,6 +575,133 @@ public char[] getCurrentTokenSourceString() {
}
return result;
}
+protected final boolean scanForTextBlockBeginning() {
+ if (this.activeParser != null && !this.activeParser.isParsingJava13()) {
+ return false;
+ }
+ try {
+ // Don't change the position and current character unless we are certain
+ // to be dealing with a text block. For producing all errors like before
+ // in case of a valid """ but missing \r or \n, just return false and not
+ // throw any error.
+ int temp = this.currentPosition;
+ if ((this.source[temp++] == '\"' && this.source[temp++] == '\"')) {
+ char c = this.source[temp++];
+ while (ScannerHelper.isWhitespace(c)) {
+ switch (c) {
+ case 10 : /* \ u000a: LINE FEED */
+ case 13 : /* \ u000d: CARRIAGE RETURN */
+ this.currentCharacter = c;
+ this.currentPosition = temp;
+ return true;
+ default:
+ break;
+ }
+ c = this.source[temp++];
+ }
+ }
+ } catch(IndexOutOfBoundsException e) {
+ //let it return false;
+ }
+ return false;
+}
+protected final boolean scanForTextBlockClose() throws InvalidInputException {
+ try {
+ if (this.source[this.currentPosition] == '\"' && this.source[this.currentPosition + 1] == '\"') {
+ return true;
+ }
+ } catch(IndexOutOfBoundsException e) {
+ //let it return false;
+ }
+ return false;
+}
+public char[] getCurrentTextBlock() {
+ // 1. Normalize, i.e. convert all CR CRLF to LF
+ char[] all;
+ if (this.withoutUnicodePtr != 0) {
+ all = CharOperation.subarray(this.withoutUnicodeBuffer, this.rawStart + 1, this.withoutUnicodePtr + 1 );
+ } else {
+ all = CharOperation.subarray(this.source, this.startPosition + this.rawStart, this.currentPosition - 3);
+ if (all == null) {
+ all = new char[0];
+ }
+ }
+ // 2. Split into lines. Consider both \n and \r as line separators
+ char[][] lines = CharOperation.splitOn('\n', all);
+ int size = lines.length;
+ List<char[]> list = new ArrayList<>(lines.length);
+ for(int i = 0; i < lines.length; i++) {
+ char[] line = lines[i];
+ char[][] sub = CharOperation.splitOn('\r', line);
+ for (char[] cs : sub) {
+ if (cs.length > 0) {
+ list.add(cs);
+ }
+ }
+ }
+ size = list.size();
+ lines = list.toArray(new char[size][]);
+
+ // 3. Handle incidental white space
+ // 3.1. Split into lines and identify determining lines
+ int prefix = -1;
+ for(int i = 0; i < size; i++) {
+ char[] line = lines[i];
+ boolean blank = true;
+ int whitespaces = 0;
+ for (char c : line) {
+ if (blank) {
+ if (ScannerHelper.isWhitespace(c)) {
+ whitespaces++;
+ } else {
+ blank = false;
+ }
+ }
+ }
+ if (!blank) {
+ if (prefix < 0 || whitespaces < prefix) {
+ prefix = whitespaces;
+ }
+ }
+ }
+ // 3.2. Remove the common white space prefix
+ // 4. Handle escape sequences (already done while processing
+ if (prefix == -1)
+ prefix = 0;
+ char[] result = new char[0];
+ for(int i = 0; i < lines.length; i++) {
+ char[] l = lines[i];
+ // Remove the common prefix from each line
+ // And remove all trailing whitespace
+ // Finally append the \n at the end of the line (except the last line)
+ int length = l.length;
+ int trail = length - 1;
+ for(int j = trail; j>0; j--) {
+ if (!ScannerHelper.isWhitespace(l[j])) {
+ trail = j;
+ break;
+ }
+ }
+ int newSize = (length == 0 || prefix > trail) ? 0 : (trail - prefix + 1);
+ char[] nl;
+ if (i >= (size - 1)) {
+ if (trail <= 0 || newSize == 0)
+ continue;
+ nl = new char[newSize];
+ System.arraycopy(l, prefix, nl, 0, newSize);
+ } else {
+ newSize += 1;
+ nl = new char[newSize];
+ nl[newSize - 1] = '\n';
+ if (newSize > 1)
+ System.arraycopy(l, prefix, nl, 0, newSize - 1);
+ }
+ result = CharOperation.concat(result, nl);
+ }
+ // get rid of all the cached values
+ this.rawStart = -1;
+ return result;
+}
public final String getCurrentStringLiteral() {
//return the token REAL source (aka unicodes are precomputed).
//REMOVE the two " that are at the beginning and the end.
@@ -1194,8 +1329,7 @@ public int getNextToken() throws InvalidInputException {
if (this.activeParser == null) { // anybody interested in the grammatical structure of the program should have registered.
return token;
}
- if (token == TokenNameLPAREN || token == TokenNameLESS || token == TokenNameAT || token == TokenNameARROW
- || token == TokenNamebreak) {
+ if (token == TokenNameLPAREN || token == TokenNameLESS || token == TokenNameAT || token == TokenNameARROW) {
token = disambiguatedToken(token);
} else if (token == TokenNameELLIPSIS) {
this.consumingEllipsisAnnotations = false;
@@ -1433,6 +1567,7 @@ protected int getNextToken0() throws InvalidInputException {
case ':' :
if (getNextChar(':'))
return TokenNameCOLON_COLON;
+ ++this.yieldColons;
return TokenNameCOLON;
case '\'' :
{
@@ -1517,26 +1652,50 @@ protected int getNextToken0() throws InvalidInputException {
}
throw new InvalidInputException(INVALID_CHARACTER_CONSTANT);
case '"' :
+ boolean isTextBlock = false;
+ int lastQuotePos = 0;
try {
// consume next character
this.unicodeAsBackSlash = false;
boolean isUnicode = false;
- if (((this.currentCharacter = this.source[this.currentPosition++]) == '\\')
- && (this.source[this.currentPosition] == 'u')) {
- getNextUnicodeChar();
- isUnicode = true;
- } else {
- if (this.withoutUnicodePtr != 0) {
- unicodeStore();
+ isTextBlock = scanForTextBlockBeginning();
+ if (!isTextBlock) {
+ if (((this.currentCharacter = this.source[this.currentPosition++]) == '\\')
+ && (this.source[this.currentPosition] == 'u')) {
+ getNextUnicodeChar();
+ isUnicode = true;
+ } else {
+ if (this.withoutUnicodePtr != 0) {
+ unicodeStore();
+ }
}
}
-
- while (this.currentCharacter != '"') {
- if (this.currentPosition >= this.eofPosition) {
- throw new InvalidInputException(UNTERMINATED_STRING);
+ this.rawStart = this.currentPosition - this.startPosition;
+ int terminators = 0;
+ while (this.currentPosition <= this.eofPosition) {
+ if (this.currentCharacter == '"') {
+ if (!isTextBlock) {
+ return TerminalTokens.TokenNameStringLiteral;
+ }
+ lastQuotePos = this.currentPosition;
+ // look for text block delimiter
+ if (scanForTextBlockClose()) {
+ if (this.source[this.currentPosition + 2] == '"') {
+ terminators++;
+ if (terminators > 2)
+ throw new InvalidInputException(UNTERMINATED_TEXT_BLOCK);
+ } else {
+ this.currentPosition += 2;
+ return TerminalTokens.TokenNameTextBlock;
+ }
+ }
+ if (this.withoutUnicodePtr != 0) {
+ unicodeStore();
+ }
+ } else {
+ terminators = 0;
}
- /**** \r and \n are not valid in string literals ****/
- if ((this.currentCharacter == '\n') || (this.currentCharacter == '\r')) {
+ if (!isTextBlock && (this.currentCharacter == '\n' || this.currentCharacter == '\r')) {
// relocate if finding another quote fairly close: thus unicode '/u000D' will be fully consumed
if (isUnicode) {
int start = this.currentPosition;
@@ -1597,15 +1756,29 @@ protected int getNextToken0() throws InvalidInputException {
isUnicode = true;
} else {
isUnicode = false;
+ if (isTextBlock && this.currentCharacter == '"')
+ continue;
if (this.withoutUnicodePtr != 0) {
unicodeStore();
}
}
-
+ }
+ if (isTextBlock) {
+ if (lastQuotePos > 0)
+ this.currentPosition = lastQuotePos;
+ throw new InvalidInputException(UNTERMINATED_TEXT_BLOCK);
+ } else {
+ throw new InvalidInputException(UNTERMINATED_STRING);
}
} catch (IndexOutOfBoundsException e) {
- this.currentPosition--;
- throw new InvalidInputException(UNTERMINATED_STRING);
+ if (isTextBlock) {
+ if (lastQuotePos > 0)
+ this.currentPosition = lastQuotePos;
+ throw new InvalidInputException(UNTERMINATED_TEXT_BLOCK);
+ } else {
+ this.currentPosition--;
+ throw new InvalidInputException(UNTERMINATED_STRING);
+ }
} catch (InvalidInputException e) {
if (e.getMessage().equals(INVALID_ESCAPE)) {
// relocate if finding another quote fairly close: thus unicode '/u000D' will be fully consumed
@@ -1623,7 +1796,6 @@ protected int getNextToken0() throws InvalidInputException {
}
throw e; // rethrow
}
- return TokenNameStringLiteral;
case '/' :
if (!this.skipComments) {
int test = getNextChar('/', '*');
@@ -2046,10 +2218,13 @@ public final void jumpOverMethodBody() {
return;
}
if (this.currentCharacter == '\r'){
- if (this.source[this.currentPosition] == '\n') this.currentPosition++;
+ // For text block, we don't want to overlook \n. Hence, don't advance past \n
+ //if (this.source[this.currentPosition] == '\n') this.currentPosition++;
break NextToken; // the string cannot go further that the line
}
if (this.currentCharacter == '\n'){
+ // For text block, we don't want to overlook \n. Hence, go back one char
+ this.currentPosition--;
break; // the string cannot go further that the line
}
if (this.currentCharacter == '\\') {
@@ -3713,6 +3888,19 @@ private int internalScanIdentifierOrKeyword(int index, int length, char[] data)
return TokenNameIdentifier;
}
+ case 'y' :
+ switch (length) {
+ case 5 :
+ if ((data[++index] == 'i')
+ && (data[++index] == 'e')
+ && (data[++index] == 'l')
+ && (data[++index] == 'd'))
+ return disambiguatedRestrictedIdentifierYield(TokenNameRestrictedIdentifierYield);
+ //$FALL-THROUGH$
+ default :
+ return TokenNameIdentifier;
+ }
+
default :
return TokenNameIdentifier;
}
@@ -4053,6 +4241,7 @@ public final void setSource(char[] sourceString){
this.containsAssertKeyword = false;
this.linePtr = -1;
this.scanContext = null;
+ this.yieldColons = -1;
this.insideModuleInfo = false;
}
/*
@@ -4117,6 +4306,8 @@ public String toStringAction(int act) {
switch (act) {
case TokenNameIdentifier :
return "Identifier(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ case TokenNameRestrictedIdentifierYield :
+ return "yield"; //$NON-NLS-1$
case TokenNameabstract :
return "abstract"; //$NON-NLS-1$
case TokenNameboolean :
@@ -4232,7 +4423,8 @@ public String toStringAction(int act) {
return "Char(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
case TokenNameStringLiteral :
return "String(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
-
+ case TokenNameTextBlock :
+ return "String(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
case TokenNamePLUS_PLUS :
return "++"; //$NON-NLS-1$
case TokenNameMINUS_MINUS :
@@ -4376,6 +4568,7 @@ public static boolean isLiteral(int token) {
case TerminalTokens.TokenNameFloatingPointLiteral:
case TerminalTokens.TokenNameDoubleLiteral:
case TerminalTokens.TokenNameStringLiteral:
+ case TerminalTokens.TokenNameTextBlock:
case TerminalTokens.TokenNameCharacterLiteral:
return true;
default:
@@ -4436,6 +4629,9 @@ public static boolean isKeyword(int token) {
case TerminalTokens.TokenNamevolatile:
case TerminalTokens.TokenNamewhile:
return true;
+ case TerminalTokens.TokenNameRestrictedIdentifierYield:
+ // making explicit - yield not a (restricted) keyword but restricted identifier.
+ //$FALL-THROUGH$
default:
return false;
}
@@ -4488,12 +4684,14 @@ private static class Goal {
static int ReferenceExpressionRule = 0;
static int VarargTypeAnnotationsRule = 0;
static int BlockStatementoptRule = 0;
+ static int YieldStatementRule = 0;
static Goal LambdaParameterListGoal;
static Goal IntersectionCastGoal;
static Goal VarargTypeAnnotationGoal;
static Goal ReferenceExpressionGoal;
static Goal BlockStatementoptGoal;
+ static Goal YieldStatementGoal;
static {
@@ -4512,6 +4710,9 @@ private static class Goal {
else
if ("BlockStatementopt".equals(Parser.name[Parser.non_terminal_index[Parser.lhs[i]]])) //$NON-NLS-1$
BlockStatementoptRule = i;
+ else
+ if ("YieldStatement".equals(Parser.name[Parser.non_terminal_index[Parser.lhs[i]]])) //$NON-NLS-1$
+ YieldStatementRule = i;
}
@@ -4520,6 +4721,7 @@ private static class Goal {
VarargTypeAnnotationGoal = new Goal(TokenNameAT, new int[] { TokenNameELLIPSIS }, VarargTypeAnnotationsRule);
ReferenceExpressionGoal = new Goal(TokenNameLESS, new int[] { TokenNameCOLON_COLON }, ReferenceExpressionRule);
BlockStatementoptGoal = new Goal(TokenNameLBRACE, new int [0], BlockStatementoptRule);
+ YieldStatementGoal = new Goal(TokenNameARROW, new int [0], YieldStatementRule);
}
@@ -4548,7 +4750,7 @@ private static class Goal {
private static int [] followSetOfCast() {
return new int [] { TokenNameIdentifier, TokenNamenew, TokenNamesuper, TokenNamethis,
TokenNamefalse, TokenNametrue, TokenNamenull,
- TokenNameIntegerLiteral, TokenNameLongLiteral, TokenNameFloatingPointLiteral, TokenNameDoubleLiteral, TokenNameCharacterLiteral, TokenNameStringLiteral,
+ TokenNameIntegerLiteral, TokenNameLongLiteral, TokenNameFloatingPointLiteral, TokenNameDoubleLiteral, TokenNameCharacterLiteral, TokenNameStringLiteral, TokenNameTextBlock,
TokenNameNOT, TokenNameTWIDDLE, TokenNameLPAREN
};
}
@@ -4663,6 +4865,7 @@ private class ScanContextDetector extends VanguardParser {
};
this.scanner.recordLineSeparator = false;
this.scanner.setActiveParser(this);
+ this.scanner.previewEnabled = this.options.enablePreviewFeatures;
}
@Override
@@ -4805,6 +5008,101 @@ public static boolean isRestrictedKeyword(int token) {
return false;
}
}
+private boolean mayBeAtAnYieldStatement() {
+ // preceded by ;, {, }, ), or -> [Ref: http://mail.openjdk.java.net/pipermail/amber-spec-experts/2019-May/001401.html]
+ // above comment is super-seded by http://mail.openjdk.java.net/pipermail/amber-spec-experts/2019-May/001414.html
+ switch (this.lookBack[1]) {
+ case TokenNameLBRACE:
+ case TokenNameRBRACE:
+ case TokenNameRPAREN:
+ case TokenNameSEMICOLON:
+ case TokenNameelse:
+ case TokenNamedo:
+ return true;
+ case TokenNameCOLON:
+ return this.lookBack[0] == TokenNamedefault || this.yieldColons == 1;
+ case TokenNameDOT:
+ case TokenNameARROW:
+ default:
+ return false;
+ }
+}
+private boolean disambiguateYieldWithLookAhead() {
+ getVanguardParser();
+ this.vanguardScanner.resetTo(this.currentPosition, this.eofPosition - 1);
+ try {
+ int lookAhead1 = this.vanguardScanner.getNextToken();
+ switch (lookAhead1) {
+ case TokenNameEQUAL_EQUAL :
+ case TokenNameLESS_EQUAL :
+ case TokenNameGREATER_EQUAL :
+ case TokenNameNOT_EQUAL :
+ case TokenNameLEFT_SHIFT :
+ case TokenNameRIGHT_SHIFT :
+ case TokenNameUNSIGNED_RIGHT_SHIFT :
+ case TokenNamePLUS_EQUAL :
+ case TokenNameMINUS_EQUAL :
+ case TokenNameMULTIPLY_EQUAL :
+ case TokenNameDIVIDE_EQUAL :
+ case TokenNameAND_EQUAL :
+ case TokenNameOR_EQUAL :
+ case TokenNameXOR_EQUAL :
+ case TokenNameREMAINDER_EQUAL :
+ case TokenNameLEFT_SHIFT_EQUAL :
+ case TokenNameRIGHT_SHIFT_EQUAL :
+ case TokenNameUNSIGNED_RIGHT_SHIFT_EQUAL :
+ case TokenNameOR_OR :
+ case TokenNameAND_AND :
+ case TokenNameREMAINDER :
+ case TokenNameXOR :
+ case TokenNameAND :
+ case TokenNameMULTIPLY :
+ case TokenNameOR :
+ case TokenNameTWIDDLE :
+ case TokenNameDIVIDE :
+ case TokenNameGREATER :
+ case TokenNameLESS :
+ case TokenNameLBRACE :
+ case TokenNameRBRACE :
+ case TokenNameLBRACKET :
+ case TokenNameRBRACKET :
+ case TokenNameSEMICOLON :
+ case TokenNameQUESTION :
+ case TokenNameCOLON :
+ case TokenNameCOMMA :
+ case TokenNameDOT :
+ case TokenNameEQUAL :
+ case TokenNameAT :
+ case TokenNameELLIPSIS :
+ case TokenNameARROW :
+ case TokenNameCOLON_COLON :
+ return false;
+ case TokenNameMINUS_MINUS :
+ case TokenNamePLUS_PLUS :
+ int lookAhead2 = this.vanguardScanner.getNextToken();
+ return lookAhead2 == TokenNameIdentifier;
+ default : return true;
+ }
+ } catch (InvalidInputException e) {
+ if (e.getMessage().equals(INVALID_CHAR_IN_STRING)) {
+ //Ignore
+ } else {
+ // Shouldn't happen, but log the error
+ e.printStackTrace();
+ }
+ }
+ return false; // IIE event;
+}
+int disambiguatedRestrictedIdentifierYield(int restrictedIdentifierToken) {
+ // and here's the kludge
+ if (restrictedIdentifierToken != TokenNameRestrictedIdentifierYield)
+ return restrictedIdentifierToken;
+ if (this.sourceLevel < ClassFileConstants.JDK13 || !this.previewEnabled)
+ return TokenNameIdentifier;
+
+ return mayBeAtAnYieldStatement() && disambiguateYieldWithLookAhead() ?
+ restrictedIdentifierToken : TokenNameIdentifier;
+}
int disambiguatedRestrictedKeyword(int restrictedKeywordToken) {
int token = restrictedKeywordToken;
if (this.scanContext == ScanContext.EXPECTING_IDENTIFIER)
@@ -4844,11 +5142,7 @@ int disambiguatedRestrictedKeyword(int restrictedKeywordToken) {
}
int disambiguatedToken(int token) {
final VanguardParser parser = getVanguardParser();
- if (token == TokenNamebreak && this.sourceLevel == ClassFileConstants.JDK12 &&
- this.previewEnabled && mayBeAtBreakPreview()) {
- this.nextToken = TokenNameBreakPreviewMarker;
- return token;
- } else if (token == TokenNameARROW && this.inCase) {
+ if (token == TokenNameARROW && this.inCase) {
this.nextToken = TokenNameARROW;
this.inCase = false;
return TokenNameBeginCaseExpr;
@@ -4951,6 +5245,7 @@ public int fastForward(Statement unused) {
case TokenNameDoubleLiteral:
case TokenNameCharacterLiteral:
case TokenNameStringLiteral:
+ case TokenNameTextBlock:
case TokenNamePLUS_PLUS:
case TokenNameMINUS_MINUS:
case TokenNameLESS:
@@ -4959,6 +5254,7 @@ public int fastForward(Statement unused) {
case TokenNameAT:
case TokenNameBeginLambda:
case TokenNameAT308:
+ case TokenNameRestrictedIdentifierYield: // can be in FOLLOW of Block
if(getVanguardParser().parse(Goal.BlockStatementoptGoal) == VanguardParser.SUCCESS)
return token;
break;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/ScannerHelper.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/ScannerHelper.java
index d82322ab6b..59ec2cd72a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/ScannerHelper.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/ScannerHelper.java
@@ -47,6 +47,7 @@ public class ScannerHelper {
private static long[][][] Tables9;
private static long[][][] Tables11;
private static long[][][] Tables12;
+ private static long[][][] Tables13;
public final static int MAX_OBVIOUS = 128;
public final static int[] OBVIOUS_IDENT_CHAR_NATURES = new int[MAX_OBVIOUS];
@@ -154,6 +155,9 @@ static void initializeTableJava11() {
static void initializeTableJava12() {
Tables12 = initializeTables("unicode11"); //$NON-NLS-1$
}
+static void initializeTableJava13() {
+ Tables13 = initializeTables("unicode12_1"); //$NON-NLS-1$
+}
static long[][][] initializeTables(String unicode_path) {
long[][][] tempTable = new long[2][][];
tempTable[START_INDEX] = new long[3][];
@@ -285,12 +289,18 @@ public static boolean isJavaIdentifierPart(long complianceLevel, int codePoint)
initializeTableJava11();
}
return isJavaIdentifierPart0(codePoint, Tables11);
- } else {
+ } else if (complianceLevel <= ClassFileConstants.JDK12) {
// java 12 supports Unicode 11
if (Tables12 == null) {
initializeTableJava12();
}
return isJavaIdentifierPart0(codePoint, Tables12);
+ } else {
+ // java 13 supports Unicode 12.1
+ if (Tables13 == null) {
+ initializeTableJava13();
+ }
+ return isJavaIdentifierPart0(codePoint, Tables13);
}
}
public static boolean isJavaIdentifierPart(long complianceLevel, char high, char low) {
@@ -352,13 +362,18 @@ public static boolean isJavaIdentifierStart(long complianceLevel, int codePoint)
initializeTableJava11();
}
return isJavaIdentifierStart0(codePoint, Tables11);
- } else {
-
+ } else if (complianceLevel <= ClassFileConstants.JDK12) {
// java 12 supports Unicode 11
if (Tables12 == null) {
initializeTableJava12();
}
return isJavaIdentifierStart0(codePoint, Tables12);
+ } else {
+ // java 13 supports Unicode 12.1
+ if (Tables13 == null) {
+ initializeTableJava13();
+ }
+ return isJavaIdentifierStart0(codePoint, Tables13);
}
}
private static int toCodePoint(char high, char low) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/TerminalTokens.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/TerminalTokens.java
index 933a888fb7..6bc731e4ad 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/TerminalTokens.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/TerminalTokens.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -39,74 +39,75 @@ public interface TerminalTokens {
int TokenNameIdentifier = 22,
TokenNameabstract = 52,
- TokenNameassert = 76,
- TokenNameboolean = 99,
- TokenNamebreak = 77,
- TokenNamebyte = 100,
- TokenNamecase = 101,
- TokenNamecatch = 102,
- TokenNamechar = 103,
- TokenNameclass = 67,
- TokenNamecontinue = 78,
- TokenNameconst = 128,
- TokenNamedefault = 73,
- TokenNamedo = 79,
- TokenNamedouble = 104,
- TokenNameelse = 112,
- TokenNameenum = 71,
- TokenNameextends = 86,
+ TokenNameassert = 78,
+ TokenNameboolean = 101,
+ TokenNamebreak = 79,
+ TokenNamebyte = 102,
+ TokenNamecase = 103,
+ TokenNamecatch = 104,
+ TokenNamechar = 105,
+ TokenNameclass = 68,
+ TokenNamecontinue = 80,
+ TokenNameconst = 129,
+ TokenNamedefault = 74,
+ TokenNamedo = 81,
+ TokenNamedouble = 106,
+ TokenNameelse = 114,
+ TokenNameenum = 72,
+ TokenNameextends = 88,
TokenNamefalse = 38,
TokenNamefinal = 53,
- TokenNamefinally = 111,
- TokenNamefloat = 105,
- TokenNamefor = 80,
- TokenNamegoto = 129,
- TokenNameif = 81,
- TokenNameimplements = 123,
- TokenNameimport = 106,
+ TokenNamefinally = 113,
+ TokenNamefloat = 107,
+ TokenNamefor = 82,
+ TokenNamegoto = 130,
+ TokenNameif = 83,
+ TokenNameimplements = 125,
+ TokenNameimport = 108,
TokenNameinstanceof = 17,
- TokenNameint = 107,
- TokenNameinterface = 70,
- TokenNamelong = 108,
+ TokenNameint = 109,
+ TokenNameinterface = 71,
+ TokenNamelong = 110,
TokenNamenative = 54,
TokenNamenew = 36,
TokenNamenull = 39,
- TokenNamepackage = 85,
+ TokenNamepackage = 87,
TokenNameprivate = 55,
TokenNameprotected = 56,
TokenNamepublic = 57,
- TokenNamereturn = 82,
- TokenNameshort = 109,
- TokenNamestatic = 48,
+ TokenNamereturn = 84,
+ TokenNameshort = 111,
+ TokenNamestatic = 40,
TokenNamestrictfp = 58,
TokenNamesuper = 34,
- TokenNameswitch = 51,
- TokenNamesynchronized = 50,
+ TokenNameswitch = 59,
+ TokenNamesynchronized = 51,
TokenNamethis = 35,
- TokenNamethrow = 74,
- TokenNamethrows = 120,
- TokenNametransient = 59,
- TokenNametrue = 40,
- TokenNametry = 83,
- TokenNamevoid = 110,
- TokenNamevolatile = 60,
- TokenNamewhile = 75,
- TokenNamemodule = 113,
- TokenNameopen = 114,
- TokenNamerequires = 115,
- TokenNametransitive = 121,
- TokenNameexports = 116,
- TokenNameopens = 117,
- TokenNameto = 124,
- TokenNameuses = 118,
- TokenNameprovides = 119,
- TokenNamewith = 125,
- TokenNameIntegerLiteral = 41,
- TokenNameLongLiteral = 42,
- TokenNameFloatingPointLiteral = 43,
- TokenNameDoubleLiteral = 44,
- TokenNameCharacterLiteral = 45,
- TokenNameStringLiteral = 46,
+ TokenNamethrow = 75,
+ TokenNamethrows = 122,
+ TokenNametransient = 60,
+ TokenNametrue = 41,
+ TokenNametry = 85,
+ TokenNamevoid = 112,
+ TokenNamevolatile = 61,
+ TokenNamewhile = 76,
+ TokenNamemodule = 115,
+ TokenNameopen = 116,
+ TokenNamerequires = 117,
+ TokenNametransitive = 123,
+ TokenNameexports = 118,
+ TokenNameopens = 119,
+ TokenNameto = 126,
+ TokenNameuses = 120,
+ TokenNameprovides = 121,
+ TokenNamewith = 127,
+ TokenNameIntegerLiteral = 42,
+ TokenNameLongLiteral = 43,
+ TokenNameFloatingPointLiteral = 44,
+ TokenNameDoubleLiteral = 45,
+ TokenNameCharacterLiteral = 46,
+ TokenNameStringLiteral = 47,
+ TokenNameTextBlock = 48,
TokenNamePLUS_PLUS = 2,
TokenNameMINUS_MINUS = 3,
TokenNameEQUAL_EQUAL = 19,
@@ -116,28 +117,28 @@ public interface TerminalTokens {
TokenNameLEFT_SHIFT = 18,
TokenNameRIGHT_SHIFT = 14,
TokenNameUNSIGNED_RIGHT_SHIFT = 16,
- TokenNamePLUS_EQUAL = 87,
- TokenNameMINUS_EQUAL = 88,
- TokenNameMULTIPLY_EQUAL = 89,
- TokenNameDIVIDE_EQUAL = 90,
- TokenNameAND_EQUAL = 91,
- TokenNameOR_EQUAL = 92,
- TokenNameXOR_EQUAL = 93,
- TokenNameREMAINDER_EQUAL = 94,
- TokenNameLEFT_SHIFT_EQUAL = 95,
- TokenNameRIGHT_SHIFT_EQUAL = 96,
- TokenNameUNSIGNED_RIGHT_SHIFT_EQUAL = 97,
+ TokenNamePLUS_EQUAL = 89,
+ TokenNameMINUS_EQUAL = 90,
+ TokenNameMULTIPLY_EQUAL = 91,
+ TokenNameDIVIDE_EQUAL = 92,
+ TokenNameAND_EQUAL = 93,
+ TokenNameOR_EQUAL = 94,
+ TokenNameXOR_EQUAL = 95,
+ TokenNameREMAINDER_EQUAL = 96,
+ TokenNameLEFT_SHIFT_EQUAL = 97,
+ TokenNameRIGHT_SHIFT_EQUAL = 98,
+ TokenNameUNSIGNED_RIGHT_SHIFT_EQUAL = 99,
TokenNameOR_OR = 31,
TokenNameAND_AND = 30,
TokenNamePLUS = 4,
TokenNameMINUS = 5,
- TokenNameNOT = 63,
+ TokenNameNOT = 64,
TokenNameREMAINDER = 9,
TokenNameXOR = 24,
TokenNameAND = 21,
TokenNameMULTIPLY = 8,
- TokenNameOR = 28,
- TokenNameTWIDDLE = 64,
+ TokenNameOR = 27,
+ TokenNameTWIDDLE = 65,
TokenNameDIVIDE = 10,
TokenNameGREATER = 15,
TokenNameLESS = 11,
@@ -146,25 +147,25 @@ public interface TerminalTokens {
TokenNameLBRACE = 49,
TokenNameRBRACE = 33,
TokenNameLBRACKET = 6,
- TokenNameRBRACKET = 66,
+ TokenNameRBRACKET = 67,
TokenNameSEMICOLON = 25,
TokenNameQUESTION = 29,
- TokenNameCOLON = 62,
+ TokenNameCOLON = 63,
TokenNameCOMMA = 32,
TokenNameDOT = 1,
- TokenNameEQUAL = 72,
+ TokenNameEQUAL = 73,
TokenNameAT = 37,
- TokenNameELLIPSIS = 122,
- TokenNameARROW = 98,
+ TokenNameELLIPSIS = 124,
+ TokenNameARROW = 100,
TokenNameCOLON_COLON = 7,
- TokenNameBeginLambda = 47,
- TokenNameBeginIntersectionCast = 65,
- TokenNameBeginTypeArguments = 84,
- TokenNameElidedSemicolonAndRightBrace = 68,
- TokenNameAT308 = 27,
- TokenNameAT308DOTDOTDOT = 126,
- TokenNameBeginCaseExpr = 69,
- TokenNameBreakPreviewMarker = 127,
- TokenNameEOF = 61,
- TokenNameERROR = 130;
+ TokenNameBeginLambda = 50,
+ TokenNameBeginIntersectionCast = 66,
+ TokenNameBeginTypeArguments = 86,
+ TokenNameElidedSemicolonAndRightBrace = 69,
+ TokenNameAT308 = 28,
+ TokenNameAT308DOTDOTDOT = 128,
+ TokenNameBeginCaseExpr = 70,
+ TokenNameRestrictedIdentifierYield = 77,
+ TokenNameEOF = 62,
+ TokenNameERROR = 131;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/diagnose/DiagnoseParser.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/diagnose/DiagnoseParser.java
index 719f1aaa76..adf0615eba 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/diagnose/DiagnoseParser.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/diagnose/DiagnoseParser.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -2568,4 +2568,9 @@ public class DiagnoseParser implements ParserBasicInformation, TerminalTokens, C
//
return this.parser.isParsingModuleDeclaration();
}
+
+ @Override
+ public boolean isParsingJava13() {
+ return this.parser.isParsingJava13();
+ }
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser1.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser1.rsc
index 4d51c7a3f4..52334ae633 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser1.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser1.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser10.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser10.rsc
index 4c4973bdc4..b967ced38a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser10.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser10.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser11.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser11.rsc
index 3a6874056f..a3846c0a63 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser11.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser11.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser12.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser12.rsc
index b347b6287e..df41dc143b 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser12.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser12.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser13.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser13.rsc
index 0e96f31792..5247d001d2 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser13.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser13.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser14.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser14.rsc
index 2861812c26..eb9a79ce01 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser14.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser14.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser15.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser15.rsc
index fa54266d22..9858fb849f 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser15.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser15.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser16.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser16.rsc
index c3826f413a..aa8fbda449 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser16.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser16.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser17.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser17.rsc
index 97366ec7d3..713085fc4c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser17.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser17.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser18.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser18.rsc
index b9ffe0288b..9f6e258a03 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser18.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser18.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser19.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser19.rsc
index 51dd3aa8a8..62357ba027 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser19.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser19.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser2.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser2.rsc
index ccce9dfb4a..3f3f04ae7a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser2.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser2.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser20.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser20.rsc
index b0029d5159..59f82181ab 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser20.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser20.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser21.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser21.rsc
index c201d9bfce..851824bf48 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser21.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser21.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser22.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser22.rsc
index ad9e312e73..b54da0c192 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser22.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser22.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser23.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser23.rsc
index 03b54e68de..7b269508a0 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser23.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser23.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser24.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser24.rsc
index 5b4675f3c8..12926e56e7 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser24.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser24.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser3.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser3.rsc
index 0ecda888bc..0133cd6715 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser3.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser3.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser4.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser4.rsc
index 4ee5cbedbd..20dca0ab19 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser4.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser4.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser5.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser5.rsc
index 3a519c6a5a..7c37f17dc3 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser5.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser5.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser6.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser6.rsc
index ed603bb9f3..9826dddf4c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser6.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser6.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser7.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser7.rsc
index 6e1a63e12d..96f7f6d3a4 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser7.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser7.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser8.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser8.rsc
index f29bb3cfc6..0f46a22317 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser8.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser8.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser9.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser9.rsc
index bb709b8dfe..e73b7ac12f 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser9.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser9.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/readableNames.props b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/readableNames.props
index 64eb6d9eba..5859a30651 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/readableNames.props
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/readableNames.props
@@ -365,3 +365,4 @@ WildcardBounds1=WildcardBounds1
WildcardBounds2=WildcardBounds2
WildcardBounds3=WildcardBound3
WildcardBounds=WildcardBounds
+YieldStatement=YieldStatement
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/unicode12_1/part0.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/unicode12_1/part0.rsc
new file mode 100644
index 0000000000..957b88736f
--- /dev/null
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/unicode12_1/part0.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/unicode12_1/part1.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/unicode12_1/part1.rsc
new file mode 100644
index 0000000000..9ad9b095b4
--- /dev/null
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/unicode12_1/part1.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/unicode12_1/part14.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/unicode12_1/part14.rsc
new file mode 100644
index 0000000000..c8241e80d5
--- /dev/null
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/unicode12_1/part14.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/unicode12_1/part2.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/unicode12_1/part2.rsc
new file mode 100644
index 0000000000..ab6b33ed48
--- /dev/null
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/unicode12_1/part2.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/unicode12_1/start0.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/unicode12_1/start0.rsc
new file mode 100644
index 0000000000..ce615fa24f
--- /dev/null
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/unicode12_1/start0.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/unicode12_1/start1.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/unicode12_1/start1.rsc
new file mode 100644
index 0000000000..3ef6c46511
--- /dev/null
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/unicode12_1/start1.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/unicode12_1/start2.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/unicode12_1/start2.rsc
new file mode 100644
index 0000000000..ab6b33ed48
--- /dev/null
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/unicode12_1/start2.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblem.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblem.java
index 047dd4fc27..2ea54609cf 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblem.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblem.java
@@ -178,6 +178,8 @@ public String getInternalCategoryMessage() {
return "restriction"; //$NON-NLS-1$
case CAT_MODULE:
return "module"; //$NON-NLS-1$
+ case CAT_PREVIEW_RELATED:
+ return "preview related"; //$NON-NLS-1$
}
return null;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
index 69bf233605..7876f23a88 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
@@ -818,6 +818,8 @@ public static int getProblemCategory(int severity, int problemID) {
return CategorizedProblem.CAT_MODULE;
if ((problemID & IProblem.Compliance) != 0)
return CategorizedProblem.CAT_COMPLIANCE;
+ if ((problemID & IProblem.PreviewRelated) != 0)
+ return CategorizedProblem.CAT_PREVIEW_RELATED;
}
return CategorizedProblem.CAT_INTERNAL;
}
@@ -834,6 +836,16 @@ public void abortDueToInternalError(String errorMessage, ASTNode location) {
location == null ? 0 : location.sourceStart,
location == null ? 0 : location.sourceEnd);
}
+public void abortDueToPreviewEnablingNotAllowed(String sourceLevel, String expectedSourceLevel) {
+ String[] args = new String[] {sourceLevel, expectedSourceLevel};
+ this.handle(
+ IProblem.PreviewFeaturesNotAllowed,
+ args,
+ args,
+ ProblemSeverities.Error | ProblemSeverities.Abort | ProblemSeverities.Fatal,
+ 0,
+ 0);
+}
public void abstractMethodCannotBeOverridden(SourceTypeBinding type, MethodBinding concreteMethod) {
this.handle(
@@ -1603,7 +1615,10 @@ public int computeSeverity(int problemID){
switch (problemID) {
case IProblem.VarargsConflict :
- return ProblemSeverities.Warning;
+ case IProblem.SwitchExpressionsYieldUnqualifiedMethodWarning:
+ case IProblem.SwitchExpressionsYieldRestrictedGeneralWarning:
+ case IProblem.SwitchExpressionsYieldTypeDeclarationWarning:
+ return ProblemSeverities.Warning;
case IProblem.TypeCollidesWithPackage :
return ProblemSeverities.Error;
@@ -5093,6 +5108,9 @@ private boolean isKeyword(int token) {
case TerminalTokens.TokenNamevolatile:
case TerminalTokens.TokenNamewhile:
return true;
+ case TerminalTokens.TokenNameRestrictedIdentifierYield:
+ // making explicit - yield not a (restricted) keyword but restricted identifier.
+ //$FALL-THROUGH$
default:
return false;
}
@@ -6513,7 +6531,7 @@ public void missingEnumConstantCase(SwitchExpression switchExpression, FieldBind
}
private void missingSwitchExpressionEnumConstantCase(CaseStatement defaultCase, FieldBinding enumConstant, ASTNode expression) {
this.handle(
- IProblem.SwitchExpressionMissingEnumConstantCase,
+ IProblem.SwitchExpressionsYieldMissingEnumConstantCase,
new String[] {new String(enumConstant.declaringClass.readableName()), new String(enumConstant.name) },
new String[] {new String(enumConstant.declaringClass.shortReadableName()), new String(enumConstant.name) },
expression.sourceStart,
@@ -6538,7 +6556,7 @@ public void missingDefaultCase(SwitchStatement switchStatement, boolean isEnumSw
} else {
this.handle(
switchStatement instanceof SwitchExpression ?
- IProblem.SwitchExpressionMissingDefaultCase : IProblem.MissingDefaultCase,
+ IProblem.SwitchExpressionsYieldMissingDefaultCase : IProblem.MissingDefaultCase,
NoArgument,
NoArgument,
switchStatement.expression.sourceStart,
@@ -7906,6 +7924,8 @@ public void scannerError(Parser parser, String errorTokenName) {
flag = IProblem.InvalidFloat;
else if (errorTokenName.equals(Scanner.UNTERMINATED_STRING))
flag = IProblem.UnterminatedString;
+ else if (errorTokenName.equals(Scanner.UNTERMINATED_TEXT_BLOCK))
+ flag = IProblem.UnterminatedTextBlock;
else if (errorTokenName.equals(Scanner.UNTERMINATED_COMMENT))
flag = IProblem.UnterminatedComment;
else if (errorTokenName.equals(Scanner.INVALID_CHAR_IN_STRING))
@@ -8131,6 +8151,8 @@ private String replaceIfSynthetic(String token) {
return "."; //$NON-NLS-1$
if (token.equals("BeginLambda")) //$NON-NLS-1$
return "("; //$NON-NLS-1$
+ if (token.equals("RestrictedIdentifierYield")) //$NON-NLS-1$
+ return "yield"; //$NON-NLS-1$
return token;
}
public void task(String tag, String message, String priority, int start, int end){
@@ -11068,7 +11090,7 @@ public void switchExpressionIncompatibleResultExpressions(SwitchExpression expre
return;
TypeBinding type = expression.resultExpressions.get(0).resolvedType;
this.handle(
- IProblem.SwitchExpressionsIncompatibleResultExpressionTypes,
+ IProblem.SwitchExpressionsYieldIncompatibleResultExpressionTypes,
new String[] {new String(type.readableName())},
new String[] {new String(type.shortReadableName())},
expression.sourceStart,
@@ -11078,7 +11100,7 @@ public void switchExpressionEmptySwitchBlock(SwitchExpression expression) {
if (!this.options.enablePreviewFeatures)
return;
this.handle(
- IProblem.SwitchExpressionsEmptySwitchBlock,
+ IProblem.SwitchExpressionsYieldEmptySwitchBlock,
NoArgument,
NoArgument,
expression.sourceStart,
@@ -11088,7 +11110,7 @@ public void switchExpressionNoResultExpressions(SwitchExpression expression) {
if (!this.options.enablePreviewFeatures)
return;
this.handle(
- IProblem.SwitchExpressionsNoResultExpression,
+ IProblem.SwitchExpressionsYieldNoResultExpression,
NoArgument,
NoArgument,
expression.sourceStart,
@@ -11098,7 +11120,7 @@ public void switchExpressionSwitchLabeledBlockCompletesNormally(Block block) {
if (!this.options.enablePreviewFeatures)
return;
this.handle(
- IProblem.SwitchExpressionSwitchLabeledBlockCompletesNormally,
+ IProblem.SwitchExpressionaYieldSwitchLabeledBlockCompletesNormally,
NoArgument,
NoArgument,
block.sourceStart,
@@ -11108,7 +11130,7 @@ public void switchExpressionLastStatementCompletesNormally(Statement stmt) {
if (!this.options.enablePreviewFeatures)
return;
this.handle(
- IProblem.SwitchExpressionSwitchLabeledBlockCompletesNormally,
+ IProblem.SwitchExpressionaYieldSwitchLabeledBlockCompletesNormally,
NoArgument,
NoArgument,
stmt.sourceStart,
@@ -11118,7 +11140,7 @@ public void switchExpressionIllegalLastStatement(Statement stmt) {
if (!this.options.enablePreviewFeatures)
return;
this.handle(
- IProblem.SwitchExpressionIllegalLastStatement,
+ IProblem.SwitchExpressionsYieldIllegalLastStatement,
NoArgument,
NoArgument,
stmt.sourceStart,
@@ -11128,7 +11150,7 @@ public void switchExpressionTrailingSwitchLabels(Statement stmt) {
if (!this.options.enablePreviewFeatures)
return;
this.handle(
- IProblem.SwitchExpressionTrailingSwitchLabels,
+ IProblem.SwitchExpressionsYieldTrailingSwitchLabels,
NoArgument,
NoArgument,
stmt.sourceStart,
@@ -11138,17 +11160,83 @@ public void switchExpressionMixedCase(ASTNode statement) {
if (!this.options.enablePreviewFeatures)
return;
this.handle(
- IProblem.switchMixedCase,
+ IProblem.SwitchPreviewMixedCase,
+ NoArgument,
+ NoArgument,
+ statement.sourceStart,
+ statement.sourceEnd);
+}
+public void switchExpressionBreakNotAllowed(ASTNode statement) {
+ if (!this.options.enablePreviewFeatures)
+ return;
+ this.handle(
+ IProblem.SwitchExpressionsYieldBreakNotAllowed,
+ NoArgument,
+ NoArgument,
+ statement.sourceStart,
+ statement.sourceEnd);
+}
+public void switchExpressionsYieldUnqualifiedMethodWarning(ASTNode statement) {
+ this.handle(
+ IProblem.SwitchExpressionsYieldUnqualifiedMethodWarning,
+ NoArgument,
+ NoArgument,
+ statement.sourceStart,
+ statement.sourceEnd);
+}
+public void switchExpressionsYieldUnqualifiedMethodError(ASTNode statement) {
+ if (!this.options.enablePreviewFeatures)
+ return;
+ this.handle(
+ IProblem.SwitchExpressionsYieldUnqualifiedMethodError,
+ NoArgument,
+ NoArgument,
+ statement.sourceStart,
+ statement.sourceEnd);
+}
+public void switchExpressionsYieldOutsideSwitchExpression(ASTNode statement) {
+ if (!this.options.enablePreviewFeatures)
+ return;
+ this.handle(
+ IProblem.SwitchExpressionsYieldOutsideSwitchExpression,
+ NoArgument,
+ NoArgument,
+ statement.sourceStart,
+ statement.sourceEnd);
+}
+public void switchExpressionsYieldRestrictedGeneralWarning(ASTNode statement) {
+ if (!this.options.enablePreviewFeatures)
+ return;
+ this.handle(
+ IProblem.SwitchExpressionsYieldRestrictedGeneralWarning,
+ NoArgument,
+ NoArgument,
+ statement.sourceStart,
+ statement.sourceEnd);
+}
+public void switchExpressionsYieldIllegalStatement(ASTNode statement) {
+ if (!this.options.enablePreviewFeatures)
+ return;
+ this.handle(
+ IProblem.SwitchExpressionsYieldIllegalStatement,
+ NoArgument,
+ NoArgument,
+ statement.sourceStart,
+ statement.sourceEnd);
+}
+public void switchExpressionsYieldTypeDeclarationWarning(ASTNode statement) {
+ this.handle(
+ IProblem.SwitchExpressionsYieldTypeDeclarationWarning,
NoArgument,
NoArgument,
statement.sourceStart,
statement.sourceEnd);
}
-public void switchExpressionBreakMissingValue(ASTNode statement) {
+public void switchExpressionsYieldTypeDeclarationError(ASTNode statement) {
if (!this.options.enablePreviewFeatures)
return;
this.handle(
- IProblem.SwitchExpressionBreakMissingValue,
+ IProblem.SwitchExpressionsYieldTypeDeclarationError,
NoArgument,
NoArgument,
statement.sourceStart,
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties
index 27b62609e6..03d5704d4e 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties
@@ -288,6 +288,7 @@
268 = Underscores have to be located within digits
269 = Underscores can only be used with source level 1.7 or greater
271 = This lambda expression refers to the missing type {0}
+272 = Text block is not properly closed with the delimiter
280 = Discouraged access: {0}
@@ -885,6 +886,7 @@
1103 = {0} is a preview feature and disabled by default. Use --enable-preview to enable
1104 = You are using a preview language feature that may or may not be supported in a future release
1105 = The preview feature {0} is only available with source level {1} and above
+1106 = Preview features enabled at an invalid source release level {0}, preview can be enabled only at source level {1}
# more programming problems:
1200 = Unlikely argument type {0} for {1} on a {2}
@@ -974,7 +976,7 @@
1511 = 'var' is not allowed here
1512 = 'var' cannot be mixed with non-var parameters
-# Switch-Expressions
+# Switch-Expressions Java 12 Preview
1600 = Incompatible switch results expressions {0}
1601 = A switch expression should have a non-empty switch block
1602 = A switch expression should have at least one result expression
@@ -989,6 +991,27 @@
1611 = A Switch expression should cover all possible values
1612 = 'continue' or 'return' cannot be the last statement in a Switch expression case body
+# Switch-Expressions Java 13 Preview
+1700 = Incompatible switch results expressions {0}
+1701 = A switch expression should have a non-empty switch block
+1702 = A switch expression should have at least one result expression
+1703 = A switch labeled block in a switch expression should not complete normally
+1704 = The last statement of a switch block in a switch expression should not complete normally
+1705 = Trailing switch labels are not allowed in a switch expression.
+1706 = Mixing of different kinds of case statements '->' and ':' is not allowed within a switch
+1707 = A switch expression should have a default case
+1708 = yield of a switch expression should have a value
+1709 = A Switch expression should cover all possible values
+1710 = 'continue' or 'return' cannot be the last statement in a Switch expression case body
+1711 = break out of switch expression not allowed
+1712 = yield may be disallowed in future - qualify method calls to avoid this message
+1713 = restricted identifier yield not allowed here - method calls need to be qualified
+1714 = yield outside of switch expression
+1715 = yield is a restricted keyword and may be disallowed in future
+1716 = yield statement is illegal here
+1717 = yield may be a restricted identifier in future and may be disallowed as a type name
+1718 = yield is a restricted identifier and cannot be used as type name
+
### ELABORATIONS
## Access restrictions
78592 = The type ''{1}'' is not API (restriction on classpath entry ''{0}'')
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Messages.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Messages.java
index 53169bffbb..0f4885d7f2 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Messages.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Messages.java
@@ -116,6 +116,7 @@ public final class Messages {
public static String ast_missingCode;
public static String constant_cannotCastedInto;
public static String constant_cannotConvertedTo;
+ public static String abort_againstPreviewNotAllowed;
static {
initializeMessages(BUNDLE_NAME, Messages.class);
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.java
index 44a12d8086..e4a3742a81 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.java
@@ -17,6 +17,8 @@ package org.eclipse.jdt.core.dom;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
@@ -119,7 +121,7 @@ public final class AST {
* </p>
*
* @since 3.0
- * @deprecated Clients should use the {@link #JLS11} AST API instead.
+ * @deprecated Clients should use the {@link #JLS_Latest} AST API instead.
*/
public static final int JLS2 = 2;
@@ -143,7 +145,7 @@ public final class AST {
* </p>
*
* @since 3.1
- * @deprecated Clients should use the {@link #JLS11} AST API instead.
+ * @deprecated Clients should use the {@link #JLS_Latest} AST API instead.
*/
public static final int JLS3 = 3;
@@ -167,7 +169,7 @@ public final class AST {
* </p>
*
* @since 3.7.1
- * @deprecated Clients should use the {@link #JLS11} AST API instead.
+ * @deprecated Clients should use the {@link #JLS_Latest} AST API instead.
*/
public static final int JLS4 = 4;
@@ -191,7 +193,7 @@ public final class AST {
* </p>
*
* @since 3.10
- * @deprecated Clients should use the {@link #JLS11} AST API instead.
+ * @deprecated Clients should use the {@link #JLS_Latest} AST API instead.
*/
public static final int JLS8 = 8;
@@ -215,7 +217,7 @@ public final class AST {
* </p>
*
* @since 3.14
- * @deprecated Clients should use the {@link #JLS11} AST API instead.
+ * @deprecated Clients should use the {@link #JLS_Latest} AST API instead.
*/
public static final int JLS9 = 9;
@@ -239,7 +241,7 @@ public final class AST {
* </p>
*
* @since 3.14
- * @deprecated Clients should use the {@link #JLS11} AST API instead.
+ * @deprecated Clients should use the {@link #JLS_Latest} AST API instead.
*/
public static final int JLS10 = 10;
@@ -262,6 +264,7 @@ public final class AST {
* up to and including Java SE 11 (aka JDK 11).
* </p>
*
+ * @deprecated Clients should use the {@link #JLS_Latest} AST API instead.
* @since 3.16
*/
public static final int JLS11 = 11;
@@ -284,7 +287,7 @@ public final class AST {
* programs written in all versions of the Java language
* up to and including Java SE 12 (aka JDK 12).
* </p>
- *
+ * @deprecated Clients should use the {@link #JLS_Latest} AST API instead.
* @since 3.18
*/
public static final int JLS12 = 12;
@@ -294,12 +297,43 @@ public final class AST {
* @since 3.18
*/
static final int JLS12_INTERNAL = JLS12;
+
+ /**
+ * Constant for indicating the AST API that handles JLS13.
+ * <p>
+ * This API is capable of handling all constructs in the
+ * Java language as described in the Java Language
+ * Specification, Java SE 13 Edition (JLS13).
+ * JLS13 is a superset of all earlier versions of the
+ * Java language, and the JLS13 API can be used to manipulate
+ * programs written in all versions of the Java language
+ * up to and including Java SE 13 (aka JDK 13).
+ * </p>
+ *
+ * @since 3.20
+ */
+ public static final int JLS13 = 13;
+
+ /**
+ * Internal synonym for {@link #JLS13}. Use to alleviate
+ * deprecation warnings once JLS13 is deprecated
+ * @since 3.20
+ */
+ static final int JLS13_INTERNAL = JLS13;
+ @SuppressWarnings("unused")
+ /* Used for Java doc only*/
+ private static final int JLS_Latest = JLS13;
+
/*
* Must not collide with a value for ICompilationUnit constants
*/
static final int RESOLVED_BINDINGS = 0x80000000;
+ private static Map<String, Long> jdkLevelMap = getLevelMapTable();
+
+ private static Map<String, Integer> apiLevelMap = getApiLevelMapTable();
+
/**
* Internal method.
* <p>
@@ -440,6 +474,38 @@ public final class AST {
}
/**
+ * Creates a new Java abstract syntax tree
+ * <p>
+ * Following option keys are significant:
+ * <ul>
+ * <li><code>"org.eclipse.jdt.core.compiler.source"</code>
+ * indicates the api level and source compatibility mode (as per <code>JavaCore</code>) - defaults to 1.3
+ * <ul>
+ * <li>
+ * <code>"1.3"</code> means the source code is as per JDK 1.3 and api level {@link #JLS3}.</li>
+ * <li><code>"1.4", "1.5", "1.6", "1.7" "1.8"</code> implies the respective source JDK levels 1.4, 1.5, 1.6, 1.7 and api level {@link #JLS4}.</li>
+ * <li><code>"1.8"</code> implies the respective source JDK level 1.8 and api level {@link #JLS8}.</li>
+ * <li><code>"9", "10", "11" "12"</code> implies the respective JDK levels 9, 10, 11 and 12
+ * and api levels {@link #JLS9}, {@link #JLS10}, {@link #JLS11}, and {@link #JLS12}.</li>
+ * Additional legal values may be added later.
+ * </li>
+ * </ul>
+ * <li><code>"org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures"</code> -
+ * indicates whether the preview is enabled or disabled
+ * legal values are <code>"enabled"</code> and <code>"disabled"</code> implying preview enabled and disabled respectively.
+ * preview enabling has an effect only with the latest ast level.
+ * </ul>
+ * <p>
+ * </p>
+ *
+ * @param options the table of options
+ * @see JavaCore#getDefaultOptions()
+ * @since 3.20
+ */
+ public static AST newAST(Map<String, String> options) {
+ return new AST(options);
+ }
+ /**
* Parses the given string as a Java compilation unit and creates and
* returns a corresponding abstract syntax tree.
* <p>
@@ -922,57 +988,75 @@ public final class AST {
true/*taskCaseSensitive*/,
previewEnabled);
break;
+ case JLS13_INTERNAL :
+ this.apiLevel = level;
+ // initialize a scanner
+ compliance = ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_13);
+ this.scanner = new Scanner(
+ true /*comment*/,
+ true /*whitespace*/,
+ false /*nls*/,
+ compliance /*sourceLevel*/,
+ compliance /*complianceLevel*/,
+ null/*taskTag*/,
+ null/*taskPriorities*/,
+ true/*taskCaseSensitive*/,
+ previewEnabled);
+ break;
default:
throw new IllegalArgumentException("Unsupported JLS level"); //$NON-NLS-1$
}
}
/**
- * Creates a new, empty abstract syntax tree using the given options.
+ * Creates a new Java abstract syntax tree
* <p>
* Following option keys are significant:
* <ul>
- * <li><code>"org.eclipse.jdt.core.compiler.source"</code> -
- * indicates source compatibility mode (as per <code>JavaCore</code>);
- * <code>"1.3"</code> means the source code is as per JDK 1.3;
- * <code>"1.4"</code> means the source code is as per JDK 1.4
- * (<code>"assert"</code> is now a keyword);
- * <code>"1.5"</code> means the source code is as per JDK 1.5
- * (<code>"enum"</code> is now a keyword);
- * <code>"1.7"</code> means the source code is as per JDK 1.7;
- * additional legal values may be added later. </li>
+ * <li><code>"org.eclipse.jdt.core.compiler.source"</code>
+ * indicates the api level and source compatibility mode (as per <code>JavaCore</code>) - defaults to 1.3
+ * <ul>
+ * <li>
+ * <code>"1.3"</code> means the source code is as per JDK 1.3 and api level {@link #JLS3}.</li>
+ * <li><code>"1.4", "1.5", "1.6", "1.7" "1.8"</code> implies the respective source JDK levels 1.4, 1.5, 1.6, 1.7 and api level {@link #JLS4}.</li>
+ * <li><code>"1.8"</code> implies the respective source JDK level 1.8 and api level {@link #JLS8}.</li>
+ * <li><code>"9", "10", "11" "12"</code> implies the respective JDK levels 9, 10, 11 and 12
+ * and api levels {@link #JLS9}, {@link #JLS10}, {@link #JLS11}, and {@link #JLS12}.</li>
+ * Additional legal values may be added later.
+ * </li>
+ * </ul>
+ * <li><code>"org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures"</code> -
+ * indicates whether the preview is enabled or disabled
+ * legal values are <code>"enabled"</code> and <code>"disabled"</code> implying preview enabled and disabled respectively.
+ * preview enabling has an effect only with the latest ast level.
* </ul>
* <p>
- * Options other than the above are ignored.
* </p>
*
* @param options the table of options (key type: <code>String</code>;
* value type: <code>String</code>)
* @see JavaCore#getDefaultOptions()
- * @deprecated Clients should port their code to use the latest JLS* AST API and call
- * {@link #newAST(int, boolean) AST.newAST(AST.JLS12, false)} instead of using this constructor.
*/
public AST(Map options) {
- this(JLS2, false);
- Object sourceLevelOption = options.get(JavaCore.COMPILER_SOURCE);
- long sourceLevel = ClassFileConstants.JDK1_3;
- if (JavaCore.VERSION_1_4.equals(sourceLevelOption)) {
- sourceLevel = ClassFileConstants.JDK1_4;
- } else if (JavaCore.VERSION_1_5.equals(sourceLevelOption)) {
- sourceLevel = ClassFileConstants.JDK1_5;
- } else if (JavaCore.VERSION_1_7.equals(sourceLevelOption)) {
- sourceLevel = ClassFileConstants.JDK1_7;
- }
- Object complianceLevelOption = options.get(JavaCore.COMPILER_COMPLIANCE);
- long complianceLevel = ClassFileConstants.JDK1_3;
- if (JavaCore.VERSION_1_4.equals(complianceLevelOption)) {
- complianceLevel = ClassFileConstants.JDK1_4;
- } else if (JavaCore.VERSION_1_5.equals(complianceLevelOption)) {
- complianceLevel = ClassFileConstants.JDK1_5;
- } else if (JavaCore.VERSION_1_7.equals(complianceLevelOption)) {
- complianceLevel = ClassFileConstants.JDK1_7;
- }
- // override scanner if 1.4 or 1.5 asked for
+ this(apiLevelMap.get(options.get(JavaCore.COMPILER_SOURCE)),
+ JavaCore.ENABLED.equals(options.get(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES)));
+
+ long sourceLevel;
+ long complianceLevel;
+ switch(this.apiLevel) {
+ case JLS2_INTERNAL :
+ case JLS3_INTERNAL :
+ sourceLevel = ClassFileConstants.JDK1_3;
+ complianceLevel = ClassFileConstants.JDK1_5;
+ break;
+ case JLS4_INTERNAL :
+ sourceLevel = ClassFileConstants.JDK1_7;
+ complianceLevel = ClassFileConstants.JDK1_7;
+ break;
+ default :
+ sourceLevel = AST.jdkLevelMap.get(options.get(JavaCore.COMPILER_SOURCE));
+ complianceLevel = sourceLevel;
+ }
this.scanner = new Scanner(
true /*comment*/,
true /*whitespace*/,
@@ -982,9 +1066,43 @@ public final class AST {
null/*taskTag*/,
null/*taskPriorities*/,
true/*taskCaseSensitive*/,
- JavaCore.ENABLED.equals(options.get(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES)));
+ this.previewEnabled /* isPreviewEnabled*/);
+ }
+
+ private static Map<String, Long> getLevelMapTable() {
+ Map<String, Long> t = new HashMap<>();
+ t.put(null, ClassFileConstants.JDK1_2);
+ t.put(JavaCore.VERSION_1_2, ClassFileConstants.JDK1_2);
+ t.put(JavaCore.VERSION_1_3, ClassFileConstants.JDK1_3);
+ t.put(JavaCore.VERSION_1_4, ClassFileConstants.JDK1_4);
+ t.put(JavaCore.VERSION_1_5, ClassFileConstants.JDK1_5);
+ t.put(JavaCore.VERSION_1_6, ClassFileConstants.JDK1_6);
+ t.put(JavaCore.VERSION_1_7, ClassFileConstants.JDK1_7);
+ t.put(JavaCore.VERSION_1_8, ClassFileConstants.JDK1_8);
+ t.put(JavaCore.VERSION_9, ClassFileConstants.JDK9);
+ t.put(JavaCore.VERSION_10, ClassFileConstants.JDK10);
+ t.put(JavaCore.VERSION_11, ClassFileConstants.JDK11);
+ t.put(JavaCore.VERSION_12, ClassFileConstants.JDK12);
+ t.put(JavaCore.VERSION_13, ClassFileConstants.JDK13);
+ return Collections.unmodifiableMap(t);
+ }
+ private static Map<String, Integer> getApiLevelMapTable() {
+ Map<String, Integer> t = new HashMap<>();
+ t.put(null, JLS2_INTERNAL);
+ t.put(JavaCore.VERSION_1_2, JLS2_INTERNAL);
+ t.put(JavaCore.VERSION_1_3, JLS3_INTERNAL);
+ t.put(JavaCore.VERSION_1_4, JLS4_INTERNAL);
+ t.put(JavaCore.VERSION_1_5, JLS4_INTERNAL);
+ t.put(JavaCore.VERSION_1_6, JLS4_INTERNAL);
+ t.put(JavaCore.VERSION_1_7, JLS4_INTERNAL);
+ t.put(JavaCore.VERSION_1_8, JLS8_INTERNAL);
+ t.put(JavaCore.VERSION_9, JLS9_INTERNAL);
+ t.put(JavaCore.VERSION_10, JLS10_INTERNAL);
+ t.put(JavaCore.VERSION_11, JLS11_INTERNAL);
+ t.put(JavaCore.VERSION_12, JLS12_INTERNAL);
+ t.put(JavaCore.VERSION_13, JLS13_INTERNAL);
+ return Collections.unmodifiableMap(t);
}
-
/**
* Return the API level supported by this AST.
*
@@ -2663,6 +2781,18 @@ public final class AST {
TagElement result = new TagElement(this);
return result;
}
+
+ /**
+ * Creates an unparented yield statement node owned by this AST. The yield statement has no
+ * label/identifier/expression and is not implicit.
+ *
+ * @return a new unparented yield statement node
+ * @since 3.20
+ * @noreference This method is not intended to be referenced by clients.
+ */
+ public TextBlock newTextBlock() {
+ return new TextBlock(this);
+ }
/**
* Creates and returns a new text element node.
@@ -2965,6 +3095,18 @@ public final class AST {
}
/**
+ * Creates an unparented yield statement node owned by this AST. The yield statement has no
+ * label/identifier/expression and is not implicit.
+ *
+ * @return a new unparented yield statement node
+ * @since 3.20
+ * @noreference This method is not intended to be referenced by clients.
+ */
+ public YieldStatement newYieldStatement() {
+ return new YieldStatement(this);
+ }
+
+ /**
* Reports that the given node has just gained a child.
*
* @param node the node that was modified
@@ -3460,10 +3602,13 @@ public final class AST {
/**
*
- * @return previewEnabled
+ * @return If preview is enabled and apiLevel is latest, return <code>true</code> else <code>false</code>
* @since 3.19
*/
public boolean isPreviewEnabled() {
- return this.previewEnabled;
+ if (this.apiLevel == AST.JLS13_INTERNAL && this.previewEnabled) {
+ return true;
+ }
+ return false;
}
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java
index 2c38bc8db8..a0f144ad5d 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java
@@ -1287,39 +1287,19 @@ class ASTConverter {
public BreakStatement convert(org.eclipse.jdt.internal.compiler.ast.BreakStatement statement) {
BreakStatement breakStatement = new BreakStatement(this.ast);
- if (this.ast.apiLevel == AST.JLS12_INTERNAL && this.ast.isPreviewEnabled()) {
- breakStatement.setImplicit(statement.isImplicit);
- if (statement.isImplicit) {
- breakStatement.setSourceRange(statement.sourceEnd -1, 0);
- } else {
- breakStatement.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 1);
- }
- }
- else {
- breakStatement.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 1);
- }
+ breakStatement.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 1);
if (statement.label != null) {
final SimpleName name = new SimpleName(this.ast);
name.internalSetIdentifier(new String(statement.label));
retrieveIdentifierAndSetPositions(statement.sourceStart, statement.sourceEnd, name);
breakStatement.setLabel(name);
}
- else if (statement.expression != null && this.ast.apiLevel == AST.JLS12_INTERNAL && this.ast.isPreviewEnabled()) {
- final Expression expression= convert(statement.expression);
- breakStatement.setExpression(expression);
- int sourceEnd = statement.sourceEnd;
- if (sourceEnd == -1) {
- breakStatement.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 2);
- } else {
- breakStatement.setSourceRange(statement.sourceStart, sourceEnd - statement.sourceStart + 1);
- }
- }
return breakStatement;
}
public SwitchCase convert(org.eclipse.jdt.internal.compiler.ast.CaseStatement statement) {
SwitchCase switchCase = new SwitchCase(this.ast);
- if (this.ast.apiLevel == AST.JLS12_INTERNAL && this.ast.isPreviewEnabled()) {
+ if (this.ast.isPreviewEnabled()) {
org.eclipse.jdt.internal.compiler.ast.Expression[] expressions = statement.constantExpressions;
if (expressions == null || expressions.length == 0) {
switchCase.expressions().clear();
@@ -1336,7 +1316,7 @@ class ASTConverter {
internalSetExpression(switchCase, convert(constantExpression));
}
}
- if (this.ast.apiLevel == AST.JLS12_INTERNAL && this.ast.isPreviewEnabled()) {
+ if (this.ast.isPreviewEnabled()) {
switchCase.setSwitchLabeledRule(statement.isExpr);
}
switchCase.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 1);
@@ -1849,6 +1829,9 @@ class ASTConverter {
if (expression instanceof org.eclipse.jdt.internal.compiler.ast.ExtendedStringLiteral) {
return convert((org.eclipse.jdt.internal.compiler.ast.ExtendedStringLiteral) expression);
}
+ if (expression instanceof org.eclipse.jdt.internal.compiler.ast.TextBlock) {
+ return convert((org.eclipse.jdt.internal.compiler.ast.TextBlock) expression);
+ }
if (expression instanceof org.eclipse.jdt.internal.compiler.ast.StringLiteral) {
return convert((org.eclipse.jdt.internal.compiler.ast.StringLiteral) expression);
}
@@ -2850,6 +2833,9 @@ class ASTConverter {
if (statement instanceof org.eclipse.jdt.internal.compiler.ast.WhileStatement) {
return convert((org.eclipse.jdt.internal.compiler.ast.WhileStatement) statement);
}
+ if (statement instanceof org.eclipse.jdt.internal.compiler.ast.YieldStatement) {
+ return convert((org.eclipse.jdt.internal.compiler.ast.YieldStatement) statement);
+ }
if (statement instanceof org.eclipse.jdt.internal.compiler.ast.Expression &&
((org.eclipse.jdt.internal.compiler.ast.Expression) statement).isTrulyExpression()) {
org.eclipse.jdt.internal.compiler.ast.Expression statement2 = (org.eclipse.jdt.internal.compiler.ast.Expression) statement;
@@ -2878,9 +2864,9 @@ class ASTConverter {
literal.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1);
return literal;
}
-
+
public Expression convert(org.eclipse.jdt.internal.compiler.ast.SwitchExpression expression) {
- if (this.ast.apiLevel < AST.JLS12_INTERNAL || !this.ast.isPreviewEnabled()) {
+ if (!this.ast.isPreviewEnabled()) {
return createFakeNullLiteral(expression);
}
SwitchExpression switchExpression = new SwitchExpression(this.ast);
@@ -2935,6 +2921,21 @@ class ASTConverter {
return synchronizedStatement;
}
+ public Expression convert(org.eclipse.jdt.internal.compiler.ast.TextBlock expression) {
+ if (!this.ast.isPreviewEnabled()) {
+ return createFakeNullLiteral(expression);
+ }
+ int length = expression.sourceEnd - expression.sourceStart + 1;
+ int sourceStart = expression.sourceStart;
+ TextBlock literal = new TextBlock(this.ast);
+ if (this.resolveBindings) {
+ this.recordNodes(literal, expression);
+ }
+ literal.internalSetEscapedValue(new String(this.compilationUnitSource, sourceStart, length));
+ literal.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1);
+ return literal;
+ }
+
public Expression convert(org.eclipse.jdt.internal.compiler.ast.ThisReference reference) {
if (reference.isImplicitThis()) {
// There is no source associated with an implicit this
@@ -3217,6 +3218,18 @@ class ASTConverter {
return whileStatement;
}
+ public Statement convert(org.eclipse.jdt.internal.compiler.ast.YieldStatement statement) {
+ if (this.ast.apiLevel != AST.JLS13_INTERNAL) {
+ return createFakeEmptyStatement(statement);
+ }
+ YieldStatement yieldStatement = new YieldStatement(this.ast);
+ // We don't need to record Nodes
+ yieldStatement.setExpression(convert(statement.expression));
+ yieldStatement.setImplicit(statement.isImplicit);
+ yieldStatement.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 1);
+ return yieldStatement;
+ }
+
public ImportDeclaration convertImport(org.eclipse.jdt.internal.compiler.ast.ImportReference importReference) {
final ImportDeclaration importDeclaration = new ImportDeclaration(this.ast);
Name name = getImportName(importReference);
@@ -6136,4 +6149,5 @@ class ASTConverter {
}
}
}
+
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTMatcher.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTMatcher.java
index 2bfe6beac5..5e7935a82f 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTMatcher.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTMatcher.java
@@ -484,9 +484,7 @@ public class ASTMatcher {
return false;
}
BreakStatement o = (BreakStatement) other;
- return ( node.getAST().apiLevel == AST.JLS12_INTERNAL && node.getAST().isPreviewEnabled() && node.getExpression() != null
- ? safeSubtreeMatch(node.getExpression(), o.getExpression()) && node.isImplicit() == o.isImplicit()
- : safeSubtreeMatch(node.getLabel(), o.getLabel()));
+ return (safeSubtreeMatch(node.getLabel(), o.getLabel()));
}
/**
@@ -2269,7 +2267,7 @@ public class ASTMatcher {
return false;
}
SwitchCase o = (SwitchCase) other;
- return ( node.getAST().apiLevel == AST.JLS12_INTERNAL && node.getAST().isPreviewEnabled()
+ return ( node.getAST().isPreviewEnabled()
? safeSubtreeListMatch(node.expressions(), o.expressions())
: compareDeprecatedSwitchExpression(node, o));
}
@@ -2394,6 +2392,31 @@ public class ASTMatcher {
* @return <code>true</code> if the subtree matches, or
* <code>false</code> if they do not match or the other object has a
* different node type or is <code>null</code>
+ * @noreference This method is not intended to be referenced by clients as it is a part of Java preview feature.
+ * @nooverride This method is not intended to be re-implemented or extended by clients as it is a part of Java preview feature.
+ * @since 3.20
+ */
+ public boolean match(TextBlock node, Object other) {
+ if (!(other instanceof TextBlock)) {
+ return false;
+ }
+ TextBlock o = (TextBlock) other;
+ return safeEquals(node.getEscapedValue(), o.getEscapedValue());
+ }
+
+ /**
+ * Returns whether the given node and the other object match.
+ * <p>
+ * The default implementation provided by this class tests whether the
+ * other object is a node of the same type with structurally isomorphic
+ * child subtrees. Subclasses may override this method as needed.
+ * </p>
+ *
+ * @param node the node
+ * @param other the other object, or <code>null</code>
+ * @return <code>true</code> if the subtree matches, or
+ * <code>false</code> if they do not match or the other object has a
+ * different node type or is <code>null</code>
* @since 3.0
*/
public boolean match(TextElement node, Object other) {
@@ -2816,5 +2839,30 @@ public class ASTMatcher {
&& node.isUpperBound() == o.isUpperBound()
&& safeSubtreeMatch(node.getBound(), o.getBound());
}
+
+ /**
+ * Returns whether the given node and the other object match.
+ * <p>
+ * The default implementation provided by this class tests whether the
+ * other object is a node of the same type with structurally isomorphic
+ * child subtrees. Subclasses may override this method as needed.
+ * </p>
+ *
+ * @param node the node
+ * @param other the other object, or <code>null</code>
+ * @return <code>true</code> if the subtree matches, or
+ * <code>false</code> if they do not match or the other object has a
+ * different node type or is <code>null</code>
+ * @noreference This method is not intended to be referenced by clients as it is a part of Java preview feature.
+ * @nooverride This method is not intended to be re-implemented or extended by clients as it is a part of Java preview feature.
+ * @since 3.20
+ */
+ public boolean match(YieldStatement node, Object other) {
+ if (!(other instanceof YieldStatement)) {
+ return false;
+ }
+ YieldStatement o = (YieldStatement) other;
+ return safeSubtreeMatch(node.getExpression(), o.getExpression());
+ }
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTNode.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTNode.java
index f9193e2ddc..1df43ab99c 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTNode.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTNode.java
@@ -961,6 +961,22 @@ public abstract class ASTNode {
* @since 3.18
*/
public static final int SWITCH_EXPRESSION = 100;
+
+ /**
+ * Node type constant indicating a node of type
+ * <code>YieldStatement</code>.
+ * @see YieldStatement
+ * @since 3.20
+ */
+ public static final int YIELD_STATEMENT = 101;
+
+ /**
+ * Node type constant indicating a node of type
+ * <code>TextBlock</code>.
+ * @see TextBlock
+ * @since 3.20
+ */
+ public static final int TEXT_BLOCK = 102;
/**
* Returns the node class for the corresponding node type.
@@ -1142,6 +1158,8 @@ public abstract class ASTNode {
return SynchronizedStatement.class;
case TAG_ELEMENT :
return TagElement.class;
+ case TEXT_BLOCK :
+ return TextBlock.class;
case TEXT_ELEMENT :
return TextElement.class;
case THIS_EXPRESSION :
@@ -1174,6 +1192,8 @@ public abstract class ASTNode {
return WhileStatement.class;
case WILDCARD_TYPE :
return WildcardType.class;
+ case YIELD_STATEMENT :
+ return YieldStatement.class;
}
throw new IllegalArgumentException();
}
@@ -2108,6 +2128,7 @@ public abstract class ASTNode {
* </p>
*
* @exception UnsupportedOperationException if this operation is used below JLS12
+ * @deprecated
* @since 3.16
*/
final void unsupportedBelow12() {
@@ -2167,6 +2188,38 @@ public abstract class ASTNode {
}
/**
+ * Checks that this AST operation is only used when
+ * building JLS12 level ASTs.
+ * <p>
+ * Use this method to prevent access to properties available only in JLS12.
+ * </p>
+ *
+ * @exception UnsupportedOperationException if this operation is is not used in JLS12
+ * @since 3.20
+ */
+ // In API Javadocs, add: * @deprecated In the JLS13 API, this method is replaced by {@link #replacement()}.
+ final void supportedOnlyIn12() {
+ if (this.ast.apiLevel != AST.JLS12_INTERNAL) {
+ throw new UnsupportedOperationException("Operation only supported in JLS12 AST"); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Checks that this AST operation is only used when
+ * building JLS13 level ASTs.
+ * <p>
+ * Use this method to prevent access to new properties available only in JLS13.
+ * </p>
+ *
+ * @exception UnsupportedOperationException if this operation is not used in JLS13
+ * @since 3.20
+ */
+ final void supportedOnlyIn13() {
+ if (this.ast.apiLevel != AST.JLS13_INTERNAL) {
+ throw new UnsupportedOperationException("Operation only supported in JLS13 AST"); //$NON-NLS-1$
+ }
+ }
+ /**
* Sets or clears this node's parent node and location.
* <p>
* Note that this method is package-private. The pointer from a node
@@ -3137,11 +3190,4 @@ public abstract class ASTNode {
* @return the size of this node in bytes
*/
abstract int memSize();
-
- boolean isPreviewEnabled() {
- if (this.ast.apiLevel == AST.JLS12_INTERNAL && this.ast.isPreviewEnabled()) {
- return true;
- }
- return false;
- }
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTParser.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTParser.java
index 66d1215404..e454771905 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTParser.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTParser.java
@@ -235,6 +235,7 @@ public class ASTParser {
case AST.JLS10_INTERNAL:
case AST.JLS11_INTERNAL:
case AST.JLS12_INTERNAL:
+ case AST.JLS13_INTERNAL:
break;
default:
throw new IllegalArgumentException();
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTVisitor.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTVisitor.java
index a7eb1fc1a3..bb5494e294 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTVisitor.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTVisitor.java
@@ -1533,6 +1533,8 @@ public abstract class ASTVisitor {
* @return <code>true</code> if the children of this node should be
* visited, and <code>false</code> if the children of this node should
* be skipped
+ * @noreference This method is not intended to be referenced by clients as it is a part of Java preview feature.
+ * @nooverride This method is not intended to be re-implemented or extended by clients as it is a part of Java preview feature.
* @since 3.18
*/
public boolean visit(SwitchExpression node) {
@@ -1593,6 +1595,25 @@ public abstract class ASTVisitor {
/**
* Visits the given type-specific AST node.
* <p>
+ * The default implementation does nothing and returns true.
+ * Subclasses may reimplement.
+ * </p>
+ *
+ * @param node the node to visit
+ * @return <code>true</code> if the children of this node should be
+ * visited, and <code>false</code> if the children of this node should
+ * be skipped
+ * @noreference This method is not intended to be referenced by clients as it is a part of Java preview feature.
+ * @nooverride This method is not intended to be re-implemented or extended by clients as it is a part of Java preview feature.
+ * @since 3.20
+ */
+ public boolean visit(TextBlock node) {
+ return true;
+ }
+
+ /**
+ * Visits the given type-specific AST node.
+ * <p>
* The default implementation does nothing and return true.
* Subclasses may reimplement.
* </p>
@@ -1854,6 +1875,25 @@ public abstract class ASTVisitor {
}
/**
+ * Visits the given type-specific AST node.
+ * <p>
+ * The default implementation does nothing and returns true.
+ * Subclasses may reimplement.
+ * </p>
+ *
+ * @param node the node to visit
+ * @return <code>true</code> if the children of this node should be
+ * visited, and <code>false</code> if the children of this node should
+ * be skipped
+ * @noreference This method is not intended to be referenced by clients as it is a part of Java preview feature.
+ * @nooverride This method is not intended to be re-implemented or extended by clients as it is a part of Java preview feature.
+ * @since 3.20
+ */
+ public boolean visit(YieldStatement node) {
+ return true;
+ }
+
+ /**
* End of visit the given type-specific AST node.
* <p>
* The default implementation does nothing. Subclasses may reimplement.
@@ -2897,6 +2937,21 @@ public abstract class ASTVisitor {
* </p>
*
* @param node the node to visit
+ * @noreference This method is not intended to be referenced by clients as it is a part of Java preview feature.
+ * @nooverride This method is not intended to be re-implemented or extended by clients as it is a part of Java preview feature.
+ * @since 3.20
+ */
+ public void endVisit(TextBlock node) {
+ // default implementation: do nothing
+ }
+
+ /**
+ * End of visit the given type-specific AST node.
+ * <p>
+ * The default implementation does nothing. Subclasses may reimplement.
+ * </p>
+ *
+ * @param node the node to visit
* @since 3.0
*/
public void endVisit(TextElement node) {
@@ -3100,4 +3155,19 @@ public abstract class ASTVisitor {
public void endVisit(WildcardType node) {
// default implementation: do nothing
}
+
+ /**
+ * End of visit the given type-specific AST node.
+ * <p>
+ * The default implementation does nothing. Subclasses may reimplement.
+ * </p>
+ *
+ * @param node the node to visit
+ * @noreference This method is not intended to be referenced by clients as it is a part of Java preview feature.
+ * @nooverride This method is not intended to be re-implemented or extended by clients as it is a part of Java preview feature.
+ * @since 3.20
+ */
+ public void endVisit(YieldStatement node) {
+ // default implementation: do nothing
+ }
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/BreakStatement.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/BreakStatement.java
index 46afdc1cb9..25ca48c8e3 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/BreakStatement.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/BreakStatement.java
@@ -43,6 +43,8 @@ public class BreakStatement extends Statement {
/**
* The "expression" structural property of this node type (child type: {@link Expression}). (added in JEP 325).
+ * @noreference This property is not intended to be referenced by clients as it is a part of Java preview feature.
+ * @deprecated
* @since 3.18
*/
public static final ChildPropertyDescriptor EXPRESSION_PROPERTY =
@@ -56,13 +58,6 @@ public class BreakStatement extends Statement {
private static final List PROPERTY_DESCRIPTORS;
/**
- * A list of property descriptors (element type:
- * {@link StructuralPropertyDescriptor}),
- * or null if uninitialized.
- */
- private static final List PROPERTY_DESCRIPTORS_12;
-
- /**
* <code>true</code> indicates implicit and <code>false</code> indicates not implicit.
*/
private boolean isImplicit = false;
@@ -72,12 +67,6 @@ public class BreakStatement extends Statement {
createPropertyList(BreakStatement.class, properyList);
addProperty(LABEL_PROPERTY, properyList);
PROPERTY_DESCRIPTORS = reapPropertyList(properyList);
-
- List properyList_12 = new ArrayList(2);
- createPropertyList(BreakStatement.class, properyList_12);
- addProperty(LABEL_PROPERTY, properyList_12);
- addProperty(EXPRESSION_PROPERTY, properyList_12);
- PROPERTY_DESCRIPTORS_12 = reapPropertyList(properyList_12);
}
/**
@@ -96,12 +85,20 @@ public class BreakStatement extends Statement {
}
/**
- * @since 3.19 BETA_JAVA13
+ * Returns a list of structural property descriptors for this node type.
+ * Clients must not modify the result.
+ *
+ * @param apiLevel the API level; one of the
+ * <code>AST.JLS*</code> constants
+ * @param previewEnabled the previewEnabled flag
+
+ * @return a list of property descriptors (element type:
+ * {@link StructuralPropertyDescriptor})
+ * @noreference This method is not intended to be referenced by clients as it is a part of Java preview feature.
+ * @deprecated
+ * @since 3.20
*/
public static List propertyDescriptors(int apiLevel, boolean previewEnabled) {
- if (apiLevel == AST.JLS12_INTERNAL && previewEnabled) {
- return PROPERTY_DESCRIPTORS_12;
- }
return PROPERTY_DESCRIPTORS;
}
@@ -134,11 +131,6 @@ public class BreakStatement extends Statement {
}
@Override
- final List internalStructuralPropertiesForType(int apiLevel, boolean isPreviewEnabled) {
- return propertyDescriptors(apiLevel, isPreviewEnabled);
- }
-
- @Override
final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) {
if (property == LABEL_PROPERTY) {
if (get) {
@@ -171,9 +163,6 @@ public class BreakStatement extends Statement {
result.setSourceRange(getStartPosition(), getLength());
result.copyLeadingComment(this);
result.setLabel((SimpleName) ASTNode.copySubtree(target, getLabel()));
- if (isPreviewEnabled()) {
- result.setExpression((Expression) ASTNode.copySubtree(target, getExpression()));
- }
return result;
}
@@ -187,9 +176,6 @@ public class BreakStatement extends Statement {
void accept0(ASTVisitor visitor) {
boolean visitChildren = visitor.visit(this);
if (visitChildren) {
- if (isPreviewEnabled()) {
- acceptChild(visitor, getExpression());
- }
acceptChild(visitor, getLabel());
}
visitor.endVisit(this);
@@ -228,14 +214,15 @@ public class BreakStatement extends Statement {
* there is none.
*
* @return the expression, or <code>null</code> if there is none
- * @exception UnsupportedOperationException if this operation is used below JLS12
- * @exception UnsupportedOperationException if this expression is used with previewEnabled flag as false
+ * @exception UnsupportedOperationException if this operation is used other than JLS12
+ * @noreference This method is not intended to be referenced by clients as it is a part of Java preview feature.
+ * @nooverride This method is not intended to be re-implemented or extended by clients as it is a part of Java preview feature.
+ * @deprecated
* @since 3.18
*/
public Expression getExpression() {
// optionalExpression can be null
- unsupportedBelow12();
- unsupportedWithoutPreviewError();
+ supportedOnlyIn12();
return this.optionalExpression;
}
@@ -249,13 +236,14 @@ public class BreakStatement extends Statement {
* <li>the node belongs to a different AST</li>
* <li>the node already has a parent</li>
* </ul>
- * @exception UnsupportedOperationException if this operation is used below JLS12
- * @exception UnsupportedOperationException if this expression is used with previewEnabled flag as false
+ * @exception UnsupportedOperationException if this operation is used other than JLS12
+ * @noreference This method is not intended to be referenced by clients as it is a part of Java preview feature.
+ * @nooverride This method is not intended to be re-implemented or extended by clients as it is a part of Java preview feature.
+ * @deprecated
* @since 3.18
*/
public void setExpression(Expression expression) {
- unsupportedBelow12();
- unsupportedWithoutPreviewError();
+ supportedOnlyIn12();
ASTNode oldChild = this.optionalExpression;
preReplaceChild(oldChild, expression, EXPRESSION_PROPERTY);
this.optionalExpression = expression;
@@ -267,13 +255,14 @@ public class BreakStatement extends Statement {
*<code>true</code> indicates implicit and <code>false</code> indicates not implicit.
*
* @return isImplicit <code>true</code> or <code>false</code>
- * @exception UnsupportedOperationException if this operation is used below JLS12
- * @exception UnsupportedOperationException if this expression is used with previewEnabled flag as false
+ * @exception UnsupportedOperationException if this operation is used other than JLS12
+ * @noreference This method is not intended to be referenced by clients as it is a part of Java preview feature.
+ * @nooverride This method is not intended to be re-implemented or extended by clients as it is a part of Java preview feature.
+ * @deprecated
* @since 3.18
*/
public boolean isImplicit() {
- unsupportedBelow12();
- unsupportedWithoutPreviewError();
+ supportedOnlyIn12();
return this.isImplicit;
}
@@ -283,13 +272,12 @@ public class BreakStatement extends Statement {
* generated by compiler and is not expected to be set by client.
* @param isImplicit <code>true</code> or <code>false</code>
- * @exception UnsupportedOperationException if this operation is used below JLS12
- * @exception UnsupportedOperationException if this expression is used with previewEnabled flag as false
+ * @exception UnsupportedOperationException if this operation is used other than JLS12
+ * @deprecated
* @since 3.18
*/
void setImplicit(boolean isImplicit) {
- unsupportedBelow12();
- unsupportedWithoutPreviewError();
+ supportedOnlyIn12();
this.isImplicit = isImplicit;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultASTVisitor.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultASTVisitor.java
index 749fa7c209..333d5b5c4a 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultASTVisitor.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultASTVisitor.java
@@ -353,6 +353,10 @@ class DefaultASTVisitor extends ASTVisitor {
endVisitNode(node);
}
@Override
+ public void endVisit(TextBlock node) {
+ endVisitNode(node);
+ }
+ @Override
public void endVisit(TextElement node) {
endVisitNode(node);
}
@@ -413,6 +417,10 @@ class DefaultASTVisitor extends ASTVisitor {
public void endVisit(WildcardType node) {
endVisitNode(node);
}
+ @Override
+ public void endVisit(YieldStatement node) {
+ endVisitNode(node);
+ }
protected void endVisitNode(ASTNode node) {
// do nothing
}
@@ -756,6 +764,11 @@ class DefaultASTVisitor extends ASTVisitor {
}
@Override
+ public boolean visit(TextBlock node) {
+ return visitNode(node);
+ }
+
+ @Override
public boolean visit(TextElement node) {
return visitNode(node);
}
@@ -829,6 +842,11 @@ class DefaultASTVisitor extends ASTVisitor {
public boolean visit(WildcardType node) {
return visitNode(node);
}
+
+ @Override
+ public boolean visit(YieldStatement node) {
+ return visitNode(node);
+ }
protected boolean visitNode(ASTNode node) {
return true;
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java
index 537d4e2679..ee36dc5527 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java
@@ -755,6 +755,7 @@ class DefaultBindingResolver extends BindingResolver {
return this.getTypeBinding(compilerExpression.resolvedType);
}
break;
+ case ASTNode.TEXT_BLOCK :
case ASTNode.STRING_LITERAL :
if (this.scope != null) {
return this.getTypeBinding(this.scope.getJavaLangString());
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SwitchCase.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SwitchCase.java
index 55c31294f4..7fc71259e8 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SwitchCase.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SwitchCase.java
@@ -46,6 +46,7 @@ public class SwitchCase extends Statement {
/**
* The "expression" structural property of this node type (child type: {@link Expression}). (added in JEP 325).
+ * @noreference This property is not intended to be referenced by clients as it is a part of Java preview feature.
* @since 3.18
*/
public static final ChildListPropertyDescriptor EXPRESSIONS2_PROPERTY =
@@ -53,6 +54,7 @@ public class SwitchCase extends Statement {
/**
* The "switchLabeledRule" structural property of this node type (type: {@link Boolean}).
+ * @noreference This property is not intended to be referenced by clients as it is a part of Java preview feature.
* @since 3.18
*/
public static final SimplePropertyDescriptor SWITCH_LABELED_RULE_PROPERTY =
@@ -70,7 +72,7 @@ public class SwitchCase extends Statement {
* {@link StructuralPropertyDescriptor}),
* or null if uninitialized.
*/
- private static final List PROPERTY_DESCRIPTORS_12;
+ private static final List PROPERTY_DESCRIPTORS_13;
static {
List propertyList = new ArrayList(2);
@@ -82,7 +84,7 @@ public class SwitchCase extends Statement {
createPropertyList(SwitchCase.class, propertyList);
addProperty(EXPRESSIONS2_PROPERTY , propertyList);
addProperty(SWITCH_LABELED_RULE_PROPERTY, propertyList);
- PROPERTY_DESCRIPTORS_12 = reapPropertyList(propertyList);
+ PROPERTY_DESCRIPTORS_13 = reapPropertyList(propertyList);
}
/**
@@ -112,8 +114,8 @@ public class SwitchCase extends Statement {
* @since 3.19
*/
public static List propertyDescriptors(int apiLevel, boolean previewEnabled) {
- if (apiLevel == AST.JLS12_INTERNAL && previewEnabled) {
- return PROPERTY_DESCRIPTORS_12;
+ if (apiLevel == AST.JLS13_INTERNAL && previewEnabled) {
+ return PROPERTY_DESCRIPTORS_13;
}
return PROPERTY_DESCRIPTORS;
}
@@ -150,7 +152,7 @@ public class SwitchCase extends Statement {
*/
SwitchCase(AST ast) {
super(ast);
- if (isPreviewEnabled()) {
+ if (ast.isPreviewEnabled()) {
this.expressions = new ASTNode.NodeList(EXPRESSIONS2_PROPERTY );
}
}
@@ -213,7 +215,7 @@ public class SwitchCase extends Statement {
SwitchCase result = new SwitchCase(target);
result.setSourceRange(getStartPosition(), getLength());
result.copyLeadingComment(this);
- if (isPreviewEnabled()) {
+ if (this.ast.isPreviewEnabled()) {
result.expressions().addAll(
ASTNode.copySubtrees(target, expressions()));
} else {
@@ -233,7 +235,7 @@ public class SwitchCase extends Statement {
void accept0(ASTVisitor visitor) {
boolean visitChildren = visitor.visit(this);
if (visitChildren) {
- if (isPreviewEnabled()) {
+ if (this.ast.isPreviewEnabled()) {
acceptChildren(visitor, this.expressions);
} else {
acceptChild(visitor, getExpression());
@@ -271,13 +273,15 @@ public class SwitchCase extends Statement {
*
* @return the list of expression nodes
* (element type: {@link Expression})
- * @exception UnsupportedOperationException if this operation is used below JLS12
+ * @exception UnsupportedOperationException if this operation is used other than JLS13
* @exception UnsupportedOperationException if this expression is used with previewEnabled flag as false
+ * @noreference This method is not intended to be referenced by clients as it is a part of Java preview feature.
+ * @nooverride This method is not intended to be re-implemented or extended by clients as it is a part of Java preview feature.
* @since 3.18
*/
public List expressions() {
if (this.expressions == null) {
- unsupportedBelow12();
+ supportedOnlyIn13();
unsupportedWithoutPreviewError();
}
return this.expressions;
@@ -310,12 +314,14 @@ public class SwitchCase extends Statement {
* <code>true</code> indicates "->" and <code>false</code> indicates ":".
* @param switchLabeledRule <code>true</code> or <code>false</code>
- * @exception UnsupportedOperationException if this operation is used below JLS12
+ * @exception UnsupportedOperationException if this operation is used other than JLS13
* @exception UnsupportedOperationException if this expression is used with previewEnabled flag as false
+ * @noreference This method is not intended to be referenced by clients as it is a part of Java preview feature.
+ * @nooverride This method is not intended to be re-implemented or extended by clients as it is a part of Java preview feature.
* @since 3.18
*/
public void setSwitchLabeledRule(boolean switchLabeledRule) {
- unsupportedBelow12();
+ supportedOnlyIn13();
unsupportedWithoutPreviewError();
preValueChange(SWITCH_LABELED_RULE_PROPERTY);
this.switchLabeledRule = switchLabeledRule;
@@ -327,12 +333,14 @@ public class SwitchCase extends Statement {
*<code>true</code> indicates "->" and <code>false</code> indicates ":".
*
* @return switchLabeledRule <code>true</code> or <code>false</code>
- * @exception UnsupportedOperationException if this operation is used below JLS12
+ * @exception UnsupportedOperationException if this operation is used other than JLS13
* @exception UnsupportedOperationException if this expression is used with previewEnabled flag as false
+ * @noreference This method is not intended to be referenced by clients as it is a part of Java preview feature.
+ * @nooverride This method is not intended to be re-implemented or extended by clients as it is a part of Java preview feature.
* @since 3.18
*/
public boolean isSwitchLabeledRule() {
- unsupportedBelow12();
+ supportedOnlyIn13();
unsupportedWithoutPreviewError();
return this.switchLabeledRule;
}
@@ -348,7 +356,7 @@ public class SwitchCase extends Statement {
* <code>false</code> if this is a non-default switch case
*/
public boolean isDefault() {
- if (isPreviewEnabled()) {
+ if (this.ast.isPreviewEnabled()) {
return expressions().isEmpty();
}
return getExpression() == null;
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SwitchExpression.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SwitchExpression.java
index de55fbf8a5..a8ec3012df 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SwitchExpression.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SwitchExpression.java
@@ -32,6 +32,7 @@ import java.util.List;
*
* @since 3.18
* @noinstantiate This class is not intended to be instantiated by clients.
+ * @noreference This method is not intended to be referenced by clients as it is a part of Java preview feature.
*/
@SuppressWarnings({"rawtypes", "unchecked"})
public class SwitchExpression extends Expression {
@@ -55,14 +56,14 @@ public class SwitchExpression extends Expression {
* {@link StructuralPropertyDescriptor}),
* or null if uninitialized.
*/
- private static final List PROPERTY_DESCRIPTORS_12_0;
+ private static final List PROPERTY_DESCRIPTORS;
static {
List propertyList = new ArrayList(3);
createPropertyList(SwitchExpression.class, propertyList);
addProperty(EXPRESSION_PROPERTY, propertyList);
addProperty(STATEMENTS_PROPERTY, propertyList);
- PROPERTY_DESCRIPTORS_12_0 = reapPropertyList(propertyList);
+ PROPERTY_DESCRIPTORS = reapPropertyList(propertyList);
}
/**
@@ -88,11 +89,12 @@ public class SwitchExpression extends Expression {
* @param previewEnabled previewEnabled flag
* @return a list of property descriptors (element type:
* {@link StructuralPropertyDescriptor})
- * @since 3.19
+ * @noreference This method is not intended to be referenced by clients.
+ * @since 3.20
*/
public static List propertyDescriptors(int apiLevel, boolean previewEnabled) {
- if (previewEnabled) {
- return PROPERTY_DESCRIPTORS_12_0;
+ if (apiLevel == AST.JLS13_INTERNAL && previewEnabled) {
+ return PROPERTY_DESCRIPTORS;
}
return null;
}
@@ -120,11 +122,12 @@ public class SwitchExpression extends Expression {
* </p>
*
* @param ast the AST that is to own this node
- * @exception UnsupportedOperationException if this operation is used below JLS12
+ * @exception UnsupportedOperationException if this operation is used other than JLS13
+ * @exception UnsupportedOperationException if this expression is used with previewEnabled flag as false
*/
SwitchExpression(AST ast) {
super(ast);
- unsupportedBelow12();
+ supportedOnlyIn13();
unsupportedWithoutPreviewError();
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TextBlock.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TextBlock.java
new file mode 100644
index 0000000000..a74ed8307e
--- /dev/null
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TextBlock.java
@@ -0,0 +1,296 @@
+/*******************************************************************************
+ * Copyright (c) 2019 IBM Corporation and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.jdt.core.dom;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jdt.core.compiler.InvalidInputException;
+import org.eclipse.jdt.internal.compiler.parser.Scanner;
+import org.eclipse.jdt.internal.compiler.parser.ScannerHelper;
+import org.eclipse.jdt.internal.compiler.parser.TerminalTokens;
+
+/**
+ * TextBolck AST node type.
+ *
+ * These are block of String literal nodes.
+ *
+ * @since 3.20
+ * @noinstantiate This class is not intended to be instantiated by clients.
+ * @noreference This class is not intended to be referenced by clients as it is a part of Java preview feature.
+ */
+@SuppressWarnings("rawtypes")
+public class TextBlock extends Expression {
+
+ /**
+ * The "escapedValue" structural property of this node type (type: {@link String}).
+ * @since 3.0
+ */
+ public static final SimplePropertyDescriptor ESCAPED_VALUE_PROPERTY =
+ new SimplePropertyDescriptor(TextBlock.class, "escapedValue", String.class, MANDATORY); //$NON-NLS-1$
+
+ /**
+ * A list of property descriptors (element type:
+ * {@link StructuralPropertyDescriptor}),
+ * or null if uninitialized.
+ */
+ private static final List PROPERTY_DESCRIPTORS;
+
+ static {
+ List propertyList = new ArrayList(2);
+ createPropertyList(TextBlock.class, propertyList);
+ addProperty(ESCAPED_VALUE_PROPERTY, propertyList);
+ PROPERTY_DESCRIPTORS = reapPropertyList(propertyList);
+ }
+
+ /**
+ * Returns a list of structural property descriptors for this node type.
+ * Clients must not modify the result.
+ *
+ * @param apiLevel the API level; one of the
+ * <code>AST.JLS*</code> constants
+
+ * @return a list of property descriptors (element type:
+ * {@link StructuralPropertyDescriptor})
+ * @since 3.0
+ */
+ public static List propertyDescriptors(int apiLevel) {
+ return propertyDescriptors(apiLevel, false);
+ }
+
+ /**
+ * Returns a list of structural property descriptors for this node type.
+ * Clients must not modify the result.
+ *
+ * @param apiLevel the API level; one of the
+ * <code>AST.JLS*</code> constants
+ * @param previewEnabled the previewEnabled flag
+ * @return a list of property descriptors (element type:
+ * {@link StructuralPropertyDescriptor})
+ * @noreference This method is not intended to be referenced by clients.
+ * @since 3.20
+ */
+ public static List propertyDescriptors(int apiLevel, boolean previewEnabled) {
+ if (apiLevel == AST.JLS13_INTERNAL && previewEnabled) {
+ return PROPERTY_DESCRIPTORS;
+ }
+ return null;
+ }
+ /**
+ * The literal string, including quotes and escapes; defaults to the
+ * literal for the empty string.
+ */
+ private String escapedValue = "\"\"";//$NON-NLS-1$
+
+ /**
+ * Creates a new unparented TextBlock node owned by the given AST.
+ * By default, the TextBlock denotes the empty string.
+ * <p>
+ * N.B. This constructor is package-private.
+ * </p>
+ *
+ * @param ast the AST that is to own this node
+ * @exception UnsupportedOperationException if this operation is used other than JLS13
+ * @exception UnsupportedOperationException if this expression is used with previewEnabled flag as false
+ */
+ TextBlock(AST ast) {
+ super(ast);
+ supportedOnlyIn13();
+ unsupportedWithoutPreviewError();
+ }
+
+ @Override
+ final List internalStructuralPropertiesForType(int apiLevel) {
+ return propertyDescriptors(apiLevel);
+ }
+
+ @Override
+ final List internalStructuralPropertiesForType(int apiLevel, boolean previewEnabled) {
+ return propertyDescriptors(apiLevel, previewEnabled);
+ }
+
+ @Override
+ final Object internalGetSetObjectProperty(SimplePropertyDescriptor property, boolean get, Object value) {
+ if (property == ESCAPED_VALUE_PROPERTY) {
+ if (get) {
+ return getEscapedValue();
+ } else {
+ setEscapedValue((String) value);
+ return null;
+ }
+ }
+ // allow default implementation to flag the error
+ return super.internalGetSetObjectProperty(property, get, value);
+ }
+
+ @Override
+ final int getNodeType0() {
+ return TEXT_BLOCK;
+ }
+
+ @Override
+ ASTNode clone0(AST target) {
+ TextBlock result = new TextBlock(target);
+ result.setSourceRange(getStartPosition(), getLength());
+ result.setEscapedValue(getEscapedValue());
+ return result;
+ }
+
+ @Override
+ final boolean subtreeMatch0(ASTMatcher matcher, Object other) {
+ // dispatch to correct overloaded match method
+ return matcher.match(this, other);
+ }
+
+ @Override
+ void accept0(ASTVisitor visitor) {
+ visitor.visit(this);
+ visitor.endVisit(this);
+ }
+
+ /**
+ * Returns the string value of this literal node to the given string
+ * literal token. The token is the sequence of characters that would appear
+ * in the source program, including enclosing double quotes and embedded
+ * escapes.
+ *
+ * @return the string literal token, including enclosing double
+ * quotes and embedded escapes
+ */
+ public String getEscapedValue() {
+ return this.escapedValue;
+ }
+
+ /**
+ * Sets the string value of this literal node to the given string literal
+ * token. The token is the sequence of characters that would appear in the
+ * source program, including enclosing double quotes and embedded escapes.
+ * For example,
+ * <ul>
+ * <li><code>""</code> <code>setLiteral("\"\"")</code></li>
+ * <li><code>"hello world"</code> <code>setLiteral("\"hello world\"")</code></li>
+ * <li><code>"boo\nhoo"</code> <code>setLiteral("\"boo\\nhoo\"")</code></li>
+ * </ul>
+ *
+ * @param token the string literal token, including enclosing double
+ * quotes and embedded escapes
+ * @exception IllegalArgumentException if the argument is incorrect
+ */
+ public void setEscapedValue(String token) {
+ // update internalSetEscapedValue(String) if this is changed
+ if (token == null) {
+ throw new IllegalArgumentException("Token cannot be null"); //$NON-NLS-1$
+ }
+ Scanner scanner = this.ast.scanner;
+ char[] source = token.toCharArray();
+ scanner.setSource(source);
+ scanner.resetTo(0, source.length);
+ try {
+ int tokenType = scanner.getNextToken();
+ switch(tokenType) {
+ case TerminalTokens.TokenNameTextBlock:
+ break;
+ default:
+ throw new IllegalArgumentException("Invalid Text Block : >" + token + "<"); //$NON-NLS-1$//$NON-NLS-2$
+ }
+ } catch(InvalidInputException e) {
+ throw new IllegalArgumentException("Invalid Text Block : >" + token + "<");//$NON-NLS-1$//$NON-NLS-2$
+ }
+ preValueChange(ESCAPED_VALUE_PROPERTY);
+ this.escapedValue = token;
+ postValueChange(ESCAPED_VALUE_PROPERTY);
+ }
+
+ /* (omit javadoc for this method)
+ * This method is a copy of setEscapedValue(String) that doesn't do any validation.
+ */
+ void internalSetEscapedValue(String token) {
+ preValueChange(ESCAPED_VALUE_PROPERTY);
+ this.escapedValue = token;
+ postValueChange(ESCAPED_VALUE_PROPERTY);
+ }
+
+ /**
+ * Returns the value of this literal node.
+ * <p>
+ * For example,
+ * <pre>
+ * TextBlock s;
+ * s.setEscapedValue("\"\"\" \n hello\\n world\"");
+ * assert s.getLiteralValue().equals("hello\n world");
+ * </pre>
+ * <p>
+ * Note that this is a convenience method that converts from the stored
+ * TextBlock token returned by <code>getEscapedLiteral</code>.
+ * </p>
+ *
+ * @return the string value without enclosing triple quotes
+ * @exception IllegalArgumentException if the literal value cannot be converted
+ */
+ public String getLiteralValue() {
+ String s = getEscapedValue();
+ int len = s.length();
+ if (len < 2 || s.indexOf("\"\"\"") != 0 || !s.substring(len-3, len).equals("\"\"\"") ) { //$NON-NLS-1$ //$NON-NLS-2$
+ throw new IllegalArgumentException();
+ }
+
+ boolean newLineFound = false;
+ for (int i = 3; i < s.length(); i++) {
+ char c = s.charAt(i);
+ while (ScannerHelper.isWhitespace(c)) {
+ switch (c) {
+ case 10 : /* \ u000a: LINE FEED */
+ case 13 : /* \ u000d: CARRIAGE RETURN */
+ newLineFound = true;
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ if (!newLineFound) {
+ throw new IllegalArgumentException();
+ }
+
+ Scanner scanner = this.ast.scanner;
+ char[] source = s.toCharArray();
+ scanner.setSource(source);
+ scanner.resetTo(0, source.length);
+ try {
+ int tokenType = scanner.getNextToken();
+ switch(tokenType) {
+ case TerminalTokens.TokenNameTextBlock:
+ return scanner.getCurrentStringLiteral();
+ default:
+ throw new IllegalArgumentException();
+ }
+ } catch(InvalidInputException e) {
+ throw new IllegalArgumentException();
+ }
+ }
+
+
+ @Override
+ int memSize() {
+ int size = BASE_NODE_SIZE + 1 * 4 + stringSize(this.escapedValue);
+ return size;
+ }
+
+ @Override
+ int treeSize() {
+ return memSize();
+ }
+}
+
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/YieldStatement.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/YieldStatement.java
new file mode 100644
index 0000000000..4b1af17390
--- /dev/null
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/YieldStatement.java
@@ -0,0 +1,247 @@
+/*******************************************************************************
+ * Copyright (c) 2019 IBM Corporation and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.jdt.core.dom;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Yield statement AST node type.
+ *
+ * <pre>
+ * YieldStatement:
+ * <b>Yield</b> <b>{ Identifier/Expression }</b>
+ * </pre>
+ *
+ * @since 3.20
+ * @noinstantiate This class is not intended to be instantiated by clients.
+ * @noreference This class is not intended to be referenced by clients as it is a part of Java preview feature.
+ */
+@SuppressWarnings("rawtypes")
+public class YieldStatement extends Statement {
+
+ /**
+ * The "expression" structural property of this node type (child type: {@link Expression}). (added in JEP 354).
+ */
+ public static final ChildPropertyDescriptor EXPRESSION_PROPERTY =
+ new ChildPropertyDescriptor(YieldStatement.class, "expression", Expression.class, MANDATORY, NO_CYCLE_RISK); //$NON-NLS-1$);
+
+ /**
+ * A list of property descriptors (element type:
+ * {@link StructuralPropertyDescriptor}),
+ * or null if uninitialized.
+ */
+ private static final List PROPERTY_DESCRIPTORS;
+
+ /**
+ * <code>true</code> indicates implicit and <code>false</code> indicates not implicit.
+ */
+ private boolean isImplicit = false;
+
+ static {
+ List properyList = new ArrayList(2);
+ createPropertyList(YieldStatement.class, properyList);
+ addProperty(EXPRESSION_PROPERTY, properyList);
+ PROPERTY_DESCRIPTORS = reapPropertyList(properyList);
+ }
+
+ /**
+ * Returns a list of structural property descriptors for this node type.
+ * Clients must not modify the result.
+ *
+ * @param apiLevel the API level; one of the
+ * <code>AST.JLS*</code> constants
+
+ * @return a list of property descriptors (element type:
+ * {@link StructuralPropertyDescriptor})
+ */
+ public static List propertyDescriptors(int apiLevel) {
+ return propertyDescriptors(apiLevel, false);
+ }
+
+ /**
+ * Returns a list of structural property descriptors for this node type.
+ * Clients must not modify the result.
+ *
+ * @param apiLevel the API level; one of the
+ * <code>AST.JLS*</code> constants
+ * @param previewEnabled the previewEnabled flag
+ * @return a list of property descriptors (element type:
+ * {@link StructuralPropertyDescriptor})
+ * @noreference This method is not intended to be referenced by clients.
+ * @since 3.20
+ */
+ public static List propertyDescriptors(int apiLevel, boolean previewEnabled) {
+ if (apiLevel == AST.JLS13_INTERNAL && previewEnabled) {
+ return PROPERTY_DESCRIPTORS;
+ }
+ return null;
+ }
+
+ /**
+ * The expression
+ */
+ private Expression expression = null;
+
+ /**
+ * Creates a new unparented Yield statement node owned by the given
+ * AST. By default, the Yield statement has identifier/expression.
+ * <p>
+ * N.B. This constructor is package-private.
+ * </p>
+ *
+ * @param ast the AST that is to own this node
+ * @exception UnsupportedOperationException if this operation is used other than JLS13
+ * @exception UnsupportedOperationException if this expression is used with previewEnabled flag as false
+ */
+ YieldStatement(AST ast) {
+ super(ast);
+ supportedOnlyIn13();
+ unsupportedWithoutPreviewError();
+ }
+
+ @Override
+ final List internalStructuralPropertiesForType(int apiLevel) {
+ return propertyDescriptors(apiLevel);
+ }
+
+ @Override
+ final List internalStructuralPropertiesForType(int apiLevel, boolean previewEnabled) {
+ return propertyDescriptors(apiLevel, previewEnabled);
+ }
+
+ @Override
+ final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) {
+ if (property == EXPRESSION_PROPERTY) {
+ if (get) {
+ return getExpression();
+ } else {
+ setExpression((Expression) child);
+ return null;
+ }
+ }
+ // allow default implementation to flag the error
+ return super.internalGetSetChildProperty(property, get, child);
+ }
+
+ @Override
+ final int getNodeType0() {
+ return YIELD_STATEMENT;
+ }
+
+ @Override
+ ASTNode clone0(AST target) {
+ YieldStatement result = new YieldStatement(target);
+ result.setSourceRange(getStartPosition(), getLength());
+ result.copyLeadingComment(this);
+ if (this.ast.apiLevel >= AST.JLS12_INTERNAL) {
+ result.setExpression((Expression) ASTNode.copySubtree(target, getExpression()));
+ }
+ return result;
+ }
+
+ @Override
+ final boolean subtreeMatch0(ASTMatcher matcher, Object other) {
+ // dispatch to correct overloaded match method
+ return matcher.match(this, other);
+ }
+
+ @Override
+ void accept0(ASTVisitor visitor) {
+ boolean visitChildren = visitor.visit(this);
+ if (visitChildren) {
+ if (this.ast.apiLevel >= AST.JLS13_INTERNAL) {
+ acceptChild(visitor, getExpression());
+ }
+ }
+ visitor.endVisit(this);
+ }
+
+ /**
+ * Returns the expression of this Yield statement, or <code>null</code> if
+ * there is none.
+ *
+ * @return the expression, or <code>null</code> if there is none
+ * @exception UnsupportedOperationException if this operation is used other than JLS13
+ * @noreference This method is not intended to be referenced by clients as it is a part of Java preview feature.
+ * @nooverride This method is not intended to be re-implemented or extended by clients as it is a part of Java preview feature.
+ */
+ public Expression getExpression() {
+ supportedOnlyIn13();
+ return this.expression;
+ }
+
+ /**
+ * Sets or clears the expression of this Yield statement.
+ *
+ * @param expression the expression
+ * @exception IllegalArgumentException if:
+ * <ul>
+ * <li>the node belongs to a different AST</li>
+ * <li>the node already has a parent</li>
+ * </ul>
+ * @exception UnsupportedOperationException if this operation is used other than JLS13
+ * @noreference This method is not intended to be referenced by clients as it is a part of Java preview feature.
+ * @nooverride This method is not intended to be re-implemented or extended by clients as it is a part of Java preview feature.
+ */
+ public void setExpression(Expression expression) {
+ supportedOnlyIn13();
+ ASTNode oldChild = this.expression;
+ preReplaceChild(oldChild, expression, EXPRESSION_PROPERTY);
+ this.expression = expression;
+ postReplaceChild(oldChild, expression, EXPRESSION_PROPERTY);
+ }
+
+ /**
+ * Gets the isImplicit of this break statement as <code>true</code> or <code>false</code>.
+ *<code>true</code> indicates implicit and <code>false</code> indicates not implicit.
+ *
+ * @return isImplicit <code>true</code> or <code>false</code>
+ * @exception UnsupportedOperationException if this operation is used other than JLS13
+ * @noreference This method is not intended to be referenced by clients as it is a part of Java preview feature.
+ * @nooverride This method is not intended to be re-implemented or extended by clients as it is a part of Java preview feature.
+ */
+ public boolean isImplicit() {
+ supportedOnlyIn13();
+ return this.isImplicit;
+ }
+
+ /**
+ * Sets the isImplicit of this break statement as <code>true</code> or <code>false</code>.
+ * <code>true</code> indicates implicit and <code>false</code> indicates not implicit. This flag is
+ * generated by compiler and is not expected to be set by client.
+
+ * @param isImplicit <code>true</code> or <code>false</code>
+ * @exception UnsupportedOperationException if this operation is used other than JLS13
+ */
+ void setImplicit(boolean isImplicit) {
+ supportedOnlyIn13();
+ this.isImplicit = isImplicit;
+ }
+
+
+ @Override
+ int memSize() {
+ return super.memSize() + 2 * 4;
+ }
+
+ @Override
+ int treeSize() {
+ return
+ memSize()
+ + (this.expression == null ? 0 : getExpression().treeSize());
+ }
+}
+
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/rewrite/ImportRewrite.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/rewrite/ImportRewrite.java
index c9a89edb63..2814267000 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/rewrite/ImportRewrite.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/rewrite/ImportRewrite.java
@@ -1315,7 +1315,7 @@ public final class ImportRewrite {
CompilationUnit usedAstRoot= this.astRoot;
if (usedAstRoot == null) {
- ASTParser parser= ASTParser.newParser(AST.JLS11);
+ ASTParser parser= ASTParser.newParser(AST.JLS13);
parser.setSource(this.compilationUnit);
parser.setFocalPosition(0); // reduced AST
parser.setResolveBindings(false);
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/NaiveASTFlattener.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/NaiveASTFlattener.java
index 42099a2d81..f179e40e2f 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/NaiveASTFlattener.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/NaiveASTFlattener.java
@@ -83,14 +83,6 @@ public class NaiveASTFlattener extends ASTVisitor {
private static final int JLS9 = AST.JLS9;
/**
- * Internal synonym for {@link AST#JLS12}. Use to alleviate
- * deprecation warnings.
- * @since 3.18
- */
- private static final int JLS12 = AST.JLS12;
-
-
- /**
* The string buffer into which the serialized representation of the AST is
* written.
*/
@@ -460,21 +452,12 @@ public class NaiveASTFlattener extends ASTVisitor {
@Override
public boolean visit(BreakStatement node) {
- if (node.getAST().apiLevel() == JLS12 && node.getAST().isPreviewEnabled() && node.isImplicit() && node.getExpression() == null) {
- return false;
- }
printIndent();
- this.buffer.append("break"); //$NON-NLS-1$
+ this.buffer.append("break");//$NON-NLS-1$
if (node.getLabel() != null) {
this.buffer.append(" ");//$NON-NLS-1$
node.getLabel().accept(this);
}
- if (node.getAST().apiLevel() == JLS12 && node.getAST().isPreviewEnabled()) {
- if (node.getExpression() != null) {
- this.buffer.append(" ");//$NON-NLS-1$
- node.getExpression().accept(this);
- }
- }
this.buffer.append(";\n");//$NON-NLS-1$
return false;
}
@@ -1504,7 +1487,7 @@ public class NaiveASTFlattener extends ASTVisitor {
@Override
public boolean visit(SwitchCase node) {
- if (node.getAST().apiLevel() == JLS12 && node.getAST().isPreviewEnabled()) {
+ if ((node.getAST().isPreviewEnabled())) {
if (node.isDefault()) {
this.buffer.append("default");//$NON-NLS-1$
this.buffer.append(node.isSwitchLabeledRule() ? " ->" : ":");//$NON-NLS-1$ //$NON-NLS-2$
@@ -1630,6 +1613,12 @@ public class NaiveASTFlattener extends ASTVisitor {
}
@Override
+ public boolean visit(TextBlock node) {
+ this.buffer.append(node.getEscapedValue());
+ return false;
+ }
+
+ @Override
public boolean visit(TextElement node) {
this.buffer.append(node.getText());
return false;
@@ -1920,6 +1909,21 @@ public class NaiveASTFlattener extends ASTVisitor {
}
return false;
}
+
+ @Override
+ public boolean visit(YieldStatement node) {
+ if ((node.getAST().isPreviewEnabled()) && node.isImplicit() && node.getExpression() == null) {
+ return false;
+ }
+ printIndent();
+ this.buffer.append("yield"); //$NON-NLS-1$
+ if (node.getExpression() != null) {
+ this.buffer.append(" ");//$NON-NLS-1$
+ node.getExpression().accept(this);
+ }
+ this.buffer.append(";\n");//$NON-NLS-1$
+ return false;
+ }
/**
* @deprecated
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteAnalyzer.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteAnalyzer.java
index 04f7245a58..cc8296832a 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteAnalyzer.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteAnalyzer.java
@@ -137,8 +137,6 @@ public final class ASTRewriteAnalyzer extends ASTVisitor {
/** @deprecated using deprecated code */
private static final int JLS9_INTERNAL = AST.JLS9;
- private static final int JLS12_INTERNAL = AST.JLS12;
-
TextEdit currentEdit;
final RewriteEventStore eventStore; // used from inner classes
@@ -2576,9 +2574,6 @@ public final class ASTRewriteAnalyzer extends ASTVisitor {
try {
int offset= getScanner().getTokenEndOffset(TerminalTokens.TokenNamebreak, node.getStartPosition());
rewriteNode(node, BreakStatement.LABEL_PROPERTY, offset, ASTRewriteFormatter.SPACE); // space between break and label
- if (node.getAST().apiLevel() == JLS12_INTERNAL && node.getAST().isPreviewEnabled()) {
- rewriteNode(node, BreakStatement.EXPRESSION_PROPERTY, offset, ASTRewriteFormatter.SPACE); // space between break and label
- }
} catch (CoreException e) {
handleException(e);
}
@@ -3519,7 +3514,7 @@ public final class ASTRewriteAnalyzer extends ASTVisitor {
}
// dont allow switching from case to default or back. New statements should be created.
- if (node.getAST().apiLevel() == JLS12_INTERNAL && node.getAST().isPreviewEnabled()) {
+ if (node.getAST().isPreviewEnabled()) {
int pos = node.expressions().size() == 0 ? node.getStartPosition() :
rewriteNodeList(node, SwitchCase.EXPRESSIONS2_PROPERTY, node.getStartPosition(), Util.EMPTY_STRING, ", "); //$NON-NLS-1$
if (isChanged(node, SwitchCase.SWITCH_LABELED_RULE_PROPERTY)) {
@@ -3743,7 +3738,7 @@ public final class ASTRewriteAnalyzer extends ASTVisitor {
insertIndent++;
}
ParagraphListRewriter listRewriter;
- if (node.getAST().apiLevel() == JLS12_INTERNAL && node.getAST().isPreviewEnabled()) {
+ if ((node.getAST().isPreviewEnabled())) {
listRewriter= new SwitchListLabeledRuleRewriter(insertIndent);
} else {
listRewriter= new SwitchListRewriter(insertIndent);
@@ -4066,6 +4061,18 @@ public final class ASTRewriteAnalyzer extends ASTVisitor {
}
@Override
+ public boolean visit(TextBlock node) {
+ if (!hasChildrenChanges(node)) {
+ return doVisitUnchangedChildren(node);
+ }
+ String escapedSeq= (String) getNewValue(node, TextBlock.ESCAPED_VALUE_PROPERTY);
+ TextEditGroup group = getEditGroup(node, TextBlock.ESCAPED_VALUE_PROPERTY);
+ doTextReplace(node.getStartPosition(), node.getLength(), escapedSeq, group);
+
+ return false;
+ }
+
+ @Override
public boolean visit(TextElement node) {
if (!hasChildrenChanges(node)) {
return doVisitUnchangedChildren(node);
@@ -4469,6 +4476,23 @@ public final class ASTRewriteAnalyzer extends ASTVisitor {
}
return false;
}
+
+ @Override
+ public boolean visit(YieldStatement node) {
+ if (!hasChildrenChanges(node)) {
+ return doVisitUnchangedChildren(node);
+ }
+
+ try {
+ int offset= getScanner().getTokenEndOffset(TerminalTokens.TokenNamebreak, node.getStartPosition());
+ if ((node.getAST().isPreviewEnabled())) {
+ rewriteNode(node, YieldStatement.EXPRESSION_PROPERTY, offset, ASTRewriteFormatter.SPACE); // space between yield and label
+ }
+ } catch (CoreException e) {
+ handleException(e);
+ }
+ return false;
+ }
final void handleException(Throwable e) {
throw new IllegalArgumentException("Document does not match the AST", e); //$NON-NLS-1$
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteFlattener.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteFlattener.java
index f3b3101320..c2f775acd4 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteFlattener.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteFlattener.java
@@ -94,14 +94,6 @@ public class ASTRewriteFlattener extends ASTVisitor {
/** @deprecated using deprecated code */
private static final int JLS9_INTERNAL = AST.JLS9;
- /**
- * Internal synonym for {@link AST#JLS12}. Use to alleviate
- * deprecation warnings.
- * @since 3.18
- */
- private static final int JLS12 = AST.JLS12;
-
-
public static String asString(ASTNode node, RewriteEventStore store) {
ASTRewriteFlattener flattener= new ASTRewriteFlattener(store);
node.accept(flattener);
@@ -362,23 +354,12 @@ public class ASTRewriteFlattener extends ASTVisitor {
@Override
public boolean visit(BreakStatement node) {
- if (node.getAST().apiLevel() == JLS12 && node.getAST().isPreviewEnabled() && node.isImplicit() && node.getExpression() == null) {
- return false;
- }
-
this.result.append("break"); //$NON-NLS-1$
ASTNode label= getChildNode(node, BreakStatement.LABEL_PROPERTY);
if (label != null) {
this.result.append(' ');
label.accept(this);
}
- if (node.getAST().apiLevel() == JLS12 && node.getAST().isPreviewEnabled()) {
- ASTNode expression = getChildNode(node, BreakStatement.EXPRESSION_PROPERTY);
- if (expression != null ) {
- this.result.append(' ');
- expression.accept(this);
- }
- }
this.result.append(';');
return false;
}
@@ -981,7 +962,7 @@ public class ASTRewriteFlattener extends ASTVisitor {
@Override
public boolean visit(SwitchCase node) {
- if (node.getAST().apiLevel() == JLS12 && node.getAST().isPreviewEnabled()) {
+ if ((node.getAST().isPreviewEnabled())) {
if (node.isDefault()) {
this.result.append("default");//$NON-NLS-1$
this.result.append(getBooleanAttribute(node, SwitchCase.SWITCH_LABELED_RULE_PROPERTY) ? " ->" : ":");//$NON-NLS-1$ //$NON-NLS-2$
@@ -1281,6 +1262,12 @@ public class ASTRewriteFlattener extends ASTVisitor {
}
@Override
+ public boolean visit(TextBlock node) {
+ this.result.append(getAttribute(node, TextBlock.ESCAPED_VALUE_PROPERTY));
+ return false;
+ }
+
+ @Override
public boolean visit(TextElement node) {
this.result.append(getAttribute(node, TextElement.TEXT_PROPERTY));
return false;
@@ -1507,4 +1494,21 @@ public class ASTRewriteFlattener extends ASTVisitor {
}
return false;
}
+
+ @Override
+ public boolean visit(YieldStatement node) {
+ if (node.getAST().isPreviewEnabled() && node.isImplicit() && node.getExpression() == null) {
+ return false;
+ }
+
+ this.result.append("yield"); //$NON-NLS-1$
+
+ ASTNode expression = getChildNode(node, YieldStatement.EXPRESSION_PROPERTY);
+ if (expression != null ) {
+ this.result.append(' ');
+ expression.accept(this);
+ }
+ this.result.append(';');
+ return false;
+ }
}
diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatter.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatter.java
index 4c6e9470f3..fbad7115b5 100644
--- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatter.java
+++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatter.java
@@ -127,14 +127,14 @@ public class DefaultCodeFormatter extends CodeFormatter {
this.workingOptions = new DefaultCodeFormatterOptions(options);
this.oldCommentFormatOption = getOldCommentFormatOption(options);
String compilerSource = options.get(CompilerOptions.OPTION_Source);
- this.sourceLevel = compilerSource != null ? compilerSource : CompilerOptions.VERSION_12;
+ this.sourceLevel = compilerSource != null ? compilerSource : CompilerOptions.VERSION_13;
this.previewEnabled = JavaCore.ENABLED.equals(options.get(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES));
} else {
Map<String, String> settings = DefaultCodeFormatterConstants.getJavaConventionsSettings();
this.originalOptions = new DefaultCodeFormatterOptions(settings);
this.workingOptions = new DefaultCodeFormatterOptions(settings);
this.oldCommentFormatOption = DefaultCodeFormatterConstants.TRUE;
- this.sourceLevel = CompilerOptions.VERSION_12;
+ this.sourceLevel = CompilerOptions.VERSION_13;
}
if (defaultCodeFormatterOptions != null) {
this.originalOptions.set(defaultCodeFormatterOptions.getMap());
@@ -334,7 +334,7 @@ public class DefaultCodeFormatter extends CodeFormatter {
}
private ASTParser createParser(int kind) {
- ASTParser parser = ASTParser.newParser(AST.JLS12);
+ ASTParser parser = ASTParser.newParser(AST.JLS13);
if (kind == K_MODULE_INFO) {
parser.setSource(createDummyModuleInfoCompilationUnit());
diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/LineBreaksPreparator.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/LineBreaksPreparator.java
index e4767e48db..e4cfe2ddd9 100644
--- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/LineBreaksPreparator.java
+++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/LineBreaksPreparator.java
@@ -12,6 +12,7 @@
* Mateusz Matela <mateusz.matela@gmail.com> - [formatter] Formatter does not format Java code correctly, especially when max line width is set - https://bugs.eclipse.org/303519
* Mateusz Matela <mateusz.matela@gmail.com> - [formatter] IndexOutOfBoundsException in TokenManager - https://bugs.eclipse.org/462945
* Mateusz Matela <mateusz.matela@gmail.com> - [formatter] follow up bug for comments - https://bugs.eclipse.org/458208
+ * IBM Corporation - DOM AST changes for JEP 354
*******************************************************************************/
package org.eclipse.jdt.internal.formatter;
@@ -75,6 +76,7 @@ import org.eclipse.jdt.core.dom.TypeDeclaration;
import org.eclipse.jdt.core.dom.VariableDeclarationExpression;
import org.eclipse.jdt.core.dom.VariableDeclarationStatement;
import org.eclipse.jdt.core.dom.WhileStatement;
+import org.eclipse.jdt.core.dom.YieldStatement;
import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants;
public class LineBreaksPreparator extends ASTVisitor {
@@ -364,7 +366,8 @@ public class LineBreaksPreparator extends ASTVisitor {
this.tm.get(nonBreakStatementEnd + 1).indent();
this.tm.firstTokenIn(statement, -1).unindent();
}
- } else if (!(statement instanceof BreakStatement || statement instanceof Block)) {
+ } else if (!(statement instanceof BreakStatement || statement instanceof YieldStatement
+ || statement instanceof Block)) {
indent(statement);
}
nonBreakStatementEnd = isBreaking ? -1 : this.tm.lastIndexIn(statement, -1);
@@ -377,7 +380,7 @@ public class LineBreaksPreparator extends ASTVisitor {
}
if (this.options.indent_breaks_compare_to_cases) {
for (Statement statement : statements) {
- if (statement instanceof BreakStatement)
+ if (statement instanceof BreakStatement || statement instanceof YieldStatement)
indent(statement);
}
}
@@ -403,7 +406,7 @@ public class LineBreaksPreparator extends ASTVisitor {
private boolean isSwitchBreakingStatement(Statement statement) {
return statement instanceof BreakStatement || statement instanceof ReturnStatement
|| statement instanceof ContinueStatement || statement instanceof ThrowStatement
- || statement instanceof Block;
+ || statement instanceof YieldStatement || statement instanceof Block;
}
@Override
diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/SpacePreparator.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/SpacePreparator.java
index 86a8afd20b..da62bba784 100644
--- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/SpacePreparator.java
+++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/SpacePreparator.java
@@ -6,12 +6,12 @@
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Mateusz Matela <mateusz.matela@gmail.com> - [formatter] Formatter does not format Java code correctly, especially when max line width is set - https://bugs.eclipse.org/303519
* Mateusz Matela <mateusz.matela@gmail.com> - [formatter] IndexOutOfBoundsException in TokenManager - https://bugs.eclipse.org/462945
* Mateusz Matela <mateusz.matela@gmail.com> - [formatter] follow up bug for comments - https://bugs.eclipse.org/458208
+ * IBM Corporation - DOM AST changes for JEP 354
*******************************************************************************/
package org.eclipse.jdt.internal.formatter;
@@ -25,6 +25,7 @@ import java.util.List;
import java.util.Map;
import java.util.function.Predicate;
+import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.ASTVisitor;
import org.eclipse.jdt.core.dom.Annotation;
@@ -38,7 +39,6 @@ import org.eclipse.jdt.core.dom.ArrayType;
import org.eclipse.jdt.core.dom.AssertStatement;
import org.eclipse.jdt.core.dom.Assignment;
import org.eclipse.jdt.core.dom.Block;
-import org.eclipse.jdt.core.dom.BreakStatement;
import org.eclipse.jdt.core.dom.CastExpression;
import org.eclipse.jdt.core.dom.CatchClause;
import org.eclipse.jdt.core.dom.ClassInstanceCreation;
@@ -103,6 +103,7 @@ import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
import org.eclipse.jdt.core.dom.VariableDeclarationStatement;
import org.eclipse.jdt.core.dom.WhileStatement;
import org.eclipse.jdt.core.dom.WildcardType;
+import org.eclipse.jdt.core.dom.YieldStatement;
import org.eclipse.jdt.internal.compiler.parser.ScannerHelper;
public class SpacePreparator extends ASTVisitor {
@@ -396,7 +397,7 @@ public class SpacePreparator extends ASTVisitor {
@Override
public boolean visit(SwitchCase node) {
- if (node.isSwitchLabeledRule()) {
+ if (node.getAST().apiLevel() == AST.JLS13 && node.isSwitchLabeledRule()) {
handleToken(this.tm.lastTokenIn(node, TokenNameARROW),
node.isDefault() ? this.options.insert_space_before_arrow_in_switch_default
: this.options.insert_space_before_arrow_in_switch_case,
@@ -410,16 +411,18 @@ public class SpacePreparator extends ASTVisitor {
}
if (!node.isDefault()) {
handleToken(node, TokenNamecase, false, true);
- handleCommas(node.expressions(), this.options.insert_space_before_comma_in_switch_case_expressions,
+ if (node.getAST().apiLevel() == AST.JLS13) {
+ handleCommas(node.expressions(), this.options.insert_space_before_comma_in_switch_case_expressions,
this.options.insert_space_after_comma_in_switch_case_expressions);
+ }
}
return true;
}
@Override
- public boolean visit(BreakStatement node) {
+ public boolean visit(YieldStatement node) {
if (node.getExpression() != null && !node.isImplicit()) {
- this.tm.firstTokenIn(node, TokenNamebreak).spaceAfter();
+ this.tm.firstTokenIn(node, -1).spaceAfter();
}
return true;
}
diff --git a/org.eclipse.jdt.core/grammar/java.g b/org.eclipse.jdt.core/grammar/java.g
index b39cc92ed1..2b12257bb6 100644
--- a/org.eclipse.jdt.core/grammar/java.g
+++ b/org.eclipse.jdt.core/grammar/java.g
@@ -56,6 +56,7 @@ $Terminals
DoubleLiteral
CharacterLiteral
StringLiteral
+ TextBlock
PLUS_PLUS
MINUS_MINUS
@@ -114,7 +115,7 @@ $Terminals
AT308
AT308DOTDOTDOT
BeginCaseExpr
- BreakPreviewMarker
+ RestrictedIdentifierYield
-- BodyMarker
@@ -217,6 +218,8 @@ Goal ::= '(' ParenthesizedCastNameAndBounds
Goal ::= '<' ReferenceExpressionTypeArgumentsAndTrunk
-- JSR 308 Reconnaissance mission.
Goal ::= '@' TypeAnnotations
+-- JSR 354 Reconnaissance mission.
+Goal ::= '->' YieldStatement
/:$readableName Goal:/
Literal -> IntegerLiteral
@@ -225,6 +228,7 @@ Literal -> FloatingPointLiteral
Literal -> DoubleLiteral
Literal -> CharacterLiteral
Literal -> StringLiteral
+Literal -> TextBlock
Literal -> null
Literal -> BooleanLiteral
/:$readableName Literal:/
@@ -1207,6 +1211,7 @@ StatementWithoutTrailingSubstatement -> SynchronizedStatement
StatementWithoutTrailingSubstatement -> ThrowStatement
StatementWithoutTrailingSubstatement -> TryStatement
StatementWithoutTrailingSubstatement -> TryStatementWithResources
+StatementWithoutTrailingSubstatement -> YieldStatement
/:$readableName Statement:/
EmptyStatement ::= ';'
@@ -1327,6 +1332,10 @@ SwitchLabelCaseLhs ::= 'case' ConstantExpressions
-- END SwitchExpression (JEP 325) --
+YieldStatement ::= RestrictedIdentifierYield Expression ;
+/.$putCase consumeStatementYield() ; $break ./
+/:$readableName YieldStatement:/
+
WhileStatement ::= 'while' '(' Expression ')' Statement
/.$putCase consumeStatementWhile() ; $break ./
/:$readableName WhileStatement:/
@@ -1378,15 +1387,6 @@ BreakStatement ::= 'break' Identifier ';'
/.$putCase consumeStatementBreakWithLabel() ; $break ./
/:$readableName BreakStatement:/
-BreakStatement ::= 'break' BreakPreviewMarker ';'
-/.$putCase consumeStatementBreak() ; $break ./
-/:$compliance 12:/
-
-BreakStatement ::= 'break' BreakPreviewMarker Expression ';'
-/.$putCase consumeStatementBreakWithExpressionOrLabel() ; $break ./
-/:$readableName BreakStatement:/
-/:$compliance 12:/
-
ContinueStatement ::= 'continue' ';'
/.$putCase consumeStatementContinue() ; $break ./
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java
index 7d8ad5faf4..3b56560176 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java
@@ -3081,12 +3081,18 @@ public final class JavaCore extends Plugin {
public static final String VERSION_12 = "12"; //$NON-NLS-1$
/**
* Configurable option value: {@value}.
+ * @since 3.20
+ * @category OptionValue
+ */
+ public static final String VERSION_13 = "13"; //$NON-NLS-1$
+ /**
+ * Configurable option value: {@value}.
* @since 3.4
* @category OptionValue
*/
public static final String VERSION_CLDC_1_1 = "cldc1.1"; //$NON-NLS-1$
private static List<String> allVersions = Collections.unmodifiableList(Arrays.asList(VERSION_CLDC_1_1, VERSION_1_1, VERSION_1_2, VERSION_1_3, VERSION_1_4, VERSION_1_5,
- VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_9, VERSION_10, VERSION_11, VERSION_12));
+ VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_9, VERSION_10, VERSION_11, VERSION_12, VERSION_13));
/**
* Returns all {@link JavaCore}{@code #VERSION_*} levels in the order of their
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CopyResourceElementsOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CopyResourceElementsOperation.java
index a55bb957e4..c0a44f1c4f 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CopyResourceElementsOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CopyResourceElementsOperation.java
@@ -90,7 +90,7 @@ public class CopyResourceElementsOperation extends MultiOperation implements Suf
initializeASTParser();
}
private void initializeASTParser() {
- this.parser = ASTParser.newParser(AST.JLS11);
+ this.parser = ASTParser.newParser(AST.JLS13);
}
/**
* Returns the children of <code>source</code> which are affected by this operation.
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateElementInCUOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateElementInCUOperation.java
index 02de1a2244..d277903abd 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateElementInCUOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateElementInCUOperation.java
@@ -267,7 +267,7 @@ public abstract class CreateElementInCUOperation extends JavaModelOperation {
// ensure cu is consistent (noop if already consistent)
cu.makeConsistent(this.progressMonitor);
// create an AST for the compilation unit
- ASTParser parser = ASTParser.newParser(AST.JLS11);
+ ASTParser parser = ASTParser.newParser(AST.JLS13);
parser.setSource(cu);
return (CompilationUnit) parser.createAST(this.progressMonitor);
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateTypeMemberOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateTypeMemberOperation.java
index 40b2454030..68b331de0b 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateTypeMemberOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateTypeMemberOperation.java
@@ -83,7 +83,7 @@ protected StructuralPropertyDescriptor getChildPropertyDescriptor(ASTNode parent
protected ASTNode generateElementAST(ASTRewrite rewriter, ICompilationUnit cu) throws JavaModelException {
if (this.createdNode == null) {
this.source = removeIndentAndNewLines(this.source, cu);
- ASTParser parser = ASTParser.newParser(AST.JLS11);
+ ASTParser parser = ASTParser.newParser(AST.JLS13);
parser.setSource(this.source.toCharArray());
parser.setProject(getCompilationUnit().getJavaProject());
parser.setKind(ASTParser.K_CLASS_BODY_DECLARATIONS);
@@ -170,7 +170,7 @@ protected String generateSyntaxIncorrectAST() {
buff.append(lineSeparator + " public class A {" + lineSeparator); //$NON-NLS-1$
buff.append(this.source);
buff.append(lineSeparator).append('}');
- ASTParser parser = ASTParser.newParser(AST.JLS11);
+ ASTParser parser = ASTParser.newParser(AST.JLS13);
parser.setSource(buff.toString().toCharArray());
CompilationUnit compilationUnit = (CompilationUnit) parser.createAST(null);
TypeDeclaration typeDeclaration = (TypeDeclaration) compilationUnit.types().iterator().next();
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeleteElementsOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeleteElementsOperation.java
index 78fc71d275..a5a61f1e4f 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeleteElementsOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeleteElementsOperation.java
@@ -84,7 +84,7 @@ public class DeleteElementsOperation extends MultiOperation {
}
private void initASTParser() {
- this.parser = ASTParser.newParser(AST.JLS11);
+ this.parser = ASTParser.newParser(AST.JLS13);
}
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/CommentRecorderParser.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/CommentRecorderParser.java
index 20582f6b23..4f6ab52fd0 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/CommentRecorderParser.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/CommentRecorderParser.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/PublicScanner.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/PublicScanner.java
index e22c9ae6af..e7084cd927 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/PublicScanner.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/PublicScanner.java
@@ -106,6 +106,7 @@ public class PublicScanner implements IScanner, ITerminalSymbols {
public static final String INVALID_CHARACTER_CONSTANT = "Invalid_Character_Constant"; //$NON-NLS-1$
public static final String INVALID_ESCAPE = "Invalid_Escape"; //$NON-NLS-1$
public static final String INVALID_INPUT = "Invalid_Input"; //$NON-NLS-1$
+ public static final String INVALID_TEXTBLOCK = "Invalid_Textblock"; //$NON-NLS-1$
public static final String INVALID_UNICODE_ESCAPE = "Invalid_Unicode_Escape"; //$NON-NLS-1$
public static final String INVALID_FLOAT = "Invalid_Float_Literal"; //$NON-NLS-1$
public static final String INVALID_LOW_SURROGATE = "Invalid_Low_Surrogate"; //$NON-NLS-1$
diff --git a/org.eclipse.jdt.tests.latestBREE/.classpath b/org.eclipse.jdt.tests.latestBREE/.classpath
new file mode 100644
index 0000000000..9c30b5c58f
--- /dev/null
+++ b/org.eclipse.jdt.tests.latestBREE/.classpath
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-13">
+ <attributes>
+ <attribute name="module" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src">
+ <attributes>
+ <attribute name="test" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.jdt.tests.latestBREE/.project b/org.eclipse.jdt.tests.latestBREE/.project
new file mode 100644
index 0000000000..55a5e82801
--- /dev/null
+++ b/org.eclipse.jdt.tests.latestBREE/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.jdt.tests.latestBREE</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.eclipse.jdt.tests.latestBREE/.settings/org.eclipse.core.resources.prefs b/org.eclipse.jdt.tests.latestBREE/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000000..d0ef0d68bd
--- /dev/null
+++ b/org.eclipse.jdt.tests.latestBREE/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding//src/org/eclipse/jdt/core/tests/compiler/regression/latest/TextBlockTest.java=UTF-8
diff --git a/org.eclipse.jdt.tests.latestBREE/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.jdt.tests.latestBREE/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000000..edf160662a
--- /dev/null
+++ b/org.eclipse.jdt.tests.latestBREE/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,115 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled
+org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
+org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
+org.eclipse.jdt.core.compiler.annotation.nonnull.secondary=
+org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
+org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary=
+org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
+org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
+org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=13
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=13
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.APILeak=warning
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
+org.eclipse.jdt.core.compiler.problem.deadCode=warning
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=ignore
+org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
+org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=enabled
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
+org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
+org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
+org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning
+org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
+org.eclipse.jdt.core.compiler.problem.nullReference=warning
+org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
+org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
+org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.terminalDeprecation=warning
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType=warning
+org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict=disabled
+org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=info
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unstableAutoModuleName=warning
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.release=enabled
+org.eclipse.jdt.core.compiler.source=13
diff --git a/org.eclipse.jdt.tests.latestBREE/META-INF/MANIFEST.MF b/org.eclipse.jdt.tests.latestBREE/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..527baf4f5a
--- /dev/null
+++ b/org.eclipse.jdt.tests.latestBREE/META-INF/MANIFEST.MF
@@ -0,0 +1,22 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: LatestBREE
+Bundle-SymbolicName: org.eclipse.jdt.tests.latestBREE
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.eclipse.jdt.tests.latestbree.Activator
+Require-Bundle: org.junit;bundle-version="3.8.1",
+ org.eclipse.jdt.debug;bundle-version="[3.2.0,4.0.0)",
+ org.eclipse.jdt.core;bundle-version="[3.10.0,4.0.0)",
+ org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
+ org.eclipse.test.performance;bundle-version="[3.10.0,4.0.0)",
+ org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
+ org.eclipse.jdt.annotation;bundle-version="[1.1.0,2.0.0)";resolution:=optional,
+ org.eclipse.jdt.annotation;bundle-version="[2.0.0,3.0.0)";resolution:=optional,
+ org.eclipse.jdt.core.tests.model;bundle-version="[3.10.0,4.0.0)",
+ org.eclipse.jdt.core.tests.compiler;bundle-version="[3.10.0,4.0.0)",
+ javax.annotation
+Bundle-RequiredExecutionEnvironment: JavaSE-13
+Automatic-Module-Name: org.eclipse.jdt.tests.latestBREE
+Bundle-ActivationPolicy: lazy
+Export-Package: org.eclipse.jdt.core.tests.compiler.regression.latest,
+ org.eclipse.jdt.tests.latestbree
diff --git a/org.eclipse.jdt.tests.latestBREE/build.properties b/org.eclipse.jdt.tests.latestBREE/build.properties
new file mode 100644
index 0000000000..34d2e4d2da
--- /dev/null
+++ b/org.eclipse.jdt.tests.latestBREE/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/org.eclipse.jdt.tests.latestBREE/pom.xml b/org.eclipse.jdt.tests.latestBREE/pom.xml
new file mode 100644
index 0000000000..fbd00ad965
--- /dev/null
+++ b/org.eclipse.jdt.tests.latestBREE/pom.xml
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2019 IBM Corporation and others.
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Distribution License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/org/documents/edl-v10.php
+
+ Contributors:
+ IBM Corporation - initial API and implementation
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>tests-pom</artifactId>
+ <groupId>eclipse.jdt.core</groupId>
+ <version>4.13.0-SNAPSHOT</version>
+ <relativePath>../tests-pom/</relativePath>
+ </parent>
+ <groupId>org.eclipse.jdt</groupId>
+ <artifactId>org.eclipse.jdt.tests.latestBREE</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>eclipse-test-plugin</packaging>
+
+ <properties>
+ <defaultSigning-excludeInnerJars>true</defaultSigning-excludeInnerJars>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-surefire-plugin</artifactId>
+ <version>${tycho.version}</version>
+ <configuration>
+ <includes>
+ <include>org/eclipse/jdt/core/tests/compiler/regression//latest/TestAll.class</include>
+ </includes>
+ <argLine>${tycho.surefire.argLine}</argLine>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>test-on-javase-13</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-toolchains-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+ <execution>
+ <phase>validate</phase>
+ <goals>
+ <goal>toolchain</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <toolchains>
+ <jdk>
+ <id>JavaSE-13</id>
+ </jdk>
+ </toolchains>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <properties>
+ <tycho.surefire.argLine>--add-modules ALL-SYSTEM -Dcompliance=1.4,1.7,1.8,13</tycho.surefire.argLine>
+ </properties>
+ </profile>
+ </profiles>
+
+</project>
diff --git a/org.eclipse.jdt.tests.latestBREE/src/org/eclipse/jdt/core/tests/compiler/regression/latest/TestAll.java b/org.eclipse.jdt.tests.latestBREE/src/org/eclipse/jdt/core/tests/compiler/regression/latest/TestAll.java
new file mode 100644
index 0000000000..cdf4712cb7
--- /dev/null
+++ b/org.eclipse.jdt.tests.latestBREE/src/org/eclipse/jdt/core/tests/compiler/regression/latest/TestAll.java
@@ -0,0 +1,34 @@
+package org.eclipse.jdt.core.tests.compiler.regression.latest;
+
+import java.util.ArrayList;
+
+import org.eclipse.jdt.core.tests.junit.extension.TestCase;
+import org.eclipse.jdt.core.tests.model.CompletionTests13;
+import org.eclipse.jdt.core.tests.util.AbstractCompilerTest;
+import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+@SuppressWarnings({ "unchecked", "rawtypes" })
+public class TestAll extends junit.framework.TestCase {
+
+public TestAll(String testName) {
+ super(testName);
+}
+public static Test suite() {
+
+ // Common test suites
+ ArrayList standardTests = new ArrayList();
+ standardTests.add(TextBlockTest.class);
+ standardTests.add(CompletionTests13.class);
+ TestSuite all = new TestSuite(TestAll.class.getName());
+ int possibleComplianceLevels = AbstractCompilerTest.getPossibleComplianceLevels();
+ if ((possibleComplianceLevels & AbstractCompilerTest.F_13) != 0) {
+ ArrayList tests_13 = (ArrayList)standardTests.clone();
+ TestCase.resetForgottenFilters(tests_13);
+ all.addTest(AbstractCompilerTest.buildComplianceTestSuite(ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_13), tests_13));
+ }
+ return all;
+}
+}
diff --git a/org.eclipse.jdt.tests.latestBREE/src/org/eclipse/jdt/core/tests/compiler/regression/latest/TextBlockTest.java b/org.eclipse.jdt.tests.latestBREE/src/org/eclipse/jdt/core/tests/compiler/regression/latest/TextBlockTest.java
new file mode 100644
index 0000000000..d4f5032082
--- /dev/null
+++ b/org.eclipse.jdt.tests.latestBREE/src/org/eclipse/jdt/core/tests/compiler/regression/latest/TextBlockTest.java
@@ -0,0 +1,879 @@
+/*******************************************************************************
+ * Copyright (c) 2019 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.compiler.regression.latest;
+
+import java.util.Map;
+
+import org.eclipse.jdt.core.tests.compiler.regression.AbstractRegressionTest;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+
+import junit.framework.Test;
+
+@SuppressWarnings("preview")
+public class TextBlockTest extends AbstractRegressionTest {
+
+ static {
+// TESTS_NUMBERS = new int [] { 40 };
+// TESTS_NAMES = new String[] { "test007" };
+ }
+
+ public static Class<?> testClass() {
+ return TextBlockTest.class;
+ }
+ public static Test suite() {
+ return buildMinimalComplianceTestSuite(testClass(), F_13);
+ }
+ public TextBlockTest(String testName){
+ super(testName);
+ }
+ protected Map<String, String> getCompilerOptions() {
+ return getCompilerOptions(true);
+ }
+ // Enables the tests to run individually
+ protected Map<String, String> getCompilerOptions(boolean previewFlag) {
+ Map<String, String> defaultOptions = super.getCompilerOptions();
+ defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_13);
+ defaultOptions.put(CompilerOptions.OPTION_EnablePreviews, previewFlag ? CompilerOptions.ENABLED : CompilerOptions.DISABLED);
+ defaultOptions.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
+ return defaultOptions;
+ }
+
+ @Override
+ protected void runConformTest(String[] testFiles, Map<String, String> customOptions) {
+ super.runConformTest(testFiles, "", null, true, new String[] {"--enable-preview"}, customOptions, null);
+ }
+
+ @Override
+ protected void runConformTest(String[] testFiles, String expectedOutput, Map<String, String> customOptions) {
+ super.runConformTest(testFiles, expectedOutput, null, true, new String[] {"--enable-preview"}, customOptions, null);
+ }
+ public void test001() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static String textb = \"\"\"\"\"\";\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(textb);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " public static String textb = \"\"\"\"\"\";\n" +
+ " ^^\n" +
+ "Syntax error on token \"\"\"\", invalid AssignmentOperator\n" +
+ "----------\n");
+ }
+ public void test002() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static String textb = \"\"\" \"\"\";\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(textb);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " public static String textb = \"\"\" \"\"\";\n" +
+ " ^^^\n" +
+ "Syntax error on token \"\" \"\", invalid AssignmentOperator\n" +
+ "----------\n");
+ }
+ public void test003() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static String textb = \"\"\"\n" +
+ "\";\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(textb);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " public static String textb = \"\"\"\n" +
+ "\";\n" +
+ " ^^^^^\n" +
+ "Text block is not properly closed with the delimiter\n" +
+ "----------\n");
+ }
+ /*
+ * negative - unescaped '\' in a text block
+ */
+ public void test004() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static String textb = \"\"\"\n" +
+ "abc\\def" +
+ "\"\"\";\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(textb);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " public static String textb = \"\"\"\n" +
+ "abc\\def\"\"\";\n" +
+ " ^^^^^^^^^^^^\n" +
+ "Invalid escape sequence (valid ones are \\b \\t \\n \\f \\r \\\" \\\' \\\\ )\n" +
+ "----------\n");
+ }
+ /* empty text block */
+ public void test005() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static String textb = \"\"\"\n" +
+ "\"\"\";\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(textb);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "",
+ null,
+ new String[] {"--enable-preview"});
+ }
+ /*
+ * positive - escaped '\'
+ */
+ public void test006() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static String textb = \"\"\"\n" +
+ "abc\\\\def\"" +
+ "\"\"\";\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(textb);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "abc\\def\"",
+ null,
+ new String[] {"--enable-preview"});
+ }
+ /*
+ * Positive - Multi line text block with varying indentation
+ * and \n
+ */
+ public void test007() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static String textb = \"\"\"\n" +
+ " line 1\n" +
+ " line 2\n" +
+ " \n" +
+ " line 3\"\"\";\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.print(textb);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "line 1\n" + // test framework trims the leading whitespace
+ " line 2\n" +
+ "\n" +
+ "line 3",
+ null,
+ new String[] {"--enable-preview"});
+ }
+ /*
+ * Positive - Multi line text block with varying indentation
+ * and \n and \r
+ */
+ public void test008() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static String textb = \"\"\"\n" +
+ " line 1\n" +
+ " line 2\r" +
+ " \r" +
+ " line 3\n\"\"\";\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(textb);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "line 1\n" +
+ " line 2\n" +
+ "\n" +
+ "line 3", // the trailing whitespace is trimmed by the test framework
+ null,
+ new String[] {"--enable-preview"});
+ }
+ /*
+ * positive - using unescaped '"' in text block
+ */
+ public void test009() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static String textb = \"\"\"\n" +
+ "\"abc-def\"" +
+ "\"\"\";\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(textb);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "\"abc-def\"",
+ null,
+ new String[] {"--enable-preview"});
+ }
+ /*
+ * positive - using escaped '"' in text block
+ */
+ public void test010() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static String textb = \"\"\"\n" +
+ "\"abc-def\\\"\"\"\";\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(textb);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "\"abc-def\"",
+ null,
+ new String[] {"--enable-preview"});
+ }
+ /*
+ * positive - using escaped escaped \ and escaped " in text block
+ */
+ public void test011() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static String textb = \"\"\"\n" +
+ "\"abc\\\"\"\"def\"\"\"\";\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(textb);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "\"abc\"\"\"def\"",
+ null,
+ new String[] {"--enable-preview"});
+ }
+ /*
+ * positive - using Unicode in text block
+ * and compare with an equal String literal
+ */
+ public void test012() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static String textb = \"\"\"\n" +
+ "\\u0ba4\\u0bae\\u0bbf\\u0bb4\"\"\";\n" +
+ " public static String str = \"\\u0ba4\\u0bae\\u0bbf\\u0bb4\";\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(str.equals(textb));\n" +
+ " }\n" +
+ "}\n"
+ },
+ "true",
+ null,
+ new String[] {"--enable-preview"});
+ }
+ /*
+ * positive - bigger piece of code as text block
+ */
+ public void test013() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ "static String code = \"\"\"\n" +
+ " public void print(Object o) {\n" +
+ " System.out.println(Objects.toString(o));\n" +
+ " }\n" +
+ " \"\"\";\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(code);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "public void print(Object o) {\n" +
+ " System.out.println(Objects.toString(o));\n" +
+ "}",
+ null,
+ new String[] {"--enable-preview"});
+ }
+ /*
+ * positive - concatenation of string with text block
+ */
+ public void test014() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " static String code = \"public void print(Object o) {\\n\" +\n" +
+ " \"\"\"\n" +
+ " System.out.println(Objects.toString(o));\n" +
+ " }\n" +
+ " \"\"\";\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(code);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "public void print(Object o) {\n" +
+ " System.out.println(Objects.toString(o));\n" +
+ "}",
+ null,
+ new String[] {"--enable-preview"});
+ }
+ /*
+ * positive - freely using quotes
+ */
+ public void test015() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " static String story = \"\"\"\n" +
+ " \"When I use a word,\" Humpty Dumpty said,\n" +
+ " in rather a scornful tone, \"it means just what I\n" +
+ " choose it to mean - neither more nor less.\"\n" +
+ " \"The question is,\" said Alice, \"whether you\n" +
+ " can make words mean so many different things.\"\n" +
+ " \"The question is,\" said Humpty Dumpty,\n" +
+ " \"which is to be master - that's all.\"\"\"\";\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(story);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "\"When I use a word,\" Humpty Dumpty said,\n" +
+ "in rather a scornful tone, \"it means just what I\n" +
+ "choose it to mean - neither more nor less.\"\n" +
+ "\"The question is,\" said Alice, \"whether you\n" +
+ "can make words mean so many different things.\"\n" +
+ "\"The question is,\" said Humpty Dumpty,\n" +
+ "\"which is to be master - that's all.\"",
+ null,
+ new String[] {"--enable-preview"});
+ }
+ /*
+ * positive - html code with indentation
+ */
+ public void test016() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " static String html = \"\"\"\n" +
+ " <html>\\r" +
+ " <body>\\r" +
+ " <p>Hello, world</p>\\r" +
+ " </body>\\r" +
+ " </html>\\r" +
+ " \"\"\";\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(html);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "<html>\n" +
+ " <body>\n" +
+ " <p>Hello, world</p>\n" +
+ " </body>\n" +
+ "</html>",
+ null,
+ new String[] {"--enable-preview"});
+ }
+ /*
+ * positive - html code with indentation with empty lines
+ */
+ public void test016a() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " static String html = \"\"\"\n" +
+ " <html>\\r\\n" +
+ " <body>\\r\\n" +
+ " <p>Hello, world</p>\\r\\n" +
+ " </body>\\r\\n" +
+ " </html>\\r\\n" +
+ " \"\"\";\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(html);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "<html>\n" +
+ " <body>\n" +
+ " <p>Hello, world</p>\n" +
+ " </body>\n" +
+ "</html>",
+ null,
+ new String[] {"--enable-preview"});
+ }
+ /*
+ * positive - html code with indentation with empty lines
+ * output compared with String API
+ */
+ @SuppressWarnings("removal")
+ public void test016b() {
+ String text = " <html>\n" +
+ " <body>\n" +
+ " <p>Hello, world</p>\n" +
+ " </body>\n" +
+ " </html>";
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " static String html = \"\"\"\n" +
+ text + "\\n" +
+ "\"\"\";\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(html);\n" +
+ " }\n" +
+ "}\n"
+ },
+ text.stripIndent().translateEscapes(),
+ null,
+ new String[] {"--enable-preview"});
+
+ }
+ /*
+ * positive - html code with indentation with \r as terminator
+ */
+ public void test016c() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " static String html = \"\"\"\n" +
+ " <html>\\r" +
+ " <body>\\r" +
+ " <p>Hello, world</p>\\r" +
+ " </body>\\r" +
+ " </html>\\r" +
+ " \"\"\";\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(html);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "<html>\n" +
+ " <body>\n" +
+ " <p>Hello, world</p>\n" +
+ " </body>\n" +
+ "</html>",
+ null,
+ new String[] {"--enable-preview"});
+ }
+ /*
+ * positive - html code with indentation and trailing whitespace
+ */
+ public void test017() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " static String html = \"\"\"\n" +
+ " <html> \\r" +
+ " <body> \\r" +
+ " <p>Hello, world</p> \\r" +
+ " </body> \\r" +
+ " </html> \\r" +
+ " \"\"\";\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(html);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "<html>\n" +
+ " <body>\n" +
+ " <p>Hello, world</p>\n" +
+ " </body>\n" +
+ "</html>",
+ null,
+ new String[] {"--enable-preview"});
+ }
+ /*
+ * positive - using octal escape char for trailing whitespace
+ */
+ public void test018() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " static String html = \"\"\"\n" +
+ " <html>\\040\\040\\r" +
+ " <body>\\040\\040\\r" +
+ " <p>Hello, world</p>\\040\\040\\040\\r" +
+ " </body>\\040\\040\\r" +
+ " </html>\\040\\040\\r" +
+ " \"\"\";\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(html);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "<html> \n" +
+ " <body> \n" +
+ " <p>Hello, world</p> \n" +
+ " </body> \n" +
+ "</html> ",
+ null,
+ new String[] {"--enable-preview"});
+ }
+ /*
+ * positive - using text block as a method argument
+ */
+ public void test019() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(\"\"\"\n" +
+ " <html>\\n" +
+ " <body>\\n" +
+ " <p>Hello, world</p>\\n" +
+ " </body>\\n" +
+ " </html>\\n" +
+ " \"\"\");\n" +
+ " }\n" +
+ "}\n"
+ },
+ "<html>\n" +
+ " <body>\n" +
+ " <p>Hello, world</p>\n" +
+ " </body>\n" +
+ "</html>",
+ null,
+ new String[] {"--enable-preview"});
+ }
+ /*
+ * positive - using variable assigned with text block as a method argument
+ */
+ public void test020() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " String html = \"\"\"\n" +
+ " <html>\n" +
+ " <body>\n" +
+ " <p>Hello, world</p>\n" +
+ " </body>\n" +
+ " </html>\n" +
+ " \"\"\";\n" +
+ " System.out.println(html);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "<html>\n" +
+ " <body>\n" +
+ " <p>Hello, world</p>\n" +
+ " </body>\n" +
+ "</html>",
+ null,
+ new String[] {"--enable-preview"});
+ }
+ /*
+ * positive - assigning strings and text blocks interchangeably.
+ */
+ public void test021() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " String html = \"\"\"\n" +
+ " <html>\n" +
+ " <body>\n" +
+ " <p>Hello, world</p>\n" +
+ " </body>\n" +
+ " </html>\n" +
+ " \"\"\";\n" +
+ " String s = html;\n" +
+ " System.out.println(s);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "<html>\n" +
+ " <body>\n" +
+ " <p>Hello, world</p>\n" +
+ " </body>\n" +
+ "</html>",
+ null,
+ new String[] {"--enable-preview"});
+ }
+ /*
+ * positive - escaped '\', compare with String::translateEscapes
+ */
+ @SuppressWarnings("removal")
+ public void test022() {
+ String text = "abc\\\\def\"";
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static String textb = \"\"\"\n" +
+ text +
+ "\"\"\";\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(textb);\n" +
+ " }\n" +
+ "}\n"
+ },
+ text.translateEscapes(),
+ null,
+ new String[] {"--enable-preview"});
+ }
+ /*
+ * positive - escaped """, compare output with
+ * String::translateEscapes
+ * String::stripIndent
+ */
+ @SuppressWarnings("removal")
+ public void test023() {
+ String text = "abc\\\"\"\"def\" ";
+ System.out.println(text.translateEscapes().stripIndent());
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static String textb = \"\"\"\n" +
+ text +
+ "\"\"\";\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(textb);\n" +
+ " }\n" +
+ "}\n"
+ },
+ text.translateEscapes().stripIndent(),
+ null,
+ new String[] {"--enable-preview"});
+ }
+ public void test024() {
+ runConformTest(
+ new String[] {
+ "Main.java",
+ "@SuppressWarnings(\"preview\")\n" +
+ "public class Main {\n" +
+ " public static void main(String[] args) {\n" +
+ " runConformTest(\n" +
+ " new String[] {\n" +
+ " \"XYZ.java\",\n" +
+ " \"\"\"\n" +
+ " public class XYZ {\n" +
+ " public static String textb = \\\"\"\"\n" +
+ " abc\\\\\\\"\"\"def\" \n" +
+ " \\\"\"\";\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(textb);\n" +
+ " }\n" +
+ " } \n" +
+ " \"\"\"\n" +
+ " }, \n" +
+ " \"\",\n" +
+ " null,\n" +
+ " new String[] {\"--enable-preview\"});\n" +
+ " }\n" +
+ " private static void runConformTest(String[] strings, String text, Object object, String[] strings2) {\n" +
+ " System.out.println(strings[1]);\n" +
+ " }\n" +
+ "}"
+ },
+ "public class XYZ {\n" +
+ " public static String textb = \"\"\"\n" +
+ " abc\\\"\"\"def\"\n" +
+ " \"\"\";\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(textb);\n" +
+ " }\n" +
+ "}",
+ null,
+ new String[] {"--enable-preview"});
+ }
+ public void test025() {
+ runNegativeTest(
+ new String[] {
+ """
+ X.java""",
+ """
+ public class X {
+ public static String textb = \"""
+ abc\\def\""";
+ public static void main(String[] args) {
+ System.out.println(textb);
+ }
+ }
+ """
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " public static String textb = \"\"\"\n" +
+ " abc\\def\"\"\";\n" +
+ " ^^^^^^^^^^^^^^^\n" +
+ "Invalid escape sequence (valid ones are \\b \\t \\n \\f \\r \\\" \\\' \\\\ )\n" +
+ "----------\n",
+ null,
+ true,
+ getCompilerOptions());
+ }
+ @SuppressWarnings("removal")
+ public void test026() {
+ String text = "abc\\\\def";
+ runConformTest(
+ new String[] {
+ """
+ X.java""",
+ """
+ public class X {
+ public static String textb = \"""
+ abc\\\\def\""";
+ public static void main(String[] args) {
+ System.out.println(textb);
+ }
+ }
+ """
+ },
+ text.translateEscapes(),
+ getCompilerOptions(),
+ new String[] {"--enable-preview"});
+ }
+ public void test027() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main (String[] args) {\n" +
+ " String xyz = \n" +
+ " \"\"\"\n" +
+ " public class Switch {\n" +
+ " public static void bar(int arg0) {\n" +
+ " int arg1 = 0;\n" +
+ " pointer: foo(\n" +
+ " switch (0 + arg0) {\n" +
+ " case 1 -> 1;\n" +
+ " default -> {break p;}\\n\"\n" +
+ " }\n" +
+ " });\n" +
+ " public static void foo(int arg0) {\n" +
+ " bar(MyDay.SUNDAY);\n" +
+ " }\n" +
+ " }\\n\"\"\"; \n" +
+ " System.out.println(xyz);\n" +
+ " }\n" +
+ "}"
+ },
+ "public class Switch {\n" +
+ " public static void bar(int arg0) {\n" +
+ " int arg1 = 0;\n" +
+ " pointer: foo(\n" +
+ " switch (0 + arg0) {\n" +
+ " case 1 -> 1;\n" +
+ " default -> {break p;}\n" +
+ "\"\n" +
+ " }\n" +
+ " });\n" +
+ " public static void foo(int arg0) {\n" +
+ " bar(MyDay.SUNDAY);\n" +
+ " }\n" +
+ " }",
+ getCompilerOptions(),
+ new String[] {"--enable-preview"});
+ }
+ // An empty text block
+ public void test028() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main (String[] args) {\n" +
+ " String xyz = \n" +
+ " \"\"\"\n" +
+ " \\n\"\"\"; \n" +
+ " System.out.println(xyz);\n" +
+ " }\n" +
+ "}"
+ },
+ "",
+ getCompilerOptions(),
+ new String[] {"--enable-preview"});
+ }
+ // An empty text block
+ public void test029() {
+ runConformTest(
+ new String[] {
+ "Cls2.java",
+ "public class Cls2 {\n" +
+ " public static String str = \"\"\"\n" +
+ " Hello Guru \n" +
+ " \n" +
+ " \"\"\";\n" +
+ " public static void main (String[] args) {\n" +
+ " System.out.println(str);\n" +
+ " }\n" +
+ "}"
+ },
+ "Hello Guru", // output comparison tool strips off all trailing whitespace
+ getCompilerOptions(),
+ new String[] {"--enable-preview"});
+ }
+ public void testBug550356() {
+ Map<String, String> options = getCompilerOptions(false);
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static String textb = \"\"\"\n" +
+ "\"\"\";\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(textb);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " public static String textb = \"\"\"\n" +
+ "\"\"\";\n" +
+ " ^^^^^^^\n" +
+ "Text Blocks is a preview feature and disabled by default. Use --enable-preview to enable\n" +
+ "----------\n",
+ null,
+ true,
+ options);
+ }
+}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests12.java b/org.eclipse.jdt.tests.latestBREE/src/org/eclipse/jdt/core/tests/model/CompletionTests13.java
index ea0370267a..82237b0ffe 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests12.java
+++ b/org.eclipse.jdt.tests.latestBREE/src/org/eclipse/jdt/core/tests/model/CompletionTests13.java
@@ -14,28 +14,30 @@ package org.eclipse.jdt.core.tests.model;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.codeassist.RelevanceConstants;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import junit.framework.Test;
-public class CompletionTests12 extends AbstractJavaModelCompletionTests {
+@SuppressWarnings("preview")
+public class CompletionTests13 extends AbstractJavaModelCompletionTests {
static {
-// TESTS_NAMES = new String[]{"test018e"};
+// TESTS_NAMES = new String[]{"test034"};
}
- public CompletionTests12(String name) {
+ public CompletionTests13(String name) {
super(name);
}
public void setUpSuite() throws Exception {
if (COMPLETION_PROJECT == null) {
- COMPLETION_PROJECT = setUpJavaProject("Completion", "12");
+ COMPLETION_PROJECT = setUpJavaProject("Completion", "13");
} else {
- setUpProjectCompliance(COMPLETION_PROJECT, "12");
+ setUpProjectCompliance(COMPLETION_PROJECT, "13");
}
super.setUpSuite();
}
public static Test suite() {
- return buildModelTestSuite(CompletionTests12.class);
+ return buildModelTestSuite(CompletionTests13.class);
}
public void test001() throws JavaModelException {
this.workingCopies = new ICompilationUnit[1];
@@ -223,18 +225,21 @@ public class CompletionTests12 extends AbstractJavaModelCompletionTests {
this.workingCopies = new ICompilationUnit[1];
this.workingCopies[0] = getWorkingCopy(
"/Completion/src/Switch.java",
- "public class Switch {\n" +
- " public static void bar(MyDay day) {\n" +
- " switch (day.toS) {\n" +
- " case \"SATURDAY\" -> \n" +
- " System.out.println(day.toString());\n" +
- " }\n" +
- " }\n" +
- " public static void main(String[] args) {\n" +
- " bar(MyDay.SUNDAY);\n" +
- " }\n" +
- "}\n" +
- "enum MyDay { SATURDAY, SUNDAY}");
+ """
+ public class Switch {
+ public static void bar(MyDay day) {
+ switch (day.toS) {
+ case "SATURDAY" ->
+ System.out.println(day.toString());
+ }
+ }
+ public static void main(String[] args) {
+ bar(MyDay.SUNDAY);
+ }
+ }
+ enum MyDay { SATURDAY, SUNDAY}
+ """
+ );
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
requestor.allowAllRequiredProposals();
String str = this.workingCopies[0].getSource();
@@ -449,30 +454,31 @@ public class CompletionTests12 extends AbstractJavaModelCompletionTests {
"switch[KEYWORD]{switch, null, null, switch, null, 49}",
requestor.getResults());
}
- public void _test015() throws JavaModelException {
+ public void test015() throws JavaModelException {
this.workingCopies = new ICompilationUnit[1];
this.workingCopies[0] = getWorkingCopy(
"/Completion/src/X.java",
- "public class Switch {\n" +
- " public static void bar(int arg0) {\n" +
- " foo(\n" +
- " switch (0 + arg0) {\n" +
- " case 1 -> {break ar;}\n" +
- " default -> 0;\n" +
- " }\n" +
- " });\n" +
- " public static void foo(int arg0) {\n" +
- " bar(MyDay.SUNDAY);\n" +
- " }\n" +
- "}\n");
+ """
+ public class Switch {
+ public static void bar(int arg0) {
+ pointer: foo(
+ switch (0 + arg0) {
+ case 1 -> {break ;}
+ default -> 0;
+ }
+ });
+ public static void foo(int arg0) {
+ bar(MyDay.SUNDAY);
+ }
+ }""");
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
requestor.allowAllRequiredProposals();
String str = this.workingCopies[0].getSource();
- String completeBehind = "break ar";
+ String completeBehind = "break ";
int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "arg0[LOCAL_VARIABLE_REF]{arg0, null, I, arg0, null, 52}",
+ "pointer[LABEL_REF]{pointer, null, null, pointer, null, 49}",
requestor.getResults());
}
public void test016() throws JavaModelException {
@@ -501,34 +507,35 @@ public class CompletionTests12 extends AbstractJavaModelCompletionTests {
"arg0[LOCAL_VARIABLE_REF]{arg0, null, I, arg0, null, 52}",
requestor.getResults());
}
- public void _test017() throws JavaModelException {
+ public void test017() throws JavaModelException {
this.workingCopies = new ICompilationUnit[1];
this.workingCopies[0] = getWorkingCopy(
"/Completion/src/X.java",
- "public class Switch {\n" +
- " public static void bar(int arg0) {\n" +
- " int arg1 = 0;\n" +
- " foo(\n" +
- " switch (0 + arg0) {\n" +
- " case 1 -> 1;\n" +
- " default -> {break ar;}\n" +
- " }\n" +
- " });\n" +
- " public static void foo(int arg0) {\n" +
- " bar(MyDay.SUNDAY);\n" +
- " }\n" +
- "}\n");
+ """
+ public class Switch {
+ public static void bar(int arg0) {
+ int arg1 = 0;
+ pointer: foo(
+ switch (0 + arg0) {
+ case 1 -> 1;
+ default -> {break p;}
+ }
+ });
+ public static void foo(int arg0) {
+ bar(MyDay.SUNDAY);
+ }
+ }""");
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
requestor.allowAllRequiredProposals();
String str = this.workingCopies[0].getSource();
- String completeBehind = "break ar";
+ String completeBehind = "break p";
int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "arg0[LOCAL_VARIABLE_REF]{arg0, null, I, arg0, null, 52}",
+ "pointer[LABEL_REF]{pointer, null, null, pointer, null, 49}",
requestor.getResults());
}
- public void _test017a() throws JavaModelException {
+ public void test017a() throws JavaModelException {
this.workingCopies = new ICompilationUnit[1];
this.workingCopies[0] = getWorkingCopy(
"/Completion/src/X.java",
@@ -551,7 +558,6 @@ public class CompletionTests12 extends AbstractJavaModelCompletionTests {
int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "arg0[LOCAL_VARIABLE_REF]{arg0, null, I, arg0, null, 52}\n" +
"argLabel[LABEL_REF]{argLabel, null, null, argLabel, null, 49}",
requestor.getResults());
}
@@ -853,4 +859,745 @@ public class CompletionTests12 extends AbstractJavaModelCompletionTests {
"hashCode[METHOD_REF]{hashCode, Ljava.lang.Object;, ()I, hashCode, null, 90}",
requestor.getResults());
}
+ /*
+ * Try completion for break keyword inside switch expression - negative
+ */
+ public void test022() throws JavaModelException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/X.java",
+ "public class X {\n" +
+ " static final String MONDAY = \"MONDAY\";\n" +
+ " static final String TUESDAY = \"TUESDAY\";\n" +
+ " static final String WEDNESDAY = \"WEDNESDAY\";\n" +
+ " @SuppressWarnings(\"preview\")\n" +
+ " public static void main(String[] args) {\n" +
+ " String day = \"MONDAY\";\n" +
+ " int k = switch (day) {\n" +
+ " case MONDAY -> throw new NullPointerException();\n" +
+ " case TUESDAY -> 1;\n" +
+ " case WEDNESDAY -> {br;}\n" +
+ " default -> {\n" +
+ " int g = day.hashCode();\n" +
+ " int result = f(g);\n" +
+ " yield result;\n" +
+ " }};\n" +
+ " }\n" +
+ " static int f(int k) {\n" +
+ " return k*k;\n" +
+ " }\n" +
+ "}");
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "case WEDNESDAY -> {br";
+ int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults(
+ "break[KEYWORD]{break, null, null, break, null, 49}",
+ requestor.getResults());
+ }
+ /*
+ * Try completion for yield keyword - positive
+ */
+ public void test023() throws JavaModelException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/X.java",
+ """
+ public class X {
+ @SuppressWarnings("preview")
+ public static void main(String[] args) {
+ String day = "MONDAY";
+ int k = switch (day) {
+ case "M" -> throw new NullPointerException();
+ case "T" -> 1;
+ case "W" -> {yi ;}
+ default -> {
+ int g = day.hashCode();
+ int result = f(g);
+ yield result;
+ }};
+ }
+ static int f(int k) {
+ return k*k;
+ }
+ }
+ """);
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "case \"W\" -> {yi";
+ int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults(
+ "yield[KEYWORD]{yield, null, null, yield, null, 49}",
+ requestor.getResults());
+ }
+ /*
+ * Try completion for yield with identifier - positive
+ */
+ public void test024() throws JavaModelException {
+ String old = COMPLETION_PROJECT.getOption(CompilerOptions.OPTION_EnablePreviews, true);
+ COMPLETION_PROJECT.setOption(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/X.java",
+ "public class X {\n" +
+ " @SuppressWarnings(\"preview\")\n" +
+ " public static void main(String day) {\n" +
+ " int k = switch (day) {\n" +
+ " default -> {\n" +
+ " int g = day.hashCode();\n" +
+ " int result = f(g);\n" +
+ " yield res;\n" +
+ " }};\n" +
+ " }\n" +
+ " static int f(int k) {\n" +
+ " return k*k;\n" +
+ " }\n" +
+ "}");
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "yield res";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults(
+ "result[LOCAL_VARIABLE_REF]{result, null, I, result, null, 52}",
+ requestor.getResults());
+ COMPLETION_PROJECT.setOption(CompilerOptions.OPTION_EnablePreviews, old);
+ }
+ /*
+ * Try completion for yield with identifier with a preceding case with yield - positive
+ */
+ public void test024a() throws JavaModelException {
+ String old = COMPLETION_PROJECT.getOption(CompilerOptions.OPTION_EnablePreviews, true);
+ COMPLETION_PROJECT.setOption(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/X.java",
+ "public class X {\n" +
+ " @SuppressWarnings(\"preview\")\n" +
+ " public static void main(String day) {\n" +
+ " int k = switch (day) {\n" +
+ " case TUESDAY -> { yield 1;}\n" +
+ " default -> {\n" +
+ " int g = day.hashCode();\n" +
+ " int result = f(g);\n" +
+ " yield res;\n" +
+ " }};\n" +
+ " }\n" +
+ " static int f(int k) {\n" +
+ " return k*k;\n" +
+ " }\n" +
+ "}");
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "yield res";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults(
+ "result[LOCAL_VARIABLE_REF]{result, null, I, result, null, 52}",
+ requestor.getResults());
+ COMPLETION_PROJECT.setOption(CompilerOptions.OPTION_EnablePreviews, old);
+ }
+ /*
+ * Try completion for yield with identifier with a preceding case with yield - positive
+ */
+ public void test024b() throws JavaModelException {
+ String old = COMPLETION_PROJECT.getOption(CompilerOptions.OPTION_EnablePreviews, true);
+ COMPLETION_PROJECT.setOption(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/X.java",
+ "public class X {\n" +
+ " @SuppressWarnings(\"preview\")\n" +
+ " public static void main(String day) {\n" +
+ " int k = switch (day) {\n" +
+ " case TUESDAY -> { yield 1;}\n" +
+ " default -> {\n" +
+ " int g = day.hashCode();\n" +
+ " int result = f(g);\n" +
+ " yield 0 + res;\n" +
+ " }};\n" +
+ " }\n" +
+ " static int f(int k) {\n" +
+ " return k*k;\n" +
+ " }\n" +
+ "}");
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "yield 0 + res";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults(
+ "result[LOCAL_VARIABLE_REF]{result, null, I, result, null, 52}",
+ requestor.getResults());
+ COMPLETION_PROJECT.setOption(CompilerOptions.OPTION_EnablePreviews, old);
+ }
+ /*
+ * Try completion in a switch expression case block without any assist keyword
+ */
+ public void test024c() throws JavaModelException {
+ String old = COMPLETION_PROJECT.getOption(CompilerOptions.OPTION_EnablePreviews, true);
+ COMPLETION_PROJECT.setOption(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/X.java",
+ "public class X {\n" +
+ " @SuppressWarnings(\"preview\")\n" +
+ " public static void main(String day) {\n" +
+ " int k = switch (day) {\n" +
+ " case TUESDAY -> { yield 1;}\n" +
+ " default -> {\n" +
+ " int[] g = new int[0];\n" +
+ " yield g.;\n" +
+ " }};\n" +
+ " }\n" +
+ " static int f(int k) {\n" +
+ " return k*k;\n" +
+ " }\n" +
+ "}");
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "yield g.";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults(
+ "length[FIELD_REF]{length, [I, I, length, null, 49}\n" +
+ "clone[METHOD_REF]{clone(), [I, ()[I, clone, null, 60}\n" +
+ "equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), 60}\n" +
+ "finalize[METHOD_REF]{finalize(), Ljava.lang.Object;, ()V, finalize, null, 60}\n" +
+ "getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<+Ljava.lang.Object;>;, getClass, null, 60}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Object;, ()I, hashCode, null, 60}\n" +
+ "notify[METHOD_REF]{notify(), Ljava.lang.Object;, ()V, notify, null, 60}\n" +
+ "notifyAll[METHOD_REF]{notifyAll(), Ljava.lang.Object;, ()V, notifyAll, null, 60}\n" +
+ "toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, 60}\n" +
+ "wait[METHOD_REF]{wait(), Ljava.lang.Object;, ()V, wait, null, 60}\n" +
+ "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (J)V, wait, (millis), 60}\n" +
+ "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (JI)V, wait, (millis, nanos), 60}",
+ requestor.getResults());
+ COMPLETION_PROJECT.setOption(CompilerOptions.OPTION_EnablePreviews, old);
+ }
+ /*
+ * Try completion in a switch expression case block without any assist keyword
+ */
+ public void test024d() throws JavaModelException {
+ String old = COMPLETION_PROJECT.getOption(CompilerOptions.OPTION_EnablePreviews, true);
+ COMPLETION_PROJECT.setOption(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/X.java",
+ "public class X {\n" +
+ " @SuppressWarnings(\"preview\")\n" +
+ " public static void main(String[] args) {\n" +
+ " String day = args[0];\n" +
+ " int k = switch (day) {\n" +
+ " case TUESDAY -> { yield 1;}\n" +
+ " default -> {\n" +
+ " int[] g = args.;\n" +
+ " yield g;\n" +
+ " }};\n" +
+ " }\n" +
+ " static int f(int k) {\n" +
+ " return k*k;\n" +
+ " }\n" +
+ "}");
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "int[] g = args.";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults(
+ "length[FIELD_REF]{length, [Ljava.lang.String;, I, length, null, 49}\n" +
+ "finalize[METHOD_REF]{finalize(), Ljava.lang.Object;, ()V, finalize, null, 55}\n" +
+ "notify[METHOD_REF]{notify(), Ljava.lang.Object;, ()V, notify, null, 55}\n" +
+ "notifyAll[METHOD_REF]{notifyAll(), Ljava.lang.Object;, ()V, notifyAll, null, 55}\n" +
+ "wait[METHOD_REF]{wait(), Ljava.lang.Object;, ()V, wait, null, 55}\n" +
+ "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (J)V, wait, (millis), 55}\n" +
+ "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (JI)V, wait, (millis, nanos), 55}\n" +
+ "clone[METHOD_REF]{clone(), [Ljava.lang.String;, ()[Ljava.lang.String;, clone, null, 60}\n" +
+ "equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), 60}\n" +
+ "getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<+Ljava.lang.Object;>;, getClass, null, 60}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Object;, ()I, hashCode, null, 60}\n" +
+ "toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, 60}",
+ requestor.getResults());
+ COMPLETION_PROJECT.setOption(CompilerOptions.OPTION_EnablePreviews, old);
+ }
+ /*
+ * Try completion for yield with value inside switch - positive
+ *
+ */
+ public void test025() throws JavaModelException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/X.java",
+ "public class X {\n" +
+ " static final String MONDAY = \"MONDAY\";\n" +
+ " static final String TUESDAY = \"TUESDAY\";\n" +
+ " static final String WEDNESDAY = \"WEDNESDAY\";\n" +
+ " @SuppressWarnings(\"preview\")\n" +
+ " public static void main(String[] args) {\n" +
+ " resolve: {" +
+ " String day = \"MONDAY\";\n" +
+ " int k = switch (day) {\n" +
+ " case MONDAY -> throw new NullPointerException();\n" +
+ " case TUESDAY -> 1;\n" +
+ " case WEDNESDAY -> {yield 10;}\n" +
+ " default -> {\n" +
+ " yield day.h;\n" +
+ " }};\n" +
+ " }" +
+ " }\n" +
+ " static int f(int k) {\n" +
+ " return k*k;\n" +
+ " }\n" +
+ "}");
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "yield day.h";
+ int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults(
+ "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Object;, ()I, hashCode, null, 60}",
+ requestor.getResults());
+ }
+ /*
+ * Try completion for yield keyword - inside nested block
+ */
+ public void test026() throws JavaModelException {
+ String old = COMPLETION_PROJECT.getOption(CompilerOptions.OPTION_EnablePreviews, true);
+ COMPLETION_PROJECT.setOption(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/X.java",
+ """
+ public class X {
+ @SuppressWarnings("preview")
+ public static void main(String day) {
+ int k = switch (day) {
+ case "W" -> {yield 2;}
+ default -> {
+ int g = day.hashCode();
+ int result = f(g);
+ {
+ yie;
+ }
+ }};
+ }
+ static int f(int k) {
+ return k*k;
+ }
+ }
+ """);
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "yie";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults(
+ "yield[KEYWORD]{yield, null, null, yield, null, 49}",
+ requestor.getResults());
+ COMPLETION_PROJECT.setOption(CompilerOptions.OPTION_EnablePreviews, old);
+ }
+ /*
+ * Try completion for yield - inside nested block
+ */
+ public void test027() throws JavaModelException {
+ String old = COMPLETION_PROJECT.getOption(CompilerOptions.OPTION_EnablePreviews, true);
+ COMPLETION_PROJECT.setOption(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/X.java",
+ """
+ public class X {
+ @SuppressWarnings("preview")
+ public static void main(String day) {
+ int k = switch (day) {
+ case "W" -> {yield 2;}
+ default -> {
+ int g = day.hashCode();
+ int result = f(g);
+ {
+ yield res;
+ }
+ }};
+ }
+ static int f(int k) {
+ return k*k;
+ }
+ }
+ """);
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "yield res";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults(
+ "result[LOCAL_VARIABLE_REF]{result, null, I, result, null, 52}",
+ requestor.getResults());
+ COMPLETION_PROJECT.setOption(CompilerOptions.OPTION_EnablePreviews, old);
+ }
+ /*
+ * Try completion for yield - inside nested block
+ */
+ public void test028() throws JavaModelException {
+ String old = COMPLETION_PROJECT.getOption(CompilerOptions.OPTION_EnablePreviews, true);
+ COMPLETION_PROJECT.setOption(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/X.java",
+ """
+ public class X {
+ @SuppressWarnings("preview")
+ public static void main(String day) {
+ int k = switch (day) {
+ case "W" -> {yield 2;}
+ default -> {
+ int g = day.hashCode();
+ int result = f(g);
+ {
+ for(int i = 0; i < 3; i++) {
+ if (i == 0) {
+ yield day.h
+ }
+ }
+ yield 0;
+ }
+ }};
+ }
+ static int f(int k) {
+ return k*k;
+ }
+ }
+ """);
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "yield day.h";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults(
+ "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Object;, ()I, hashCode, null, 60}",
+ requestor.getResults());
+ COMPLETION_PROJECT.setOption(CompilerOptions.OPTION_EnablePreviews, old);
+ }
+ /*
+ * Try completion of other keywords inside switch expression nested block
+ */
+ public void test029() throws JavaModelException {
+ String old = COMPLETION_PROJECT.getOption(CompilerOptions.OPTION_EnablePreviews, true);
+ COMPLETION_PROJECT.setOption(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/X.java",
+ """
+ public class X {
+ @SuppressWarnings("preview")
+ public static void main(String day) {
+ int k = switch (day) {
+ case "W" -> {yield 2;}
+ default -> {
+ int g = day.hashCode();
+ int result = f(g);
+ {
+ for(int i = 0; i < 3; i++) {
+ if (i == 0) {
+ thr
+ }
+ }
+ yield 0;
+ }
+ }};
+ }
+ static int f(int k) {
+ return k*k;
+ }
+ }
+ """);
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "thr";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults(
+ "Throwable[TYPE_REF]{Throwable, java.lang, Ljava.lang.Throwable;, null, null, 42}\n" +
+ "throw[KEYWORD]{throw, null, null, throw, null, 49}",
+ requestor.getResults());
+ COMPLETION_PROJECT.setOption(CompilerOptions.OPTION_EnablePreviews, old);
+ }
+ /*
+ * Try completion of other keywords inside switch expression nested block
+ */
+ public void test030() throws JavaModelException {
+ String old = COMPLETION_PROJECT.getOption(CompilerOptions.OPTION_EnablePreviews, true);
+ COMPLETION_PROJECT.setOption(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/X.java",
+ """
+ public class X {
+ @SuppressWarnings("preview")
+ public static void main(String day) {
+ int k = switch (day) {
+ case "W" -> {yield 2;}
+ default -> {
+ int g = day.hashCode();
+ int result = f(g);
+ {
+ for(int i = 0; i < 3; i++) {
+ if (i == 0) {
+ throw Exc
+ }
+ }
+ yield 0;
+ }
+ }};
+ }
+ static int f(int k) {
+ return k*k;
+ }
+ }
+ """);
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "throw Exc";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults(
+ "Exception[TYPE_REF]{Exception, java.lang, Ljava.lang.Exception;, null, null, 52}",
+ requestor.getResults());
+ COMPLETION_PROJECT.setOption(CompilerOptions.OPTION_EnablePreviews, old);
+ }
+ /*
+ * Try completion inside a lambda nested inside a switch expression
+ */
+ public void test031() throws JavaModelException {
+ String old = COMPLETION_PROJECT.getOption(CompilerOptions.OPTION_EnablePreviews, true);
+ COMPLETION_PROJECT.setOption(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/X.java",
+ """
+ public class X {
+ @SuppressWarnings("preview")
+ public static void main(String[] args) {
+ String day = "";
+ int i = switch (day) {
+ default -> {
+ for (int j = 0; j < 3; j++) {
+ if (j == 0) {
+ IntPredicate pre = (_value) -> !test(_v);
+ };
+ }
+ }
+ yield 0;
+ }
+ };
+ }
+ private static boolean test(int value) {
+ return false;
+ }
+ }
+ interface IntPredicate {
+ boolean test(int value);
+ }
+ """);
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "test(_v";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults(
+ "_value[LOCAL_VARIABLE_REF]{_value, null, I, _value, null, 52}",
+ requestor.getResults());
+ COMPLETION_PROJECT.setOption(CompilerOptions.OPTION_EnablePreviews, old);
+ }
+ /*
+ * Try completion inside a lambda (block) nested inside a switch expression
+ */
+ public void test032() throws JavaModelException {
+ String old = COMPLETION_PROJECT.getOption(CompilerOptions.OPTION_EnablePreviews, true);
+ COMPLETION_PROJECT.setOption(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/X.java",
+ """
+ public class X {
+ @SuppressWarnings("preview")
+ public static void main(String[] args) {
+ String day = "";
+ int i = switch (day) {
+ default -> {
+ for (int j = 0; j < 3; j++) {
+ if (j == 0) {
+ IntPredicate pre = (_value) -> {
+ return !test(_v);
+ };
+ }
+ }
+ yield 0;
+ }
+ };
+ }
+ private static boolean test(int value) {
+ return false;
+ }
+ }
+ interface IntPredicate {
+ boolean test(int value);
+ }
+ """);
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "test(_v";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults(
+ "_value[LOCAL_VARIABLE_REF]{_value, null, I, _value, null, 52}",
+ requestor.getResults());
+ COMPLETION_PROJECT.setOption(CompilerOptions.OPTION_EnablePreviews, old);
+ }
+ /*
+ * Try completion inside a switch expression nested inside a lambda expression
+ */
+ public void test033() throws JavaModelException {
+ String old = COMPLETION_PROJECT.getOption(CompilerOptions.OPTION_EnablePreviews, true);
+ COMPLETION_PROJECT.setOption(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/X.java",
+ """
+ public class X {
+ @SuppressWarnings("preview")
+ public static void main(String[] args) {
+ IntPredicate pre = (_value) -> !test(
+ switch (_value) {
+ default -> {
+ yield _v;
+ }
+ }
+ );
+ }
+ private static boolean test(int value) {
+ return false;
+ }
+ }
+ interface IntPredicate {
+ boolean test(int value);
+ }
+ """);
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "yield _v";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults(
+ "_value[LOCAL_VARIABLE_REF]{_value, null, I, _value, null, 52}",
+ requestor.getResults());
+ COMPLETION_PROJECT.setOption(CompilerOptions.OPTION_EnablePreviews, old);
+ }
+ /*
+ * Try completion inside a switch expression nested inside a lambda expression
+ */
+ public void test034() throws JavaModelException {
+ String old = COMPLETION_PROJECT.getOption(CompilerOptions.OPTION_EnablePreviews, true);
+ COMPLETION_PROJECT.setOption(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/X.java",
+ """
+ public class X {
+ @SuppressWarnings("preview")
+ public static void main(String[] args) {
+ IntPredicate pre = (_value) -> {
+ return !test(
+ switch (_value) {
+ default -> {
+ yield _v;
+ }
+ }
+ );
+ };
+ }
+ private static boolean test(int value) {
+ return false;
+ }
+ }
+ interface IntPredicate {
+ boolean test(int value);
+ }
+ """);
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "yield _v";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults(
+ "_value[LOCAL_VARIABLE_REF]{_value, null, I, _value, null, 52}",
+ requestor.getResults());
+ COMPLETION_PROJECT.setOption(CompilerOptions.OPTION_EnablePreviews, old);
+ }
+ public void testBug545783() throws JavaModelException {
+ String old = COMPLETION_PROJECT.getOption(CompilerOptions.OPTION_EnablePreviews, true);
+ COMPLETION_PROJECT.setOption(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/bugs/C.java",
+ """
+ package bugs;
+ public class C {
+ int foo(String str) {
+ return switch (str) {
+ case "x", "y" -> {
+ yield 0;
+ }
+ default -> {
+ i: for (int i = 0; i < 10; i++) {
+ if (str.) {
+ yield i;
+ }
+ }
+ yield -1;
+ }
+ };
+ }
+ }
+ """);
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "if (str.";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults(
+ "finalize[METHOD_REF]{finalize(), Ljava.lang.Object;, ()V, finalize, null, 55}\n" +
+ "notify[METHOD_REF]{notify(), Ljava.lang.Object;, ()V, notify, null, 55}\n" +
+ "notifyAll[METHOD_REF]{notifyAll(), Ljava.lang.Object;, ()V, notifyAll, null, 55}\n" +
+ "wait[METHOD_REF]{wait(), Ljava.lang.Object;, ()V, wait, null, 55}\n" +
+ "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (J)V, wait, (millis), 55}\n" +
+ "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (JI)V, wait, (millis, nanos), 55}\n" +
+ "clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, 60}\n" +
+ "getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<+Ljava.lang.Object;>;, getClass, null, 60}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Object;, ()I, hashCode, null, 60}\n" +
+ "length[METHOD_REF]{length(), Ljava.lang.String;, ()I, length, null, 60}\n" +
+ "toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, 60}\n" +
+ "equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), 90}",
+ requestor.getResults());
+ COMPLETION_PROJECT.setOption(CompilerOptions.OPTION_EnablePreviews, old);
+ }
}
diff --git a/org.eclipse.jdt.tests.latestBREE/src/org/eclipse/jdt/tests/latestbree/Activator.java b/org.eclipse.jdt.tests.latestBREE/src/org/eclipse/jdt/tests/latestbree/Activator.java
new file mode 100644
index 0000000000..30cd86bce6
--- /dev/null
+++ b/org.eclipse.jdt.tests.latestBREE/src/org/eclipse/jdt/tests/latestbree/Activator.java
@@ -0,0 +1,22 @@
+package org.eclipse.jdt.tests.latestbree;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+ private static BundleContext context;
+
+ static BundleContext getContext() {
+ return context;
+ }
+
+ public void start(BundleContext bundleContext) throws Exception {
+ Activator.context = bundleContext;
+ }
+
+ public void stop(BundleContext bundleContext) throws Exception {
+ Activator.context = null;
+ }
+
+}
diff --git a/org.eclipse.jdt.tests.latestBREE/test.xml b/org.eclipse.jdt.tests.latestBREE/test.xml
new file mode 100644
index 0000000000..c5b0caf3d9
--- /dev/null
+++ b/org.eclipse.jdt.tests.latestBREE/test.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Copyright (c) 2019 IBM Corporation and others.
+
+ This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License 2.0
+ which accompanies this distribution, and is available at
+ https://www.eclipse.org/legal/epl-2.0/
+
+ SPDX-License-Identifier: EPL-2.0
+
+ Contributors:
+ IBM Corporation - initial API and implementation
+ -->
+
+<project name="testsuite" default="run" basedir=".">
+ <!-- The property ${eclipse-home} should be passed into this script -->
+ <!-- Set a meaningful default value for when it is not. -->
+ <property name="eclipse-home" value="${basedir}\..\.."/>
+
+ <!-- sets the properties eclipse-home, and library-file -->
+ <property name="plugin-name" value="org.eclipse.jdt.tests.latestBREE"/>
+ <property name="library-file"
+ value="${eclipse-home}/plugins/org.eclipse.test/library.xml"/>
+
+ <!-- This target holds all initialization code that needs to be done for -->
+ <!-- all tests that are to be run. Initialization for individual tests -->
+ <!-- should be done within the body of the suite target. -->
+ <target name="init">
+ <tstamp/>
+ <delete>
+ <fileset dir="${eclipse-home}" includes="org*.xml"/>
+ </delete>
+ </target>
+
+ <!-- This target defines the tests that need to be run. -->
+ <target name="suite">
+
+ <!-- Compiler regression tests -->
+ <property name="jdt-compiler-folder"
+ value="${eclipse-home}/jdt_compiler_folder"/>
+ <delete dir="${jdt-compiler-folder}" quiet="true"/>
+ <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
+ <property name="data-dir" value="${jdt-compiler-folder}"/>
+ <property name="plugin-name" value="${plugin-name}"/>
+ <property name="classname"
+ value="org.eclipse.jdt.core.tests.compiler.regression.latest.TestAll"/>
+ </ant>
+
+ </target>
+
+ <!-- This target holds code to cleanup the testing environment after -->
+ <!-- after all of the tests have been run. You can use this target to -->
+ <!-- delete temporary files that have been created. -->
+ <target name="cleanup">
+ </target>
+
+ <!-- This target runs the test suite. Any actions that need to happen -->
+ <!-- after all the tests have been run should go here. -->
+ <target name="run" depends="init,suite,cleanup">
+ <ant target="collect" antfile="${library-file}" dir="${eclipse-home}">
+ <property name="includes" value="org*.xml"/>
+ <property name="output-file" value="${plugin-name}.xml"/>
+ </ant>
+ </target>
+
+</project>
diff --git a/pom.xml b/pom.xml
index 84ce84aaf1..99eff454e2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -26,6 +26,8 @@
<properties>
<tycho.scmUrl>scm:git:git://git.eclipse.org/gitroot/jdt/eclipse.jdt.core.git</tycho.scmUrl>
+ <eclipserun-repo>https://download.eclipse.org/eclipse/updates/4.13-Y-builds/</eclipserun-repo>
+ <cbi-ecj-version>3.18.50.v20190628-1803</cbi-ecj-version>
</properties>
<!--

Back to the top