aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaloyan Raev2014-01-17 08:07:56 (EST)
committerKaloyan Raev2014-01-17 08:07:56 (EST)
commiteacb993322cad78a3475d5595cb079620016662d (patch)
tree4a3191a2de184c9edc55c9985b911b7b72ca2e72
parent91bb950382f5d733ae33e4530608f8aa97d9e997 (diff)
downloadorg.eclipse.pdt-eacb993322cad78a3475d5595cb079620016662d.zip
org.eclipse.pdt-eacb993322cad78a3475d5595cb079620016662d.tar.gz
org.eclipse.pdt-eacb993322cad78a3475d5595cb079620016662d.tar.bz2
Bug 253879 - unclosed class body causes method to appear twicerefs/changes/50/20750/1
When facing unrecovered syntax error the AbstractASTParser erroneously adds all found declaration (even those nested in other declarations) to the root of the model. This way duplicate method declarations appear in the model. This patch fixes the issue by adding only the top declaration to the model's root. Incorrect tests fixed. Bug: 253879 Change-Id: I1a5a46dcfc70625464924150fc1c64a6dee22f5d Signed-off-by: Kaloyan Raev <kaloyan.r@zend.com>
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/compiler/ast/parser/AbstractASTParser.java2
-rw-r--r--tests/org.eclipse.php.core.tests/workspace/compiler_parser/php4/testErrorClassStatement5.pdtt4
-rw-r--r--tests/org.eclipse.php.core.tests/workspace/compiler_parser/php5/testErrorClassStatement5.pdtt4
-rw-r--r--tests/org.eclipse.php.core.tests/workspace/compiler_parser/php53/testErrorClassStatement5.pdtt4
4 files changed, 4 insertions, 10 deletions
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/compiler/ast/parser/AbstractASTParser.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/compiler/ast/parser/AbstractASTParser.java
index 44310bb..f0c1cbe 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/compiler/ast/parser/AbstractASTParser.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/compiler/ast/parser/AbstractASTParser.java
@@ -166,7 +166,7 @@ abstract public class AbstractASTParser extends lr_parser {
statements.addAll((List) value);
}
- while (!declarations.isEmpty()) {
+ if (!declarations.isEmpty()) {
statements.add(declarations.remove(0));
}
if (!statements.isEmpty()) {
diff --git a/tests/org.eclipse.php.core.tests/workspace/compiler_parser/php4/testErrorClassStatement5.pdtt b/tests/org.eclipse.php.core.tests/workspace/compiler_parser/php4/testErrorClassStatement5.pdtt
index cb48a08..258d538 100644
--- a/tests/org.eclipse.php.core.tests/workspace/compiler_parser/php4/testErrorClassStatement5.pdtt
+++ b/tests/org.eclipse.php.core.tests/workspace/compiler_parser/php4/testErrorClassStatement5.pdtt
@@ -4,12 +4,10 @@ Test Error Class Statement5
<?php class A {function f(){ for(;;;); ?>
--EXPECT--
<ModuleDeclaration start="6" end="36">
- <ClassDeclaration start="6" end="13" modifiers="" name="A">
+ <ClassDeclaration start="6" end="36" modifiers="" name="A">
<PHPMethodDeclaration start="15" end="27" modifiers="" name="f">
</PHPMethodDeclaration>
</ClassDeclaration>
- <PHPMethodDeclaration start="15" end="27" modifiers="" name="f">
- </PHPMethodDeclaration>
<Errors>
<ASTError start="35" end="36">
</ASTError>
diff --git a/tests/org.eclipse.php.core.tests/workspace/compiler_parser/php5/testErrorClassStatement5.pdtt b/tests/org.eclipse.php.core.tests/workspace/compiler_parser/php5/testErrorClassStatement5.pdtt
index b3a38f0..d100ad8 100644
--- a/tests/org.eclipse.php.core.tests/workspace/compiler_parser/php5/testErrorClassStatement5.pdtt
+++ b/tests/org.eclipse.php.core.tests/workspace/compiler_parser/php5/testErrorClassStatement5.pdtt
@@ -4,12 +4,10 @@ Test Error Class Statement5
<?php class A {function f(){ for(;;;); ?>
--EXPECT--
<ModuleDeclaration start="6" end="36">
- <ClassDeclaration start="6" end="13" modifiers="" name="A">
+ <ClassDeclaration start="6" end="36" modifiers="" name="A">
<PHPMethodDeclaration start="15" end="27" modifiers="public" name="f">
</PHPMethodDeclaration>
</ClassDeclaration>
- <PHPMethodDeclaration start="15" end="27" modifiers="public" name="f">
- </PHPMethodDeclaration>
<Errors>
<ASTError start="35" end="36">
</ASTError>
diff --git a/tests/org.eclipse.php.core.tests/workspace/compiler_parser/php53/testErrorClassStatement5.pdtt b/tests/org.eclipse.php.core.tests/workspace/compiler_parser/php53/testErrorClassStatement5.pdtt
index b3a38f0..d100ad8 100644
--- a/tests/org.eclipse.php.core.tests/workspace/compiler_parser/php53/testErrorClassStatement5.pdtt
+++ b/tests/org.eclipse.php.core.tests/workspace/compiler_parser/php53/testErrorClassStatement5.pdtt
@@ -4,12 +4,10 @@ Test Error Class Statement5
<?php class A {function f(){ for(;;;); ?>
--EXPECT--
<ModuleDeclaration start="6" end="36">
- <ClassDeclaration start="6" end="13" modifiers="" name="A">
+ <ClassDeclaration start="6" end="36" modifiers="" name="A">
<PHPMethodDeclaration start="15" end="27" modifiers="public" name="f">
</PHPMethodDeclaration>
</ClassDeclaration>
- <PHPMethodDeclaration start="15" end="27" modifiers="public" name="f">
- </PHPMethodDeclaration>
<Errors>
<ASTError start="35" end="36">
</ASTError>