Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 549622

Summary: Impact of PreviewEnabled check in DOM on JDT UI
Product: [Eclipse Project] JDT Reporter: Sarika Sinha <sarika.sinha>
Component: UIAssignee: Noopur Gupta <noopur_gupta>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, kalyan_prasad, loskutov, noopur_gupta
Version: 4.13   
Target Milestone: 4.13 M3   
Hardware: All   
OS: All   
See Also: https://git.eclipse.org/r/146852
https://git.eclipse.org/r/147173
https://git.eclipse.org/r/147172
https://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=2dd58e630eefa755033abef13e0afbc6ed5d6d06
https://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=1fe269b376f145e7bd8624d45acde60649c700d1
Whiteboard:
Bug Depends on: 549106    
Bug Blocks: 550137    

Description Sarika Sinha CLA 2019-07-29 06:10:52 EDT
Taking out from Bug 549106.

To find the impact of https://git.eclipse.org/r/#/c/146614/  on JDT UI Tests.
Comment 1 Noopur Gupta CLA 2019-07-30 08:09:06 EDT
Test suites to run: org.eclipse.jdt.ui.tests.AutomatedSuite and org.eclipse.jdt.ui.tests.refactoring.all.AllAllRefactoringTests.

Currently showing 39 errors and 4 failures in the first one, and 6 errors in the second one.

