From 746563ed2bc1e25f48548e4c23872388ba929929 Mon Sep 17 00:00:00 2001 From: John Camelon Date: Mon, 29 Sep 2003 19:49:19 +0000 Subject: [PATCH] Patch for Andrew Niefer Core: - fixed bug 43834 : Empty Parameter list and parameter list taking one void do not match - fix NPE if IScannerInfoProvider returns null IScannerInfo Tests: - added testbug43834 to ParserSymbolTableTest --- core/org.eclipse.cdt.core.tests/ChangeLog | 3 ++ .../parser/tests/ParserSymbolTableTest.java | 22 ++++++++++++++ core/org.eclipse.cdt.core/parser/ChangeLog | 3 ++ .../core/parser/pst/ParserSymbolTable.java | 30 ++++++++++++++++--- core/org.eclipse.cdt.core/search/ChangeLog | 3 ++ .../core/search/matching/MatchLocator.java | 3 +- 6 files changed, 59 insertions(+), 5 deletions(-) diff --git a/core/org.eclipse.cdt.core.tests/ChangeLog b/core/org.eclipse.cdt.core.tests/ChangeLog index cf768971024..6c4ab6c50e0 100644 --- a/core/org.eclipse.cdt.core.tests/ChangeLog +++ b/core/org.eclipse.cdt.core.tests/ChangeLog @@ -1,3 +1,6 @@ +2003-09-29 Andrew Niefer + added testbug43834() to ParserSymbolTableTest + 2003-09-29 John Camelon Added testErrorHandling_1() to CompleteParseASTTest.java. diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTest.java index c2bf6276237..ee484457dba 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTest.java @@ -2822,5 +2822,27 @@ public class ParserSymbolTableTest extends TestCase { returned = ParserSymbolTable.getConditionalOperand( secondOp, thirdOp ); assertEquals( returned, secondOp ); } + + public void testbug43834() throws Exception{ + newTable(); + + IParameterizedSymbol f = table.newParameterizedSymbol( "f", TypeInfo.t_function ); + table.getCompilationUnit().addSymbol( f ); + + LinkedList parameters = new LinkedList(); + TypeInfo param = new TypeInfo( TypeInfo.t_void, 0, null ); + parameters.add( param ); + + + ISymbol look = table.getCompilationUnit().unqualifiedFunctionLookup( "f", parameters ); + assertEquals( look, f ); + + f.addParameter( TypeInfo.t_void, 0, null, false ); + + parameters.clear(); + + look = table.getCompilationUnit().unqualifiedFunctionLookup( "f", parameters ); + assertEquals( look, f ); + } } diff --git a/core/org.eclipse.cdt.core/parser/ChangeLog b/core/org.eclipse.cdt.core/parser/ChangeLog index 11195de9839..2ee4402189e 100644 --- a/core/org.eclipse.cdt.core/parser/ChangeLog +++ b/core/org.eclipse.cdt.core/parser/ChangeLog @@ -1,3 +1,6 @@ +2003-09-29 Andrew Niefer + fixed bug 43834 : Empty Parameter list and parameter list taking one void do not match + 2003-09-29 John Camelon Continued work on Bug 43062 : Outline is confused on operator methods containing spaces Partial fix for Bug 43680 : Fix Parser Error Handling diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java index 4f78325dd06..bfe5016d2f2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java @@ -721,10 +721,20 @@ public class ParserSymbolTable { currFn = (IParameterizedSymbol) iterFns.next(); sourceParams = data.parameters.iterator(); - targetParams = currFn.getParameterList().iterator(); - //number of parameters in the current function - numTargetParams = currFn.getParameterList().size(); + List parameterList = null; + if( currFn.getParameterList() == null ){ + //the only way we get here and have no parameters, is if we are looking + //for a function that takes void parameters ie f( void ) + parameterList = new LinkedList(); + parameterList.add( currFn.getSymbolTable().newSymbol( "", TypeInfo.t_void ) ); + targetParams = parameterList.iterator(); + } else { + parameterList = currFn.getParameterList(); + } + + targetParams = parameterList.iterator(); + numTargetParams = parameterList.size(); //we only need to look at the smaller number of parameters //(a larger number in the Target means default parameters, a larger @@ -825,9 +835,21 @@ public class ParserSymbolTable { if( num == numParameters ){ continue; } + //check for void + else if( numParameters == 0 && num == 1 ){ + ISymbol param = (ISymbol)function.getParameterList().iterator().next(); + if( param.isType( TypeInfo.t_void ) ) + continue; + } + else if( numParameters == 1 && num == 0 ){ + TypeInfo paramType = (TypeInfo) data.parameters.iterator().next(); + if( paramType.isType( TypeInfo.t_void ) ) + continue; + } + //A candidate function having fewer than m parameters is viable only if it has an //ellipsis in its parameter list. - else if( num < numParameters ) { + if( num < numParameters ) { //TODO ellipsis //not enough parameters, remove it iter.remove(); diff --git a/core/org.eclipse.cdt.core/search/ChangeLog b/core/org.eclipse.cdt.core/search/ChangeLog index ba900afd5bc..60b2b552b5c 100644 --- a/core/org.eclipse.cdt.core/search/ChangeLog +++ b/core/org.eclipse.cdt.core/search/ChangeLog @@ -1,3 +1,6 @@ +2003-09-29 Andrew Niefer + -fix NPE if IScannerInfoProvider returns null IScannerInfo + 2003-09-25 Andrew Niefer - bug43129 - Cannot search for definitions of global variables - check definitions for variables, fields, enumerators and namespaces diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java index 51f07b6c894..ce84abe4ffe 100644 --- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java +++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java @@ -418,7 +418,8 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project); if (provider != null){ IScannerInfo buildScanInfo = provider.getScannerInformation(project); - scanInfo = new ScannerInfo(buildScanInfo.getDefinedSymbols(), buildScanInfo.getIncludePaths()); + if( buildScanInfo != null ) + scanInfo = new ScannerInfo(buildScanInfo.getDefinedSymbols(), buildScanInfo.getIncludePaths()); } ParserLanguage language = null;