Bug 558630 - Organize use statements incorrectly removes statements that are only used in comments
Summary: Organize use statements incorrectly removes statements that are only used in ...
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: PDT (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Thierry BLIND CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 519064
  Show dependency tree
 
Reported: 2019-12-26 05:11 EST by Thierry BLIND CLA
Modified: 2020-05-14 13:19 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thierry BLIND CLA 2019-12-26 05:11:11 EST
Hi,
step to reproduce:

1. enable the "Organize use statements" option under Preferences >> PHP >> Editor >> Save Actions

2. create following PHP file:
<?php
namespace A;

class MyClass1
{
}

namespace B;

use A\MyClass1;

/**
 * @param MyClass1 $param
 */
function foo($param)
{
}
?>

3. save it, you'll get:
<?php
namespace A;

class MyClass1
{
}

namespace B;

/**
 *
 * @param MyClass1 $param
 */
function foo($param)
{
}
?>


The "use A\MyClass1;" line disappeared and there is now a "MyClass1 cannot be resolved to a type" error.
This is because type references are not searched for in comments while reorganizing use statements, let's fix that.

Thierry.
Comment 1 Dawid Pakula CLA 2019-12-26 05:16:05 EST
Duplicate of bug 519064
Comment 2 Thierry BLIND CLA 2019-12-27 06:25:42 EST
(In reply to Dawid Pakula from comment #1)
> Duplicate of bug 519064

Oh well yes, it seems to be the same problem, totally forgot this one, sorry! :/
Comment 3 Eclipse Genie CLA 2019-12-27 07:51:21 EST
New Gerrit change created: https://git.eclipse.org/r/155072
Comment 5 Thierry BLIND CLA 2019-12-27 15:38:12 EST
Fixed.