aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzzhongwei2013-05-08 02:47:36 (EDT)
committerzzhongwei2013-05-08 03:05:12 (EDT)
commit14324581846bf2f851c606a81b4620f234aa5b39 (patch)
treeaecdf42c3dddc006543a3921d0ffa7c6c7e51b52
parent1b81fc01d85ad3b77505a901b8e97917f22f397e (diff)
downloadorg.eclipse.pdt-14324581846bf2f851c606a81b4620f234aa5b39.zip
org.eclipse.pdt-14324581846bf2f851c606a81b4620f234aa5b39.tar.gz
org.eclipse.pdt-14324581846bf2f851c606a81b4620f234aa5b39.tar.bz2
407489: Use statement is added above namespace causing error
https://bugs.eclipse.org/bugs/show_bug.cgi?id=407489
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/UseStatementInjector.java25
1 files changed, 21 insertions, 4 deletions
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/UseStatementInjector.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/UseStatementInjector.java
index 43421f6..30f9769 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/UseStatementInjector.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/UseStatementInjector.java
@@ -79,7 +79,23 @@ public class UseStatementInjector {
SourceType ns = (SourceType) PHPModelUtils.getPossibleCurrentNamespace(
sourceModule, offset);
if (ns == null) {
- return null;
+ if (program.statements() != null
+ && !program.statements().isEmpty()
+ && (program.statements().get(0) instanceof NamespaceDeclaration)) {
+ NamespaceDeclaration result = (NamespaceDeclaration) program
+ .statements().get(0);
+ for (Statement statement : program.statements()) {
+ if (statement.getStart() >= offset) {
+ return result;
+ }
+ if (statement instanceof NamespaceDeclaration) {
+ result = (NamespaceDeclaration) statement;
+ }
+ }
+ return result;
+ } else {
+ return null;
+ }
}
ASTNode node = null;
try {
@@ -381,8 +397,8 @@ public class UseStatementInjector {
new ProjectScope(modelElement
.getScriptProject()
.getProject()),
- new InstanceScope(),
- new DefaultScope() };
+ InstanceScope.INSTANCE,
+ DefaultScope.INSTANCE };
for (int i = 0; i < contents.length; i++) {
IScopeContext scopeContext = contents[i];
IEclipsePreferences node = scopeContext
@@ -623,7 +639,8 @@ public class UseStatementInjector {
new ProjectScope(modelElement
.getScriptProject()
.getProject()),
- new InstanceScope(), new DefaultScope() };
+ InstanceScope.INSTANCE,
+ DefaultScope.INSTANCE };
for (int i = 0; i < contents.length; i++) {
IScopeContext scopeContext = contents[i];
IEclipsePreferences node = scopeContext