One change that's required is to add ast.isPreviewEnabled() check wherever JLS12 preview APIs are being used.
Comment 2 Noopur Gupta CLA 2019-07-30 08:20:09 EDT
(In reply to Noopur Gupta from comment #1)
> One change that's required is to add ast.isPreviewEnabled() check wherever
> JLS12 preview APIs are being used.

After these changes, getting missing 'break' issue e.g. in  org.eclipse.jdt.ui.tests.quickfix.LocalCorrectionsQuickFixTest.testSwitchCaseFallThrough1().
Comment 3 Eclipse Genie CLA 2019-07-31 06:31:55 EDT
New Gerrit change created: https://git.eclipse.org/r/146852
Comment 4 Noopur Gupta CLA 2019-07-31 06:37:02 EDT
(In reply to Eclipse Genie from comment #3)
> New Gerrit change created: https://git.eclipse.org/r/146852

With patch set 5 of JDT Core patch and the above JDT UI Gerrit, the following issues remain:

- Getting 'MISSING' from AST rewrite in tests like AdvancedQuickAssistTest17.testConvertIfToSwitch()

- QuickFixTest12.testEnablePreviewsAndOpenCompilerPropertiesProposals() failing: As discussed with Sarika, this may need a change in compiler first so should check the test case after that.
Comment 5 Noopur Gupta CLA 2019-07-31 06:51:37 EDT
Also, once changes are finalized, based on bug 549106#c6, org.eclipse.jdt.internal.corext.dom.ASTFlattener.visit(BreakStatement) should be updated.
Comment 6 Noopur Gupta CLA 2019-08-07 04:29:32 EDT
(In reply to Noopur Gupta from comment #4)
> - QuickFixTest12.testEnablePreviewsAndOpenCompilerPropertiesProposals()
> failing: As discussed with Sarika, this may need a change in compiler first
> so should check the test case after that.

This is now failing in the I-build also (I20190806-1800).
Comment 7 Noopur Gupta CLA 2019-08-07 04:49:46 EDT
(In reply to Noopur Gupta from comment #6)
> (In reply to Noopur Gupta from comment #4)
> > - QuickFixTest12.testEnablePreviewsAndOpenCompilerPropertiesProposals()
> > failing: As discussed with Sarika, this may need a change in compiler first
> > so should check the test case after that.
> 
> This is now failing in the I-build also (I20190806-1800).
Handled in bug 548476 comment #24.
Comment 8 Noopur Gupta CLA 2019-08-07 05:53:35 EDT
(In reply to Noopur Gupta from comment #4)
> (In reply to Eclipse Genie from comment #3)
> > New Gerrit change created: https://git.eclipse.org/r/146852
> 
> With patch set 5 of JDT Core patch and the above JDT UI Gerrit, the
> following issues remain:
> 
> - Getting 'MISSING' from AST rewrite in tests like
> AdvancedQuickAssistTest17.testConvertIfToSwitch()

Updated the patch. All relevant tests pass now. comment #7 will be handled by the corresponding bug.
Comment 9 Eclipse Genie CLA 2019-08-07 06:00:36 EDT
New Gerrit change created: https://git.eclipse.org/r/147173
Comment 10 Eclipse Genie CLA 2019-08-07 06:00:39 EDT
New Gerrit change created: https://git.eclipse.org/r/147172
Comment 11 Noopur Gupta CLA 2019-08-07 06:04:26 EDT
(In reply to Eclipse Genie from comment #9)
> New Gerrit change created: https://git.eclipse.org/r/147173

(In reply to Noopur Gupta from comment #5)
> Also, once changes are finalized, based on bug 549106#c6,
> org.eclipse.jdt.internal.corext.dom.ASTFlattener.visit(BreakStatement)
> should be updated.

Done.
Comment 14 Noopur Gupta CLA 2019-08-07 06:25:32 EDT
Changes have been released. To be verified in the next I-build.
Comment 15 Andrey Loskutov CLA 2019-08-08 02:44:38 EDT
(In reply to Noopur Gupta from comment #14)
> Changes have been released. To be verified in the next I-build.

Unfortunately still fails on all platforms:

https://download.eclipse.org/eclipse/downloads/drops4/I20190807-1800/testresults/html/org.eclipse.jdt.ui.tests_ep413I-unit-cen64-gtk3-java8_linux.gtk.x86_64_8.0.html

testEnablePreviewsAndOpenCompilerPropertiesProposals

Wrong number of problems, is: 7, expected: 3 Pb(1103) Switch Expressions is a preview feature and disabled by default. Use --enable-preview to enable[82 ,404] Pb(1103) Multi constant case is a preview feature and disabled by default. Use --enable-preview to enable[97 ,117] Pb(1103) Multi constant case is a preview feature and disabled by default. Use --enable-preview to enable[97 ,117] Pb(1103) Multi constant case is a preview feature and disabled by default. Use --enable-preview to enable[97 ,117] Pb(232) Syntax error on token ""Weekend day"", delete this token[126 ,138] Pb(1103) Multi constant case is a preview feature and disabled by default. Use --enable-preview to enable[143 ,191] Pb(19) Type mismatch: cannot convert from Object to String[417 ,421]

junit.framework.AssertionFailedError: Wrong number of problems, is: 7, expected: 3
Pb(1103) Switch Expressions is a preview feature and disabled by default. Use --enable-preview to enable[82 ,404]
Pb(1103) Multi constant case is a preview feature and disabled by default. Use --enable-preview to enable[97 ,117]
Pb(1103) Multi constant case is a preview feature and disabled by default. Use --enable-preview to enable[97 ,117]
Pb(1103) Multi constant case is a preview feature and disabled by default. Use --enable-preview to enable[97 ,117]
Pb(232) Syntax error on token ""Weekend day"", delete this token[126 ,138]
Pb(1103) Multi constant case is a preview feature and disabled by default. Use --enable-preview to enable[143 ,191]
Pb(19) Type mismatch: cannot convert from Object to String[417 ,421]

at junit.framework.Assert.fail(Assert.java:57)
at junit.framework.Assert.assertTrue(Assert.java:22)
at junit.framework.TestCase.assertTrue(TestCase.java:192)
at org.eclipse.jdt.ui.tests.quickfix.QuickFixTest.assertNumberOfProblems(QuickFixTest.java:307)
at org.eclipse.jdt.ui.tests.quickfix.QuickFixTest.collectCorrections(QuickFixTest.java:281)
at org.eclipse.jdt.ui.tests.quickfix.QuickFixTest.collectCorrections(QuickFixTest.java:276)
at org.eclipse.jdt.ui.tests.quickfix.QuickFixTest12.testEnablePreviewsAndOpenCompilerPropertiesProposals(QuickFixTest12.java:125)
Comment 16 Eclipse Genie CLA 2019-08-08 06:38:55 EDT
New Gerrit change created: https://git.eclipse.org/r/147252
Comment 18 Kalyan Prasad Tatavarthi CLA 2019-08-08 06:41:02 EDT
Change have been released. The change is based on the fix made in Bug 548476.
To be verified in the next I-build.
Comment 19 Noopur Gupta CLA 2019-08-08 06:58:28 EDT
(In reply to Andrey Loskutov from comment #15)
> (In reply to Noopur Gupta from comment #14)
> > Changes have been released. To be verified in the next I-build.
> 
> Unfortunately still fails on all platforms:
> 
> https://download.eclipse.org/eclipse/downloads/drops4/I20190807-1800/testresults/html/org.eclipse.jdt.ui.tests_ep413I-unit-cen64-gtk3-java8_linux.gtk.x86_64_8.0.html
> 
> 
> testEnablePreviewsAndOpenCompilerPropertiesProposals

As mentioned in comment #8, the above test is not in the scope of this bug report.

This bug report is about the impact of DOM changes in JDT UI. The above tests fails due to a different change in the compiler. 

Kalyan, please move the fix for the above test to a separate bug and capture your discussion with JDT Core team about the required changes and impact on UI features there.

Marking this bug as verified as all the DOM related tests have passed in the latest I-build.
Comment 20 Kalyan Prasad Tatavarthi CLA 2019-08-08 07:57:40 EDT
(In reply to Noopur Gupta from comment #19)
> (In reply to Andrey Loskutov from comment #15)
> > (In reply to Noopur Gupta from comment #14)
> > > Changes have been released. To be verified in the next I-build.
> > 
> > Unfortunately still fails on all platforms:
> > 
> > https://download.eclipse.org/eclipse/downloads/drops4/I20190807-1800/testresults/html/org.eclipse.jdt.ui.tests_ep413I-unit-cen64-gtk3-java8_linux.gtk.x86_64_8.0.html
> > 
> > 
> > testEnablePreviewsAndOpenCompilerPropertiesProposals
> 
> As mentioned in comment #8, the above test is not in the scope of this bug
> report.
> 
> This bug report is about the impact of DOM changes in JDT UI. The above
> tests fails due to a different change in the compiler. 
> 
> Kalyan, please move the fix for the above test to a separate bug and capture
> your discussion with JDT Core team about the required changes and impact on
> UI features there.
> 
> Marking this bug as verified as all the DOM related tests have passed in the
> latest I-build.

Created Bug 549882 for the same.
Comment 21 Sarika Sinha CLA 2019-08-16 02:35:19 EDT
Needs to be merged to Beta branch with taking care about BreakStatement changes as they are not applicable for Java 13 and also change from 12 to 13 for previewEnabled checks in SwitchCase, Switch expression etc.