Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry BLIND2016-09-13 15:56:55 -0400
committerThierry BLIND2016-09-13 16:10:03 -0400
commit3e17b1aac21e3d15126b27a288ffa4e62588e549 (patch)
treedabb898786b3b459a00d730d36f61529dd3576d5
parent7c57c36adba9e6361d15ac29c030562c8fa4c882 (diff)
downloadorg.eclipse.pdt-R4_1_0.tar.gz
org.eclipse.pdt-R4_1_0.tar.xz
org.eclipse.pdt-R4_1_0.zip
Bug 501361 - CA looses ability to interprete $this in file with globalR4_1_0
and nonglobal namespace. Signed-off-by: Thierry BLIND <thierryblind@msn.com>
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/context/ContextFinder.java8
-rw-r--r--tests/org.eclipse.php.core.tests/workspace/codeassist/php53/testNamespaceElements12.pdtt31
-rw-r--r--tests/org.eclipse.php.core.tests/workspace/codeassist/php53/testNamespaceElements13.pdtt31
3 files changed, 67 insertions, 3 deletions
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/context/ContextFinder.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/context/ContextFinder.java
index d077ea061..30c237deb 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/context/ContextFinder.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/context/ContextFinder.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 IBM Corporation and others.
+ * Copyright (c) 2009, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -80,8 +80,10 @@ public abstract class ContextFinder extends ASTVisitor {
public boolean visit(TypeDeclaration node) throws Exception {
if (node instanceof NamespaceDeclaration) {
- if (!((NamespaceDeclaration) node).isGlobal()) {
- FileContext fileContext = (FileContext) contextStack.peek();
+ FileContext fileContext = (FileContext) contextStack.peek();
+ if (((NamespaceDeclaration) node).isGlobal()) {
+ fileContext.setNamespace(null);
+ } else {
fileContext.setNamespace(node.getName());
}
} else {
diff --git a/tests/org.eclipse.php.core.tests/workspace/codeassist/php53/testNamespaceElements12.pdtt b/tests/org.eclipse.php.core.tests/workspace/codeassist/php53/testNamespaceElements12.pdtt
new file mode 100644
index 000000000..da433e6d0
--- /dev/null
+++ b/tests/org.eclipse.php.core.tests/workspace/codeassist/php53/testNamespaceElements12.pdtt
@@ -0,0 +1,31 @@
+--TEST--
+Bug 501361 - CA looses ability to interprete $this in file with global and nonglobal namespace.
+--FILE--
+<?php
+namespace NSTest
+{
+
+ class TestException extends \Exception
+ {
+ }
+}
+namespace
+{
+
+ class A
+ {
+
+ public function testA()
+ {
+ }
+
+ public function testB()
+ {
+ $this->|;
+ }
+ }
+}
+?>
+--EXPECT--
+method(testA)
+method(testB)
diff --git a/tests/org.eclipse.php.core.tests/workspace/codeassist/php53/testNamespaceElements13.pdtt b/tests/org.eclipse.php.core.tests/workspace/codeassist/php53/testNamespaceElements13.pdtt
new file mode 100644
index 000000000..0b7ca8b2e
--- /dev/null
+++ b/tests/org.eclipse.php.core.tests/workspace/codeassist/php53/testNamespaceElements13.pdtt
@@ -0,0 +1,31 @@
+--TEST--
+Bug 501361 - CA looses ability to interprete $this in file with global and nonglobal namespace.
+--FILE--
+<?php
+namespace
+{
+
+ class A
+ {
+
+ public function testA()
+ {
+ }
+
+ public function testB()
+ {
+ $this->|;
+ }
+ }
+}
+namespace NSTest
+{
+
+ class TestException extends \Exception
+ {
+ }
+}
+?>
+--EXPECT--
+method(testA)
+method(testB)

Back to the top