From 942c2996faff0fd9eed4f50451027a0a744ddbad Mon Sep 17 00:00:00 2001 From: Doug Schaefer Date: Mon, 9 Apr 2007 16:13:06 +0000 Subject: [PATCH] Patch for Bryan - 181015 - Fix a few exceptions in the indexer. --- .../core/dom/parser/cpp/CPPFunction.java | 14 +++++------ .../parser/cpp/CPPFunctionSpecialization.java | 4 ++-- .../core/dom/parser/cpp/CPPTemplates.java | 23 ++++++++++--------- .../core/dom/parser/cpp/CPPVisitor.java | 8 +++---- .../core/pdom/dom/cpp/PDOMCPPLinkage.java | 6 ++++- 5 files changed, 29 insertions(+), 26 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java index 1bf3b918f68..ce753276b51 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java @@ -496,12 +496,9 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt } static public boolean hasStorageClass( ICPPInternalFunction function, int storage ){ - IASTNode def = function.getDefinition(); - while (def instanceof IASTName) { - def = def.getParent(); - } - ICPPASTFunctionDeclarator dtor = (ICPPASTFunctionDeclarator) def; - ICPPASTFunctionDeclarator[] ds = (ICPPASTFunctionDeclarator[]) function.getDeclarations(); + ICPPASTFunctionDeclarator dtor = (ICPPASTFunctionDeclarator) function.getDefinition(); + IASTNode[] ds = (IASTNode[]) function.getDeclarations(); + int i = -1; do{ if( dtor != null ){ @@ -517,8 +514,9 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt if( declSpec.getStorageClass() == storage ) return true; } - if( ds != null && ++i < ds.length ) - dtor = ds[i]; + if( ds != null && ++i < ds.length ) { + dtor = (ICPPASTFunctionDeclarator) ds[i]; + } else break; } while( dtor != null ); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionSpecialization.java index 5899777bebe..27994a8f811 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionSpecialization.java @@ -187,7 +187,7 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP if( !(n instanceof ICPPASTFunctionDeclarator) ) return; updateParameterBindings( (ICPPASTFunctionDeclarator) n ); - super.addDefinition( node ); + super.addDefinition( n ); } public void addDeclaration(IASTNode node) { IASTNode n = node; @@ -196,7 +196,7 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP if( !(n instanceof ICPPASTFunctionDeclarator) ) return; updateParameterBindings( (ICPPASTFunctionDeclarator) n ); - super.addDeclaration( node ); + super.addDeclaration( n ); } protected void updateParameterBindings( ICPPASTFunctionDeclarator fdtor ){ IParameter [] params = null; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplates.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplates.java index 07b93ddf509..4870ace0316 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplates.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplates.java @@ -7,6 +7,7 @@ * * Contributors: * IBM - Initial API and implementation + * Bryan Wilkinson (QNX) *******************************************************************************/ /* * Created on Mar 11, 2005 @@ -347,9 +348,7 @@ public class CPPTemplates { for (int i = 0; i < templateParams.length; i++) { argMap.put( templateParams[i], args[i] ); } - if( template instanceof ICPPInternalTemplate ){ - spec = ((ICPPInternalTemplate)template).getInstance( args ); - } + spec = ((ICPPInternalTemplateInstantiator)template).getInstance( args ); if( spec == null ) { ICPPScope scope = (ICPPScope) CPPVisitor.getContainingScope( id ); spec = new CPPClassSpecialization(binding, scope, argMap ); @@ -357,13 +356,15 @@ public class CPPTemplates { ((ICPPInternalTemplate)template).addSpecialization( args, (ICPPSpecialization) spec ); } } - IASTNode parent = id.getParent(); - while( !(parent instanceof IASTDeclSpecifier ) ) - parent = parent.getParent(); - if( parent instanceof IASTElaboratedTypeSpecifier ) - ((ICPPInternalBinding)spec).addDeclaration( id ); - else if( parent instanceof IASTCompositeTypeSpecifier ) - ((ICPPInternalBinding)spec).addDefinition( id ); + if (spec instanceof ICPPInternalBinding) { + IASTNode parent = id.getParent(); + while( !(parent instanceof IASTDeclSpecifier ) ) + parent = parent.getParent(); + if( parent instanceof IASTElaboratedTypeSpecifier ) + ((ICPPInternalBinding)spec).addDeclaration( id ); + else if( parent instanceof IASTCompositeTypeSpecifier ) + ((ICPPInternalBinding)spec).addDefinition( id ); + } return spec; } //else partial specialization @@ -1438,7 +1439,7 @@ public class CPPTemplates { return null; } - IType paramType = (IType) ((ICPPInternalTemplate)template).instantiate( args ); + IType paramType = (IType) ((ICPPInternalTemplateInstantiator)template).instantiate( args ); IParameter [] functionParameters = new IParameter[] { new CPPParameter( paramType ) }; try { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java index f88f0b4e3cb..5b2b5a61ae5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2006, 2007 IBM Corporation and others. + * Copyright (c) 2004, 2007 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 @@ -2061,7 +2061,7 @@ public class CPPVisitor { } public static char [][] getQualifiedNameCharArray( IBinding binding ) { - IASTName [] ns = null; + IName [] ns = null; try { ICPPScope scope = (ICPPScope) binding.getScope(); while( scope != null ){ @@ -2078,12 +2078,12 @@ public class CPPVisitor { if( scope instanceof ICPPNamespaceScope && scope.getScopeName().toCharArray().length == 0 ) break; - ns = (IASTName[]) ArrayUtil.append( IASTName.class, ns, n ); + ns = (IName[]) ArrayUtil.append( IName.class, ns, n ); scope = (ICPPScope) scope.getParent(); } } catch ( DOMException e ) { } - ns = (IASTName[]) ArrayUtil.trim( IASTName.class, ns ); + ns = (IName[]) ArrayUtil.trim( IName.class, ns ); char[] [] result = new char[ ns.length + 1 ][]; for( int i = ns.length - 1; i >= 0; i-- ){ result[ ns.length - i - 1 ] = ns[i].toCharArray(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java index afe886cf886..a7bf696d72e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java @@ -54,6 +54,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier; import org.eclipse.cdt.internal.core.Util; +import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBlockScope; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalFunction; import org.eclipse.cdt.internal.core.pdom.PDOM; @@ -137,7 +138,9 @@ class PDOMCPPLinkage extends PDOMLinkage { try { ICPPTemplateParameter[] params = binding.getTemplateParameters(); for (int i = 0; i < params.length; i++) { - addBinding(params[i]); + if (params[i] != null && !(params[i] instanceof ProblemBinding)) { + addBinding(params[i]); + } } } catch (CoreException e) { } catch (DOMException e) { @@ -273,6 +276,7 @@ class PDOMCPPLinkage extends PDOMLinkage { if (binding instanceof ICPPSpecialization) { IBinding specialized = ((ICPPSpecialization)binding).getSpecializedBinding(); + if (specialized == null || specialized instanceof ProblemBinding) return null; PDOMBinding pdomSpecialized = addBinding(specialized); if (pdomSpecialized == null) return null;