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

Bug 559389

Summary: [Win32] Remove dead code and obsolete comments
Product: [Eclipse Project] Platform Reporter: Nikita Nemkin <nikita>
Component: SWTAssignee: Nikita Nemkin <nikita>
Status: VERIFIED FIXED QA Contact: Niraj Modi <niraj.modi>
Severity: enhancement    
Priority: P3 CC: daniel_megert, lshanmug, niraj.modi, paul-eclipse, sravan.lakkimsetti
Version: 4.15   
Target Milestone: 4.15 M3   
Hardware: PC   
OS: Windows All   
See Also: https://git.eclipse.org/r/156302
https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=3a2c1d63b5030ca10b7e2001ab2210eb232142bf
Whiteboard:
Bug Depends on:    
Bug Blocks: 549414    

Description Nikita Nemkin CLA 2020-01-22 03:17:50 EST
Remove the following:

 * Display.getLastErrorText() - never used;
 * Control.checkHandle() - pre-XP code to check GWLP_USERDATA;
 * DirectoryDialog.openCommonFileDialog() - pre-Vista code;
 * Some "This code is intentionally commented" comments that lost
   relevance.
Comment 1 Eclipse Genie CLA 2020-01-22 03:20:49 EST
New Gerrit change created: https://git.eclipse.org/r/156302
Comment 2 Paul Pazderski CLA 2020-01-22 03:28:24 EST
Even if not actively used isn't Device.getLastErrorText() quite handy while developing Windows SWT stuff?
Comment 3 Nikita Nemkin CLA 2020-01-22 03:34:39 EST
(In reply to Paul Pazderski from comment #2)
> Even if not actively used isn't Device.getLastErrorText() quite handy while
> developing Windows SWT stuff?

If you actually need it, I'll put it back.

The codes are documented: https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes and there's also "Microsoft Error Lookup Tool".
Comment 4 Paul Pazderski CLA 2020-01-22 03:47:11 EST
Not really. I didn't knew yet it exist and last time I had need it I had not thought of search for it.
I didn't knew this Error Lookup Tool. Looks handy.
Comment 6 Niraj Modi CLA 2020-02-06 14:44:16 EST
(In reply to Eclipse Genie from comment #5)
> Gerrit change https://git.eclipse.org/r/156302 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=3a2c1d63b5030ca10b7e2001ab2210eb232142bf

Remove the following:

 * Display.getLastErrorText() - never used.
 * Canvas.clearArea() - never used.
 * Control.checkHandle() - pre-XP code to check GWLP_USERDATA.
 * DirectoryDialog.openCommonFileDialog() - pre-Vista code.
 * Some "This code is intentionally commented" comments that lost
   relevance.
 * All "Use the character encoding for the default locale" comments.
 * Win98/NT4 code in BidiUtil.
Comment 7 Niraj Modi CLA 2020-02-07 03:59:48 EST
Latest Eclipse I-Build is good and Windows JUnits are also good:
https://download.eclipse.org/eclipse/downloads/drops4/I20200206-1805/testResults.php
Comment 8 Niraj Modi CLA 2020-02-12 05:22:51 EST Comment hidden (obsolete)
Comment 9 Nikita Nemkin CLA 2020-02-12 05:47:14 EST
(In reply to Niraj Modi from comment #8)
> Above patch removed an internal class BROWSEINFO.java, which as flagged as
> an API change specifically below part:
> https://git.eclipse.org/c/platform/eclipse.platform.swt.git/diff/bundles/org.
> eclipse.swt/Eclipse%20SWT%20PI/win32/org/eclipse/swt/internal/win32/
> BROWSEINFO.java?id=3a2c1d63b5030ca10b7e2001ab2210eb232142bf

Shouldn't API tools ignore internal packages?
Comment 10 Dani Megert CLA 2020-02-12 05:54:56 EST
(In reply to Nikita Nemkin from comment #9)
> (In reply to Niraj Modi from comment #8)
> > Above patch removed an internal class BROWSEINFO.java, which as flagged as
> > an API change specifically below part:
> > https://git.eclipse.org/c/platform/eclipse.platform.swt.git/diff/bundles/org.
> > eclipse.swt/Eclipse%20SWT%20PI/win32/org/eclipse/swt/internal/win32/
> > BROWSEINFO.java?id=3a2c1d63b5030ca10b7e2001ab2210eb232142bf
> 
> Shouldn't API tools ignore internal packages?
It does, that's why I marked the comment as obsolete.

The reason for the API Tools warning is https://git.eclipse.org/r/#/c/156302/7/bundles/org.eclipse.swt/Eclipse+SWT/win32/org/eclipse/swt/widgets/Shell.java

You would have noticed this error (or warning) in your workspace, assuming you have set the correct API baseline (to R4.15).
Comment 11 Niraj Modi CLA 2020-02-12 05:57:41 EST
(In reply to Eclipse Genie from comment #5)
> Gerrit change https://git.eclipse.org/r/156302 was merged to [master].
Please ignore comment 8

> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=3a2c1d63b5030ca10b7e2001ab2210eb232142bf

Above commit touched one of the below public API:
-------------------------------------------------
List of compatible changes:
- The method org.eclipse.swt.widgets.Shell.dispose() has been moved up in the 
 hierarchy
https://git.eclipse.org/c/platform/eclipse.platform.swt.git/diff/bundles/org.eclipse.swt/Eclipse%20SWT/win32/org/eclipse/swt/widgets/Shell.java?id=3a2c1d63b5030ca10b7e2001ab2210eb232142bf
-------------------------------------------------
API tools flagged it as an error:
https://download.eclipse.org/eclipse/downloads/drops4/I20200206-1805/apitools/analysis/html/org.eclipse.swt/report.html

Above was resolved via below SWT Bundle Version update:
https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=1d373db0aac19fff85101e7d4ff7f18f78a3944b

API tools error is now resolved:
https://download.eclipse.org/eclipse/downloads/drops4/I20200211-1800/apitools/analysis/html/org.eclipse.swt/report.html
Comment 12 Nikita Nemkin CLA 2020-02-12 06:45:38 EST
(In reply to Dani Megert from comment #10)
> 
> The reason for the API Tools warning is
> https://git.eclipse.org/r/#/c/156302/7/bundles/org.eclipse.swt/Eclipse+SWT/
> win32/org/eclipse/swt/widgets/Shell.java
I'm pretty sure this change is binary compatible.

> You would have noticed this error (or warning) in your workspace, assuming
> you have set the correct API baseline (to R4.15).
Right, but I run with API checker disabled, since I don't change the API and extra warnings don't help.
Comment 13 Dani Megert CLA 2020-02-12 08:03:43 EST
(In reply to Nikita Nemkin from comment #12)
> (In reply to Dani Megert from comment #10)
> > 
> > The reason for the API Tools warning is
> > https://git.eclipse.org/r/#/c/156302/7/bundles/org.eclipse.swt/Eclipse+SWT/
> > win32/org/eclipse/swt/widgets/Shell.java
> I'm pretty sure this change is binary compatible.
Sure it is. The API Tools reported that the minor version needs to be increased because there was a change (not a breakage) since the last release.


> Right, but I run with API checker disabled, since I don't change the API and
> extra warnings don't help.
You *did* change the API because Shell#dispose moved up in the hierarchy. You should not disable API Tools.
Comment 14 Nikita Nemkin CLA 2020-02-12 10:34:40 EST
You're right, I should always check with the API builder, however inconvinient it is. Sorry for the trouble.
Comment 15 Dani Megert CLA 2020-02-12 11:30:28 EST
(In reply to Nikita Nemkin from comment #14)
> You're right, I should always check with the API builder, however
> inconvinient it is. Sorry for the trouble.
You could have your main workspace with disabled API Tools and a "test" workspace where you validate your Gerrit changes with enabled API Tools. But I presume this would be more time consuming than just enabling it in the main workspace as suggested to all contributors.
Comment 16 Niraj Modi CLA 2020-02-18 06:20:24 EST
Marking Verified.