aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzzhongwei2013-01-08 03:14:39 (EST)
committerzzhongwei2013-01-08 03:19:06 (EST)
commit3aceff555cf3c6d115ea81064a43ad91a0ae73f2 (patch)
tree61a21b9bae2c3f2c6c69979384e11b233062764c
parentd84058c923b85f1676134dba6f96613350f79a84 (diff)
downloadorg.eclipse.pdt-3aceff555cf3c6d115ea81064a43ad91a0ae73f2.zip
org.eclipse.pdt-3aceff555cf3c6d115ea81064a43ad91a0ae73f2.tar.gz
org.eclipse.pdt-3aceff555cf3c6d115ea81064a43ad91a0ae73f2.tar.bz2
397639: file with a namespace - Content Assist should add a backslash
prior to the extended class if the extended class is in the root namespace https://bugs.eclipse.org/bugs/show_bug.cgi?id=397639
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/PHPModelUtils.java32
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/PHPCompletionProposalCollector.java5
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/ParameterGuessingProposal.java5
3 files changed, 38 insertions, 4 deletions
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/PHPModelUtils.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/PHPModelUtils.java
index 23ee2ee..bfa5380 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/PHPModelUtils.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/PHPModelUtils.java
@@ -35,6 +35,7 @@ import org.eclipse.dltk.core.search.IDLTKSearchScope;
import org.eclipse.dltk.core.search.SearchEngine;
import org.eclipse.dltk.internal.core.ModelElement;
import org.eclipse.dltk.internal.core.SourceField;
+import org.eclipse.dltk.internal.core.SourceRefElement;
import org.eclipse.jface.text.IRegion;
import org.eclipse.php.core.compiler.PHPFlags;
import org.eclipse.php.internal.core.Logger;
@@ -468,6 +469,37 @@ public class PHPModelUtils {
return null;
}
+ public static IType getCurrentNamespaceIfAny(ISourceModule sourceModule,
+ int offset) {
+ IType result = getCurrentNamespace(sourceModule, offset);
+ if (result == null) {
+ try {
+ IModelElement[] elements = sourceModule.getChildren();
+ for (IModelElement modelElement : elements) {
+
+ if (modelElement instanceof IType
+ && PHPFlags.isNamespace(((IType) modelElement)
+ .getFlags())) {
+ result = (IType) modelElement;
+ }
+
+ if (modelElement instanceof SourceRefElement) {
+ SourceRefElement child = (SourceRefElement) modelElement;
+ ISourceRange range = child.getSourceRange();
+ int start = range.getOffset();
+ int end = start + range.getLength();
+ if (start <= offset && offset <= end) {
+ return result;
+ }
+ }
+ }
+ } catch (ModelException e) {
+ PHPCorePlugin.log(e);
+ }
+ }
+ return null;
+ }
+
/**
* if there are error in the php file,the parser can not be parse the ast
* correctly
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/PHPCompletionProposalCollector.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/PHPCompletionProposalCollector.java
index d653842..b301136 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/PHPCompletionProposalCollector.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/PHPCompletionProposalCollector.java
@@ -238,8 +238,9 @@ public class PHPCompletionProposalCollector extends
String prefix = "";
try {
int flags = type.getFlags();
- IType currentNamespace = PHPModelUtils.getCurrentNamespace(
- getSourceModule(), getReplacementOffset());
+ IType currentNamespace = PHPModelUtils
+ .getCurrentNamespaceIfAny(getSourceModule(),
+ getReplacementOffset());
IType namespace = PHPModelUtils.getCurrentNamespace(type);
if (!PHPFlags.isNamespace(flags)
&& namespace == null
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/ParameterGuessingProposal.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/ParameterGuessingProposal.java
index 075e5b6..792b609 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/ParameterGuessingProposal.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/ParameterGuessingProposal.java
@@ -259,8 +259,9 @@ public final class ParameterGuessingProposal extends
IType type = method.getDeclaringType();
try {
int flags = type.getFlags();
- IType currentNamespace = PHPModelUtils.getCurrentNamespace(
- fSourceModule, getReplacementOffset());
+ IType currentNamespace = PHPModelUtils
+ .getCurrentNamespaceIfAny(fSourceModule,
+ getReplacementOffset());
IType namespace = PHPModelUtils.getCurrentNamespace(type);
if (!PHPFlags.isNamespace(flags)
&& namespace == null