1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00
Fixed NPE in Parser::declarator().
	Bug 39652 - AST: Nested Classes incorrectly report null qualified Names 

TESTS
	Moved testBug39652() from failed search tests to ClassDeclarationPatternTests.
This commit is contained in:
John Camelon 2003-07-04 18:03:22 +00:00
parent 8a70b5e1d2
commit 2e6093590f
7 changed files with 45 additions and 81 deletions

View file

@ -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

View file

@ -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 );
}
}

View file

@ -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 );

View file

@ -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"));

View file

@ -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().

View file

@ -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)
{

View file

@ -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