aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzzhongwei2013-03-14 22:32:18 (EDT)
committerzzhongwei2013-03-14 22:32:18 (EDT)
commit0fde69aefdb7910253830e9655bac5af4ba4f1f2 (patch)
tree9310e408e0fbd659794f61807d4df04475ede23b
parentb94669b72abad19b1e8d275748972a8564621a35 (diff)
downloadorg.eclipse.pdt-0fde69aefdb7910253830e9655bac5af4ba4f1f2.zip
org.eclipse.pdt-0fde69aefdb7910253830e9655bac5af4ba4f1f2.tar.gz
org.eclipse.pdt-0fde69aefdb7910253830e9655bac5af4ba4f1f2.tar.bz2
403407: Incorrect use statement added
https://bugs.eclipse.org/bugs/show_bug.cgi?id=403407
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/GlobalTypesStrategy.java19
1 files changed, 14 insertions, 5 deletions
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/GlobalTypesStrategy.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/GlobalTypesStrategy.java
index ac474fe..d8b5fba 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/GlobalTypesStrategy.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/GlobalTypesStrategy.java
@@ -30,6 +30,7 @@ import org.eclipse.php.internal.core.codeassist.ICompletionReporter;
import org.eclipse.php.internal.core.codeassist.ProposalExtraInfo;
import org.eclipse.php.internal.core.codeassist.contexts.AbstractCompletionContext;
import org.eclipse.php.internal.core.codeassist.contexts.NamespaceMemberContext;
+import org.eclipse.php.internal.core.codeassist.contexts.UseNameContext;
import org.eclipse.php.internal.core.compiler.ast.nodes.NamespaceReference;
import org.eclipse.php.internal.core.compiler.ast.nodes.UsePart;
import org.eclipse.php.internal.core.model.PhpModelAccess;
@@ -87,6 +88,7 @@ public class GlobalTypesStrategy extends GlobalElementStrategy {
if (abstractContext.getPrefixWithoutProcessing().trim().length() == 0) {
return;
}
+ boolean isUseContext = context instanceof UseNameContext;
SourceRange replacementRange = getReplacementRange(abstractContext);
IType[] types = getTypes(abstractContext);
@@ -105,17 +107,24 @@ public class GlobalTypesStrategy extends GlobalElementStrategy {
- 1) == '\"')) {
extraInfo = extraInfo | ProposalExtraInfo.NO_INSERT_NAMESPACE;
}
- if ("namespace".equals(abstractContext.getPreviousWord(1))) {
+ if ("namespace".equals(abstractContext.getPreviousWord(1))
+ || isUseContext) {
extraInfo = extraInfo | ProposalExtraInfo.NO_INSERT_NAMESPACE;
}
for (IType type : types) {
try {
int flags = type.getFlags();
- reporter.reportType(type,
- PHPFlags.isNamespace(flags) ? nsSuffix : suffix,
- replacementRange, extraInfo);
- if (addClassInNamespace) {
+ boolean isNamespace = PHPFlags.isNamespace(flags);
+ if (!isNamespace && isUseContext) {
+ reporter.reportType(type, isNamespace ? nsSuffix : suffix,
+ replacementRange, extraInfo
+ | ProposalExtraInfo.CLASS_IN_NAMESPACE);
+ } else {
+ reporter.reportType(type, isNamespace ? nsSuffix : suffix,
+ replacementRange, extraInfo);
+ }
+ if (addClassInNamespace && isNamespace) {
if (PHPFlags.isNamespace(flags)) {
IType[] subTypes = type.getTypes();
for (IType subType : subTypes) {