diff --git a/core/org.eclipse.cdt.core.tests/ChangeLog b/core/org.eclipse.cdt.core.tests/ChangeLog index e0174c6a114..5b785d5d222 100644 --- a/core/org.eclipse.cdt.core.tests/ChangeLog +++ b/core/org.eclipse.cdt.core.tests/ChangeLog @@ -1,3 +1,6 @@ +2003-07-04 John Camelon + Moved testBug39652() from failed search tests to ClassDeclarationPatternTests. + 2003-07-04 Andrew Niefer Added new source Folder search Added search/ClassDeclarationPatternTests::testMatchSimpleDeclaration diff --git a/core/org.eclipse.cdt.core.tests/failures/org/eclipse/cdt/core/search/failedTests/PatternsFailedTests.java b/core/org.eclipse.cdt.core.tests/failures/org/eclipse/cdt/core/search/failedTests/PatternsFailedTests.java deleted file mode 100644 index be6a712d6f5..00000000000 --- a/core/org.eclipse.cdt.core.tests/failures/org/eclipse/cdt/core/search/failedTests/PatternsFailedTests.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v0.5 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v05.html - * - * Contributors: - * IBM Corp. - Rational Software - initial implementation - ******************************************************************************/ -/* - * Created on Jul 4, 2003 - */ -package org.eclipse.cdt.core.search.failedTests; - -import java.util.Set; - -import org.eclipse.cdt.core.search.ICSearchConstants; -import org.eclipse.cdt.internal.core.search.matching.CSearchPattern; -import org.eclipse.cdt.internal.core.search.matching.MatchLocator; -import org.eclipse.cdt.internal.ui.search.CSearchResultCollector; -import org.eclipse.core.runtime.Path; - -import junit.framework.TestCase; - -/** - * @author aniefer - * - * To change the template for this generated type comment go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -public class PatternsFailedTests extends TestCase implements ICSearchConstants { - - private MatchLocator matchLocator; - private CSearchResultCollector resultCollector; - private String cppPath; - - public PatternsFailedTests(String name) { - super(name); - } - - private void initialize( CSearchPattern pattern ){ - cppPath = org.eclipse.core.runtime.Platform.getPlugin("org.eclipse.cdt.core.tests").find(new Path("/")).getFile(); - cppPath += "resources/search/classDecl.cpp"; - - resultCollector = new CSearchResultCollector(); - matchLocator = new MatchLocator( pattern, resultCollector, null, null ); - } - - public void testBug39652() { - CSearchPattern pattern = CSearchPattern.createPattern( "A::B", TYPE, DECLARATIONS, EXACT_MATCH, true ); - - initialize( pattern ); - matchLocator.locateMatches( new String[] { cppPath }, null, null ); - Set matches = resultCollector.getMatches(); - /* Test should find 1 match */ - //assertTrue( matches != null ); - //assertTrue( matches.size() == 1 ); - - /* instead it finds none because qualifications are wrong*/ - assertTrue( matches == null ); - - pattern = CSearchPattern.createPattern( "NS::NS2::a", TYPE, DECLARATIONS, EXACT_MATCH, true ); - initialize( pattern ); - matchLocator.locateMatches( new String[] { cppPath }, null, null ); - matches = resultCollector.getMatches(); - assertTrue( matches == null ); - - pattern = CSearchPattern.createPattern( "NS::B::A", TYPE, DECLARATIONS, EXACT_MATCH, true ); - initialize( pattern ); - matchLocator.locateMatches( new String[] { cppPath }, null, null ); - matches = resultCollector.getMatches(); - assertTrue( matches == null ); - } - - -} diff --git a/core/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/ClassDeclarationPatternTests.java b/core/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/ClassDeclarationPatternTests.java index 3cda9a4183f..9c3ffea07e8 100644 --- a/core/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/ClassDeclarationPatternTests.java +++ b/core/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/ClassDeclarationPatternTests.java @@ -82,6 +82,29 @@ public class ClassDeclarationPatternTests extends TestCase implements ICSearchCo assertEquals( matches.size(), 1 ); } + public void testBug39652() { + CSearchPattern pattern = CSearchPattern.createPattern( "A::B", TYPE, DECLARATIONS, EXACT_MATCH, true ); + + initialize( pattern ); + matchLocator.locateMatches( new String[] { cppPath }, null, null ); + Set matches = resultCollector.getMatches(); + /* Test should find 1 match */ + assertTrue( matches != null ); + assertTrue( matches.size() == 1 ); + + pattern = CSearchPattern.createPattern( "NS::NS2::a", TYPE, DECLARATIONS, EXACT_MATCH, true ); + initialize( pattern ); + matchLocator.locateMatches( new String[] { cppPath }, null, null ); + matches = resultCollector.getMatches(); + assertTrue( matches == null ); + + pattern = CSearchPattern.createPattern( "NS::B::A", TYPE, DECLARATIONS, EXACT_MATCH, true ); + initialize( pattern ); + matchLocator.locateMatches( new String[] { cppPath }, null, null ); + matches = resultCollector.getMatches(); + assertTrue( matches == null ); + } + public void failingtestMatchStruct(){ CSearchPattern pattern = CSearchPattern.createPattern( "A", STRUCT, DECLARATIONS, EXACT_MATCH, true ); diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java index 6be557d20cb..a758975c907 100644 --- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java +++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java @@ -27,7 +27,6 @@ import org.eclipse.cdt.core.parser.failedTests.DOMFailedTest; import org.eclipse.cdt.core.parser.failedTests.LokiFailures; import org.eclipse.cdt.core.parser.failedTests.STLFailedTests; import org.eclipse.cdt.core.parser.tests.ParserTestSuite; -import org.eclipse.cdt.core.search.failedTests.PatternsFailedTests; import org.eclipse.cdt.core.search.tests.ClassDeclarationPatternTests; import org.eclipse.core.boot.IPlatformRunnable; @@ -90,7 +89,6 @@ public class AutomatedIntegrationSuite extends TestSuite suite.addTestSuite(LokiFailures.class); suite.addTestSuite(STLFailedTests.class); suite.addTestSuite(CModelElementsFailedTests.class); - suite.addTestSuite(PatternsFailedTests.class); // Last test to trigger report generation suite.addTest(suite.new GenerateReport("generateReport")); diff --git a/core/org.eclipse.cdt.core/parser/ChangeLog b/core/org.eclipse.cdt.core/parser/ChangeLog index 60c02625495..e566d7a32d8 100644 --- a/core/org.eclipse.cdt.core/parser/ChangeLog +++ b/core/org.eclipse.cdt.core/parser/ChangeLog @@ -1,3 +1,7 @@ +2003-07-04 John Camelon + Fixed NPE in Parser::declarator(). + Bug 39652 - AST: Nested Classes incorrectly report null qualified Names + 2003-07-04 Victor Mozgin Added CTaskTagsReconciler. Extended ParserFactory with createProblemReporter() and createTranslationResult(). diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java index d3a7f0c8c31..0d683f084cb 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java @@ -2355,11 +2355,22 @@ public class Parser implements IParser { do { + IASTScope s = null; + if( sdw != null ) + s = sdw.getScope(); + else + { + Declarator i = owningDeclarator; + while( i.getOwnerDeclarator() != null ) + i = i.getOwnerDeclarator(); + s = i.getOwner().getScope(); + } + simpleDeclaration( oldKRParameterDeclarationClause, false, true, - sdw.getScope()); + s); } while (LT(1) != IToken.tLBRACE); } @@ -2944,7 +2955,7 @@ public class Parser implements IParser default : try { - declaration(classSpec); + declaration(classSpec,astClassSpecifier); } catch (Backtrack bt) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTClassSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTClassSpecifier.java index ab2c20a0b12..087d454eee3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTClassSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTClassSpecifier.java @@ -49,6 +49,8 @@ public class ASTClassSpecifier Stack names = new Stack(); IASTScope parent = getOwnerScope(); + + names.push( name ); // push on our own name while (parent != null) { if (parent instanceof IASTNamespaceDefinition