diff --git a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/CxxAstUtils.java b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/CxxAstUtils.java index 1521fb66ca4..f890b27d587 100644 --- a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/CxxAstUtils.java +++ b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/CxxAstUtils.java @@ -16,7 +16,6 @@ import java.util.HashSet; import java.util.Set; import org.eclipse.cdt.core.dom.ast.ASTVisitor; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression; import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; @@ -257,14 +256,10 @@ public final class CxxAstUtils { for (IBinding b : bindings) { if (b instanceof IFunction) { IFunction f = (IFunction) b; - try { - if (f.getParameters().length == expectedParametersNum) { - // Consider this overload - IIndexName[] decls = index.findDeclarations(b); - declSet.addAll(Arrays.asList(decls)); - } - } catch (DOMException e) { - continue; + if (f.getParameters().length == expectedParametersNum) { + // Consider this overload + IIndexName[] decls = index.findDeclarations(b); + declSet.addAll(Arrays.asList(decls)); } } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBindingResolutionTestBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBindingResolutionTestBase.java index 1a41e225ac5..21959d233df 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBindingResolutionTestBase.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBindingResolutionTestBase.java @@ -221,18 +221,14 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { } protected static void assertVariable(IBinding b, String qn, Class expType, String expTypeQN) { - try { - assertInstance(b, IVariable.class); - IVariable variable = (IVariable) b; - assertQNEquals(qn, variable); - assertInstance(variable.getType(), expType); - if (expTypeQN != null) { - IType type= variable.getType(); - assertInstance(type, IBinding.class); - assertQNEquals(expTypeQN, (IBinding) type); - } - } catch (DOMException de) { - fail(de.getMessage()); + assertInstance(b, IVariable.class); + IVariable variable = (IVariable) b; + assertQNEquals(qn, variable); + assertInstance(variable.getType(), expType); + if (expTypeQN != null) { + IType type= variable.getType(); + assertInstance(type, IBinding.class); + assertQNEquals(expTypeQN, (IBinding) type); } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java index d489765c863..94c82852431 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java @@ -1592,18 +1592,14 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti String qn, Class expType, String expTypeQN) { - try { - assertTrue(binding instanceof ICPPField); - ICPPField field = (ICPPField) binding; - assertQNEquals(qn, field); - assertTrue(expType.isInstance(field.getType())); - if (expTypeQN != null) { - assert(field.getType() instanceof ICPPBinding); - ICPPBinding tyBinding = (ICPPBinding) field.getType(); - assertQNEquals(expTypeQN, tyBinding); - } - } catch (DOMException de) { - fail(de.getMessage()); + assertTrue(binding instanceof ICPPField); + ICPPField field = (ICPPField) binding; + assertQNEquals(qn, field); + assertTrue(expType.isInstance(field.getType())); + if (expTypeQN != null) { + assert(field.getType() instanceof ICPPBinding); + ICPPBinding tyBinding = (ICPPBinding) field.getType(); + assertQNEquals(expTypeQN, tyBinding); } } @@ -1647,7 +1643,7 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti assertEquals(methods, classType.getMethods().length); assertEquals(declaredMethods, classType.getDeclaredMethods().length); assertEquals(allDeclaredMethods, classType.getAllDeclaredMethods().length); - // assertEquals(friends, classType.getFriends().length); (PDOMNotImplementedError) + assertEquals(friends, classType.getFriends().length); assertEquals(constructors, classType.getConstructors().length); assertEquals(nestedClasses, classType.getNestedClasses().length); } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMTestBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMTestBase.java index e3d8ef6362c..47d64ff85b9 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMTestBase.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMTestBase.java @@ -35,7 +35,6 @@ import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.core.testplugin.CTestPlugin; import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.core.testplugin.util.TestSourceReader; -import org.eclipse.cdt.internal.core.Util; import org.eclipse.cdt.internal.core.index.IIndexFragment; import org.eclipse.cdt.internal.core.pdom.PDOM; import org.eclipse.core.resources.IWorkspace; @@ -187,8 +186,8 @@ public class PDOMTestBase extends BaseTestCase { */ private void assertUniqueNameCount(IName[] names, int count) { Set offsets = new HashSet(); - for (int i = 0; i < names.length; i++) { - offsets.add(names[i].getFileLocation()); + for (IName name : names) { + offsets.add(name.getFileLocation()); } assertEquals(count, offsets.size()); } @@ -217,27 +216,23 @@ public class PDOMTestBase extends BaseTestCase { // this is only approximate - composite types are not supported public static IBinding[] findIFunctions(Class[] paramTypes, IBinding[] bindings) throws CoreException { - try { - List preresult = new ArrayList(); - for(int i=0; i 0) { final ICPPParameter p = pars[result-1]; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionInstance.java index 4dbb545a3b2..8550489357f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionInstance.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionInstance.java @@ -11,9 +11,7 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; -import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IType; @@ -72,17 +70,13 @@ public class CPPFunctionInstance extends CPPFunctionSpecialization implements IC @Override public boolean equals(Object obj) { if( (obj instanceof ICPPTemplateInstance) && (obj instanceof ICPPFunction)){ - try { - final ICPPTemplateInstance inst = (ICPPTemplateInstance)obj; - ICPPFunctionType ct1= ((ICPPFunction)getSpecializedBinding()).getType(); - ICPPFunctionType ct2= ((ICPPFunction)inst.getTemplateDefinition()).getType(); - if(!ct1.isSameType(ct2)) - return false; + final ICPPTemplateInstance inst = (ICPPTemplateInstance)obj; + ICPPFunctionType ct1= ((ICPPFunction)getSpecializedBinding()).getType(); + ICPPFunctionType ct2= ((ICPPFunction)inst.getTemplateDefinition()).getType(); + if(!ct1.isSameType(ct2)) + return false; - return CPPTemplates.haveSameArguments(this, inst); - } catch(DOMException de) { - CCorePlugin.log(de); - } + return CPPTemplates.haveSameArguments(this, inst); } return false; 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 c2b6d194244..120aaf011e9 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 @@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition; @@ -52,7 +51,7 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP return (ICPPFunction) getSpecializedBinding(); } - public ICPPParameter[] getParameters() throws DOMException { + public ICPPParameter[] getParameters() { if (fParams == null) { ICPPFunction function = getFunction(); ICPPParameter[] params = function.getParameters(); @@ -76,7 +75,7 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP return fParams; } - public int getRequiredArgumentCount() throws DOMException { + public int getRequiredArgumentCount() { return ((ICPPFunction) getSpecializedBinding()).getRequiredArgumentCount(); } @@ -88,7 +87,7 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP return null; } - public ICPPFunctionType getType() throws DOMException { + public ICPPFunctionType getType() { if (type == null) { ICPPFunction function = (ICPPFunction) getSpecializedBinding(); type = (ICPPFunctionType) specializeType(function.getType()); @@ -279,11 +278,7 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP public String toString() { StringBuilder result = new StringBuilder(); result.append(getName()); - IFunctionType t = null; - try { - t = getType(); - } catch (DOMException e) { - } + IFunctionType t = getType(); result.append(t != null ? ASTTypeUtil.getParameterTypeString(t) : "()"); //$NON-NLS-1$ ICPPTemplateParameterMap tpmap= getTemplateParameterMap(); if (tpmap != null) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplate.java index 194afcc513e..2d45901cd2e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplate.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplate.java @@ -15,7 +15,6 @@ import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUti import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getNestedType; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; @@ -29,17 +28,16 @@ import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IFunctionType; import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.dom.ast.IScope; +import org.eclipse.cdt.core.dom.ast.ISemanticProblem; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; import org.eclipse.cdt.internal.core.dom.parser.ASTInternal; import org.eclipse.cdt.internal.core.dom.parser.ASTQueries; -import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; +import org.eclipse.cdt.internal.core.dom.parser.ProblemFunctionType; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; /** @@ -47,31 +45,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; */ public class CPPFunctionTemplate extends CPPTemplateDefinition implements ICPPFunctionTemplate, ICPPInternalFunction { - public static final class CPPFunctionTemplateProblem extends ProblemBinding - implements ICPPFunctionTemplate { - public CPPFunctionTemplateProblem(IASTNode node, int id, char[] arg) { - super(node, id, arg); - } - public ICPPTemplateParameter[] getTemplateParameters() throws DOMException { - throw new DOMException(this); - } - public ICPPClassTemplatePartialSpecialization[] getTemplateSpecializations() throws DOMException { - throw new DOMException(this); - } - public ICPPParameter[] getParameters() throws DOMException { - throw new DOMException(this); - } - public IScope getFunctionScope() throws DOMException { - throw new DOMException(this); - } - @Override - public ICPPFunctionType getType() throws DOMException { - throw new DOMException(this); - } - public int getRequiredArgumentCount() throws DOMException { - throw new DOMException( this ); - } - } protected ICPPFunctionType type = null; @@ -145,7 +118,7 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition return CPPBuiltinParameter.createParameterList(getType()); } - public int getRequiredArgumentCount() throws DOMException { + public int getRequiredArgumentCount() { return CPPFunction.getRequiredArgumentCount(getParameters()); } @@ -165,9 +138,15 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition while (parent.getParent() instanceof IASTDeclarator) parent = parent.getParent(); - IType temp = getNestedType(CPPVisitor.createType((IASTDeclarator)parent), TDEF); - if (temp instanceof ICPPFunctionType) - type = (ICPPFunctionType) temp; + IType t = getNestedType(CPPVisitor.createType((IASTDeclarator)parent), TDEF); + if (t instanceof ICPPFunctionType) { + type = (ICPPFunctionType) t; + } else if (t instanceof ISemanticProblem){ + type= new ProblemFunctionType(((ISemanticProblem) t).getID()); + } else { + // This case is unexpected + type= new ProblemFunctionType(ISemanticProblem.TYPE_UNRESOLVED_NAME); + } } return type; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethod.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethod.java index 8176772a755..b4d0bd3301f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethod.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethod.java @@ -18,7 +18,6 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclarator; import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator; import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition; import org.eclipse.cdt.core.dom.ast.IASTName; -import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration; import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier; @@ -28,7 +27,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.core.parser.util.CharArrayUtils; import org.eclipse.cdt.internal.core.dom.parser.ASTInternal; @@ -39,27 +37,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; * The binding for a method. */ public class CPPMethod extends CPPFunction implements ICPPMethod { - public static class CPPMethodProblem extends CPPFunctionProblem implements ICPPMethod { - private ICPPClassType fOwner; - public CPPMethodProblem(ICPPClassType owner, IASTNode node, int id, char[] arg) { - super(node, id, arg); - fOwner= owner; - } - public ICPPClassType getClassOwner() { - return fOwner; - } - public boolean isDestructor() { - char[] name = getNameCharArray(); - if (name.length > 1 && name[0] == '~') - return true; - - return false; - } - public int getVisibility() { - return ICPPMember.v_private; - } - } - public CPPMethod(IASTDeclarator declarator) { super(declarator); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameterSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameterSpecialization.java index 23ab59c190d..24d857d9776 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameterSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameterSpecialization.java @@ -11,7 +11,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IValue; @@ -37,7 +36,7 @@ public class CPPParameterSpecialization extends CPPSpecialization implements ICP /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IVariable#getType() */ - public IType getType() throws DOMException { + public IType getType() { return fType; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownFunction.java index 15fdf0453b0..7958038e3c9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownFunction.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownFunction.java @@ -59,7 +59,7 @@ public class CPPUnknownFunction extends CPPUnknownBinding implements ICPPFunctio return false; } - public IScope getFunctionScope() throws DOMException { + public IScope getFunctionScope() { return asScope(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVariable.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVariable.java index e196cfb1a0b..2bf8413d45d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVariable.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVariable.java @@ -41,19 +41,12 @@ import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.internal.core.dom.Linkage; import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.IInternalVariable; -import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; import org.eclipse.cdt.internal.core.dom.parser.Value; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil; import org.eclipse.core.runtime.PlatformObject; public class CPPVariable extends PlatformObject implements ICPPVariable, ICPPInternalBinding, IInternalVariable { - public static class CPPVariableProblem extends ProblemBinding implements ICPPVariable { - public CPPVariableProblem(IASTNode node, int id, char[] arg) { - super(node, id, arg); - } - } - private IASTName fDefinition = null; private IASTName fDeclarations[] = null; private IType fType = null; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ClassTypeHelper.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ClassTypeHelper.java index 2333153491a..ef5ee68083d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ClassTypeHelper.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ClassTypeHelper.java @@ -127,9 +127,8 @@ public class ClassTypeHelper { * @param binding a binding. * @param classType a class. * @return true if binding is a friend of classType. - * @throws DOMException */ - public static boolean isFriend(IBinding binding, ICPPClassType classType) throws DOMException { + public static boolean isFriend(IBinding binding, ICPPClassType classType) { IType type; if (binding instanceof ICPPClassType) { type = (IType) binding; @@ -158,7 +157,6 @@ public class ClassTypeHelper { /** * A host maybe backed up with a definition from the index. - * @throws DOMException */ private static ICPPClassType getBackupDefinition(ICPPInternalClassTypeMixinHost host) { ICPPClassScope scope = host.getCompositeScope(); @@ -437,7 +435,7 @@ public class ClassTypeHelper { * Returns whether {@code method} is virtual. This is the case if it is declared to be virtual or * overrides another virtual method. */ - public static boolean isVirtual(ICPPMethod m) throws DOMException { + public static boolean isVirtual(ICPPMethod m) { if (m instanceof ICPPConstructor) return false; if (m.isVirtual()) @@ -489,9 +487,8 @@ public class ClassTypeHelper { /** * Returns {@code true} if {@code source} overrides {@code target}. - * @throws DOMException */ - public static boolean isOverrider(ICPPMethod source, ICPPMethod target) throws DOMException { + public static boolean isOverrider(ICPPMethod source, ICPPMethod target) { if (source instanceof ICPPConstructor || target instanceof ICPPConstructor) return false; if (!isVirtual(target)) @@ -515,9 +512,8 @@ public class ClassTypeHelper { /** * Returns all methods that are overridden by the given {@code method}. - * @throws DOMException */ - public static ICPPMethod[] findOverridden(ICPPMethod method) throws DOMException { + public static ICPPMethod[] findOverridden(ICPPMethod method) { if (method instanceof ICPPConstructor) return ICPPMethod.EMPTY_CPPMETHOD_ARRAY; @@ -551,7 +547,7 @@ public class ClassTypeHelper { * Returns whether {@code cl} contains an overridden method. */ private static boolean findOverridden(ICPPClassType cl, char[] mname, ICPPFunctionType mft, - HashMap virtualInClass, ArrayList result) throws DOMException { + HashMap virtualInClass, ArrayList result) { Boolean visitedBefore= virtualInClass.get(cl); if (visitedBefore != null) return visitedBefore; @@ -589,10 +585,9 @@ public class ClassTypeHelper { /** * Returns all methods found in the index, that override the given {@code method}. - * @throws DOMException * @throws CoreException */ - public static ICPPMethod[] findOverriders(IIndex index, ICPPMethod method) throws DOMException, CoreException { + public static ICPPMethod[] findOverriders(IIndex index, ICPPMethod method) throws CoreException { if (!isVirtual(method)) return ICPPMethod.EMPTY_CPPMETHOD_ARRAY; @@ -606,10 +601,8 @@ public class ClassTypeHelper { /** * Returns all methods belonging to the given set of classes that override the given {@code method}. - * @throws DOMException */ - public static ICPPMethod[] findOverriders(ICPPClassType[] subclasses, ICPPMethod method) - throws DOMException { + public static ICPPMethod[] findOverriders(ICPPClassType[] subclasses, ICPPMethod method) { final char[] mname= method.getNameCharArray(); final ICPPFunctionType mft= method.getType(); final ArrayList result= new ArrayList(); @@ -700,37 +693,34 @@ public class ClassTypeHelper { } private static int getImplicitMethodKind(ICPPClassType ct, ICPPMethod method) { - try { - if (method instanceof ICPPConstructor) { - final IFunctionType type= method.getType(); - final IType[] params= type.getParameterTypes(); - if (params.length == 0) + if (method instanceof ICPPConstructor) { + final IFunctionType type= method.getType(); + final IType[] params= type.getParameterTypes(); + if (params.length == 0) + return KIND_DEFAULT_CTOR; + if (params.length == 1) { + IType t= SemanticUtil.getNestedType(params[0], SemanticUtil.TDEF); + if (SemanticUtil.isVoidType(t)) return KIND_DEFAULT_CTOR; - if (params.length == 1) { - IType t= SemanticUtil.getNestedType(params[0], SemanticUtil.TDEF); - if (SemanticUtil.isVoidType(t)) - return KIND_DEFAULT_CTOR; - if (isRefToConstClass(ct, t)) - return KIND_COPY_CTOR; - } - return KIND_OTHER; + if (isRefToConstClass(ct, t)) + return KIND_COPY_CTOR; } + return KIND_OTHER; + } - if (method.isDestructor()) - return KIND_DTOR; + if (method.isDestructor()) + return KIND_DTOR; - if (CharArrayUtils.equals(method.getNameCharArray(), OverloadableOperator.ASSIGN.toCharArray())) { - final IFunctionType type= method.getType(); - final IType[] params= type.getParameterTypes(); - if (params.length == 1) { - IType t= params[0]; - if (isRefToConstClass(ct, t)) - return KIND_ASSIGNMENT_OP; - } - return KIND_OTHER; + if (CharArrayUtils.equals(method.getNameCharArray(), OverloadableOperator.ASSIGN.toCharArray())) { + final IFunctionType type= method.getType(); + final IType[] params= type.getParameterTypes(); + if (params.length == 1) { + IType t= params[0]; + if (isRefToConstClass(ct, t)) + return KIND_ASSIGNMENT_OP; } - } catch (DOMException e) { + return KIND_OTHER; } return KIND_OTHER; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/AccessContext.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/AccessContext.java index 87a6d12969b..3a99c2d5c6d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/AccessContext.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/AccessContext.java @@ -71,27 +71,22 @@ public class AccessContext { * @return true if the binding is accessible. */ public boolean isAccessible(IBinding binding) { - try { - IBinding owner; - while ((owner = binding.getOwner()) instanceof ICompositeType && - ((ICompositeType) owner).isAnonymous()) { - binding = owner; - } - if (!(owner instanceof ICPPClassType)) { - return true; // The binding is not a class member. - } - ICPPClassType accessOwner= (ICPPClassType) owner; - if (!initialize(accessOwner)) { - return true; // Assume visibility if anything goes wrong. - } - if (namingClass == null) { - return true; - } - return isAccessible(binding, (ICPPClassType) owner, namingClass, v_public, 0); - } catch (DOMException e) { - CCorePlugin.log(e); + IBinding owner; + while ((owner = binding.getOwner()) instanceof ICompositeType && + ((ICompositeType) owner).isAnonymous()) { + binding = owner; } - return true; + if (!(owner instanceof ICPPClassType)) { + return true; // The binding is not a class member. + } + ICPPClassType accessOwner= (ICPPClassType) owner; + if (!initialize(accessOwner)) { + return true; // Assume visibility if anything goes wrong. + } + if (namingClass == null) { + return true; + } + return isAccessible(binding, (ICPPClassType) owner, namingClass, v_public, 0); } /** @@ -116,7 +111,7 @@ public class AccessContext { } private boolean isAccessible(IBinding binding, ICPPClassType owner, ICPPClassType derivedClass, - int accessLevel, int depth) throws DOMException { + int accessLevel, int depth) { if (depth > CPPSemantics.MAX_INHERITANCE_DEPTH) return false; @@ -156,7 +151,7 @@ public class AccessContext { * v_private. * @return One of: v_public, v_protected, v_private. */ - private int getMemberAccessLevel(ICPPClassType classType, int inheritedAccessLevel) throws DOMException { + private int getMemberAccessLevel(ICPPClassType classType, int inheritedAccessLevel) { int accessLevel = inheritedAccessLevel; for (IBinding contextBinding : context) { if (ClassTypeHelper.isFriend(contextBinding, classType)) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/AutoTypeResolver.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/AutoTypeResolver.java index 5b9c33ecc6b..e851cdc10bc 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/AutoTypeResolver.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/AutoTypeResolver.java @@ -71,11 +71,11 @@ class AutoTypeResolver implements ICPPFunctionTemplate { return null; } - public ICPPParameter[] getParameters() throws DOMException { + public ICPPParameter[] getParameters() { throw new UnsupportedOperationException(UNEXPECTED_CALL); } - public int getRequiredArgumentCount() throws DOMException { + public int getRequiredArgumentCount() { return 1; } @@ -83,7 +83,7 @@ class AutoTypeResolver implements ICPPFunctionTemplate { return false; } - public IScope getFunctionScope() throws DOMException { + public IScope getFunctionScope() { throw new UnsupportedOperationException(UNEXPECTED_CALL); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/BuiltinOperators.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/BuiltinOperators.java index b35fb41daa9..12b114d67cc 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/BuiltinOperators.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/BuiltinOperators.java @@ -553,10 +553,7 @@ class BuiltinOperators { if (fGlobalCandidates != null) { for (Object cand : fGlobalCandidates) { if (cand instanceof IFunction && !(cand instanceof ICPPMethod)) { - try { - fSignatures.add(ASTTypeUtil.getType(((IFunction)cand).getType(), true)); - } catch (DOMException e) { - } + fSignatures.add(ASTTypeUtil.getType(((IFunction)cand).getType(), true)); } } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java index 61295e7979c..63a1bbc40b9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java @@ -1106,13 +1106,10 @@ public class CPPSemantics { } } if (b instanceof IVariable) { - try { - IType t= SemanticUtil.getUltimateType(((IVariable) b).getType(), true); - if (t instanceof ICPPUnknownBinding || t instanceof ICPPTemplateDefinition) { - result[0]= true; - return PROCESS_ABORT; - } - } catch (DOMException e) { + IType t= SemanticUtil.getUltimateType(((IVariable) b).getType(), true); + if (t instanceof ICPPUnknownBinding || t instanceof ICPPTemplateDefinition) { + result[0]= true; + return PROCESS_ABORT; } } if (name instanceof ICPPASTTemplateId) @@ -2651,15 +2648,11 @@ public class CPPSemantics { IFunction unknown= null; for (IFunction function : fns) { if (function != null) { - try { - IType t2= function.getType().getReturnType(); - if (t.isSameType(t2)) - return function; - if (unknown == null && function instanceof ICPPUnknownBinding) { - unknown= function; - } - } catch (DOMException e) { - // ignore, try other candidates + IType t2= function.getType().getReturnType(); + if (t.isSameType(t2)) + return function; + if (unknown == null && function instanceof ICPPUnknownBinding) { + unknown= function; } } } @@ -2717,10 +2710,7 @@ public class CPPSemantics { ICPPASTConstructorChainInitializer memInit= (ICPPASTConstructorChainInitializer) parentOfInit; IBinding var= memInit.getMemberInitializerId().resolveBinding(); if (var instanceof IVariable) { - try { - targetType= ((IVariable) var).getType(); - } catch (DOMException e) { - } + targetType= ((IVariable) var).getType(); } } } @@ -2783,11 +2773,8 @@ public class CPPSemantics { dtor= ASTQueries.findInnermostDeclarator(dtor); IBinding binding = dtor.getName().resolveBinding(); if (binding instanceof IFunction) { - try { - IFunctionType ft = ((IFunction) binding).getType(); - targetType= ft.getReturnType(); - } catch (DOMException e) { - } + IFunctionType ft = ((IFunction) binding).getType(); + targetType= ft.getReturnType(); } } } @@ -2815,13 +2802,10 @@ public class CPPSemantics { // First pass, consider functions for (ICPPFunction fn : fns) { - try { - if (!(fn instanceof ICPPFunctionTemplate)) { - if (targetType.isSameType(fn.getType())) - return fn; - } - } catch (DOMException e) { - } + if (!(fn instanceof ICPPFunctionTemplate)) { + if (targetType.isSameType(fn.getType())) + return fn; + } } // Second pass, consider templates @@ -3328,14 +3312,11 @@ public class CPPSemantics { for (Object object : items) { if (object instanceof ICPPFunction) { ICPPFunction func= (ICPPFunction) object; - try { - ICPPFunctionType ft = func.getType(); - IType[] pts= ft.getParameterTypes(); - if ((enum1 != null && pts.length > 0 && enum1.isSameType(getUltimateTypeUptoPointers(pts[0]))) || - (enum2 != null && pts.length > 1 && enum2.isSameType(getUltimateTypeUptoPointers(pts[1])))) { - items[j++]= object; - } - } catch (DOMException e) { + ICPPFunctionType ft = func.getType(); + IType[] pts= ft.getParameterTypes(); + if ((enum1 != null && pts.length > 0 && enum1.isSameType(getUltimateTypeUptoPointers(pts[0]))) || + (enum2 != null && pts.length > 1 && enum2.isSameType(getUltimateTypeUptoPointers(pts[1])))) { + items[j++]= object; } } } @@ -3605,12 +3586,9 @@ public class CPPSemantics { } declarator= ASTQueries.findTypeRelevantDeclarator(declarator); - try { - if (declarator instanceof ICPPASTFunctionDeclarator) { - IType type = function.getType(); - return type.isSameType(CPPVisitor.createType(declarator)); - } - } catch (DOMException e) { + if (declarator instanceof ICPPASTFunctionDeclarator) { + IType type = function.getType(); + return type.isSameType(CPPVisitor.createType(declarator)); } return false; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java index 999f1450004..4b98262bf5e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java @@ -1776,12 +1776,9 @@ public class CPPTemplates { private static IType[] addImplicitObjectType(IType[] types, ICPPMethod f1) { ICPPClassType ct = f1.getClassOwner(); if (ct != null) { - try { - ICPPFunctionType ft = f1.getType(); - final CPPReferenceType t = new CPPReferenceType(addQualifiers(ct, ft.isConst(), ft.isVolatile()), false); - return concat(t, types); - } catch (DOMException e) { - } + ICPPFunctionType ft = f1.getType(); + final CPPReferenceType t = new CPPReferenceType(addQualifiers(ct, ft.isConst(), ft.isVolatile()), false); + return concat(t, types); } return types; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java index 6935dc721b3..09553a1018a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java @@ -681,10 +681,7 @@ public class CPPVisitor extends ASTQueries { // Variable declaration IType t2= null; if (binding != null && binding instanceof IVariable && !(binding instanceof IIndexBinding)) { - try { - t2 = ((IVariable) binding).getType(); - } catch (DOMException e1) { - } + t2 = ((IVariable) binding).getType(); } if (t1 != null && t2 != null) { if (t1.isSameType(t2) || isCompatibleArray(t1, t2) != null) { @@ -1578,22 +1575,18 @@ public class CPPVisitor extends ASTQueries { IType pt = null; for (int i = 0; i < parameters.length; i++) { - try { - pt = parameters[i].getType(); - - // remove qualifiers - if (pt instanceof IQualifierType) { - pt= ((IQualifierType) pt).getType(); - } + pt = parameters[i].getType(); + + // remove qualifiers + if (pt instanceof IQualifierType) { + pt= ((IQualifierType) pt).getType(); + } - if (pt instanceof IArrayType) { - pt = new CPPPointerType(((IArrayType) pt).getType()); - } else if (pt instanceof IFunctionType) { - pt = new CPPPointerType(pt); - } - } catch (DOMException e) { - pt = e.getProblem(); - } + if (pt instanceof IArrayType) { + pt = new CPPPointerType(((IArrayType) pt).getType()); + } else if (pt instanceof IFunctionType) { + pt = new CPPPointerType(pt); + } pTypes[i] = pt; } @@ -1933,15 +1926,11 @@ public class CPPVisitor extends ASTQueries { if (b instanceof IType) { return (IType) b; } - try { - if (b instanceof IVariable) { - return ((IVariable) b).getType(); - } - if (b instanceof IFunction) { - return ((IFunction) b).getType(); - } - } catch (DOMException e) { - return e.getProblem(); + if (b instanceof IVariable) { + return ((IVariable) b).getType(); + } + if (b instanceof IFunction) { + return ((IFunction) b).getType(); } } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/ExpressionTypes.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/ExpressionTypes.java index 1cd2795bc07..70e059bea65 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/ExpressionTypes.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/ExpressionTypes.java @@ -14,7 +14,6 @@ import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUti import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.REF; import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory; import org.eclipse.cdt.core.dom.ast.IASTIdExpression; @@ -44,12 +43,8 @@ public class ExpressionTypes { public static ValueCategory valueCategoryFromFunctionCall(ICPPFunction function) { - try { - final ICPPFunctionType ft = function.getType(); - return valueCategoryFromReturnType(ft.getReturnType()); - } catch (DOMException e) { - return ValueCategory.PRVALUE; - } + final ICPPFunctionType ft = function.getType(); + return valueCategoryFromReturnType(ft.getReturnType()); } public static ValueCategory valueCategoryFromReturnType(IType r) { @@ -68,12 +63,8 @@ public class ExpressionTypes { } public static IType typeFromFunctionCall(ICPPFunction function) { - try { - final ICPPFunctionType ft = function.getType(); - return typeFromReturnType(ft.getReturnType()); - } catch (DOMException e) { - return e.getProblem(); - } + final ICPPFunctionType ft = function.getType(); + return typeFromReturnType(ft.getReturnType()); } public static IType typeFromReturnType(IType r) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CCompositesFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CCompositesFactory.java index 024188846a7..068ba418d5b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CCompositesFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CCompositesFactory.java @@ -18,6 +18,7 @@ import org.eclipse.cdt.core.dom.ast.IField; import org.eclipse.cdt.core.dom.ast.IFunction; import org.eclipse.cdt.core.dom.ast.IFunctionType; import org.eclipse.cdt.core.dom.ast.IParameter; +import org.eclipse.cdt.core.dom.ast.ISemanticProblem; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.IValue; @@ -116,7 +117,7 @@ public class CCompositesFactory extends AbstractCompositeFactory { } return at; } - if (rtype instanceof IBasicType || rtype == null) { + if (rtype instanceof IBasicType || rtype instanceof ISemanticProblem || rtype == null) { return rtype; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CompositeCFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CompositeCFunction.java index ec2e9975bb6..5737f0fc6e5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CompositeCFunction.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CompositeCFunction.java @@ -10,14 +10,12 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.index.composite.c; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IFunction; import org.eclipse.cdt.core.dom.ast.IFunctionType; import org.eclipse.cdt.core.dom.ast.IParameter; import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding; -import org.eclipse.cdt.internal.core.index.IIndexScope; import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory; class CompositeCFunction extends CompositeCBinding implements IFunction { @@ -26,12 +24,11 @@ class CompositeCFunction extends CompositeCBinding implements IFunction { super(cf, rbinding); } - public IScope getFunctionScope() throws DOMException { - IScope scope= ((IFunction)rbinding).getFunctionScope(); - return cf.getCompositeScope((IIndexScope)scope); + public IScope getFunctionScope() { + return null; } - public IParameter[] getParameters() throws DOMException { + public IParameter[] getParameters() { IParameter[] preResult = ((IFunction)rbinding).getParameters(); IParameter[] result = new IParameter[preResult.length]; for(int i=0; i= 0; --i) { - // There may be fewer or less original parameters, because of parameter packs. - if (i < origAstParams.length-1) { - // Normal case - origPar= new PDOMCPPParameter(linkage, specialized, origAstParams[i], null); - } else if (origPar == null) { - // Use last parameter - origPar= new PDOMCPPParameter(linkage, specialized, origAstParams[origAstParams.length-1], null); - } - next= new PDOMCPPParameterSpecialization(linkage, this, astParams[i], origPar, next); - } - db.putRecPtr(record + FIRST_PARAM, next == null ? 0 : next.getRecord()); - } - fAnnotation = getAnnotation(astFunction); - db.putShort(record + ANNOTATION_OFFSET, fAnnotation); - db.putInt(record + REQUIRED_ARG_COUNT_OFFSET, astFunction.getRequiredArgumentCount()); - } catch (DOMException e) { - throw new CoreException(Util.createStatus(e)); + ICPPParameter[] astParams= astFunction.getParameters(); + IFunctionType astFt= astFunction.getType(); + if (astFt != null) { + getLinkage().storeType(record + FUNCTION_TYPE, astFt); } + + ICPPFunction origAstFunc= (ICPPFunction) ((ICPPSpecialization)astFunction).getSpecializedBinding(); + ICPPParameter[] origAstParams= origAstFunc.getParameters(); + if (origAstParams.length == 0) { + db.putInt(record + NUM_PARAMS, 0); + db.putRecPtr(record + FIRST_PARAM, 0); + } else { + final int length= astParams.length; + db.putInt(record + NUM_PARAMS, length); + + db.putRecPtr(record + FIRST_PARAM, 0); + PDOMCPPParameter origPar= null; + PDOMCPPParameterSpecialization next= null; + for (int i= length-1; i >= 0; --i) { + // There may be fewer or less original parameters, because of parameter packs. + if (i < origAstParams.length-1) { + // Normal case + origPar= new PDOMCPPParameter(linkage, specialized, origAstParams[i], null); + } else if (origPar == null) { + // Use last parameter + origPar= new PDOMCPPParameter(linkage, specialized, origAstParams[origAstParams.length-1], null); + } + next= new PDOMCPPParameterSpecialization(linkage, this, astParams[i], origPar, next); + } + db.putRecPtr(record + FIRST_PARAM, next == null ? 0 : next.getRecord()); + } + fAnnotation = getAnnotation(astFunction); + db.putShort(record + ANNOTATION_OFFSET, fAnnotation); + db.putInt(record + REQUIRED_ARG_COUNT_OFFSET, astFunction.getRequiredArgumentCount()); long typelist= 0; if (astFunction instanceof ICPPMethod && ((ICPPMethod) astFunction).isImplicit()) { // don't store the exception specification, computed it on demand. @@ -176,11 +171,11 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP return false; } - public IScope getFunctionScope() throws DOMException { - throw new PDOMNotImplementedError(); + public IScope getFunctionScope() { + return null; } - public ICPPParameter[] getParameters() throws DOMException { + public ICPPParameter[] getParameters() { try { PDOMLinkage linkage= getLinkage(); Database db= getDB(); @@ -204,12 +199,13 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP } } - public ICPPFunctionType getType() throws DOMException { + public ICPPFunctionType getType() { if (fType == null) { try { fType= (ICPPFunctionType) getLinkage().loadType(record + FUNCTION_TYPE); } catch(CoreException ce) { CCorePlugin.log(ce); + fType= new ProblemFunctionType(ISemanticProblem.TYPE_NOT_PERSISTED); } } return fType; @@ -242,7 +238,7 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP } - public int getRequiredArgumentCount() throws DOMException { + public int getRequiredArgumentCount() { if (fRequiredArgCount == -1) { try { fRequiredArgCount= getDB().getInt(record + REQUIRED_ARG_COUNT_OFFSET); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethod.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethod.java index 0044eed621c..0a5d2e03466 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethod.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethod.java @@ -35,7 +35,6 @@ import org.eclipse.cdt.internal.core.pdom.db.Database; import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage; import org.eclipse.cdt.internal.core.pdom.dom.PDOMName; import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode; -import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError; import org.eclipse.cdt.internal.core.pdom.dom.c.PDOMCAnnotation; import org.eclipse.core.runtime.CoreException; @@ -126,7 +125,7 @@ class PDOMCPPMethod extends PDOMCPPFunction implements ICPPMethod { @Override public boolean isMutable() { - throw new PDOMNotImplementedError(); + return false; } public boolean isImplicit() { @@ -138,8 +137,8 @@ class PDOMCPPMethod extends PDOMCPPFunction implements ICPPMethod { } @Override - public IScope getFunctionScope() throws DOMException { - throw new PDOMNotImplementedError(); + public IScope getFunctionScope() { + return null; } @Override @@ -175,7 +174,7 @@ class PDOMCPPMethod extends PDOMCPPFunction implements ICPPMethod { @Override public Object clone() { - throw new PDOMNotImplementedError(); + throw new UnsupportedOperationException(); } public boolean isConst() { @@ -208,12 +207,8 @@ class PDOMCPPMethod extends PDOMCPPFunction implements ICPPMethod { if (fieldOwner instanceof IASTIdExpression) { IBinding b= ((IASTIdExpression) fieldOwner).getName().resolveBinding(); if (b instanceof IVariable) { - try { - IType t = ((IVariable) b).getType(); - if (!(t instanceof ICPPReferenceType)) { - return 0; - } - } catch (DOMException e) { + IType t = ((IVariable) b).getType(); + if (!(t instanceof ICPPReferenceType)) { return 0; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPNamespace.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPNamespace.java index 799959c45a8..2ddf68de649 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPNamespace.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPNamespace.java @@ -235,7 +235,9 @@ class PDOMCPPNamespace extends PDOMCPPBinding return result; } - public void addUsingDirective(ICPPUsingDirective directive) { fail(); } + public void addUsingDirective(ICPPUsingDirective directive) { + throw new UnsupportedOperationException(); + } public IIndexBinding getScopeBinding() { return this; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPNamespaceAlias.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPNamespaceAlias.java index 9f93d1e31ba..ef058652067 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPNamespaceAlias.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPNamespaceAlias.java @@ -14,6 +14,7 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.ast.IBinding; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace; import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias; import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope; import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants; @@ -21,7 +22,6 @@ import org.eclipse.cdt.internal.core.pdom.db.Database; import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding; import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage; import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode; -import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError; import org.eclipse.core.runtime.CoreException; /** @@ -88,7 +88,20 @@ class PDOMCPPNamespaceAlias extends PDOMCPPBinding implements ICPPNamespaceAlias } public IBinding[] getMemberBindings() { - throw new PDOMNotImplementedError(); + ICPPNamespace ns= this; + for (int i = 0; i < 20; i++) { + if (ns instanceof ICPPNamespaceAlias) { + IBinding b= ((ICPPNamespaceAlias) ns).getBinding(); + if (b instanceof ICPPNamespace) { + ns= (ICPPNamespace) b; + } else { + return IBinding.EMPTY_BINDING_ARRAY; + } + } else { + break; + } + } + return ns.getMemberBindings(); } public IBinding getBinding() { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPParameter.java index 8705bb7cbaa..67839086882 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPParameter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPParameter.java @@ -28,7 +28,6 @@ import org.eclipse.cdt.internal.core.pdom.dom.IPDOMBinding; import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage; import org.eclipse.cdt.internal.core.pdom.dom.PDOMNamedNode; import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode; -import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError; import org.eclipse.cdt.internal.core.pdom.dom.c.PDOMCAnnotation; import org.eclipse.core.runtime.CoreException; @@ -198,10 +197,6 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBind // parameter bindings do not span index fragments return true; } - - public int compareTo(Object arg0) { - throw new PDOMNotImplementedError(); - } public int getBindingConstant() { return getNodeType(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPParameterSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPParameterSpecialization.java index d8343400cce..6d537ead4f3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPParameterSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPParameterSpecialization.java @@ -11,7 +11,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom.dom.cpp; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IParameter; import org.eclipse.cdt.core.dom.ast.IType; @@ -77,28 +76,25 @@ class PDOMCPPParameterSpecialization extends PDOMCPPSpecialization implements IC IType type= null; IBinding parent = getParentBinding(); if (parent instanceof ICPPSpecialization && parent instanceof ICPPFunction) { - try { - IParameter[] pars= ((ICPPFunction) parent).getParameters(); - int parPos= -1; - for (parPos= 0; parPos 0) { - ArrayList list= new ArrayList(); - list.addAll(Arrays.asList(IndexUI.findRepresentative(index, binding))); - for (IBinding overrider : virtualOverriders) { - list.addAll(Arrays.asList(IndexUI.findRepresentative(index, overrider))); - } - return list.toArray(new ICElement[list.size()]); + IBinding[] virtualOverriders= ClassTypeHelper.findOverriders(index, binding); + if (virtualOverriders.length > 0) { + ArrayList list= new ArrayList(); + list.addAll(Arrays.asList(IndexUI.findRepresentative(index, binding))); + for (IBinding overrider : virtualOverriders) { + list.addAll(Arrays.asList(IndexUI.findRepresentative(index, overrider))); } - } catch (DOMException e) { - // index bindings don't throw DOMExceptions + return list.toArray(new ICElement[list.size()]); } return null; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AddIncludeOnSelectionAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AddIncludeOnSelectionAction.java index fe91d0dd353..70c4b781c64 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AddIncludeOnSelectionAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AddIncludeOnSelectionAction.java @@ -48,7 +48,6 @@ import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.ui.texteditor.TextEditorAction; import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNodeSelector; @@ -218,18 +217,14 @@ public class AddIncludeOnSelectionAction extends TextEditorAction { char[] nameChars = name.toCharArray(); lookupName[0] = new String(nameChars); IBinding binding = name.resolveBinding(); - try { - if (binding instanceof ICPPVariable) { - IType type = ((ICPPVariable) binding).getType(); - type = SemanticUtil.getNestedType(type, - SemanticUtil.ALLCVQ | SemanticUtil.PTR | SemanticUtil.ARRAY | SemanticUtil.REF); - if (type instanceof IBinding) { - binding = (IBinding) type; - nameChars = binding.getNameCharArray(); - } + if (binding instanceof ICPPVariable) { + IType type = ((ICPPVariable) binding).getType(); + type = SemanticUtil.getNestedType(type, + SemanticUtil.ALLCVQ | SemanticUtil.PTR | SemanticUtil.ARRAY | SemanticUtil.REF); + if (type instanceof IBinding) { + binding = (IBinding) type; + nameChars = binding.getNameCharArray(); } - } catch (DOMException e) { - CUIPlugin.log(e); } if (nameChars.length == 0) { return; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java index db6081306b5..e93a9654b38 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java @@ -835,9 +835,7 @@ public class SemanticHighlightings { } } catch (DOMException exc) { CUIPlugin.log(exc); - } catch (Error e) /* PDOMNotImplementedError */ { - // ignore - } + } } } } @@ -920,9 +918,7 @@ public class SemanticHighlightings { } } catch (DOMException exc) { CUIPlugin.log(exc); - } catch (Error e) /* PDOMNotImplementedError */ { - // ignore - } + } } } } @@ -1023,9 +1019,7 @@ public class SemanticHighlightings { } } catch (DOMException exc) { CUIPlugin.log(exc); - } catch (Error e) /* PDOMNotImplementedError */ { - // ignore - } + } } } return false; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexLabelProvider.java index 57037922c4f..492c696d9ca 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexLabelProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexLabelProvider.java @@ -146,11 +146,7 @@ public class IndexLabelProvider extends LabelProvider { * we don't currently store return types */ if(element instanceof IFunction) { - try { - result += " "+ASTTypeUtil.getParameterTypeString(((IFunction) element).getType()); //$NON-NLS-1$ - } catch(DOMException de) { - /* NO-OP: just use plain name as label */ - } + result += " "+ASTTypeUtil.getParameterTypeString(((IFunction) element).getType()); //$NON-NLS-1$ } return result; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoring.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoring.java index cb5b444f06e..71c49852acb 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoring.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoring.java @@ -22,20 +22,16 @@ import java.util.Vector; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.ILog; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.SubMonitor; import org.eclipse.jface.viewers.ISelection; import org.eclipse.ltk.core.refactoring.RefactoringDescriptor; import org.eclipse.ltk.core.refactoring.RefactoringStatus; import org.eclipse.text.edits.TextEditGroup; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression; import org.eclipse.cdt.core.dom.ast.IASTComment; import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement; @@ -78,7 +74,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.core.dom.rewrite.ASTRewrite; import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.model.ICProject; -import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.internal.core.dom.parser.c.CASTBinaryExpression; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTBinaryExpression; @@ -584,56 +579,48 @@ public class ExtractFunctionRefactoring extends CRefactoring { String name = new String(declarator.getName().toCharArray()); if (bind instanceof ICPPClassType) { ICPPClassType classBind = (ICPPClassType) bind; - try { - IField[] fields = classBind.getFields(); - for (IField field : fields) { - if (field.getName().equals(name)) { - return true; - } + IField[] fields = classBind.getFields(); + for (IField field : fields) { + if (field.getName().equals(name)) { + return true; } - ICPPMethod[] methods = classBind.getAllDeclaredMethods(); - for (ICPPMethod method : methods) { - if (!method.takesVarArgs() && name.equals(method.getName())) { - IParameter[] parameters = method.getParameters(); - if (parameters.length == declarator.getParameters().length) { - for (int i = 0; i < parameters.length; i++) { - IASTName[] origParameterName = unit - .getDeclarationsInAST(parameters[i]); + } + ICPPMethod[] methods = classBind.getAllDeclaredMethods(); + for (ICPPMethod method : methods) { + if (!method.takesVarArgs() && name.equals(method.getName())) { + IParameter[] parameters = method.getParameters(); + if (parameters.length == declarator.getParameters().length) { + for (int i = 0; i < parameters.length; i++) { + IASTName[] origParameterName = unit + .getDeclarationsInAST(parameters[i]); - IASTParameterDeclaration origParameter = (IASTParameterDeclaration) origParameterName[0] - .getParent().getParent(); - IASTParameterDeclaration newParameter = declarator - .getParameters()[i]; + IASTParameterDeclaration origParameter = (IASTParameterDeclaration) origParameterName[0] + .getParent().getParent(); + IASTParameterDeclaration newParameter = declarator + .getParameters()[i]; - // if not the same break; - if (!(equalityChecker.isEquals(origParameter - .getDeclSpecifier(), newParameter - .getDeclSpecifier()) && ASTHelper - .samePointers(origParameter - .getDeclarator() - .getPointerOperators(), - newParameter.getDeclarator() - .getPointerOperators(), - equalityChecker))) { - break; - } + // if not the same break; + if (!(equalityChecker.isEquals(origParameter + .getDeclSpecifier(), newParameter + .getDeclSpecifier()) && ASTHelper + .samePointers(origParameter + .getDeclarator() + .getPointerOperators(), + newParameter.getDeclarator() + .getPointerOperators(), + equalityChecker))) { + break; + } - if (!(i < (parameters.length - 1))) { - return true; - } + if (!(i < (parameters.length - 1))) { + return true; } } - } - } - return false; - } catch (DOMException e) { - ILog logger = CUIPlugin.getDefault().getLog(); - IStatus status = new Status(IStatus.WARNING, - CUIPlugin.PLUGIN_ID, IStatus.OK, e.getMessage(), e); - logger.log(status); + } } + return false; } return true; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/TrailNodeEqualityChecker.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/TrailNodeEqualityChecker.java index 2a5ae734baf..d60a42478e8 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/TrailNodeEqualityChecker.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/TrailNodeEqualityChecker.java @@ -18,7 +18,6 @@ import java.util.Map; import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.CoreException; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTASMDeclaration; import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression; import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier; @@ -434,12 +433,9 @@ public class TrailNodeEqualityChecker implements EqualityChecker { } private IType getType(IBinding binding) { - try { - if (binding instanceof ICPPVariable) { - ICPPVariable var = (ICPPVariable) binding; - return var.getType(); - } - } catch (DOMException e) { + if (binding instanceof ICPPVariable) { + ICPPVariable var = (ICPPVariable) binding; + return var.getType(); } return null; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMethodProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMethodProcessor.java index 629cea9ed5c..fa58c0f1e39 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMethodProcessor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMethodProcessor.java @@ -20,7 +20,6 @@ import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.ltk.core.refactoring.RefactoringStatus; import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; @@ -113,8 +112,6 @@ public class CRenameMethodProcessor extends CRenameGlobalProcessor { bindings.addAll(Arrays.asList(bs)); bs= ClassTypeHelper.findOverriders(getIndex(), m); bindings.addAll(Arrays.asList(bs)); - } catch (DOMException e) { - getAstManager().handleDOMException(argument.getTranslationUnit(), e, status); } catch (CoreException e) { status.addError(e.getMessage()); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/NameHelper.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/NameHelper.java index 9e4999c2b38..7d2b62c897b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/NameHelper.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/NameHelper.java @@ -17,7 +17,6 @@ import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration; import org.eclipse.cdt.core.dom.ast.IBinding; @@ -26,7 +25,6 @@ import org.eclipse.cdt.core.dom.ast.IVariable; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; import org.eclipse.cdt.core.parser.Keywords; import org.eclipse.cdt.core.parser.util.CharArrayIntMap; -import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTQualifiedName; @@ -144,13 +142,9 @@ public class NameHelper { IASTName name = parameter.getDeclarator().getName(); IBinding binding = name.resolveBinding(); if (binding instanceof IVariable) { - try { - IType type = ((IVariable) binding).getType(); - if (type != null) { - return ASTTypeUtil.getType(type); - } - } catch (DOMException e) { - CUIPlugin.log(e); + IType type = ((IVariable) binding).getType(); + if (type != null) { + return ASTTypeUtil.getType(type); } } return ""; //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LinkedNamesFinder.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LinkedNamesFinder.java index cd4ddfcf4f4..0bbfe23e972 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LinkedNamesFinder.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LinkedNamesFinder.java @@ -99,12 +99,8 @@ public class LinkedNamesFinder { } } else if (target instanceof ICPPMethod) { ICPPMethod method= (ICPPMethod) target; - try { - for (ICPPMethod m : ClassTypeHelper.findOverridden(method)) { - findBinding(m); - } - } catch (DOMException e) { - // Ignore. + for (ICPPMethod m : ClassTypeHelper.findOverridden(method)) { + findBinding(m); } try { for (ICPPMethod m : findOverridersInAST(method)) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchQuery.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchQuery.java index 2f3318be3e8..caffd9a8622 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchQuery.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchQuery.java @@ -44,7 +44,6 @@ import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.IPositionConverter; import org.eclipse.cdt.core.browser.ITypeReference; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTFileLocation; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; @@ -330,20 +329,16 @@ public abstract class PDOMSearchQuery implements ISearchQuery { if (binding instanceof ICPPMethod) { ICPPMethod m= (ICPPMethod) binding; - try { - ICPPMethod[] msInBases = ClassTypeHelper.findOverridden(m); - if (msInBases.length > 0) { - if (polymorphicNames == null) { - polymorphicNames= new ArrayList(); - } - for (ICPPMethod mInBase : msInBases) { - if (mInBase != null && handled.add(mInBase)) { - createMatches1(index, mInBase, polymorphicNames); - } + ICPPMethod[] msInBases = ClassTypeHelper.findOverridden(m); + if (msInBases.length > 0) { + if (polymorphicNames == null) { + polymorphicNames= new ArrayList(); + } + for (ICPPMethod mInBase : msInBases) { + if (mInBase != null && handled.add(mInBase)) { + createMatches1(index, mInBase, polymorphicNames); } } - } catch (DOMException e) { - CUIPlugin.log(e); } } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java index 1f2dc556a31..f1ee815d040 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java @@ -74,7 +74,6 @@ import org.eclipse.cdt.core.model.ILanguage; import org.eclipse.cdt.core.model.ISourceRange; import org.eclipse.cdt.core.model.ISourceReference; import org.eclipse.cdt.core.model.ITranslationUnit; -import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels; import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.parser.util.CharArrayUtils; import org.eclipse.cdt.ui.CUIPlugin; @@ -93,6 +92,7 @@ import org.eclipse.cdt.internal.core.model.ext.ICElementHandle; import org.eclipse.cdt.internal.ui.actions.OpenActionUtil; import org.eclipse.cdt.internal.ui.editor.ASTProvider; import org.eclipse.cdt.internal.ui.editor.CEditorMessages; +import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels; import org.eclipse.cdt.internal.ui.viewsupport.IndexUI; class OpenDeclarationsJob extends Job implements ASTRunnable { @@ -730,27 +730,22 @@ class OpenDeclarationsJob extends Job implements ASTRunnable { // For c++ we can check the number of parameters. if (binding instanceof ICPPFunction) { ICPPFunction f= (ICPPFunction) binding; - try { - if (f.getRequiredArgumentCount() > funcArgCount) { + if (f.getRequiredArgumentCount() > funcArgCount) { + iterator.remove(); + result.add(binding); + continue; + } + if (!f.takesVarArgs() && !f.hasParameterPack()) { + final IType[] parameterTypes = f.getType().getParameterTypes(); + int maxArgs= parameterTypes.length; + if (maxArgs == 1 && SemanticUtil.isVoidType(parameterTypes[0])) { + maxArgs= 0; + } + if (maxArgs < funcArgCount) { iterator.remove(); result.add(binding); continue; } - if (!f.takesVarArgs() && !f.hasParameterPack()) { - final IType[] parameterTypes = f.getType().getParameterTypes(); - int maxArgs= parameterTypes.length; - if (maxArgs == 1 && SemanticUtil.isVoidType(parameterTypes[0])) { - maxArgs= 0; - } - if (maxArgs < funcArgCount) { - iterator.remove(); - result.add(binding); - continue; - } - } - } catch (DOMException e) { - // Ignore problem bindings. - continue; } } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CSourceHover.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CSourceHover.java index 68a4aa079dc..f11d5fe1bdf 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CSourceHover.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CSourceHover.java @@ -389,13 +389,10 @@ public class CSourceHover extends AbstractCEditorTextHover { } else { final boolean expectClosingBrace; IType type= null; - try { - if (binding instanceof ITypedef) { - type= ((ITypedef)binding).getType(); - } else if (binding instanceof IVariable) { - type= ((IVariable)binding).getType(); - } - } catch (DOMException exc) { + if (binding instanceof ITypedef) { + type= ((ITypedef)binding).getType(); + } else if (binding instanceof IVariable) { + type= ((IVariable)binding).getType(); } expectClosingBrace= type instanceof ICompositeType || type instanceof IEnumeration; final int nameLine= doc.getLineOfOffset(nameOffset); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionProposalComputer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionProposalComputer.java index faf07027c8a..5aa81d6a642 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionProposalComputer.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionProposalComputer.java @@ -373,47 +373,44 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer StringBuilder idargs = new StringBuilder(); // for the idargString boolean hasArgs = true; String returnTypeStr = null; - try { - IParameter[] params = function.getParameters(); - if (params != null) { - for (int i = 0; i < params.length; ++i) { - IType paramType = params[i].getType(); - if (i > 0) { - dispargs.append(','); - idargs.append(','); - } + IParameter[] params = function.getParameters(); + if (params != null) { + for (int i = 0; i < params.length; ++i) { + IType paramType = params[i].getType(); + if (i > 0) { + dispargs.append(','); + idargs.append(','); + } - dispargs.append(ASTTypeUtil.getType(paramType, false)); - idargs.append(ASTTypeUtil.getType(paramType, false)); - String paramName = params[i].getName(); - if (paramName != null && paramName.length() > 0) { - dispargs.append(' '); - dispargs.append(paramName); - } - } - - if (function.takesVarArgs()) { - if (params.length > 0) { - dispargs.append(','); - idargs.append(','); - } - dispargs.append("..."); //$NON-NLS-1$ - idargs.append("..."); //$NON-NLS-1$ - } else if (params.length == 0) { // force the void in - dispargs.append("void"); //$NON-NLS-1$ - idargs.append("void"); //$NON-NLS-1$ + dispargs.append(ASTTypeUtil.getType(paramType, false)); + idargs.append(ASTTypeUtil.getType(paramType, false)); + String paramName = params[i].getName(); + if (paramName != null && paramName.length() > 0) { + dispargs.append(' '); + dispargs.append(paramName); } } - IFunctionType functionType = function.getType(); - if (functionType != null) { - IType returnType = functionType.getReturnType(); - if (returnType != null) - returnTypeStr = ASTTypeUtil.getType(returnType, false); + + if (function.takesVarArgs()) { + if (params.length > 0) { + dispargs.append(','); + idargs.append(','); + } + dispargs.append("..."); //$NON-NLS-1$ + idargs.append("..."); //$NON-NLS-1$ + } else if (params.length == 0) { // force the void in + dispargs.append("void"); //$NON-NLS-1$ + idargs.append("void"); //$NON-NLS-1$ } - - hasArgs = ASTTypeUtil.functionTakesParameters(function); - } catch (DOMException e) { } + IFunctionType functionType = function.getType(); + if (functionType != null) { + IType returnType = functionType.getReturnType(); + if (returnType != null) + returnTypeStr = ASTTypeUtil.getType(returnType, false); + } + + hasArgs = ASTTypeUtil.functionTakesParameters(function); String dispargString = dispargs.toString(); String idargString = idargs.toString(); @@ -457,18 +454,14 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer private void handleVariable(IVariable variable, CContentAssistInvocationContext context, int baseRelevance, List proposals) { if (context.isContextInformationStyle()) { - // Handle the case where a variable is initialized with a constructor - try { - IType t = variable.getType(); - t= unwindTypedefs(t); - if (t instanceof ICPPClassType) { - ICPPClassType classType= (ICPPClassType) t; - ICPPConstructor[] constructors = classType.getConstructors(); - for (ICPPConstructor constructor : constructors) { - handleFunction(constructor, context, baseRelevance, proposals); - } + IType t = variable.getType(); + t= unwindTypedefs(t); + if (t instanceof ICPPClassType) { + ICPPClassType classType= (ICPPClassType) t; + ICPPConstructor[] constructors = classType.getConstructors(); + for (ICPPConstructor constructor : constructors) { + handleFunction(constructor, context, baseRelevance, proposals); } - } catch (DOMException e) { } return; } @@ -477,12 +470,9 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer repStringBuff.append(variable.getName()); String returnTypeStr = ""; //$NON-NLS-1$ - try { - IType varType = variable.getType(); - if (varType != null) - returnTypeStr = ASTTypeUtil.getType(varType, false); - } catch (DOMException e) { - } + IType varType = variable.getType(); + if (varType != null) + returnTypeStr = ASTTypeUtil.getType(varType, false); StringBuilder dispStringBuff = new StringBuilder(repStringBuff.toString()); if (returnTypeStr != null) {