Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry BLIND2016-06-23 13:23:43 -0400
committerMichal Niewrzal2016-06-23 18:01:03 -0400
commit5b2b79912c33fe17f66e9647a131e1ed1cd1dcf3 (patch)
tree39de3248fa422cd6397839180af4fecdb2c80c45
parent9449987f2cbca73f002cff47a067901cf4e40c80 (diff)
downloadorg.eclipse.pdt-stable-4.0.tar.gz
org.eclipse.pdt-stable-4.0.tar.xz
org.eclipse.pdt-stable-4.0.zip
Bug 477908 - Use statement validator search occurrences in commentsR4_0_1stable-4.0
Change-Id: I2f1fdb358ebf9c5cf0827141a9f0bc27541dc920 Signed-off-by: Thierry BLIND <thierryblind@msn.com>
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/builder/OrganizeBuildParticipantFactory.java6
-rw-r--r--tests/org.eclipse.php.core.tests/workspace/errors/php53/testUseStatementUsage03.pdtt11
2 files changed, 15 insertions, 2 deletions
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/builder/OrganizeBuildParticipantFactory.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/builder/OrganizeBuildParticipantFactory.java
index 1116518a0..60c6df3e1 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/builder/OrganizeBuildParticipantFactory.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/builder/OrganizeBuildParticipantFactory.java
@@ -103,14 +103,14 @@ public class OrganizeBuildParticipantFactory extends AbstractBuildParticipantTyp
private IBuildContext context;
private IDocument doc;
private UseStatement[] statements;
- private List<Position> excludePositions;
+ private ASTNode[] excludeNodes;
private NamespaceDeclaration currentNamespace;
public ImportValidationVisitor(IBuildContext context, UseStatement[] statements, ASTNode[] excludeNodes) {
this.context = context;
this.statements = statements;
+ this.excludeNodes = excludeNodes;
this.doc = new Document(new String(context.getContents()));
- this.excludePositions = DocumentUtils.getExcludeSortedAndFilteredPositions(excludeNodes);
}
public boolean visit(NamespaceDeclaration n) throws Exception {
@@ -124,6 +124,8 @@ public class OrganizeBuildParticipantFactory extends AbstractBuildParticipantTyp
return super.visit(s);
}
+ List<Position> excludePositions = DocumentUtils.getExcludeSortedAndFilteredPositions(excludeNodes);
+
String total;
if (this.currentNamespace != null && this.currentNamespace.isBracketed()) {
total = DocumentUtils.stripUseStatements(statements, doc, this.currentNamespace.sourceStart(),
diff --git a/tests/org.eclipse.php.core.tests/workspace/errors/php53/testUseStatementUsage03.pdtt b/tests/org.eclipse.php.core.tests/workspace/errors/php53/testUseStatementUsage03.pdtt
new file mode 100644
index 000000000..f4ea88297
--- /dev/null
+++ b/tests/org.eclipse.php.core.tests/workspace/errors/php53/testUseStatementUsage03.pdtt
@@ -0,0 +1,11 @@
+--TEST--
+Test unused use statement
+--FILE--
+<?php
+use Foo\Bar;
+use Foo\Boo; // should show warning
+
+//$var = new Boo();
+--EXPECT--
+[line=2, start=6, end=18] Unused import 'Foo\Bar', consider removing
+[line=3, start=19, end=31] Unused import 'Foo\Boo', consider removing \ No newline at end of file

Back to the top