From 3d7ad1a899227f47c005a0825237d08cacd433bc Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Wed, 15 Jul 2009 10:49:09 +0000 Subject: [PATCH] Removes unused throw declarations, bug 283523. --- .../tests/IndexBindingResolutionTestBase.java | 18 +-- .../tests/IndexCPPBindingResolutionTest.java | 22 ++- .../eclipse/cdt/core/dom/ast/ASTTypeUtil.java | 67 ++------- .../eclipse/cdt/core/dom/ast/IArrayType.java | 3 +- .../cdt/core/dom/ast/IFunctionType.java | 6 +- .../cdt/core/dom/ast/IPointerType.java | 3 +- .../cdt/core/dom/ast/IQualifierType.java | 3 +- .../eclipse/cdt/core/dom/ast/ITypedef.java | 2 +- .../core/dom/ast/cpp/ICPPReferenceType.java | 5 +- .../core/dom/parser/ITypeContainer.java | 15 +- .../dom/parser/VariableReadWriteFlags.java | 20 ++- .../c/CASTArraySubscriptExpression.java | 13 +- .../parser/c/CASTFunctionCallExpression.java | 13 +- .../dom/parser/c/CASTUnaryExpression.java | 13 +- .../core/dom/parser/c/CFunctionType.java | 22 +-- .../core/dom/parser/c/CPointerType.java | 22 +-- .../core/dom/parser/c/CQualifierType.java | 26 ++-- .../internal/core/dom/parser/c/CTypedef.java | 17 +-- .../dom/parser/c/CVariableReadWriteFlags.java | 27 ++-- .../internal/core/dom/parser/c/CVisitor.java | 18 +-- .../parser/cpp/CPPASTBinaryExpression.java | 6 +- .../dom/parser/cpp/CPPASTNewExpression.java | 7 +- .../dom/parser/cpp/CPPASTUnaryExpression.java | 22 ++- .../core/dom/parser/cpp/CPPArrayType.java | 21 +-- .../core/dom/parser/cpp/CPPFunctionType.java | 20 +-- .../dom/parser/cpp/CPPImplicitTypedef.java | 33 ++--- .../cpp/CPPParameterSpecialization.java | 13 +- .../core/dom/parser/cpp/CPPPointerType.java | 6 +- .../core/dom/parser/cpp/CPPQualifierType.java | 13 +- .../core/dom/parser/cpp/CPPReferenceType.java | 18 +-- .../dom/parser/cpp/CPPSpecialization.java | 2 +- .../core/dom/parser/cpp/CPPTypedef.java | 12 +- .../parser/cpp/CPPTypedefSpecialization.java | 32 ++--- .../parser/cpp/semantics/CPPSemantics.java | 22 +-- .../parser/cpp/semantics/CPPTemplates.java | 105 ++++++-------- .../semantics/CPPVariableReadWriteFlags.java | 36 ++--- .../dom/parser/cpp/semantics/CPPVisitor.java | 16 +-- .../parser/cpp/semantics/SemanticUtil.java | 131 ++++++++---------- .../internal/core/index/ArrayTypeClone.java | 23 ++- .../core/index/CPPReferenceTypeClone.java | 19 +-- .../internal/core/index/CPPTypedefClone.java | 25 ++-- .../internal/core/index/PointerTypeClone.java | 19 +-- .../core/index/QualifierTypeClone.java | 20 +-- .../composite/CompositeFunctionType.java | 7 +- .../index/composite/CompositePointerType.java | 7 +- .../composite/CompositeQualifierType.java | 5 +- .../composite/CompositeTypeContainer.java | 12 +- .../index/composite/ICompositesFactory.java | 5 +- .../index/composite/c/CCompositesFactory.java | 4 +- .../index/composite/c/CompositeCTypedef.java | 7 +- .../composite/cpp/CPPCompositesFactory.java | 3 +- .../cpp/CompositeCPPPointerToMemberType.java | 3 +- .../cpp/CompositeCPPReferenceType.java | 7 +- .../composite/cpp/CompositeCPPTypedef.java | 7 +- .../composite/cpp/TemplateInstanceUtil.java | 16 +-- .../internal/core/pdom/dom/PDOMArrayType.java | 28 ++-- .../core/pdom/dom/PDOMPointerType.java | 45 +++--- .../core/pdom/dom/PDOMQualifierType.java | 52 +++---- .../core/pdom/dom/c/PDOMCFunctionType.java | 23 ++- .../core/pdom/dom/c/PDOMCTypedef.java | 21 ++- .../pdom/dom/cpp/PDOMCPPFunctionType.java | 5 +- .../pdom/dom/cpp/PDOMCPPReferenceType.java | 31 ++--- .../core/pdom/dom/cpp/PDOMCPPTypedef.java | 23 ++- .../dom/cpp/PDOMCPPTypedefSpecialization.java | 31 ++--- .../ui/refactoring/rename/ASTManager.java | 7 +- 65 files changed, 468 insertions(+), 837 deletions(-) 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 1cf4a4a3a63..c470347b2d9 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 @@ -224,17 +224,13 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { } protected static void assertTypeContainer(IType conType, String expQN, Class containerType, Class expContainedType, String expContainedTypeQN) { - try { - assertInstance(conType, ITypeContainer.class); - assertInstance(conType, containerType); - IType containedType= ((ITypeContainer)conType).getType(); - assertInstance(containedType, expContainedType); - if (expContainedTypeQN != null) { - assertInstance(containedType, IBinding.class); - assertQNEquals(expContainedTypeQN, (IBinding) containedType); - } - } catch (DOMException de) { - fail(de.getMessage()); + assertInstance(conType, ITypeContainer.class); + assertInstance(conType, containerType); + IType containedType= ((ITypeContainer)conType).getType(); + assertInstance(containedType, expContainedType); + if (expContainedTypeQN != null) { + assertInstance(containedType, IBinding.class); + assertQNEquals(expContainedTypeQN, (IBinding) containedType); } } 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 d29962df958..708c1272d70 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Symbian Software Systems and others. + * Copyright (c) 2007, 2009 Symbian Software Systems 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 @@ -1456,18 +1456,14 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti * @param qn may be null */ static protected void assertPTM(IType type, String cqn, String qn) { - try { - assertTrue(type instanceof ICPPPointerToMemberType); - ICPPPointerToMemberType ptmt = (ICPPPointerToMemberType) type; - ICPPClassType classType = (ICPPClassType) ptmt.getMemberOfClass(); - assertQNEquals(cqn, classType); - if(qn!=null) { - assert(ptmt.getType() instanceof ICPPBinding); - ICPPBinding tyBinding = (ICPPBinding) ptmt.getType(); - assertQNEquals(qn, tyBinding); - } - } catch(DOMException de) { - fail(de.getMessage()); + assertTrue(type instanceof ICPPPointerToMemberType); + ICPPPointerToMemberType ptmt = (ICPPPointerToMemberType) type; + ICPPClassType classType = (ICPPClassType) ptmt.getMemberOfClass(); + assertQNEquals(cqn, classType); + if(qn!=null) { + assert(ptmt.getType() instanceof ICPPBinding); + ICPPBinding tyBinding = (ICPPBinding) ptmt.getType(); + assertQNEquals(qn, tyBinding); } } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java index e520dd58d0e..530263c84c9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java @@ -58,7 +58,6 @@ public class ASTTypeUtil { private static final String COMMA_SPACE = ", "; //$NON-NLS-1$ private static final String EMPTY_STRING = ""; //$NON-NLS-1$ private static final String SPACE = " "; //$NON-NLS-1$ - private static final String[] EMPTY_STRING_ARRAY = new String[0]; private static final int DEAULT_ITYPE_SIZE = 2; /** @@ -183,13 +182,7 @@ public class ASTTypeUtil { * @see #getType(IType, boolean) */ public static String[] getParameterTypeStringArray(IFunctionType type) { - IType[] parms = null; - try { - parms = type.getParameterTypes(); - } catch (DOMException e) { - return EMPTY_STRING_ARRAY; - } - + IType[] parms = type.getParameterTypes(); String[] result = new String[parms.length]; for (int i = 0; i < parms.length; i++) { @@ -503,17 +496,9 @@ public class ASTTypeUtil { } } if (type instanceof ITypeContainer) { - try { - type = ((ITypeContainer) type).getType(); - } catch (DOMException e) { - type= null; - } + type = ((ITypeContainer) type).getType(); } else if (type instanceof IFunctionType) { - try { - type= ((IFunctionType) type).getReturnType(); - } catch (DOMException e) { - type= null; - } + type= ((IFunctionType) type).getReturnType(); } else { type= null; } @@ -663,54 +648,24 @@ public class ASTTypeUtil { } /** - * This can be used to invoke the IType's isConst() if it has an isConst() method. - * This returns the result of that invoked isConst() method. - * It is a convenience function so that the structure of IType does not need - * to be known to determine if the IType is const or not. - * - * Note: false is returned if no isConst() method is found - * - * @param type + * @deprecated don't use it does something strange */ + @Deprecated public static boolean isConst(IType type) { if (type instanceof IQualifierType) { return ((IQualifierType) type).isConst(); } else if (type instanceof ITypeContainer) { - try { - return isConst(((ITypeContainer) type).getType()); - } catch (DOMException e) { - return false; - } + return isConst(((ITypeContainer) type).getType()); } else if (type instanceof IArrayType) { - try { - return isConst(((IArrayType) type).getType()); - } catch (DOMException e) { - return false; - } + return isConst(((IArrayType) type).getType()); } else if (type instanceof ICPPReferenceType) { - try { - return isConst(((ICPPReferenceType) type).getType()); - } catch (DOMException e) { - return false; - } + return isConst(((ICPPReferenceType) type).getType()); } else if (type instanceof IFunctionType) { - try { - return isConst(((IFunctionType) type).getReturnType()); - } catch (DOMException e) { - return false; - } + return isConst(((IFunctionType) type).getReturnType()); } else if (type instanceof IPointerType) { - try { - return isConst(((IPointerType) type).getType()); - } catch (DOMException e) { - return false; - } + return isConst(((IPointerType) type).getType()); } else if (type instanceof ITypedef) { - try { - return isConst(((ITypedef) type).getType()); - } catch (DOMException e) { - return false; - } + return isConst(((ITypedef) type).getType()); } else { return false; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IArrayType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IArrayType.java index 077cba8eace..d34b5712bfd 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IArrayType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IArrayType.java @@ -17,9 +17,8 @@ package org.eclipse.cdt.core.dom.ast; public interface IArrayType extends IType { /** * get the type that this is an array of - * @throws DOMException */ - IType getType() throws DOMException; + IType getType(); /** * get the expression that represents the size of this array diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IFunctionType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IFunctionType.java index 2b51b329977..b6e3c7c4152 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IFunctionType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IFunctionType.java @@ -18,14 +18,12 @@ public interface IFunctionType extends IType { /** * get the return type of this function type - * @throws DOMException */ - public IType getReturnType() throws DOMException; + public IType getReturnType(); /** * get the adjusted parameter types * ISO C99 6.7.5.3, ISO C++98 8.3.4-3 - * @throws DOMException */ - public IType[] getParameterTypes() throws DOMException; + public IType[] getParameterTypes(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IPointerType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IPointerType.java index c14fdc12587..ad312577755 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IPointerType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IPointerType.java @@ -17,9 +17,8 @@ package org.eclipse.cdt.core.dom.ast; public interface IPointerType extends IType { /** * get the type that this is a pointer to - * @throws DOMException */ - public IType getType() throws DOMException; + public IType getType(); /** * is this a const pointer diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IQualifierType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IQualifierType.java index 3224225fcfd..63139dd769d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IQualifierType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IQualifierType.java @@ -30,7 +30,6 @@ public interface IQualifierType extends IType { /** * get the type that this is qualifying - * @throws DOMException */ - public IType getType() throws DOMException; + public IType getType(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ITypedef.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ITypedef.java index 3d247cbdab6..5942eaf1cf9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ITypedef.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ITypedef.java @@ -19,6 +19,6 @@ public interface ITypedef extends IBinding, IType { /** * Returns the type that this thing is a typedef of */ - public IType getType() throws DOMException; + public IType getType(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPReferenceType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPReferenceType.java index 1d321dd1393..195d32317db 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPReferenceType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPReferenceType.java @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.cpp; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IType; /** @@ -21,8 +20,6 @@ public interface ICPPReferenceType extends IType { /** * get the type that this is a reference of - * - * @throws DOMException */ - public IType getType() throws DOMException; + public IType getType(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeContainer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeContainer.java index e5bac35f6df..d27d4de23e6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeContainer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeContainer.java @@ -1,36 +1,29 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2009 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 * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Corporation - initial API and implementation + * Andrew Niefer (IBM Corporation) - initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ - -/* - * Created on Dec 13, 2004 - */ package org.eclipse.cdt.internal.core.dom.parser; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IType; /** * Internal interface representing types that contain other types - * @author aniefer */ public interface ITypeContainer extends IType { /** * get the type this contains - * @throws DOMException */ - IType getType() throws DOMException; + IType getType(); /** * set the type this contains - * @param type */ void setType(IType type); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/VariableReadWriteFlags.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/VariableReadWriteFlags.java index c0f294d1b5d..76e37adcc82 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/VariableReadWriteFlags.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/VariableReadWriteFlags.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2009 Wind River Systems, Inc. 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 @@ -162,20 +162,16 @@ public abstract class VariableReadWriteFlags { } protected int rwArgumentForFunctionCall(final IASTFunctionCallExpression func, int parameterIdx, int indirection) { - try { - final IASTExpression functionNameExpression = func.getFunctionNameExpression(); - if (functionNameExpression != null) { - final IType type= functionNameExpression.getExpressionType(); - if (type instanceof IFunctionType) { - IType[] ptypes= ((IFunctionType) type).getParameterTypes(); - if (ptypes != null && ptypes.length > parameterIdx) { - return rwAssignmentToType(ptypes[parameterIdx], indirection); - } + final IASTExpression functionNameExpression = func.getFunctionNameExpression(); + if (functionNameExpression != null) { + final IType type= functionNameExpression.getExpressionType(); + if (type instanceof IFunctionType) { + IType[] ptypes= ((IFunctionType) type).getParameterTypes(); + if (ptypes != null && ptypes.length > parameterIdx) { + return rwAssignmentToType(ptypes[parameterIdx], indirection); } } } - catch (DOMException e) { - } return READ | WRITE; // fallback } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArraySubscriptExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArraySubscriptExpression.java index 7bb7f6ab29a..3b90f56212f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArraySubscriptExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArraySubscriptExpression.java @@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.core.dom.parser.c; import org.eclipse.cdt.core.dom.ast.ASTVisitor; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTNode; @@ -114,14 +113,10 @@ public class CASTArraySubscriptExpression extends ASTNode implements public IType getExpressionType() { IType t = getArrayExpression().getExpressionType(); - try { - if (t instanceof IPointerType) - return ((IPointerType)t).getType(); - else if (t instanceof IArrayType) - return ((IArrayType)t).getType(); - } catch (DOMException e) { - return e.getProblem(); - } + if (t instanceof IPointerType) + return ((IPointerType)t).getType(); + else if (t instanceof IArrayType) + return ((IArrayType)t).getType(); return t; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFunctionCallExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFunctionCallExpression.java index 3ab59a668a7..95a8586e1a4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFunctionCallExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFunctionCallExpression.java @@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.core.dom.parser.c; import org.eclipse.cdt.core.dom.ast.ASTVisitor; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression; import org.eclipse.cdt.core.dom.ast.IASTNode; @@ -115,14 +114,10 @@ public class CASTFunctionCallExpression extends ASTNode implements public IType getExpressionType() { IType type = getFunctionNameExpression().getExpressionType(); - try { - while (type instanceof ITypeContainer) - type = ((ITypeContainer) type).getType(); - if (type instanceof IFunctionType) - return ((IFunctionType) type).getReturnType(); - } catch (DOMException e) { - return e.getProblem(); - } + while (type instanceof ITypeContainer) + type = ((ITypeContainer) type).getType(); + if (type instanceof IFunctionType) + return ((IFunctionType) type).getReturnType(); return null; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTUnaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTUnaryExpression.java index 71258607df6..4628de96277 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTUnaryExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTUnaryExpression.java @@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.core.dom.parser.c; import org.eclipse.cdt.core.dom.ast.ASTVisitor; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression; @@ -102,14 +101,10 @@ public class CASTUnaryExpression extends ASTNode implements IASTUnaryExpression, public IType getExpressionType() { IType type = getOperand().getExpressionType(); int op = getOperator(); - try { - if (op == IASTUnaryExpression.op_star && (type instanceof IPointerType || type instanceof IArrayType)) { - return ((ITypeContainer) type).getType(); - } else if (op == IASTUnaryExpression.op_amper) { - return new CPointerType(type, 0); - } - } catch (DOMException e) { - return e.getProblem(); + if (op == IASTUnaryExpression.op_star && (type instanceof IPointerType || type instanceof IArrayType)) { + return ((ITypeContainer) type).getType(); + } else if (op == IASTUnaryExpression.op_amper) { + return new CPointerType(type, 0); } return type; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunctionType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunctionType.java index cf40f080e30..508d03cb4d4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunctionType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunctionType.java @@ -1,23 +1,19 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2009 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 * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Corporation - initial API and implementation + * Devin Steffler (IBM Corporation) - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IFunctionType; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; -/** - * @author dsteffle - */ public class CFunctionType implements IFunctionType { IType[] parameters = null; IType returnType = null; @@ -39,19 +35,11 @@ public class CFunctionType implements IFunctionType { if( o instanceof IFunctionType ){ IFunctionType ft = (IFunctionType) o; IType [] fps; - try { - fps = ft.getParameterTypes(); - } catch ( DOMException e ) { - return false; - } + fps = ft.getParameterTypes(); if( fps.length != parameters.length ) return false; - try { - if( ! returnType.isSameType( ft.getReturnType() ) ) - return false; - } catch ( DOMException e1 ) { - return false; - } + if( ! returnType.isSameType( ft.getReturnType() ) ) + return false; for( int i = 0; i < parameters.length; i++ ) if( ! parameters[i].isSameType( fps[i] ) ) return false; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CPointerType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CPointerType.java index 916b2153b84..a502d793b93 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CPointerType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CPointerType.java @@ -1,24 +1,20 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. + * Copyright (c) 2005, 2009 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 * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Rational Software - Initial API and implementation + * Devin Steffler (IBM Rational Software) - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.c.ICPointerType; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; -/** - * @author dsteffle - */ public class CPointerType implements ICPointerType, ITypeContainer { static public final int IS_CONST = 1; static public final int IS_RESTRICT = 1 << 1; @@ -42,15 +38,11 @@ public class CPointerType implements ICPointerType, ITypeContainer { if( obj instanceof ICPointerType ){ ICPointerType pt = (ICPointerType) obj; - try { - if( isConst() != pt.isConst() ) return false; - if( isRestrict() != pt.isRestrict() ) return false; - if( isVolatile() != pt.isVolatile() ) return false; - - return pt.getType().isSameType( nextType ); - } catch ( DOMException e ) { - return false; - } + if( isConst() != pt.isConst() ) return false; + if( isRestrict() != pt.isRestrict() ) return false; + if( isVolatile() != pt.isVolatile() ) return false; + + return pt.getType().isSameType( nextType ); } return false; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CQualifierType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CQualifierType.java index 13e1945616d..f3cc13db0e0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CQualifierType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CQualifierType.java @@ -1,16 +1,15 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. + * Copyright (c) 2005, 2009 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 * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Rational Software - Initial API and implementation + * Devin Steffler (IBM Rational Software) - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier; @@ -22,9 +21,6 @@ import org.eclipse.cdt.core.dom.ast.c.ICASTTypedefNameSpecifier; import org.eclipse.cdt.core.dom.ast.c.ICQualifierType; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; -/** - * @author dsteffle - */ public class CQualifierType implements ICQualifierType, ITypeContainer { private boolean isConst; @@ -57,17 +53,13 @@ public class CQualifierType implements ICQualifierType, ITypeContainer { if( obj instanceof ICQualifierType ){ ICQualifierType qt = (ICQualifierType) obj; - try { - if( isConst() != qt.isConst() ) return false; - if( isRestrict() != qt.isRestrict() ) return false; - if( isVolatile() != qt.isVolatile() ) return false; - - if( type == null ) - return false; - return type.isSameType( qt.getType() ); - } catch ( DOMException e ) { - return false; - } + if( isConst() != qt.isConst() ) return false; + if( isRestrict() != qt.isRestrict() ) return false; + if( isVolatile() != qt.isVolatile() ) return false; + + if( type == null ) + return false; + return type.isSameType( qt.getType() ); } return false; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CTypedef.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CTypedef.java index 689dd05203e..a622fbe2f0b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CTypedef.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CTypedef.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. + * Copyright (c) 2005, 2009 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 @@ -86,15 +86,12 @@ public class CTypedef extends PlatformObject implements ITypedef, ITypeContainer public boolean isSameType( IType t ) { if( t == this ) return true; - if( t instanceof ITypedef ) - try { - IType temp = getType(); - if( temp != null ) - return temp.isSameType( ((ITypedef)t).getType()); - return false; - } catch ( DOMException e ) { - return false; - } + if( t instanceof ITypedef ) { + IType temp = getType(); + if( temp != null ) + return temp.isSameType( ((ITypedef)t).getType()); + return false; + } IType temp = getType(); if( temp != null ) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVariableReadWriteFlags.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVariableReadWriteFlags.java index d1d63e1525c..b32c6c3a869 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVariableReadWriteFlags.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVariableReadWriteFlags.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2009 Wind River Systems, Inc. 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 @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTExpressionList; import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression; @@ -82,21 +81,17 @@ public final class CVariableReadWriteFlags extends VariableReadWriteFlags { if (indirection == 0) { return READ; } - try { - while(indirection > 0 && (type instanceof IPointerType)) { - type= ((IPointerType) type).getType(); - indirection--; - } - if (indirection == 0) { - if (type instanceof IQualifierType) { - return ((IQualifierType) type).isConst() ? READ : READ | WRITE; - } - else if (type instanceof IPointerType) { - return ((IPointerType) type).isConst() ? READ : READ | WRITE; - } - } + while(indirection > 0 && (type instanceof IPointerType)) { + type= ((IPointerType) type).getType(); + indirection--; } - catch (DOMException e) { + if (indirection == 0) { + if (type instanceof IQualifierType) { + return ((IQualifierType) type).isConst() ? READ : READ | WRITE; + } + else if (type instanceof IPointerType) { + return ((IPointerType) type).isConst() ? READ : READ | WRITE; + } } return READ | WRITE; // fallback } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java index 9d69b3178c6..0e98e452116 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java @@ -602,11 +602,7 @@ public class CVisitor extends ASTQueries { IType type = fieldOwner.getExpressionType(); while (type != null && type instanceof ITypeContainer) { - try { - type = ((ITypeContainer)type).getType(); - } catch (DOMException e) { - return e.getProblem(); - } + type = ((ITypeContainer)type).getType(); } if (type != null && type instanceof ICompositeType) { @@ -925,14 +921,10 @@ public class CVisitor extends ASTQueries { } } else if (struct instanceof ITypeContainer) { IType type; - try { - type = ((ITypeContainer)struct).getType(); - while (type instanceof ITypeContainer && !(type instanceof CStructure)) { - type = ((ITypeContainer)type).getType(); - } - } catch (DOMException e) { - return e.getProblem(); - } + type = ((ITypeContainer)struct).getType(); + while (type instanceof ITypeContainer && !(type instanceof CStructure)) { + type = ((ITypeContainer)type).getType(); + } if (type instanceof CStructure) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryExpression.java index c20b1eeb3a1..0b0ed39ee45 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryExpression.java @@ -224,11 +224,7 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr case ICPPASTBinaryExpression.op_pmarrow: case ICPPASTBinaryExpression.op_pmdot: if (type2 instanceof ICPPPointerToMemberType) { - try { - return ((ICPPPointerToMemberType) type2).getType(); - } catch (DOMException e) { - return e.getProblem(); - } + return ((ICPPPointerToMemberType) type2).getType(); } return new ProblemBinding(this, IProblemBinding.SEMANTIC_INVALID_TYPE, getRawSignature().toCharArray()); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNewExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNewExpression.java index c243bb39ccd..dedb270d20c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNewExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNewExpression.java @@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp; import org.eclipse.cdt.core.dom.ast.ASTVisitor; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator; import org.eclipse.cdt.core.dom.ast.IASTArrayModifier; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; @@ -253,11 +252,7 @@ public class CPPASTNewExpression extends ASTNode implements public IType getExpressionType() { IType t= CPPVisitor.createType(getTypeId()); if (t instanceof IArrayType) { - try { - t= ((IArrayType) t).getType(); - } catch (DOMException e) { - return e.getProblem(); - } + t= ((IArrayType) t).getType(); } return new CPPPointerType(t); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUnaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUnaryExpression.java index 6c9bd21059a..bb23f377cbd 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUnaryExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUnaryExpression.java @@ -12,7 +12,9 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; -import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.*; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.CVQ; +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.ASTVisitor; import org.eclipse.cdt.core.dom.ast.DOMException; @@ -231,17 +233,13 @@ public class CPPASTUnaryExpression extends ASTNode implements ICPPASTUnaryExpres if (type instanceof IProblemBinding) { return type; } - try { - IType operator = findOperatorReturnType(); - if(operator != null) { - return operator; - } else if (type instanceof IPointerType || type instanceof IArrayType) { - return ((ITypeContainer) type).getType(); - } else if (type instanceof ICPPUnknownType) { - return CPPUnknownClass.createUnnamedInstance(); - } - } catch (DOMException e) { - return e.getProblem(); + IType operator = findOperatorReturnType(); + if(operator != null) { + return operator; + } else if (type instanceof IPointerType || type instanceof IArrayType) { + return ((ITypeContainer) type).getType(); + } else if (type instanceof ICPPUnknownType) { + return CPPUnknownClass.createUnnamedInstance(); } return new ProblemBinding(this, IProblemBinding.SEMANTIC_INVALID_TYPE, this.getRawSignature().toCharArray()); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPArrayType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPArrayType.java index 7d9ebc6be91..24de95ea2e8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPArrayType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPArrayType.java @@ -6,25 +6,18 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Corporation - initial API and implementation + * Andrew Niefer (IBM Corporation) - initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ - -/* - * Created on Dec 13, 2004 - */ 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.IASTExpression; import org.eclipse.cdt.core.dom.ast.IArrayType; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; -/** - * @author aniefer - */ public class CPPArrayType implements IArrayType, ITypeContainer { private IType type; private IASTExpression sizeExpression; @@ -53,13 +46,9 @@ public class CPPArrayType implements IArrayType, ITypeContainer { return ((ITypedef) obj).isSameType(this); if (obj instanceof IArrayType) { - try { - IType objType = ((IArrayType) obj).getType(); - if (objType != null) - return objType.isSameType(type); - } catch (DOMException e) { - return false; - } + IType objType = ((IArrayType) obj).getType(); + if (objType != null) + return objType.isSameType(type); } return false; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionType.java index 2d4654a9f7e..b223e0d5b74 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionType.java @@ -51,20 +51,12 @@ public class CPPFunctionType implements ICPPFunctionType { if (o instanceof ICPPFunctionType) { ICPPFunctionType ft = (ICPPFunctionType) o; IType[] fps; - try { - fps = ft.getParameterTypes(); - } catch (DOMException e) { - return false; - } - try { - //constructors & destructors have null return type - if ((returnType == null) ^ (ft.getReturnType() == null)) - return false; - else if (returnType != null && ! returnType.isSameType(ft.getReturnType())) - return false; - } catch (DOMException e1) { - return false; - } + fps = ft.getParameterTypes(); + //constructors & destructors have null return type + if ((returnType == null) ^ (ft.getReturnType() == null)) + return false; + else if (returnType != null && ! returnType.isSameType(ft.getReturnType())) + return false; try { if (parameters.length == 1 && fps.length == 0) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitTypedef.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitTypedef.java index 5c3115cbc57..e81e3416b41 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitTypedef.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitTypedef.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.IASTNode; import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IType; @@ -57,23 +56,21 @@ public class CPPImplicitTypedef extends CPPTypedef { @Override public boolean isSameType(IType t) { - if( t == this ) - return true; - if( t instanceof ITypedef ) { - IType temp = getType(); - if( temp != null ) - try { - return temp.isSameType( ((ITypedef)t).getType()); - } catch (DOMException e) {} - return false; - } - - IType temp; - temp = getType(); - if( temp != null ) - return temp.isSameType( t ); - return false; - } + if (t == this) + return true; + if (t instanceof ITypedef) { + IType temp = getType(); + if (temp != null) + return temp.isSameType(((ITypedef) t).getType()); + return false; + } + + IType temp; + temp = getType(); + if (temp != null) + return temp.isSameType(t); + return false; + } @Override public Object clone(){ 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 f04a8e8ca4c..a16f7a8be8d 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. + * Copyright (c) 2005, 2009 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 @@ -45,12 +45,15 @@ public class CPPParameterSpecialization extends CPPSpecialization implements ICP } @Override - public IType specializeType(IType type) throws DOMException { + public IType specializeType(IType type) { IBinding owner= getOwner(); if (owner != null) { - owner= owner.getOwner(); - if (owner instanceof ICPPClassSpecialization) { - return CPPTemplates.instantiateType(type, getTemplateParameterMap(), (ICPPClassSpecialization) owner); + try { + owner= owner.getOwner(); + if (owner instanceof ICPPClassSpecialization) { + return CPPTemplates.instantiateType(type, getTemplateParameterMap(), (ICPPClassSpecialization) owner); + } + } catch (DOMException e) { } } return CPPTemplates.instantiateType(type, getTemplateParameterMap(), null); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPPointerType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPPointerType.java index 37564fc540b..769634f3799 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPPointerType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPPointerType.java @@ -12,7 +12,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.IASTPointer; import org.eclipse.cdt.core.dom.ast.IPointerType; import org.eclipse.cdt.core.dom.ast.IType; @@ -71,10 +70,7 @@ public class CPPPointerType implements IPointerType, ITypeContainer { IPointerType pt = (IPointerType) o; if (isConst == pt.isConst() && isVolatile == pt.isVolatile()) { - try { - return type.isSameType(pt.getType()); - } catch (DOMException e) { - } + return type.isSameType(pt.getType()); } return false; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPQualifierType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPQualifierType.java index f43900279c3..498f2d0593c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPQualifierType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPQualifierType.java @@ -6,22 +6,18 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Corporation - initial API and implementation + * Andrew Niefer (IBM Corporation) - initial API and implementation * Markus Schorn (Wind River Systems) *******************************************************************************/ 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.IQualifierType; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; import org.eclipse.cdt.internal.core.index.IIndexType; -/** - * @author aniefer - */ public class CPPQualifierType implements IQualifierType, ITypeContainer { private final boolean isConst; private final boolean isVolatile; @@ -40,11 +36,8 @@ public class CPPQualifierType implements IQualifierType, ITypeContainer { return false; IQualifierType pt = (IQualifierType) o; - try { - if (isConst() == pt.isConst() && isVolatile() == pt.isVolatile()) - return type.isSameType(pt.getType()); - } catch (DOMException e) { - } + if (isConst() == pt.isConst() && isVolatile() == pt.isVolatile()) + return type.isSameType(pt.getType()); return false; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPReferenceType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPReferenceType.java index 609f1591b00..3d3fa3cbacf 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPReferenceType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPReferenceType.java @@ -1,29 +1,21 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2009 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 * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Corporation - initial API and implementation + * Andrew Niefer (IBM Corporation) - initial API and implementation *******************************************************************************/ - -/* - * Created on Dec 15, 2004 - */ 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.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; -/** - * @author aniefer - */ public class CPPReferenceType implements ICPPReferenceType, ITypeContainer { IType type = null; @@ -50,11 +42,7 @@ public class CPPReferenceType implements ICPPReferenceType, ITypeContainer { return (obj == null); if (obj instanceof ICPPReferenceType) { - try { - return type.isSameType(((ICPPReferenceType) obj).getType()); - } catch (DOMException e) { - return false; - } + return type.isSameType(((ICPPReferenceType) obj).getType()); } return false; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSpecialization.java index 6dbf667608e..5c7a99c8b7d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSpecialization.java @@ -51,7 +51,7 @@ public abstract class CPPSpecialization extends PlatformObject implements ICPPSp this.argumentMap = argumentMap; } - public IType specializeType(IType type) throws DOMException { + public IType specializeType(IType type) { if (owner instanceof ICPPClassSpecialization) { return CPPTemplates.instantiateType(type, getTemplateParameterMap(), (ICPPClassSpecialization) owner); } else { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTypedef.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTypedef.java index 267425948b1..b05ea3a7db7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTypedef.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTypedef.java @@ -65,14 +65,10 @@ public class CPPTypedef extends PlatformObject implements ITypedef, ITypeContain if (o == this) return true; if (o instanceof ITypedef) { - try { - IType t = getType(); - if (t != null) - return t.isSameType(((ITypedef)o).getType()); - return false; - } catch (DOMException e) { - return false; - } + IType t = getType(); + if (t != null) + return t.isSameType(((ITypedef)o).getType()); + return false; } IType t = getType(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTypedefSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTypedefSpecialization.java index 7cb3398d800..680fcf25a1d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTypedefSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTypedefSpecialization.java @@ -33,7 +33,7 @@ public class CPPTypedefSpecialization extends CPPSpecialization implements IType final static class RecursionResolvingBinding extends ProblemBinding { public RecursionResolvingBinding(IASTNode node, char[] arg) { super(node, IProblemBinding.SEMANTIC_RECURSION_IN_LOOKUP, arg); - Assert.isTrue(CPPASTName.sAllowRecursionBindings, getMessage()); + Assert.isTrue(CPPASTNameBase.sAllowRecursionBindings, getMessage()); } } @@ -54,7 +54,7 @@ public class CPPTypedefSpecialization extends CPPSpecialization implements IType /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.ITypedef#getType() */ - public IType getType() throws DOMException { + public IType getType() { if (type == null) { try { if (++fResolutionDepth > MAX_RESOLUTION_DEPTH) { @@ -66,7 +66,11 @@ public class CPPTypedefSpecialization extends CPPSpecialization implements IType if (type instanceof ITypedef && type instanceof ICPPSpecialization) { ITypedef td= (ITypedef) type; if (CharArrayUtils.equals(td.getNameCharArray(), getNameCharArray())) { - IBinding owner= ((ICPPSpecialization) type).getOwner(); + IBinding owner= getOwner(); + try { + owner = ((ICPPSpecialization) type).getOwner(); + } catch (DOMException e) { + } if (owner instanceof IType) { if (((IType) owner).isSameType((ICPPClassType) getOwner())) { type = new RecursionResolvingBinding(getDefinition(), getNameCharArray()); @@ -108,23 +112,15 @@ public class CPPTypedefSpecialization extends CPPSpecialization implements IType if (o == this) return true; if (o instanceof ITypedef) { - try { - IType t = getType(); - if (t != null) - return t.isSameType(((ITypedef) o).getType()); - return false; - } catch (DOMException e) { - return false; - } + IType t = getType(); + if (t != null) + return t.isSameType(((ITypedef) o).getType()); + return false; } - try { - IType t = getType(); - if (t != null) - return t.isSameType(o); - } catch (DOMException e) { - return false; - } + IType t = getType(); + if (t != null) + return t.isSameType(o); return false; } 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 9fa98ca9271..e8aa96a2aba 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 @@ -2497,11 +2497,7 @@ public class CPPSemantics { IType[] result = null; for (int i = 0; i < types.length && types[i] != null; i++) { IType[] pts = null; - try { - pts = types[i].getParameterTypes(); - } catch (DOMException e) { - continue; - } + pts = types[i].getParameterTypes(); if (pts.length > idx) result = (IType[]) ArrayUtil.append(IType.class, result, pts[idx]); } @@ -2732,11 +2728,7 @@ public class CPPSemantics { IType type = exp.getExpressionType(); if (type instanceof IProblem) return null; - try { - type = ((IPointerType)type).getType(); - } catch (DOMException e) { - return null; - } + type = ((IPointerType)type).getType(); IASTTypeId typeId = exp.getTypeId().copy(); IASTExpression sizeExpression = new CPPASTTypeIdExpression(IASTTypeIdExpression.op_sizeof, typeId); @@ -2767,13 +2759,9 @@ public class CPPSemantics { IType type1 = exp.getOperand().getExpressionType(); IType ultimateType1 = SemanticUtil.getUltimateTypeUptoPointers(type1); if (ultimateType1 instanceof IPointerType) { - try { - IType classType = ((IPointerType)ultimateType1).getType(); - if (classType instanceof ICPPClassType) - return (ICPPClassType) classType; - } catch (DOMException e) { - return null; - } + IType classType = ((IPointerType)ultimateType1).getType(); + if (classType instanceof ICPPClassType) + return (ICPPClassType) classType; } return null; } 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 02999758053..0a348ab252d 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 @@ -998,7 +998,7 @@ public class CPPTemplates { } public static void associateTemplateDeclarations(ICPPASTInternalTemplateDeclaration tdecl) { - // find innermost template decl + // find innermost template declaration IASTDeclaration decl= tdecl.getDeclaration(); while (decl instanceof ICPPASTInternalTemplateDeclaration) { tdecl= (ICPPASTInternalTemplateDeclaration) decl; @@ -1006,7 +1006,7 @@ public class CPPTemplates { } final ICPPASTInternalTemplateDeclaration innerMostTDecl= tdecl; - // find name declared in nested declaration + // find name declared within the template declaration IASTName name= getNameForDeclarationInTemplateDeclaration(decl); // count template declarations @@ -1021,7 +1021,7 @@ public class CPPTemplates { // determine association of names with template declarations boolean lastIsTemplate= true; - int additionalLevels= 0; + int missingTemplateDecls= 0; if (name instanceof ICPPASTQualifiedName) { ICPPASTQualifiedName qname= (ICPPASTQualifiedName) name; final IASTName lastName = qname.getLastName(); @@ -1030,8 +1030,7 @@ public class CPPTemplates { // count template-ids int idcount= 0; final IASTName[] ns= qname.getNames(); - for (int j = 0; j < ns.length; j++) { - final IASTName n = ns[j]; + for (final IASTName n : ns) { if (n instanceof ICPPASTTemplateId) { idcount++; } @@ -1051,25 +1050,23 @@ public class CPPTemplates { } if (lastIsID && !isCtorWithTemplateID) { - additionalLevels= idcount-tdeclcount; + missingTemplateDecls= idcount-tdeclcount; } else { - additionalLevels= idcount+1-tdeclcount; - if (additionalLevels > 0) { + missingTemplateDecls= idcount+1-tdeclcount; + if (missingTemplateDecls > 0) { // last name is probably not a template - additionalLevels--; + missingTemplateDecls--; lastIsTemplate= false; CharArraySet tparnames= collectTemplateParameterNames(outerMostTDecl); int j= 0; - IASTName n; - for (int i = 0; i < ns.length; i++) { - n = ns[j]; + for (IASTName n : ns) { if (n instanceof ICPPASTTemplateId) { // if we find a dependent id, there can be no explicit specialization. ICPPASTTemplateId id= (ICPPASTTemplateId) n; if (usesTemplateParameter(id, tparnames)) break; - if (j++ == additionalLevels) { + if (j++ == missingTemplateDecls) { IBinding b= n.resolveBinding(); if (b instanceof ICPPTemplateInstance && b instanceof ICPPClassType) { try { @@ -1077,7 +1074,7 @@ public class CPPTemplates { if (!(s instanceof ICPPClassSpecializationScope)) { // template-id of an explicit specialization. // here we don't have a template declaration. (see 14.7.3.5) - additionalLevels++; + missingTemplateDecls++; lastIsTemplate= true; } } catch (DOMException e) { @@ -1092,12 +1089,12 @@ public class CPPTemplates { } } - if (additionalLevels < 0) { - additionalLevels= 0; // too many template declarations + if (missingTemplateDecls < 0) { + missingTemplateDecls= 0; // too many template declarations } // determine nesting level of parent - int level= additionalLevels; + int level= missingTemplateDecls; if (!CPPVisitor.isFriendFunctionDeclaration(innerMostTDecl.getDeclaration())) { node= outerMostTDecl.getParent(); while (node != null) { @@ -1556,23 +1553,16 @@ public class CPPTemplates { static private IType getArgumentTypeForDeduction(IType type, boolean parameterIsAReferenceType) { type = SemanticUtil.getSimplifiedType(type); if (type instanceof ICPPReferenceType) { - try { - type = ((ICPPReferenceType) type).getType(); - } catch (DOMException e) { - } + type = ((ICPPReferenceType) type).getType(); } IType result = type; if (!parameterIsAReferenceType) { - try { - if (type instanceof IArrayType) { - result = new CPPPointerType(((IArrayType) type).getType()); - } else if (type instanceof IFunctionType) { - result = new CPPPointerType(type); - } else { - result = SemanticUtil.getNestedType(type, SemanticUtil.TDEF | SemanticUtil.CVQ | SemanticUtil.PTR_CVQ ); - } - } catch (DOMException e) { - result = e.getProblem(); + if (type instanceof IArrayType) { + result = new CPPPointerType(((IArrayType) type).getType()); + } else if (type instanceof IFunctionType) { + result = new CPPPointerType(type); + } else { + result = SemanticUtil.getNestedType(type, SemanticUtil.TDEF | SemanticUtil.CVQ | SemanticUtil.PTR_CVQ ); } } return result; @@ -1934,12 +1924,8 @@ public class CPPTemplates { } static private boolean isValidType(IType t) { - try { - while (t instanceof ITypeContainer) { - t = ((ITypeContainer) t).getType(); - } - } catch (DOMException e) { - return false; + while (t instanceof ITypeContainer) { + t = ((ITypeContainer) t).getType(); } return !(t instanceof IProblemBinding); } @@ -2030,11 +2016,7 @@ public class CPPTemplates { if (paramType instanceof IFunctionType) { paramType = new CPPPointerType(paramType); } else if (paramType instanceof IArrayType) { - try { - paramType = new CPPPointerType(((IArrayType) paramType).getType()); - } catch (DOMException e) { - paramType = e.getProblem(); - } + paramType = new CPPPointerType(((IArrayType) paramType).getType()); } Cost cost = Conversions.checkStandardConversionSequence(arg, paramType, false); return cost != null && cost.getRank() != Rank.NO_MATCH; @@ -2088,30 +2070,25 @@ public class CPPTemplates { } public static boolean isDependentType(IType t) { - try { - while (true) { - if (t instanceof ICPPUnknownType) + while (true) { + if (t instanceof ICPPUnknownType) + return true; + + if (t instanceof ICPPFunctionType) { + final ICPPFunctionType ft = (ICPPFunctionType) t; + if (containsDependentType(ft.getParameterTypes())) return true; - - if (t instanceof ICPPFunctionType) { - final ICPPFunctionType ft = (ICPPFunctionType) t; - if (containsDependentType(ft.getParameterTypes())) - return true; - t= ft.getReturnType(); - } else if (t instanceof ICPPPointerToMemberType) { - ICPPPointerToMemberType ptmt= (ICPPPointerToMemberType) t; - if (isDependentType(ptmt.getMemberOfClass())) - return true; - t= ptmt.getType(); - } else if (t instanceof ITypeContainer) { - t= ((ITypeContainer) t).getType(); - } else { - return false; - } + t= ft.getReturnType(); + } else if (t instanceof ICPPPointerToMemberType) { + ICPPPointerToMemberType ptmt= (ICPPPointerToMemberType) t; + if (isDependentType(ptmt.getMemberOfClass())) + return true; + t= ptmt.getType(); + } else if (t instanceof ITypeContainer) { + t= ((ITypeContainer) t).getType(); + } else { + return false; } - } catch (DOMException e) { - // treat as non-dependent - return false; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVariableReadWriteFlags.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVariableReadWriteFlags.java index 2d8245ebb6e..40639690116 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVariableReadWriteFlags.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVariableReadWriteFlags.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2009 Wind River Systems, Inc. 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 @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression; @@ -50,30 +49,21 @@ public final class CPPVariableReadWriteFlags extends VariableReadWriteFlags { if (!(type instanceof ICPPReferenceType)) { return READ; } - try { - type= ((ICPPReferenceType) type).getType(); - } - catch (DOMException e) { - return READ; // fallback - } + type= ((ICPPReferenceType) type).getType(); } - try { - while(indirection > 0 && (type instanceof ITypeContainer)) { - if (type instanceof IPointerType) { - indirection--; - } - type= ((ITypeContainer) type).getType(); - } - if (indirection == 0) { - if (type instanceof IQualifierType) { - return ((IQualifierType) type).isConst() ? READ : READ | WRITE; - } - else if (type instanceof IPointerType) { - return ((IPointerType) type).isConst() ? READ : READ | WRITE; - } + while(indirection > 0 && (type instanceof ITypeContainer)) { + if (type instanceof IPointerType) { + indirection--; } + type= ((ITypeContainer) type).getType(); } - catch (DOMException e) { + if (indirection == 0) { + if (type instanceof IQualifierType) { + return ((IQualifierType) type).isConst() ? READ : READ | WRITE; + } + else if (type instanceof IPointerType) { + return ((IPointerType) type).isConst() ? READ : READ | WRITE; + } } return READ | WRITE; // fallback } 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 cf981f192cd..b7796c390da 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 @@ -624,16 +624,12 @@ public class CPPVisitor extends ASTQueries { } else if (simpleDecl != null && simpleDecl.getDeclSpecifier().getStorageClass() == IASTDeclSpecifier.sc_typedef) { if (binding instanceof ICPPInternalBinding && binding instanceof ITypedef && name.isActive()) { - try { - IType t1 = ((ITypedef) binding).getType(); - IType t2 = createType(declarator); - if (t1 != null && t2 != null && t1.isSameType(t2)) { - ASTInternal.addDeclaration(binding, name); - return binding; - } - } catch (DOMException e) { - return e.getProblem(); - } + IType t1 = ((ITypedef) binding).getType(); + IType t2 = createType(declarator); + if (t1 != null && t2 != null && t1.isSameType(t2)) { + ASTInternal.addDeclaration(binding, name); + return binding; + } return new ProblemBinding(name, IProblemBinding.SEMANTIC_INVALID_REDECLARATION); } // if we don't resolve the target type first, we get a problem binding in case the typedef diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java index d0be99d8ee3..231a9ea5c67 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java @@ -189,53 +189,49 @@ public class SemanticUtil { boolean ptr= (options & PTR) != 0; boolean mptr= (options & MPTR) != 0; assert !(ptrcvq && (ptr || mptr)); - try { - while (true) { - IType t= null; - if (type instanceof IPointerType) { - final boolean isMbrPtr = type instanceof ICPPPointerToMemberType; - if ((ptr && !isMbrPtr) || (mptr && isMbrPtr)) { - t= ((IPointerType) type).getType(); - } else if (ptrcvq) { - if (type instanceof CPPPointerType) { - return ((CPPPointerType) type).stripQualifiers(); - } - IPointerType p= (IPointerType) type; - if (p.isConst() || p.isVolatile()) { - if (p instanceof ICPPPointerToMemberType) { - final IType memberOfClass = ((ICPPPointerToMemberType) p).getMemberOfClass(); - if (memberOfClass instanceof ICPPClassType) - return new CPPPointerToMemberType(p.getType(), memberOfClass, false, false); - } else { - return new CPPPointerType(p.getType(), false, false); - } + while (true) { + IType t= null; + if (type instanceof IPointerType) { + final boolean isMbrPtr = type instanceof ICPPPointerToMemberType; + if ((ptr && !isMbrPtr) || (mptr && isMbrPtr)) { + t= ((IPointerType) type).getType(); + } else if (ptrcvq) { + if (type instanceof CPPPointerType) { + return ((CPPPointerType) type).stripQualifiers(); + } + IPointerType p= (IPointerType) type; + if (p.isConst() || p.isVolatile()) { + if (p instanceof ICPPPointerToMemberType) { + final IType memberOfClass = ((ICPPPointerToMemberType) p).getMemberOfClass(); + if (memberOfClass instanceof ICPPClassType) + return new CPPPointerToMemberType(p.getType(), memberOfClass, false, false); + } else { + return new CPPPointerType(p.getType(), false, false); } } - } else if (tdef && type instanceof ITypedef) { - t= ((ITypedef) type).getType(); - } else if (type instanceof IQualifierType) { - final IQualifierType qt = (IQualifierType) type; - if (((options & CVQ) != 0)) { - t= qt.getType(); - } else if (tdef) { - IType temp= qt.getType(); - if (temp instanceof ITypedef) { - temp= getNestedType(temp, TDEF); - return addQualifiers(temp, qt.isConst(), qt.isVolatile()); - } - } - } else if ((options & ARRAY) != 0 && type instanceof IArrayType) { - t= ((IArrayType) type).getType(); - } else if ((options & REF) != 0 && type instanceof ICPPReferenceType) { - t= ((ICPPReferenceType) type).getType(); } - if (t == null) - return type; - - type= t; + } else if (tdef && type instanceof ITypedef) { + t= ((ITypedef) type).getType(); + } else if (type instanceof IQualifierType) { + final IQualifierType qt = (IQualifierType) type; + if (((options & CVQ) != 0)) { + t= qt.getType(); + } else if (tdef) { + IType temp= qt.getType(); + if (temp instanceof ITypedef) { + temp= getNestedType(temp, TDEF); + return addQualifiers(temp, qt.isConst(), qt.isVolatile()); + } + } + } else if ((options & ARRAY) != 0 && type instanceof IArrayType) { + t= ((IArrayType) type).getType(); + } else if ((options & REF) != 0 && type instanceof ICPPReferenceType) { + t= ((ICPPReferenceType) type).getType(); } - } catch (DOMException e) { - return e.getProblem(); + if (t == null) + return type; + + type= t; } } @@ -353,13 +349,9 @@ public class SemanticUtil { public static IType adjustParameterType(final IType pt, boolean forFunctionType) { // bug 239975 IType t= SemanticUtil.getNestedType(pt, TDEF); - try { - if (t instanceof IArrayType) { - IArrayType at = (IArrayType) t; - return new CPPPointerType(at.getType()); - } - } catch (DOMException e) { - return e.getProblem(); + if (t instanceof IArrayType) { + IArrayType at = (IArrayType) t; + return new CPPPointerType(at.getType()); } if (t instanceof IFunctionType) { return new CPPPointerType(pt); @@ -375,28 +367,25 @@ public class SemanticUtil { public static IType addQualifiers(IType baseType, boolean cnst, boolean vol) { if (cnst || vol) { - try { - if (baseType instanceof IQualifierType) { - IQualifierType qt= (IQualifierType) baseType; - if ((cnst && !qt.isConst()) || (vol && !qt.isVolatile())) { - return new CPPQualifierType(qt.getType(), cnst || qt.isConst(), vol || qt.isVolatile()); - } - return baseType; - } else if (baseType instanceof ICPPPointerToMemberType) { - ICPPPointerToMemberType pt= (ICPPPointerToMemberType) baseType; - if ((cnst && !pt.isConst()) || (vol && !pt.isVolatile())) { - return new CPPPointerToMemberType(pt.getType(), pt.getMemberOfClass(), cnst - || pt.isConst(), vol || pt.isVolatile()); - } - return baseType; - } else if (baseType instanceof IPointerType) { - IPointerType pt= (IPointerType) baseType; - if ((cnst && !pt.isConst()) || (vol && !pt.isVolatile())) { - return new CPPPointerType(pt.getType(), cnst || pt.isConst(), vol || pt.isVolatile()); - } - return baseType; + if (baseType instanceof IQualifierType) { + IQualifierType qt= (IQualifierType) baseType; + if ((cnst && !qt.isConst()) || (vol && !qt.isVolatile())) { + return new CPPQualifierType(qt.getType(), cnst || qt.isConst(), vol || qt.isVolatile()); } - } catch (DOMException e) { + return baseType; + } else if (baseType instanceof ICPPPointerToMemberType) { + ICPPPointerToMemberType pt= (ICPPPointerToMemberType) baseType; + if ((cnst && !pt.isConst()) || (vol && !pt.isVolatile())) { + return new CPPPointerToMemberType(pt.getType(), pt.getMemberOfClass(), cnst + || pt.isConst(), vol || pt.isVolatile()); + } + return baseType; + } else if (baseType instanceof IPointerType) { + IPointerType pt= (IPointerType) baseType; + if ((cnst && !pt.isConst()) || (vol && !pt.isVolatile())) { + return new CPPPointerType(pt.getType(), cnst || pt.isConst(), vol || pt.isVolatile()); + } + return baseType; } return new CPPQualifierType(baseType, cnst, vol); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/ArrayTypeClone.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/ArrayTypeClone.java index a32a18d0cee..d8d81484b14 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/ArrayTypeClone.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/ArrayTypeClone.java @@ -1,12 +1,12 @@ /******************************************************************************* - * Copyright (c) 2007 QNX Software Systems and others. + * Copyright (c) 2007, 2009 QNX Software Systems 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 * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * QNX - Initial API and implementation + * Bryan Wilkinson (QNX) - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.index; @@ -17,9 +17,6 @@ import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; -/** - * @author Bryan Wilkinson - */ public class ArrayTypeClone implements IIndexType, IArrayType, ITypeContainer { private final IArrayType delegate; private IType type; @@ -35,23 +32,19 @@ public class ArrayTypeClone implements IIndexType, IArrayType, ITypeContainer { if (!(type instanceof IArrayType)) return false; - try { - IType type1= this.getType(); - if (type1 == null) - return false; + IType type1= this.getType(); + if (type1 == null) + return false; - IArrayType rhs = (IArrayType) type; - return type1.isSameType(rhs.getType()); - } catch (DOMException e) { - } - return false; + IArrayType rhs = (IArrayType) type; + return type1.isSameType(rhs.getType()); } public IASTExpression getArraySizeExpression() throws DOMException { return delegate.getArraySizeExpression(); } - public IType getType() throws DOMException { + public IType getType() { if (type == null) { return delegate.getType(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CPPReferenceTypeClone.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CPPReferenceTypeClone.java index 9bc823fd32a..cd92e1cfb5f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CPPReferenceTypeClone.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CPPReferenceTypeClone.java @@ -1,24 +1,20 @@ /******************************************************************************* - * Copyright (c) 2007 QNX Software Systems and others. + * Copyright (c) 2007, 2009 QNX Software Systems 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 * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * QNX - Initial API and implementation + * Bryan Wilkinson (QNX) - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.index; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; -/** - * @author Bryan Wilkinson - */ public class CPPReferenceTypeClone implements ICPPReferenceType, ITypeContainer, IIndexType { private final ICPPReferenceType delegate; private IType type; @@ -27,7 +23,7 @@ public class CPPReferenceTypeClone implements ICPPReferenceType, ITypeContainer, this.delegate = reference; } - public IType getType() throws DOMException { + public IType getType() { if (type == null) { return delegate.getType(); } @@ -42,12 +38,9 @@ public class CPPReferenceTypeClone implements ICPPReferenceType, ITypeContainer, return false; ICPPReferenceType rhs = (ICPPReferenceType) type; - try { - IType type1= getType(); - if (type1 != null) { - return type1.isSameType(rhs.getType()); - } - } catch (DOMException e) { + IType type1= getType(); + if (type1 != null) { + return type1.isSameType(rhs.getType()); } return false; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CPPTypedefClone.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CPPTypedefClone.java index 22b18a61095..06a386855a2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CPPTypedefClone.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CPPTypedefClone.java @@ -1,12 +1,12 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 QNX Software Systems and others. + * Copyright (c) 2007, 2009 QNX Software Systems 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 * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * QNX - Initial API and implementation + * Bryan Wilkinson (QNX) - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.index; @@ -20,9 +20,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; import org.eclipse.core.runtime.CoreException; -/** - * @author Bryan Wilkinson - */ public class CPPTypedefClone implements ITypedef, ITypeContainer, IIndexType, ICPPBinding { protected final ITypedef delegate; private IType type; @@ -31,7 +28,7 @@ public class CPPTypedefClone implements ITypedef, ITypeContainer, IIndexType, IC this.delegate = typedef; } - public IType getType() throws DOMException { + public IType getType() { if (type == null) { return delegate.getType(); } @@ -64,18 +61,14 @@ public class CPPTypedefClone implements ITypedef, ITypeContainer, IIndexType, IC } public boolean isSameType(IType type) { - try { - IType myrtype = getType(); - if (myrtype == null) - return false; + IType myrtype = getType(); + if (myrtype == null) + return false; - if (type instanceof ITypedef) { - type= ((ITypedef) type).getType(); - } - return myrtype.isSameType(type); - } catch (DOMException e) { + if (type instanceof ITypedef) { + type= ((ITypedef) type).getType(); } - return false; + return myrtype.isSameType(type); } public void setType(IType type) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/PointerTypeClone.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/PointerTypeClone.java index 0d71eafa0fd..cc7b4b2eff6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/PointerTypeClone.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/PointerTypeClone.java @@ -6,21 +6,17 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * QNX - Initial API and implementation + * Bryan Wilkinson (QNX) - Initial API and implementation * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.index; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IPointerType; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; -/** - * @author Bryan Wilkinson - */ public class PointerTypeClone implements IPointerType, ITypeContainer, IIndexType { protected final IPointerType delegate; private IType type; @@ -29,7 +25,7 @@ public class PointerTypeClone implements IPointerType, ITypeContainer, IIndexTyp this.delegate = pointer; } - public IType getType() throws DOMException { + public IType getType() { if (type == null) { return delegate.getType(); } @@ -55,14 +51,11 @@ public class PointerTypeClone implements IPointerType, ITypeContainer, IIndexTyp return false; IPointerType rhs = (IPointerType) type; - try { - if (isConst() == rhs.isConst() && isVolatile() == rhs.isVolatile()) { - IType type1= getType(); - if (type1 != null) { - return type1.isSameType(rhs.getType()); - } + if (isConst() == rhs.isConst() && isVolatile() == rhs.isVolatile()) { + IType type1= getType(); + if (type1 != null) { + return type1.isSameType(rhs.getType()); } - } catch (DOMException e) { } return false; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/QualifierTypeClone.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/QualifierTypeClone.java index f328fe2ba82..fca6794c3d9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/QualifierTypeClone.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/QualifierTypeClone.java @@ -1,24 +1,21 @@ /******************************************************************************* - * Copyright (c) 2007 QNX Software Systems and others. + * Copyright (c) 2007, 2009 QNX Software Systems 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 * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * QNX - Initial API and implementation + * Bryan Wilkinson (QNX) - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.index; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IQualifierType; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; -/** - * @author Bryan Wilkinson - */ public class QualifierTypeClone implements IQualifierType, ITypeContainer, IIndexType { private final IQualifierType delegate; private IType type; @@ -27,7 +24,7 @@ public class QualifierTypeClone implements IQualifierType, ITypeContainer, IInde this.delegate = qualifier; } - public IType getType() throws DOMException { + public IType getType() { if (type == null) { return delegate.getType(); } @@ -49,12 +46,9 @@ public class QualifierTypeClone implements IQualifierType, ITypeContainer, IInde return false; IQualifierType pt = (IQualifierType) type; - try { - if (isConst() == pt.isConst() && isVolatile() == pt.isVolatile()) { - IType myType= getType(); - return myType != null && myType.isSameType(pt.getType()); - } - } catch (DOMException e) { + if (isConst() == pt.isConst() && isVolatile() == pt.isVolatile()) { + IType myType= getType(); + return myType != null && myType.isSameType(pt.getType()); } return false; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositeFunctionType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositeFunctionType.java index 9520271e83a..f728f28549f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositeFunctionType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositeFunctionType.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Symbian Software Systems and others. + * Copyright (c) 2007, 2009 Symbian Software Systems 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 @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.index.composite; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IFunctionType; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.internal.core.index.IIndexType; @@ -21,7 +20,7 @@ public class CompositeFunctionType extends CompositeType implements IFunctionTyp super(rtype, cf); } - public IType[] getParameterTypes() throws DOMException { + public IType[] getParameterTypes() { IType[] result = ((IFunctionType) type).getParameterTypes(); for (int i = 0; i < result.length; i++) { result[i] = cf.getCompositeType((IIndexType)result[i]); @@ -29,7 +28,7 @@ public class CompositeFunctionType extends CompositeType implements IFunctionTyp return result; } - public IType getReturnType() throws DOMException { + public IType getReturnType() { return cf.getCompositeType((IIndexType) ((IFunctionType) type).getReturnType()); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositePointerType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositePointerType.java index 6405fcbbf87..bb4db8f03fd 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositePointerType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositePointerType.java @@ -1,23 +1,22 @@ /******************************************************************************* - * Copyright (c) 2007 Symbian Software Systems and others. + * Copyright (c) 2007, 2009 Symbian Software Systems 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 * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Andrew Ferguson (Symbian) - Initial implementation + * Andrew Ferguson (Symbian) - Initial implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.index.composite; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IPointerType; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; import org.eclipse.cdt.internal.core.index.PointerTypeClone; public class CompositePointerType extends CompositeTypeContainer implements IPointerType { - public CompositePointerType(IPointerType pointerType, ICompositesFactory cf) throws DOMException { + public CompositePointerType(IPointerType pointerType, ICompositesFactory cf) { super((ITypeContainer) pointerType, cf); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositeQualifierType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositeQualifierType.java index ff9cd970ea8..1db1953b813 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositeQualifierType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositeQualifierType.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Symbian Software Systems and others. + * Copyright (c) 2007, 2009 Symbian Software Systems 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 @@ -10,14 +10,13 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.index.composite; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IQualifierType; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; import org.eclipse.cdt.internal.core.index.QualifierTypeClone; public class CompositeQualifierType extends CompositeTypeContainer implements IQualifierType { - public CompositeQualifierType(IQualifierType qualifierType, ICompositesFactory cf) throws DOMException { + public CompositeQualifierType(IQualifierType qualifierType, ICompositesFactory cf) { super((ITypeContainer) qualifierType, cf); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositeTypeContainer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositeTypeContainer.java index 78102ae4b9b..2dcd7086f17 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositeTypeContainer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositeTypeContainer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Symbian Software Systems and others. + * Copyright (c) 2007, 2009 Symbian Software Systems 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 @@ -8,11 +8,9 @@ * Contributors: * Andrew Ferguson (Symbian) - Initial implementation *******************************************************************************/ - package org.eclipse.cdt.internal.core.index.composite; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; import org.eclipse.cdt.internal.core.index.IIndexType; @@ -23,16 +21,12 @@ public class CompositeTypeContainer extends CompositeType implements ITypeContai super(rtype, cf); } - public final IType getType() throws DOMException { + public final IType getType() { return cf.getCompositeType((IIndexType) ((ITypeContainer) type).getType()); } @Override public String toString() { - try { - return ASTTypeUtil.getType(getType()); - } catch (DOMException e) { - return ""; //$NON-NLS-1$ - } + return ASTTypeUtil.getType(getType()); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/ICompositesFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/ICompositesFactory.java index 38e23893ff7..2df2c1a5682 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/ICompositesFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/ICompositesFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Symbian Software Systems and others. + * Copyright (c) 2007, 2009 Symbian Software Systems 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 @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.index.composite; -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.index.IIndexBinding; @@ -26,7 +25,7 @@ public interface ICompositesFactory { * Returns a composite (in the sense of potentially spanning multiple index fragments - i.e. not to be confused * with ICompositeType) type for the specified type. */ - public IType getCompositeType(IIndexType rtype) throws DOMException; + public IType getCompositeType(IIndexType rtype); /** * Returns a composite (index context carrying) binding for the specified binding. It does not 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 bd1f626609e..baf860b6a23 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Symbian Software Systems and others. + * Copyright (c) 2007, 2009 Symbian Software Systems 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 @@ -68,7 +68,7 @@ public class CCompositesFactory extends AbstractCompositeFactory { /* * @see org.eclipse.cdt.internal.core.index.composite.cpp.ICompositesFactory#getCompositeType(org.eclipse.cdt.core.index.IIndex, org.eclipse.cdt.core.dom.ast.IType) */ - public IType getCompositeType(IIndexType rtype) throws DOMException { + public IType getCompositeType(IIndexType rtype) { IType result; if(rtype==null) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CompositeCTypedef.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CompositeCTypedef.java index 4ea3cd43548..1c40d0db1f4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CompositeCTypedef.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CompositeCTypedef.java @@ -1,16 +1,15 @@ /******************************************************************************* - * Copyright (c) 2007 Symbian Software Systems and others. + * Copyright (c) 2007, 2009 Symbian Software Systems 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 * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Andrew Ferguson (Symbian) - Initial implementation + * Andrew Ferguson (Symbian) - Initial implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.index.composite.c; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; @@ -23,7 +22,7 @@ class CompositeCTypedef extends CompositeCBinding implements ITypedef, IIndexTyp super(cf, rbinding); } - public IType getType() throws DOMException { + public IType getType() { IType type = ((ITypedef)rbinding).getType(); return cf.getCompositeType((IIndexType)type); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java index 9981c53f527..91106707530 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java @@ -12,7 +12,6 @@ package org.eclipse.cdt.internal.core.index.composite.cpp; import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IArrayType; import org.eclipse.cdt.core.dom.ast.IBasicType; @@ -117,7 +116,7 @@ public class CPPCompositesFactory extends AbstractCompositeFactory { /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.index.composite.cpp.ICompositesFactory#getCompositeType(org.eclipse.cdt.core.index.IIndex, org.eclipse.cdt.core.dom.ast.IType) */ - public IType getCompositeType(IIndexType rtype) throws DOMException { + public IType getCompositeType(IIndexType rtype) { IType result; if (rtype instanceof ICPPSpecialization) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPPointerToMemberType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPPointerToMemberType.java index d765fe21d45..bcc6e553a23 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPPointerToMemberType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPPointerToMemberType.java @@ -11,7 +11,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.index.composite.cpp; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType; import org.eclipse.cdt.internal.core.index.CPPPointerToMemberTypeClone; @@ -21,7 +20,7 @@ import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory; class CompositeCPPPointerToMemberType extends CompositePointerType implements ICPPPointerToMemberType { - CompositeCPPPointerToMemberType(ICompositesFactory cf, ICPPPointerToMemberType pointerToMemberType) throws DOMException { + CompositeCPPPointerToMemberType(ICompositesFactory cf, ICPPPointerToMemberType pointerToMemberType) { super(pointerToMemberType, cf); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPReferenceType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPReferenceType.java index 73f5a5ca69b..3fc31105a5a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPReferenceType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPReferenceType.java @@ -1,16 +1,15 @@ /******************************************************************************* - * Copyright (c) 2007 Symbian Software Systems and others. + * Copyright (c) 2007, 2009 Symbian Software Systems 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 * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Andrew Ferguson (Symbian) - Initial implementation + * Andrew Ferguson (Symbian) - Initial implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.index.composite.cpp; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; import org.eclipse.cdt.internal.core.index.CPPReferenceTypeClone; @@ -18,7 +17,7 @@ import org.eclipse.cdt.internal.core.index.composite.CompositeTypeContainer; import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory; class CompositeCPPReferenceType extends CompositeTypeContainer implements ICPPReferenceType { - public CompositeCPPReferenceType(ICPPReferenceType referenceType, ICompositesFactory cf) throws DOMException { + public CompositeCPPReferenceType(ICPPReferenceType referenceType, ICompositesFactory cf) { super((ITypeContainer) referenceType, cf); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPTypedef.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPTypedef.java index 9efb5334190..693c44e78a9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPTypedef.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPTypedef.java @@ -1,16 +1,15 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Symbian Software Systems and others. + * Copyright (c) 2007, 2009 Symbian Software Systems 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 * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Andrew Ferguson (Symbian) - Initial implementation + * Andrew Ferguson (Symbian) - Initial implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.index.composite.cpp; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding; @@ -24,7 +23,7 @@ class CompositeCPPTypedef extends CompositeCPPBinding implements ITypedef, IInde super(cf, delegate); } - public IType getType() throws DOMException { + public IType getType() { IType type = ((ITypedef)rbinding).getType(); return cf.getCompositeType((IIndexType)type); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/TemplateInstanceUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/TemplateInstanceUtil.java index 78a869740d2..360b41a693a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/TemplateInstanceUtil.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/TemplateInstanceUtil.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Symbian Software Systems and others. + * Copyright (c) 2007, 2009 Symbian Software Systems 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 @@ -41,9 +41,9 @@ public class TemplateInstanceUtil { CPPTemplateParameterMap result= new CPPTemplateParameterMap(keys.length); try { - for(int i = 0; i < keys.length; i++) { - ICPPTemplateArgument arg= preresult.getArgument(keys[i]); - result.put(keys[i], convert(cf, arg)); + for (Integer key : keys) { + ICPPTemplateArgument arg= preresult.getArgument(key); + result.put(key, convert(cf, arg)); } } catch(DOMException de) { CCorePlugin.log(de); @@ -148,12 +148,8 @@ public class TemplateInstanceUtil { @Deprecated private static IType[] getArguments(ICompositesFactory cf, IType[] result) { - try { - for(int i=0; i