From c31e996fc2028a85d4b2794e2a288285ed8e6807 Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Fri, 27 Aug 2010 09:01:29 +0000 Subject: [PATCH] Bug 323723: Reduce usage of DOMExceptions. --- .../core/parser/tests/ast2/AST2BaseTest.java | 3 +- .../core/parser/tests/ast2/AST2CPPTests.java | 2 +- .../tests/IndexCPPBindingResolutionTest.java | 30 +- .../internal/core/browser/IndexModelUtil.java | 105 +++--- .../core/model/util/CElementBaseLabels.java | 3 +- .../core/model/ext/CElementHandle.java | 20 +- .../internal/core/model/ext/FieldHandle.java | 12 +- .../model/ext/FunctionDeclarationHandle.java | 11 +- .../model/ext/MethodDeclarationHandle.java | 16 +- .../core/model/ext/VariableHandle.java | 12 +- .../eclipse/cdt/core/dom/ast/ASTTypeUtil.java | 10 +- .../eclipse/cdt/core/dom/ast/IBinding.java | 2 +- .../cdt/core/dom/ast/ICompositeType.java | 15 +- .../org/eclipse/cdt/core/dom/ast/IField.java | 6 +- .../eclipse/cdt/core/dom/ast/IFunction.java | 17 +- .../org/eclipse/cdt/core/dom/ast/ILabel.java | 4 +- .../org/eclipse/cdt/core/dom/ast/IScope.java | 19 +- .../eclipse/cdt/core/dom/ast/IVariable.java | 10 +- .../core/dom/ast/c/ICCompositeTypeScope.java | 8 +- .../cdt/core/dom/ast/cpp/ICPPBase.java | 9 +- .../cdt/core/dom/ast/cpp/ICPPClassScope.java | 5 +- ...CPPClassTemplatePartialSpecialization.java | 4 +- .../cdt/core/dom/ast/cpp/ICPPClassType.java | 26 +- .../cdt/core/dom/ast/cpp/ICPPConstructor.java | 7 +- .../cdt/core/dom/ast/cpp/ICPPFunction.java | 9 +- .../cdt/core/dom/ast/cpp/ICPPMember.java | 8 +- .../cdt/core/dom/ast/cpp/ICPPMethod.java | 5 +- .../cdt/core/dom/ast/cpp/ICPPNamespace.java | 8 +- .../cdt/core/dom/ast/cpp/ICPPVariable.java | 8 +- .../eclipse/cdt/core/index/IIndexBinding.java | 5 +- .../cdt/core/parser/util/CharArraySet.java | 11 +- .../cdt/core/parser/util/ObjectMap.java | 12 +- .../cdt/core/parser/util/ObjectSet.java | 7 +- .../cdt/core/parser/util/ObjectTable.java | 12 +- .../internal/core/dom/parser/ASTInternal.java | 21 +- .../core/dom/parser/IASTInternalScope.java | 13 +- .../core/dom/parser/ProblemBinding.java | 103 +++++- .../cdt/internal/core/dom/parser/Value.java | 13 +- .../parser/c/CASTElaboratedTypeSpecifier.java | 25 +- .../internal/core/dom/parser/c/CASTName.java | 29 +- .../core/dom/parser/c/CBuiltinVariable.java | 5 +- .../core/dom/parser/c/CEnumeration.java | 3 +- .../core/dom/parser/c/CEnumerator.java | 4 - .../internal/core/dom/parser/c/CField.java | 35 +- .../internal/core/dom/parser/c/CFunction.java | 5 +- .../core/dom/parser/c/CFunctionScope.java | 13 +- .../core/dom/parser/c/CKnRParameter.java | 5 +- .../internal/core/dom/parser/c/CLabel.java | 86 +++-- .../core/dom/parser/c/CParameter.java | 235 +++++++------ .../internal/core/dom/parser/c/CScope.java | 11 +- .../core/dom/parser/c/CStructure.java | 188 ++++++----- .../internal/core/dom/parser/c/CTypedef.java | 5 +- .../internal/core/dom/parser/c/CVariable.java | 181 +++++----- .../internal/core/dom/parser/c/CVisitor.java | 219 +++++------- .../core/dom/parser/c/ICInternalBinding.java | 11 +- .../AbstractCPPClassSpecializationScope.java | 36 +- .../dom/parser/cpp/CPPASTBaseSpecifier.java | 12 +- .../core/dom/parser/cpp/CPPASTName.java | 37 +- .../parser/cpp/CPPASTNamespaceDefinition.java | 7 +- .../dom/parser/cpp/CPPASTQualifiedName.java | 58 ++-- .../core/dom/parser/cpp/CPPBaseClause.java | 47 +-- .../core/dom/parser/cpp/CPPBlockScope.java | 17 +- .../dom/parser/cpp/CPPBuiltinVariable.java | 5 +- .../core/dom/parser/cpp/CPPClassInstance.java | 7 +- .../core/dom/parser/cpp/CPPClassScope.java | 13 +- .../parser/cpp/CPPClassSpecialization.java | 69 ++-- .../core/dom/parser/cpp/CPPClassTemplate.java | 30 +- .../core/dom/parser/cpp/CPPClassType.java | 94 +++--- .../dom/parser/cpp/CPPCompositeBinding.java | 12 +- .../core/dom/parser/cpp/CPPConstructor.java | 22 +- .../parser/cpp/CPPConstructorInstance.java | 3 +- .../cpp/CPPConstructorSpecialization.java | 5 +- .../parser/cpp/CPPConstructorTemplate.java | 18 +- .../CPPConstructorTemplateSpecialization.java | 5 +- .../parser/cpp/CPPDeferredClassInstance.java | 10 +- .../core/dom/parser/cpp/CPPEnumeration.java | 6 +- .../core/dom/parser/cpp/CPPEnumerator.java | 2 +- .../core/dom/parser/cpp/CPPField.java | 40 +-- .../parser/cpp/CPPFieldSpecialization.java | 18 +- .../core/dom/parser/cpp/CPPFunction.java | 71 +--- .../core/dom/parser/cpp/CPPFunctionScope.java | 4 +- .../parser/cpp/CPPFunctionSpecialization.java | 18 +- .../dom/parser/cpp/CPPFunctionTemplate.java | 49 +-- .../dom/parser/cpp/CPPImplicitMethod.java | 15 +- .../core/dom/parser/cpp/CPPLabel.java | 12 +- .../core/dom/parser/cpp/CPPMethod.java | 40 +-- .../dom/parser/cpp/CPPMethodInstance.java | 11 +- .../parser/cpp/CPPMethodSpecialization.java | 13 +- .../dom/parser/cpp/CPPMethodTemplate.java | 27 +- .../cpp/CPPMethodTemplateSpecialization.java | 9 +- .../core/dom/parser/cpp/CPPNamespace.java | 41 +-- .../dom/parser/cpp/CPPNamespaceAlias.java | 6 +- .../dom/parser/cpp/CPPNamespaceScope.java | 5 +- .../core/dom/parser/cpp/CPPParameter.java | 42 +-- .../cpp/CPPParameterSpecialization.java | 6 +- .../core/dom/parser/cpp/CPPScope.java | 27 +- .../core/dom/parser/cpp/CPPScopeMapper.java | 12 +- .../dom/parser/cpp/CPPTemplateDefinition.java | 16 +- .../cpp/CPPTemplateNonTypeParameter.java | 9 +- .../dom/parser/cpp/CPPTemplateParameter.java | 2 +- .../core/dom/parser/cpp/CPPTemplateScope.java | 7 +- .../cpp/CPPTemplateTemplateParameter.java | 18 +- .../core/dom/parser/cpp/CPPTypedef.java | 11 +- .../dom/parser/cpp/CPPUnknownBinding.java | 2 +- .../core/dom/parser/cpp/CPPUnknownClass.java | 18 +- .../parser/cpp/CPPUnknownClassInstance.java | 14 +- .../dom/parser/cpp/CPPUnknownConstructor.java | 13 +- .../dom/parser/cpp/CPPUnknownFunction.java | 24 +- .../core/dom/parser/cpp/CPPUnknownScope.java | 21 +- .../dom/parser/cpp/CPPUsingDeclaration.java | 9 +- .../core/dom/parser/cpp/CPPVariable.java | 46 +-- .../core/dom/parser/cpp/ClassTypeHelper.java | 138 ++++---- .../dom/parser/cpp/ICPPASTInternalScope.java | 5 +- .../cpp/ICPPClassSpecializationScope.java | 13 +- .../cpp/ICPPInternalClassTypeMixinHost.java | 5 +- .../parser/cpp/semantics/AccessContext.java | 34 +- .../cpp/semantics/AutoTypeResolver.java | 22 +- .../parser/cpp/semantics/BaseClassLookup.java | 146 ++++---- .../parser/cpp/semantics/CPPSemantics.java | 33 +- .../parser/cpp/semantics/CPPTemplates.java | 112 +++---- .../dom/parser/cpp/semantics/CPPVisitor.java | 316 ++++++++---------- .../parser/cpp/semantics/SemanticUtil.java | 47 ++- .../cdt/internal/core/index/CIndex.java | 30 +- .../internal/core/index/CPPTypedefClone.java | 4 +- .../core/index/IIndexFragmentBinding.java | 5 +- .../composite/CompositeIndexBinding.java | 5 +- .../core/index/composite/CompositeScope.java | 18 +- .../index/composite/c/CCompositesFactory.java | 14 +- .../composite/c/CompositeCCompositeScope.java | 11 +- .../index/composite/c/CompositeCField.java | 5 +- .../index/composite/c/CompositeCFunction.java | 14 +- .../composite/c/CompositeCParameter.java | 10 +- .../composite/c/CompositeCStructure.java | 13 +- .../index/composite/c/CompositeCVariable.java | 10 +- .../composite/cpp/CompositeCPPClassScope.java | 40 +-- .../cpp/CompositeCPPClassSpecialization.java | 65 ++-- .../CompositeCPPClassSpecializationScope.java | 22 +- ...CPPClassTemplatePartialSpecialization.java | 14 +- ...tePartialSpecializationSpecialization.java | 4 +- .../composite/cpp/CompositeCPPClassType.java | 35 +- .../cpp/CompositeCPPConstructor.java | 5 +- .../cpp/CompositeCPPConstructorInstance.java | 5 +- ...CompositeCPPConstructorSpecialization.java | 5 +- .../cpp/CompositeCPPConstructorTemplate.java | 5 +- ...eCPPConstructorTemplateSpecialization.java | 5 +- .../composite/cpp/CompositeCPPEnumScope.java | 7 +- .../composite/cpp/CompositeCPPField.java | 9 +- .../cpp/CompositeCPPFieldSpecialization.java | 12 +- .../composite/cpp/CompositeCPPFunction.java | 18 +- .../CompositeCPPFunctionSpecialization.java | 13 +- .../composite/cpp/CompositeCPPMethod.java | 11 +- .../cpp/CompositeCPPMethodInstance.java | 11 +- .../cpp/CompositeCPPMethodSpecialization.java | 11 +- .../cpp/CompositeCPPMethodTemplate.java | 11 +- ...positeCPPMethodTemplateSpecialization.java | 11 +- .../composite/cpp/CompositeCPPNamespace.java | 5 +- .../cpp/CompositeCPPNamespaceAlias.java | 5 +- .../cpp/CompositeCPPNamespaceScope.java | 36 +- .../CompositeCPPParameterSpecialization.java | 12 +- .../CompositeCPPTypedefSpecialization.java | 12 +- .../cpp/CompositeCPPUnknownClassType.java | 11 +- .../composite/cpp/CompositeCPPVariable.java | 14 +- .../internal/core/parser/ParserMessages.java | 10 +- .../eclipse/cdt/internal/core/pdom/PDOM.java | 100 +++--- .../core/pdom/dom/PDOMASTAdapter.java | 42 +-- .../internal/core/pdom/dom/PDOMBinding.java | 9 +- .../internal/core/pdom/dom/PDOMLinkage.java | 42 ++- .../core/pdom/dom/c/PDOMCAnnotation.java | 6 +- .../core/pdom/dom/c/PDOMCFunction.java | 14 +- .../core/pdom/dom/c/PDOMCLinkage.java | 39 +-- .../core/pdom/dom/c/PDOMCParameter.java | 18 +- .../core/pdom/dom/c/PDOMCStructure.java | 48 +-- .../core/pdom/dom/c/PDOMCVariable.java | 10 +- .../core/pdom/dom/cpp/PDOMCPPAnnotation.java | 5 +- .../core/pdom/dom/cpp/PDOMCPPBase.java | 9 +- .../core/pdom/dom/cpp/PDOMCPPClassScope.java | 22 +- .../dom/cpp/PDOMCPPClassSpecialization.java | 23 +- .../pdom/dom/cpp/PDOMCPPClassTemplate.java | 27 +- .../core/pdom/dom/cpp/PDOMCPPClassType.java | 64 ++-- .../core/pdom/dom/cpp/PDOMCPPConstructor.java | 4 +- .../dom/cpp/PDOMCPPConstructorInstance.java | 5 +- .../cpp/PDOMCPPConstructorSpecialization.java | 5 +- .../dom/cpp/PDOMCPPConstructorTemplate.java | 4 +- ...MCPPConstructorTemplateSpecialization.java | 5 +- .../dom/cpp/PDOMCPPDeferredClassInstance.java | 6 +- .../core/pdom/dom/cpp/PDOMCPPEnumScope.java | 11 +- .../core/pdom/dom/cpp/PDOMCPPEnumeration.java | 23 +- .../dom/cpp/PDOMCPPFieldSpecialization.java | 18 +- .../core/pdom/dom/cpp/PDOMCPPFunction.java | 17 +- .../pdom/dom/cpp/PDOMCPPFunctionInstance.java | 11 +- .../cpp/PDOMCPPFunctionSpecialization.java | 38 +-- .../core/pdom/dom/cpp/PDOMCPPLinkage.java | 113 +++---- .../core/pdom/dom/cpp/PDOMCPPMethod.java | 14 +- .../pdom/dom/cpp/PDOMCPPMethodInstance.java | 11 +- .../dom/cpp/PDOMCPPMethodSpecialization.java | 14 +- .../pdom/dom/cpp/PDOMCPPMethodTemplate.java | 8 +- .../PDOMCPPMethodTemplateSpecialization.java | 11 +- .../core/pdom/dom/cpp/PDOMCPPNamespace.java | 8 +- .../pdom/dom/cpp/PDOMCPPNamespaceAlias.java | 5 +- .../core/pdom/dom/cpp/PDOMCPPParameter.java | 20 +- .../cpp/PDOMCPPParameterSpecialization.java | 12 +- .../dom/cpp/PDOMCPPUnknownClassInstance.java | 14 +- .../pdom/dom/cpp/PDOMCPPUnknownClassType.java | 32 +- .../pdom/dom/cpp/PDOMCPPUsingDirective.java | 4 +- .../core/pdom/dom/cpp/PDOMCPPVariable.java | 16 +- .../core/pdom/dom/cpp/PDOMClassUtil.java | 14 +- .../editor/AddIncludeOnSelectionAction.java | 26 +- .../ui/editor/SemanticHighlightings.java | 16 +- .../ui/indexview/IndexLabelProvider.java | 26 +- .../ui/refactoring/MethodContext.java | 15 +- .../internal/ui/refactoring/Visibility.java | 5 +- .../ExtractLocalVariableRefactoring.java | 17 +- .../ui/refactoring/rename/ASTManager.java | 41 +-- .../rename/CRefactoringArgument.java | 12 +- .../rename/CRenameClassProcessor.java | 31 +- .../rename/CRenameLocalProcessor.java | 16 +- .../rename/CRenameMethodProcessor.java | 9 +- .../internal/ui/search/LinkedNamesFinder.java | 39 +-- .../ui/search/PDOMSearchPatternQuery.java | 7 +- .../search/actions/OpenDeclarationsJob.java | 10 +- .../DOMCompletionProposalComputer.java | 137 ++++---- .../internal/ui/typehierarchy/THGraph.java | 24 +- .../cdt/internal/ui/viewsupport/IndexUI.java | 148 ++++---- .../deprecated/C99ResolveParserAction.java | 31 +- .../c99/bindings/C99CompositeTypeScope.java | 5 +- .../lrparser/c99/bindings/C99Enumeration.java | 3 +- .../lrparser/c99/bindings/C99Enumerator.java | 3 +- .../dom/lrparser/c99/bindings/C99Field.java | 9 +- .../dom/lrparser/c99/bindings/C99Label.java | 5 +- .../dom/lrparser/c99/bindings/C99Scope.java | 8 +- .../lrparser/c99/bindings/C99Structure.java | 5 +- .../dom/lrparser/c99/bindings/C99Typedef.java | 5 +- .../lrparser/c99/bindings/C99Variable.java | 5 +- .../lrparser/action/BuildASTParserAction.java | 20 +- 234 files changed, 2426 insertions(+), 3449 deletions(-) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java index c8b13ca8995..0dd90a2fc8b 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java @@ -23,7 +23,6 @@ import junit.framework.AssertionFailedError; import org.eclipse.cdt.core.dom.ast.ASTSignatureUtil; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression; import org.eclipse.cdt.core.dom.ast.IASTCastExpression; import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier; @@ -470,7 +469,7 @@ public class AST2BaseTest extends BaseTestCase { return clazz.cast(o); } - protected static void assertField(IBinding binding, String fieldName, String ownerName) throws DOMException { + protected static void assertField(IBinding binding, String fieldName, String ownerName) { assertInstance(binding, IField.class); assertEquals(fieldName, binding.getName()); ICompositeType struct = ((IField) binding).getCompositeTypeOwner(); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java index 9d61487821c..9b956833e27 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java @@ -3419,7 +3419,7 @@ public class AST2CPPTests extends AST2BaseTest { IProblemBinding B = (IProblemBinding) col.getName(2).resolveBinding(); assertEquals(B.getID(), IProblemBinding.SEMANTIC_NAME_NOT_FOUND); IProblemBinding C = (IProblemBinding) col.getName(3).resolveBinding(); - assertEquals(C.getID(), IProblemBinding.SEMANTIC_BAD_SCOPE); + assertEquals(C.getID(), IProblemBinding.SEMANTIC_NAME_NOT_FOUND); } public void testBug88459() throws Exception { 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 066846e11f5..d489765c863 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 @@ -1637,23 +1637,19 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti int friends, int constructors, int nestedClasses) { - try { - assertTrue(type instanceof ICPPClassType); - ICPPClassType classType = (ICPPClassType) type; - assertQNEquals(qn, classType); - assertEquals(key, classType.getKey()); - assertEquals(bases, classType.getBases().length); - assertEquals(fields, classType.getFields().length); - assertEquals(declaredFields, classType.getDeclaredFields().length); - assertEquals(methods, classType.getMethods().length); - assertEquals(declaredMethods, classType.getDeclaredMethods().length); - assertEquals(allDeclaredMethods, classType.getAllDeclaredMethods().length); - // assertEquals(friends, classType.getFriends().length); (PDOMNotImplementedError) - assertEquals(constructors, classType.getConstructors().length); - assertEquals(nestedClasses, classType.getNestedClasses().length); - } catch (DOMException de) { - fail(de.getMessage()); - } + assertTrue(type instanceof ICPPClassType); + ICPPClassType classType = (ICPPClassType) type; + assertQNEquals(qn, classType); + assertEquals(key, classType.getKey()); + assertEquals(bases, classType.getBases().length); + assertEquals(fields, classType.getFields().length); + assertEquals(declaredFields, classType.getDeclaredFields().length); + assertEquals(methods, classType.getMethods().length); + assertEquals(declaredMethods, classType.getDeclaredMethods().length); + assertEquals(allDeclaredMethods, classType.getAllDeclaredMethods().length); + // assertEquals(friends, classType.getFriends().length); (PDOMNotImplementedError) + assertEquals(constructors, classType.getConstructors().length); + assertEquals(nestedClasses, classType.getNestedClasses().length); } public void assertEnumeration(IBinding binding, String name, String[] enumerators) throws DOMException { diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/IndexModelUtil.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/IndexModelUtil.java index 48b1d9f502d..f9c06c3f561 100644 --- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/IndexModelUtil.java +++ b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/IndexModelUtil.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 QNX Software Systems and others. + * Copyright (c) 2006, 2010 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 @@ -14,7 +14,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.browser; -import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.EScopeKind; @@ -49,48 +48,44 @@ public class IndexModelUtil { * @return whether the binding is of any of the specified CElement type constants */ public static boolean bindingHasCElementType(IBinding binding, int[] kinds) { - try { - for (int kind : kinds) { - switch(kind) { - case ICElement.C_STRUCT: - if (binding instanceof ICompositeType - && ((ICompositeType)binding).getKey() == ICompositeType.k_struct) - return true; - break; - case ICElement.C_UNION: - if (binding instanceof ICompositeType - && ((ICompositeType)binding).getKey() == ICompositeType.k_union) - return true; - break; - case ICElement.C_CLASS: - if (binding instanceof ICompositeType - && ((ICompositeType)binding).getKey() == ICPPClassType.k_class) - return true; - break; - case ICElement.C_NAMESPACE: - if (binding instanceof ICPPNamespace || binding instanceof ICPPNamespaceAlias) - return true; - break; - case ICElement.C_ENUMERATION: - if (binding instanceof IEnumeration) - return true; - break; - case ICElement.C_TYPEDEF: - if(binding instanceof ITypedef) - return true; - break; - case ICElement.C_FUNCTION: - if(binding instanceof IFunction) - return true; - break; - case ICElement.C_VARIABLE: - if(binding instanceof IVariable) - return true; - break; - } + for (int kind : kinds) { + switch(kind) { + case ICElement.C_STRUCT: + if (binding instanceof ICompositeType + && ((ICompositeType)binding).getKey() == ICompositeType.k_struct) + return true; + break; + case ICElement.C_UNION: + if (binding instanceof ICompositeType + && ((ICompositeType)binding).getKey() == ICompositeType.k_union) + return true; + break; + case ICElement.C_CLASS: + if (binding instanceof ICompositeType + && ((ICompositeType)binding).getKey() == ICPPClassType.k_class) + return true; + break; + case ICElement.C_NAMESPACE: + if (binding instanceof ICPPNamespace || binding instanceof ICPPNamespaceAlias) + return true; + break; + case ICElement.C_ENUMERATION: + if (binding instanceof IEnumeration) + return true; + break; + case ICElement.C_TYPEDEF: + if(binding instanceof ITypedef) + return true; + break; + case ICElement.C_FUNCTION: + if(binding instanceof IFunction) + return true; + break; + case ICElement.C_VARIABLE: + if(binding instanceof IVariable) + return true; + break; } - } catch(DOMException de) { - CCorePlugin.log(de); } return false; } @@ -105,20 +100,16 @@ public class IndexModelUtil { if (binding instanceof ICompositeType) { ICompositeType classType = (ICompositeType) binding; - try { - switch(classType.getKey()) { - case ICPPClassType.k_class: - elementType = ICElement.C_CLASS; - break; - case ICompositeType.k_struct: - elementType = ICElement.C_STRUCT; - break; - case ICompositeType.k_union: - elementType = ICElement.C_UNION; - break; - } - } catch(DOMException de) { - CCorePlugin.log(de); + switch(classType.getKey()) { + case ICPPClassType.k_class: + elementType = ICElement.C_CLASS; + break; + case ICompositeType.k_struct: + elementType = ICElement.C_STRUCT; + break; + case ICompositeType.k_union: + elementType = ICElement.C_UNION; + break; } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/util/CElementBaseLabels.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/util/CElementBaseLabels.java index 4466e47fe46..b1b2a7fb4ea 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/util/CElementBaseLabels.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/util/CElementBaseLabels.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Corp. - Rational Software - initial implementation + * Andrew Niefer (IBM Corporation) - Initial API and implementation * Markus Schorn (Wind River Systems) * Gerhard Schaber (Wind River Systems) *******************************************************************************/ @@ -37,7 +37,6 @@ import org.eclipse.core.runtime.Path; /** * Creates labels for ICElement objects. - * @author aniefer */ public class CElementBaseLabels { diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/CElementHandle.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/CElementHandle.java index 9db060c08e4..8702443d89e 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/CElementHandle.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/CElementHandle.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2010 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 @@ -281,17 +281,13 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference { protected ASTAccessVisibility getVisibility(IBinding binding) { if (binding instanceof ICPPMember) { ICPPMember member= (ICPPMember) binding; - try { - switch (member.getVisibility()) { - case ICPPMember.v_private: - return ASTAccessVisibility.PRIVATE; - case ICPPMember.v_protected: - return ASTAccessVisibility.PROTECTED; - case ICPPMember.v_public: - return ASTAccessVisibility.PUBLIC; - } - } catch (DOMException e) { - CCorePlugin.log(e); + switch (member.getVisibility()) { + case ICPPMember.v_private: + return ASTAccessVisibility.PRIVATE; + case ICPPMember.v_protected: + return ASTAccessVisibility.PROTECTED; + case ICPPMember.v_public: + return ASTAccessVisibility.PUBLIC; } } return ASTAccessVisibility.PUBLIC; diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/FieldHandle.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/FieldHandle.java index 2f86510847e..7eba6051567 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/FieldHandle.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/FieldHandle.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2007 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2010 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 @@ -8,11 +8,8 @@ * Contributors: * Markus Schorn - initial API and implementation *******************************************************************************/ - package org.eclipse.cdt.internal.core.model.ext; -import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IField; import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.ICElement; @@ -26,12 +23,7 @@ public class FieldHandle extends CElementHandle implements org.eclipse.cdt.core. public FieldHandle(ICElement parent, IField field) { super(parent, ICElement.C_FIELD, field.getName()); fVisibility= getVisibility(field); - try { - fIsStatic= field.isStatic(); - } catch (DOMException e) { - CCorePlugin.log(e); - fIsStatic= false; - } + fIsStatic= field.isStatic(); } public ASTAccessVisibility getVisibility() throws CModelException { diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/FunctionDeclarationHandle.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/FunctionDeclarationHandle.java index 16716a39e66..d809f02c529 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/FunctionDeclarationHandle.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/FunctionDeclarationHandle.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2010 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 @@ -9,10 +9,8 @@ * Markus Schorn - initial API and implementation * Anton Leherbauer (Wind River Systems) *******************************************************************************/ - package org.eclipse.cdt.internal.core.model.ext; -import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IFunction; import org.eclipse.cdt.core.model.CModelException; @@ -32,12 +30,7 @@ public class FunctionDeclarationHandle extends CElementHandle implements org.ecl protected FunctionDeclarationHandle(ICElement parent, int type, IFunction func) throws DOMException { super(parent, type, func.getName()); fParameterTypes= extractParameterTypes(func); - try { - fIsStatic= func.isStatic(); - } catch (DOMException e) { - CCorePlugin.log(e); - fIsStatic= false; - } + fIsStatic= func.isStatic(); } @Override diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/MethodDeclarationHandle.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/MethodDeclarationHandle.java index ba21b2ab990..aade00913da 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/MethodDeclarationHandle.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/MethodDeclarationHandle.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2010 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 @@ -8,10 +8,8 @@ * Contributors: * Markus Schorn - initial API and implementation *******************************************************************************/ - package org.eclipse.cdt.internal.core.model.ext; -import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; @@ -37,14 +35,10 @@ public class MethodDeclarationHandle extends CElementHandle implements IMethodDe super(parent, type, method.getName()); fParameterTypes= extractParameterTypes(method); fVisibility= getVisibility(method); - try { - fIsStatic= method.isStatic(); - fIsConstructor= method instanceof ICPPConstructor; - if (!fIsConstructor) - fIsDestructor= method.isDestructor(); - } catch (DOMException e) { - CCorePlugin.log(e); - } + fIsStatic= method.isStatic(); + fIsConstructor= method instanceof ICPPConstructor; + if (!fIsConstructor) + fIsDestructor= method.isDestructor(); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/VariableHandle.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/VariableHandle.java index 99c35275d7e..e243ad600d8 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/VariableHandle.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/VariableHandle.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2007 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2010 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 @@ -8,11 +8,8 @@ * Contributors: * Markus Schorn - initial API and implementation *******************************************************************************/ - package org.eclipse.cdt.internal.core.model.ext; -import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IVariable; import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.ICElement; @@ -22,12 +19,7 @@ public class VariableHandle extends CElementHandle implements org.eclipse.cdt.co public VariableHandle(ICElement parent, IVariable var) { super(parent, ICElement.C_VARIABLE, var.getName()); - try { - fIsStatic= var.isStatic(); - } catch (DOMException e) { - CCorePlugin.log(e); - fIsStatic= false; - } + fIsStatic= var.isStatic(); } public boolean isStatic() throws CModelException { 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 4ae35d28f55..74185944898 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 @@ -346,12 +346,8 @@ public class ASTTypeUtil { } else if (type instanceof ICompositeType) { // 101114 fix, do not display class, and for consistency don't display struct/union as well if (type instanceof ICPPClassType) { - try { - String qn = CPPVisitor.renderQualifiedName(getQualifiedNameForAnonymous((ICPPClassType) type, normalize)); - result.append(qn); - } catch (DOMException e) { - result.append(getNameForAnonymous((ICompositeType) type)); - } + String qn = CPPVisitor.renderQualifiedName(getQualifiedNameForAnonymous((ICPPClassType) type, normalize)); + result.append(qn); } else { result.append(getNameForAnonymous((ICompositeType) type)); } @@ -695,7 +691,7 @@ public class ASTTypeUtil { } } - private static String[] getQualifiedNameForAnonymous(ICPPBinding binding, boolean normalize) throws DOMException { + private static String[] getQualifiedNameForAnonymous(ICPPBinding binding, boolean normalize) { LinkedList result= new LinkedList(); result.addFirst(getNameForAnonymous(binding)); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IBinding.java index 90eb7683513..5bca19d5550 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IBinding.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IBinding.java @@ -65,7 +65,7 @@ public interface IBinding extends IAdaptable { *
null: for types, functions, variables, namespaces and using declarations; * @since 5.1 */ - public IBinding getOwner() throws DOMException; + public IBinding getOwner(); /** * Returns the parent scope for this binding. A binding may have declarations in multiple scopes, diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ICompositeType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ICompositeType.java index 25f55d297fe..e076c4ebca8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ICompositeType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ICompositeType.java @@ -1,12 +1,12 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 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 - Initial API and implementation + * IBM - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.dom.ast; @@ -24,7 +24,7 @@ public interface ICompositeType extends IBinding, IType { /** * what kind of composite type is this? */ - public int getKey() throws DOMException; + public int getKey(); /** * Returns whether the type is anonymous or not. A type for which objects or @@ -36,14 +36,14 @@ public interface ICompositeType extends IBinding, IType { * * @since 5.1 */ - boolean isAnonymous() throws DOMException; + boolean isAnonymous(); /** * Returns the fields for this type. * * @return List of IField */ - public IField[] getFields() throws DOMException; + public IField[] getFields(); /** * returns the field that matches name, @@ -51,11 +51,10 @@ public interface ICompositeType extends IBinding, IType { * * @param name */ - public IField findField( String name ) throws DOMException; + public IField findField(String name); /** * get the IScope object that is associated with this composite type - * @throws DOMException */ - public IScope getCompositeScope() throws DOMException; + public IScope getCompositeScope(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IField.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IField.java index 072c5bfc801..38e269ebeb3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IField.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IField.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 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 @@ -21,9 +21,7 @@ public interface IField extends IVariable { /** * Returns the composite type that owns the field. - * @throws DOMException * @since 4.0 */ - ICompositeType getCompositeTypeOwner() throws DOMException; - + ICompositeType getCompositeTypeOwner(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IFunction.java index 93b1c3fb729..70ba80bbc18 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IFunction.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IFunction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 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 @@ -44,22 +44,19 @@ public interface IFunction extends IBinding { /** * Returns {@code true} if the function has the static storage-class specifier * similarly for extern, auto, register. - * @throws DOMException if this is a problem binding. */ - public boolean isStatic() throws DOMException; - public boolean isExtern() throws DOMException; - public boolean isAuto() throws DOMException; - public boolean isRegister() throws DOMException; + public boolean isStatic(); + public boolean isExtern(); + public boolean isAuto(); + public boolean isRegister(); /** * Returns {@code true} if the function is inline. - * @throws DOMException if this is a problem binding. */ - public boolean isInline() throws DOMException; + public boolean isInline(); /** * Returns {@code true} if this function takes variable arguments. - * @throws DOMException if this is a problem binding. */ - public boolean takesVarArgs() throws DOMException; + public boolean takesVarArgs(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ILabel.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ILabel.java index 4454ba3298a..5ac671ed9a7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ILabel.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ILabel.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 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 @@ -23,6 +23,6 @@ public interface ILabel extends IBinding { * Returns the label statement for this label. * */ - public IASTLabelStatement getLabelStatement() throws DOMException; + public IASTLabelStatement getLabelStatement(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IScope.java index 8cc4dfaf2c7..7ec52b91efc 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IScope.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 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 @@ -33,9 +33,8 @@ public interface IScope { /** * Get the IName for this scope, may be null * @return The name of this scope. - * @throws DOMException */ - public IName getScopeName() throws DOMException; + public IName getScopeName(); /** * The method returns the first enclosing non-template scope, or null if this @@ -55,7 +54,7 @@ public interface IScope { * @param name * @return An array of bindings. */ - public IBinding[] find(String name) throws DOMException; + public IBinding[] find(String name); /** * Get the binding in this scope that the given name would resolve to. Could @@ -68,9 +67,8 @@ public interface IScope { * whether or not to resolve the matching binding if it has not * been so already. * @return : the binding in this scope that matches the name, or null - * @throws DOMException */ - public IBinding getBinding(IASTName name, boolean resolve) throws DOMException; + public IBinding getBinding(IASTName name, boolean resolve); /** * Get the binding in this scope that the given name would resolve to. Could @@ -85,9 +83,8 @@ public interface IScope { * been so already. * @param acceptLocalBindings a set of files for which to accept local bindings. * @return : the binding in this scope that matches the name, or null - * @throws DOMException */ - public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet acceptLocalBindings) throws DOMException; + public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet acceptLocalBindings); /** * Get the bindings in this scope that the given name or prefix could resolve to. Could @@ -101,9 +98,8 @@ public interface IScope { * been so already. * @param prefixLookup whether the lookup is for a full name or a prefix * @return : the bindings in this scope that match the name or prefix, or null - * @throws DOMException */ - public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup) throws DOMException; + public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup); /** * Get the bindings in this scope that the given name or prefix could resolve to. Could @@ -118,8 +114,7 @@ public interface IScope { * @param prefixLookup whether the lookup is for a full name or a prefix * @param acceptLocalBindings a set of files for which to accept local bindings. * @return : the bindings in this scope that match the name or prefix, or null - * @throws DOMException */ - public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet acceptLocalBindings) throws DOMException; + public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet acceptLocalBindings); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IVariable.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IVariable.java index a1c64cbf4ba..28c553b1712 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IVariable.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IVariable.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 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 @@ -34,20 +34,20 @@ public interface IVariable extends IBinding { /** * Returns whether this variable is declared static. */ - public boolean isStatic() throws DOMException; + public boolean isStatic(); /** * Returns whether this variable is declared extern. */ - public boolean isExtern() throws DOMException; + public boolean isExtern(); /** * Returns whether this variable is an automatic variable. */ - public boolean isAuto() throws DOMException; + public boolean isAuto(); /** * Returns whether this variable is declared register. */ - public boolean isRegister() throws DOMException; + public boolean isRegister(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICCompositeTypeScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICCompositeTypeScope.java index 19b12e8facd..d6fdf32d95d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICCompositeTypeScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICCompositeTypeScope.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 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 @@ -11,7 +11,6 @@ *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.c; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.ICompositeType; @@ -23,11 +22,8 @@ public interface ICCompositeTypeScope extends ICScope { /** * get the binding for the member that has been previous added to this scope * and that matches the given name. - * - * @param name - * @throws DOMException */ - public IBinding getBinding(char[] name) throws DOMException; + public IBinding getBinding(char[] name); /** * Get the type this scope is associated with diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPBase.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPBase.java index 81de4e16bc5..b00f57b3b40 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPBase.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPBase.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 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 @@ -12,7 +12,6 @@ package org.eclipse.cdt.core.dom.ast.cpp; import org.eclipse.cdt.core.dom.IName; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier; @@ -33,7 +32,7 @@ public interface ICPPBase extends Cloneable { * The base class. Generally a ICPPClassType, but may be a ICPPTemplateParameter. * In the case of typedefs, the target type will be returned instead of the typedef itself. */ - public IBinding getBaseClass() throws DOMException; + public IBinding getBaseClass(); /** * Returns the name that specifies the base class. @@ -45,13 +44,13 @@ public interface ICPPBase extends Cloneable { * The visibility qualifier applied to the base class. * */ - public int getVisibility() throws DOMException; + public int getVisibility(); /** * Whether this is a virtual base class. */ - public boolean isVirtual() throws DOMException; + public boolean isVirtual(); /** * @since 5.1 diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassScope.java index 153dffdd71f..6938527c524 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassScope.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 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 @@ -11,7 +11,6 @@ *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.cpp; -import org.eclipse.cdt.core.dom.ast.DOMException; /** * Interface for class scopes. @@ -39,5 +38,5 @@ public interface ICPPClassScope extends ICPPScope { * Returns the array of constructors, including implicit ones. * @since 5.1 */ - public ICPPConstructor[] getConstructors() throws DOMException; + public ICPPConstructor[] getConstructors(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassTemplatePartialSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassTemplatePartialSpecialization.java index e157c323059..c6de47a82fa 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassTemplatePartialSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassTemplatePartialSpecialization.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 IBM Corporation and others. + * Copyright (c) 2005, 2010 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 @@ -31,7 +31,7 @@ public interface ICPPClassTemplatePartialSpecialization extends ICPPClassTemplat /** * get the ICPPTemplateDefinition which this is a specialization of */ - public ICPPClassTemplate getPrimaryClassTemplate() throws DOMException; + public ICPPClassTemplate getPrimaryClassTemplate(); /** diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassType.java index 3d61ba60f0f..de6b52dc375 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassType.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 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 @@ -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.IBinding; import org.eclipse.cdt.core.dom.ast.ICompositeType; import org.eclipse.cdt.core.dom.ast.IField; @@ -31,13 +30,13 @@ public interface ICPPClassType extends ICompositeType, ICPPBinding { * * @return List of ICPPBase */ - public ICPPBase[] getBases() throws DOMException; + public ICPPBase[] getBases(); /** * Get fields is restated here just to point out that this method returns a * list of ICPPField objects representing all fields, declared or inherited. */ - public IField[] getFields() throws DOMException; + public IField[] getFields(); /** * findField is restated here to point out that this method looks through @@ -47,7 +46,7 @@ public interface ICPPClassType extends ICompositeType, ICPPBinding { * * @param name */ - public IField findField(String name) throws DOMException; + public IField findField(String name); /** * Returns a list of ICPPField objects representing fields declared in this @@ -55,7 +54,7 @@ public interface ICPPClassType extends ICompositeType, ICPPBinding { * * @return List of ICPPField */ - public ICPPField[] getDeclaredFields() throws DOMException; + public ICPPField[] getDeclaredFields(); /** * Returns a list of ICPPMethod objects representing all methods defined for @@ -64,7 +63,7 @@ public interface ICPPClassType extends ICompositeType, ICPPBinding { * * @return List of ICPPMethod */ - public ICPPMethod[] getMethods() throws DOMException; + public ICPPMethod[] getMethods(); /** * Returns a list of ICPPMethod objects representing all method explicitly @@ -73,7 +72,7 @@ public interface ICPPClassType extends ICompositeType, ICPPBinding { * * @return List of ICPPMethod */ - public ICPPMethod[] getAllDeclaredMethods() throws DOMException; + public ICPPMethod[] getAllDeclaredMethods(); /** * Returns a list of ICPPMethod objects representing all methods explicitly @@ -82,7 +81,7 @@ public interface ICPPClassType extends ICompositeType, ICPPBinding { * * @return List of ICPPMethod */ - public ICPPMethod[] getDeclaredMethods() throws DOMException; + public ICPPMethod[] getDeclaredMethods(); /** * Returns an array of ICPPConstructor objects representing the constructors @@ -90,19 +89,16 @@ public interface ICPPClassType extends ICompositeType, ICPPBinding { * constructors. * */ - public ICPPConstructor[] getConstructors() throws DOMException; + public ICPPConstructor[] getConstructors(); /** * return an array of bindings for those classes/functions declared as * friends of this class. - * - * @throws DOMException */ - public IBinding[] getFriends() throws DOMException; + public IBinding[] getFriends(); /** * return an array of nested classes/structures - * @throws DOMException */ - public ICPPClassType[] getNestedClasses() throws DOMException; + public ICPPClassType[] getNestedClasses(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPConstructor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPConstructor.java index 89724865446..cd3db295af1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPConstructor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPConstructor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 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 @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.cpp; -import org.eclipse.cdt.core.dom.ast.DOMException; /** * @noextend This interface is not intended to be extended by clients. @@ -20,9 +19,7 @@ public interface ICPPConstructor extends ICPPMethod { public static final ICPPConstructor [] EMPTY_CONSTRUCTOR_ARRAY = new ICPPConstructor[0]; /** * Whether or not this constructor was declared as explicit - * - * @throws DOMException */ - boolean isExplicit() throws DOMException; + boolean isExplicit(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPFunction.java index 19615779414..fe621907a1b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPFunction.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPFunction.java @@ -25,27 +25,26 @@ public interface ICPPFunction extends IFunction, ICPPBinding { /** * does this function have the mutable storage class specifier - * @throws DOMException */ - public boolean isMutable() throws DOMException; + public boolean isMutable(); /** * is this an inline function */ - public boolean isInline() throws DOMException; + public boolean isInline(); /** * Returns whether this function is declared as extern "C". * @since 5.0 */ - public boolean isExternC() throws DOMException; + public boolean isExternC(); /** * Returns the exception specification for this function or null if there * is no exception specification. * @since 5.1 */ - public IType[] getExceptionSpecification() throws DOMException; + public IType[] getExceptionSpecification(); /** * {@inheritDoc} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPMember.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPMember.java index 903de6237f6..f61deba7995 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPMember.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPMember.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 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 @@ -29,19 +29,19 @@ public interface ICPPMember extends ICPPBinding { /** * Returns the accessibility of the member. */ - public int getVisibility() throws DOMException; + public int getVisibility(); /** * Same as {@link #getOwner()}. */ - public ICPPClassType getClassOwner() throws DOMException; + public ICPPClassType getClassOwner(); /** * Returns whether this is a static member or not. * @since 5.1 */ - public boolean isStatic() throws DOMException; + public boolean isStatic(); /** * Returns the type of the member (function type or type of field) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPMethod.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPMethod.java index e2349af0530..ca29b804f23 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPMethod.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPMethod.java @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.cpp; -import org.eclipse.cdt.core.dom.ast.DOMException; /** * Base interface for methods, also used for constructors. @@ -25,7 +24,7 @@ public interface ICPPMethod extends ICPPFunction, ICPPMember { * Returns whether this method is declared to be virtual. Does not detect whether * the method is virtual because of overriding a virtual method from a base class. */ - public boolean isVirtual() throws DOMException; + public boolean isVirtual(); /** * is this a destructor @@ -44,5 +43,5 @@ public interface ICPPMethod extends ICPPFunction, ICPPMember { * Returns whether this is a pure abstract method * @since 5.1 */ - public boolean isPureVirtual() throws DOMException; + public boolean isPureVirtual(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNamespace.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNamespace.java index b55f11eedda..275bddc4502 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNamespace.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNamespace.java @@ -11,7 +11,6 @@ *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.cpp; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IBinding; /** @@ -23,16 +22,13 @@ import org.eclipse.cdt.core.dom.ast.IBinding; public interface ICPPNamespace extends ICPPBinding { /** * get the scope object associated with this namespace - * - * @throws DOMException */ - public ICPPNamespaceScope getNamespaceScope() throws DOMException; + public ICPPNamespaceScope getNamespaceScope(); /** * get an array of the all the bindings declared in this namespace. - * @throws DOMException */ - public IBinding[] getMemberBindings() throws DOMException; + public IBinding[] getMemberBindings(); /** * Returns whether this is an inline namespace. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPVariable.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPVariable.java index 80e30482dfd..c9144497a35 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPVariable.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPVariable.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 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 @@ -11,7 +11,6 @@ *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.cpp; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IVariable; /** @@ -22,12 +21,11 @@ public interface ICPPVariable extends IVariable, ICPPBinding { /** * does this variable have the mutable storage class specifier - * @throws DOMException */ - public boolean isMutable() throws DOMException; + public boolean isMutable(); /** * Returns whether this variable is declared as extern "C". */ - public boolean isExternC() throws DOMException; + public boolean isExternC(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexBinding.java index 9d21afdfe68..e981b2789fd 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexBinding.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexBinding.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2010 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.core.index; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.core.runtime.CoreException; @@ -48,5 +47,5 @@ public interface IIndexBinding extends IBinding { * {@inheritDoc} * @since 5.1 */ - IIndexBinding getOwner() throws DOMException; + IIndexBinding getOwner(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/CharArraySet.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/CharArraySet.java index 320c21f3da0..723c5c4b116 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/CharArraySet.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/CharArraySet.java @@ -1,25 +1,18 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2010 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 Jul 21, 2004 - */ package org.eclipse.cdt.core.parser.util; import java.util.Collections; import java.util.List; -/** - * @author aniefer - */ public class CharArraySet extends CharTable { public static final CharArraySet EMPTY_SET = new CharArraySet( 0 ){ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/ObjectMap.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/ObjectMap.java index 36c030e36da..bb456bed4ad 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/ObjectMap.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/ObjectMap.java @@ -1,27 +1,19 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2010 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 *******************************************************************************/ - -/* - * cloned from CharArrayMap & CharArrayObjectMap - * Created on Jul 14, 2004 - */ package org.eclipse.cdt.core.parser.util; import java.util.Collections; import java.util.Comparator; import java.util.List; -/** - * @author aniefer - */ public class ObjectMap extends ObjectTable { public static final ObjectMap EMPTY_MAP = new ObjectMap(0) { @Override diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/ObjectSet.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/ObjectSet.java index b25c7106bc2..9fb851c199b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/ObjectSet.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/ObjectSet.java @@ -1,21 +1,18 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 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 *******************************************************************************/ package org.eclipse.cdt.core.parser.util; import java.util.Collections; import java.util.List; -/** - * @author aniefer - */ public class ObjectSet extends ObjectTable { /** * Represents the empty ObjectSet diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/ObjectTable.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/ObjectTable.java index 86d889b6156..fcd6e2e04d6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/ObjectTable.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/ObjectTable.java @@ -1,18 +1,13 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2010 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 *******************************************************************************/ - -/* - * For use by the Parser Symbol Table - * Created on Jul 15, 2004 - */ package org.eclipse.cdt.core.parser.util; import java.lang.reflect.Array; @@ -20,9 +15,6 @@ import java.util.ArrayList; import java.util.List; -/** - * @author aniefer - */ public abstract class ObjectTable extends HashTable { protected T[] keyTable; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTInternal.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTInternal.java index 508c780774d..359aca1e23b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTInternal.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTInternal.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2010 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; -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.IBinding; @@ -35,14 +34,14 @@ public class ASTInternal { return IASTNode.EMPTY_NODE_ARRAY; } - public static IASTNode getPhysicalNodeOfScope(IScope scope) throws DOMException { + public static IASTNode getPhysicalNodeOfScope(IScope scope) { if (scope instanceof IASTInternalScope) { return ((IASTInternalScope) scope).getPhysicalNode(); } return null; } - public static void addBinding(IScope scope, IBinding binding) throws DOMException { + public static void addBinding(IScope scope, IBinding binding) { if (scope instanceof IASTInternalScope) { ((IASTInternalScope) scope).addBinding(binding); } @@ -50,15 +49,11 @@ public class ASTInternal { public static void addName(IScope scope, IASTName name) { if (scope instanceof IASTInternalScope) { - try { - ((IASTInternalScope) scope).addName(name); - } catch (DOMException e) { - // name is not cached in scope - } + ((IASTInternalScope) scope).addName(name); } } - public static boolean isStatic(IFunction func, boolean resolveAll) throws DOMException { + public static boolean isStatic(IFunction func, boolean resolveAll) { if (func instanceof ICPPInternalFunction) { return ((ICPPInternalFunction)func).isStatic(resolveAll); } @@ -100,8 +95,7 @@ public class ASTInternal { } } if (decls != null) { - for (int i = 0; i < decls.length; i++) { - final IASTNode node= decls[i]; + for (final IASTNode node : decls) { if (node != null) { if ( (filePath= isPartOfSource(filePath, node)) == null) { return null; @@ -153,8 +147,7 @@ public class ASTInternal { filePath= def.getContainingFilename(); } if (decls != null) { - for (int i = 0; i < decls.length; i++) { - final IASTNode node= decls[i]; + for (final IASTNode node : decls) { if (node != null) { final String fn = node.getContainingFilename(); if (filePath == null) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalScope.java index aab740d46a4..1cb20611cc2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalScope.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2010 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; -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.IBinding; @@ -28,19 +27,13 @@ public interface IASTInternalScope extends IScope { /** * This adds an IBinding to the scope. It is primarily used by the parser to add * implicit IBindings to the scope (such as GCC built-in functions). - * - * @param binding - * @throws DOMException */ - public void addBinding(IBinding binding) throws DOMException; + public void addBinding(IBinding binding); /** * Add an IASTName to be cached in this scope - * - * @param name - * @throws DOMException */ - public void addName(IASTName name) throws DOMException; + public void addName(IASTName name); /** * Can be called during ambiguity resolution to populate a scope without considering diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemBinding.java index b22d16fffe8..4ee15d3beaa 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemBinding.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemBinding.java @@ -13,8 +13,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser; -import com.ibm.icu.text.MessageFormat; - import org.eclipse.cdt.core.dom.ILinkage; import org.eclipse.cdt.core.dom.IName; import org.eclipse.cdt.core.dom.ast.DOMException; @@ -26,6 +24,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.core.dom.ast.IValue; import org.eclipse.cdt.core.index.IIndexFileSet; import org.eclipse.cdt.core.parser.util.CharArrayUtils; import org.eclipse.cdt.internal.core.dom.Linkage; @@ -34,6 +33,8 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.core.parser.ParserMessages; import org.eclipse.core.runtime.PlatformObject; +import com.ibm.icu.text.MessageFormat; + /** * Implementation of problem bindings */ @@ -172,8 +173,8 @@ public class ProblemBinding extends PlatformObject implements IProblemBinding, I /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String) */ - public IBinding[] find(String name) throws DOMException { - throw new DOMException(this); + public IBinding[] find(String name) { + return IBinding.EMPTY_BINDING_ARRAY; } /* (non-Javadoc) @@ -186,34 +187,32 @@ public class ProblemBinding extends PlatformObject implements IProblemBinding, I /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IScope#addName(org.eclipse.cdt.core.dom.ast.IASTName) */ - public void addName(IASTName name) throws DOMException { - throw new DOMException(this); + public void addName(IASTName name) { } /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IScope#getBinding(org.eclipse.cdt.core.dom.ast.IASTName, boolean) */ - public IBinding getBinding(IASTName name, boolean resolve) throws DOMException { - throw new DOMException(this); + public IBinding getBinding(IASTName name, boolean resolve) { + return null; } - public final IBinding[] getBindings(IASTName name, boolean resolve, boolean prefix) - throws DOMException { - throw new DOMException(this); + public final IBinding[] getBindings(IASTName name, boolean resolve, boolean prefix) { + return IBinding.EMPTY_BINDING_ARRAY; } /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IScope#getBinding(org.eclipse.cdt.core.dom.ast.IASTName, boolean) */ - public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) throws DOMException { - throw new DOMException(this); + public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) { + return null; } /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IScope#getBinding(org.eclipse.cdt.core.dom.ast.IASTName, boolean) */ - public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet) throws DOMException { - throw new DOMException(this); + public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet) { + return IBinding.EMPTY_BINDING_ARRAY; } /* (non-Javadoc) @@ -239,8 +238,7 @@ public class ProblemBinding extends PlatformObject implements IProblemBinding, I return -1; } - public void addBinding(IBinding binding) throws DOMException { - throw new DOMException(this); + public void addBinding(IBinding binding) { } public ILinkage getLinkage() { @@ -252,7 +250,7 @@ public class ProblemBinding extends PlatformObject implements IProblemBinding, I return getMessage(); } - public IBinding getOwner() throws DOMException { + public IBinding getOwner() { return node instanceof IASTName ? CPPVisitor.findNameOwner((IASTName) node, true) : null; } @@ -265,4 +263,73 @@ public class ProblemBinding extends PlatformObject implements IProblemBinding, I public void populateCache() { } + + + // Dummy methods for derived classes + public IType getType() throws DOMException { + throw new DOMException(this); + } + public boolean isStatic() { + return false; + } + public String[] getQualifiedName() throws DOMException { + throw new DOMException(this); + } + public char[][] getQualifiedNameCharArray() throws DOMException { + throw new DOMException(this); + } + public boolean isGloballyQualified() throws DOMException { + throw new DOMException(this); + } + public boolean isMutable() { + return false; + } + public boolean isExtern() { + return false; + } + public boolean isExternC() { + return false; + } + public boolean isAuto() { + return false; + } + public boolean isRegister() { + return false; + } + public IValue getInitialValue() { + return null; + } + public boolean isAnonymous() { + return false; + } + public boolean isDeleted() { + return false; + } + public boolean isInline() { + return false; + } + public boolean takesVarArgs() { + return false; + } + public IType[] getExceptionSpecification() { + return null; + } + public boolean hasParameterPack() { + return false; + } + public boolean isVirtual() { + return false; + } + public boolean isPureVirtual() { + return false; + } + public boolean isImplicit() { + return false; + } + public boolean hasDefaultValue() { + return false; + } + public boolean isParameterPack() { + return false; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java index b1ec1a7c997..298af6d1693 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2010 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 @@ -16,7 +16,6 @@ import java.util.List; import java.util.Map; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression; import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression; import org.eclipse.cdt.core.dom.ast.IASTCastExpression; @@ -862,13 +861,9 @@ public class Value implements IValue { * Computes a signature for an unknown binding. */ private static String getSignatureForUnknown(ICPPUnknownBinding binding) { - try { - IBinding owner= binding.getOwner(); - if (owner instanceof IType) { - return ASTTypeUtil.getType((IType) owner, true) + SCOPE_OP + binding.getName(); - } - } catch (DOMException e) { - // ignore qualification + IBinding owner= binding.getOwner(); + if (owner instanceof IType) { + return ASTTypeUtil.getType((IType) owner, true) + SCOPE_OP + binding.getName(); } return binding.getName(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTElaboratedTypeSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTElaboratedTypeSpecifier.java index 8ce360f7de3..85735f522ca 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTElaboratedTypeSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTElaboratedTypeSpecifier.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 IBM Corporation and others. + * Copyright (c) 2005, 2010 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 @@ -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.IASTCompletionContext; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; @@ -122,19 +121,15 @@ public class CASTElaboratedTypeSpecifier extends CASTBaseDeclSpecifier implement IBinding b= result[i]; if (b instanceof ICompositeType) { ICompositeType ct= (ICompositeType) b; - try { - switch (ct.getKey()) { - case ICompositeType.k_struct: - if (getKind() != k_struct) - b= null; - break; - case ICompositeType.k_union: - if (getKind() != k_union) - b= null; - break; - } - } catch (DOMException e) { - // ignore and propose binding + switch (ct.getKey()) { + case ICompositeType.k_struct: + if (getKind() != k_struct) + b= null; + break; + case ICompositeType.k_union: + if (getKind() != k_union) + b= null; + break; } } else if (b instanceof IEnumeration) { if (getKind() != k_enum) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTName.java index 59f87c84686..ea060c36936 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTName.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTName.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. + * Copyright (c) 2005, 2010 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 @@ -13,10 +13,8 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; -import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.ILinkage; import org.eclipse.cdt.core.dom.ast.ASTVisitor; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTCompletionContext; import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IASTName; @@ -223,22 +221,17 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext if (bindings[i] instanceof ICompositeType) { ICompositeType type = (ICompositeType) bindings[i]; - try { - switch (type.getKey()) { - case ICompositeType.k_struct: - if (kind != IASTElaboratedTypeSpecifier.k_struct) { - bindings[i] = null; - } - break; - case ICompositeType.k_union: - if (kind != IASTElaboratedTypeSpecifier.k_union) { - bindings[i] = null; - } - break; + switch (type.getKey()) { + case ICompositeType.k_struct: + if (kind != IASTElaboratedTypeSpecifier.k_struct) { + bindings[i] = null; } - } catch (DOMException e) { - bindings[i] = null; - CCorePlugin.log(e); + break; + case ICompositeType.k_union: + if (kind != IASTElaboratedTypeSpecifier.k_union) { + bindings[i] = null; + } + break; } } else { bindings[i]= null; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CBuiltinVariable.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CBuiltinVariable.java index ba0a01f0d50..e7eebbfed0b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CBuiltinVariable.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CBuiltinVariable.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Wind River Systems Inc. and others. + * Copyright (c) 2008, 2010 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.IASTNode; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IScope; @@ -72,7 +71,7 @@ public class CBuiltinVariable extends CVariable { @Override - public IBinding getOwner() throws DOMException { + public IBinding getOwner() { return null; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CEnumeration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CEnumeration.java index c37dc247e3b..3bf43a32038 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CEnumeration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CEnumeration.java @@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.core.dom.parser.c; import org.eclipse.cdt.core.dom.ILinkage; import org.eclipse.cdt.core.dom.ast.ASTNodeProperty; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier; @@ -176,7 +175,7 @@ public class CEnumeration extends PlatformObject implements IEnumeration, ICInte return definition; } - public IBinding getOwner() throws DOMException { + public IBinding getOwner() { IASTNode node= definition; if (node == null && declarations != null && declarations.length > 0) { node= declarations[0]; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CEnumerator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CEnumerator.java index adcf6509351..dd1a7c1c05a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CEnumerator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CEnumerator.java @@ -12,7 +12,6 @@ package org.eclipse.cdt.internal.core.dom.parser.c; import org.eclipse.cdt.core.dom.ILinkage; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier; import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator; import org.eclipse.cdt.core.dom.ast.IASTName; @@ -35,9 +34,6 @@ public class CEnumerator extends PlatformObject implements IEnumerator { public static class CEnumeratorProblem extends ProblemBinding implements IEnumerator { public CEnumeratorProblem(IASTNode node, int id, char[] arg) { super(node, id, arg); - } - public IType getType() throws DOMException { - throw new DOMException(this); } public IValue getValue() { return Value.UNKNOWN; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CField.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CField.java index 03431008048..c88486330eb 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CField.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CField.java @@ -1,47 +1,42 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. + * Copyright (c) 2005, 2010 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 + * Andrew Niefer (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.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.ICompositeType; import org.eclipse.cdt.core.dom.ast.IField; import org.eclipse.cdt.core.dom.ast.c.ICCompositeTypeScope; -/** - * Created on Nov 8, 2004 - * @author aniefer - */ public class CField extends CVariable implements IField { - public static class CFieldProblem extends CVariable.CVariableProblem implements IField { - public CFieldProblem(IASTNode node, int id, char[] arg) { - super(node, id, arg); - } + public static class CFieldProblem extends CVariable.CVariableProblem implements IField { + private ICompositeType fOwner; - public ICompositeType getCompositeTypeOwner() throws DOMException { - throw new DOMException(this); + public CFieldProblem(ICompositeType owner, IASTNode node, int id, char[] arg) { + super(node, id, arg); + fOwner = owner; } - } - /** - * @param name - */ + public ICompositeType getCompositeTypeOwner() { + return fOwner; + } + } + public CField(IASTName name) { super(name); } - - public ICompositeType getCompositeTypeOwner() throws DOMException { + + public ICompositeType getCompositeTypeOwner() { ICCompositeTypeScope scope = (ICCompositeTypeScope) getScope(); return scope.getCompositeType(); } + } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunction.java index 1c1a1ba89e3..0624d1fac92 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunction.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 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 @@ -12,7 +12,6 @@ package org.eclipse.cdt.internal.core.dom.parser.c; import org.eclipse.cdt.core.dom.ILinkage; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; @@ -472,7 +471,7 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu return definition; } - public IBinding getOwner() throws DOMException { + public IBinding getOwner() { return null; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunctionScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunctionScope.java index 9382bdf2f35..61ed52b7dd0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunctionScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunctionScope.java @@ -1,16 +1,16 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. + * Copyright (c) 2005, 2010 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 + * Andrew Niefer (IBM Rational Software) - Initial API and implementation *******************************************************************************/ - package org.eclipse.cdt.internal.core.dom.parser.c; +import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.EScopeKind; import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement; import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition; @@ -20,14 +20,9 @@ import org.eclipse.cdt.core.dom.ast.IASTStatement; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.ILabel; import org.eclipse.cdt.core.dom.ast.IScope; -import org.eclipse.cdt.core.dom.ast.c.CASTVisitor; import org.eclipse.cdt.core.dom.ast.c.ICFunctionScope; import org.eclipse.cdt.core.parser.util.ArrayUtil; -/** - * Created on Nov 8, 2004 - * @author aniefer - */ public class CFunctionScope extends CScope implements ICFunctionScope { public CFunctionScope( IASTFunctionDefinition function ){ super( function, EScopeKind.eLocal); @@ -67,7 +62,7 @@ public class CFunctionScope extends CScope implements ICFunctionScope { return (ILabel[]) ArrayUtil.trim( ILabel.class, result ); } - static private class FindLabelsAction extends CASTVisitor { + static private class FindLabelsAction extends ASTVisitor { public IASTLabelStatement [] labels = null; public FindLabelsAction(){ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CKnRParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CKnRParameter.java index 746eb6a8b22..212ab0662cf 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CKnRParameter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CKnRParameter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. + * Copyright (c) 2005, 2010 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 @@ -12,7 +12,6 @@ package org.eclipse.cdt.internal.core.dom.parser.c; import org.eclipse.cdt.core.dom.ILinkage; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier; @@ -123,7 +122,7 @@ public class CKnRParameter extends PlatformObject implements IParameter { return Linkage.C_LINKAGE; } - public IBinding getOwner() throws DOMException { + public IBinding getOwner() { return CVisitor.findEnclosingFunction(declaration); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CLabel.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CLabel.java index aa8a72eddbc..e2835fdb0a0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CLabel.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CLabel.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2010 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 @@ -12,7 +12,6 @@ package org.eclipse.cdt.internal.core.dom.parser.c; import org.eclipse.cdt.core.dom.ILinkage; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTLabelStatement; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; @@ -20,65 +19,60 @@ import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.ILabel; import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.internal.core.dom.Linkage; -import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; import org.eclipse.core.runtime.PlatformObject; /** * Represents a label. */ public class CLabel extends PlatformObject implements ILabel { - - public static class CLabelProblem extends ProblemBinding implements ILabel { - public CLabelProblem(IASTNode node, int id, char[] arg) { - super(node, id, arg); - } - public IASTLabelStatement getLabelStatement() throws DOMException { - throw new DOMException(this); - } - } - - private final IASTName labelStatement; - - public CLabel(IASTName statement) { - labelStatement = statement; - statement.setBinding(this); - } + private final IASTName labelStatement; - public IASTNode getPhysicalNode() { - return labelStatement; - } + public CLabel(IASTName statement) { + labelStatement = statement; + statement.setBinding(this); + } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.ILabel#getLabelStatement() - */ - public IASTLabelStatement getLabelStatement() { - return (IASTLabelStatement) labelStatement.getParent(); - } + public IASTNode getPhysicalNode() { + return labelStatement; + } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IBinding#getName() - */ - public String getName() { - return labelStatement.toString(); - } + /* + * (non-Javadoc) + * + * @see org.eclipse.cdt.core.dom.ast.ILabel#getLabelStatement() + */ + public IASTLabelStatement getLabelStatement() { + return (IASTLabelStatement) labelStatement.getParent(); + } - public char[] getNameCharArray() { - return labelStatement.toCharArray(); - } + /* + * (non-Javadoc) + * + * @see org.eclipse.cdt.core.dom.ast.IBinding#getName() + */ + public String getName() { + return labelStatement.toString(); + } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IBinding#getScope() - */ - public IScope getScope() { - return CVisitor.getContainingScope(labelStatement.getParent()); - } + public char[] getNameCharArray() { + return labelStatement.toCharArray(); + } - public ILinkage getLinkage() { + /* + * (non-Javadoc) + * + * @see org.eclipse.cdt.core.dom.ast.IBinding#getScope() + */ + public IScope getScope() { + return CVisitor.getContainingScope(labelStatement.getParent()); + } + + public ILinkage getLinkage() { return Linkage.C_LINKAGE; } - - public IBinding getOwner() throws DOMException { + + public IBinding getOwner() { return CVisitor.findEnclosingFunction(labelStatement); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CParameter.java index 6c8bc42758b..4fac804d4cf 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CParameter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CParameter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 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 @@ -12,7 +12,6 @@ package org.eclipse.cdt.internal.core.dom.parser.c; import org.eclipse.cdt.core.dom.ILinkage; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement; import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; @@ -38,151 +37,147 @@ import org.eclipse.core.runtime.PlatformObject; * Represents the parameter of a function. */ public class CParameter extends PlatformObject implements IParameter { - public static class CParameterProblem extends ProblemBinding implements IParameter { - public CParameterProblem(IASTNode node, int id, char[] arg) { - super(node, id, arg); - } - public IType getType() throws DOMException { - throw new DOMException(this); - } - public boolean isStatic() throws DOMException { - throw new DOMException(this); - } - public boolean isExtern() throws DOMException { - throw new DOMException(this); - } - public boolean isAuto() throws DOMException { - throw new DOMException(this); - } - public boolean isRegister() throws DOMException { - throw new DOMException(this); - } - public IValue getInitialValue() { - return null; + public static class CParameterProblem extends ProblemBinding implements IParameter { + public CParameterProblem(IASTNode node, int id, char[] arg) { + super(node, id, arg); } - } - + } + private IASTName[] declarations; private IType type = null; - + public CParameter(IASTName parameterName) { this.declarations = new IASTName[] { parameterName }; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.eclipse.cdt.core.dom.ast.IVariable#getType() */ - - public IType getType() { + + public IType getType() { if (type == null && declarations[0].getParent() instanceof IASTDeclarator) - type = CVisitor.createType((IASTDeclarator)declarations[0].getParent()); - + type = CVisitor.createType((IASTDeclarator) declarations[0].getParent()); + return type; } - private IASTName getPrimaryDeclaration() { - if (declarations != null) { - for (int i = 0; i < declarations.length && declarations[i] != null; i++) { - IASTNode node = declarations[i].getParent(); - while (!(node instanceof IASTDeclaration)) - node = node.getParent(); - - if (node.getPropertyInParent() == ICASTKnRFunctionDeclarator.FUNCTION_PARAMETER || - node instanceof IASTFunctionDefinition) { - return declarations[i]; - } - } - return declarations[0]; - } - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IBinding#getName() - */ - public String getName() { - IASTName name = getPrimaryDeclaration(); - if (name != null) - return name.toString(); - return CVisitor.EMPTY_STRING; - } + private IASTName getPrimaryDeclaration() { + if (declarations != null) { + for (int i = 0; i < declarations.length && declarations[i] != null; i++) { + IASTNode node = declarations[i].getParent(); + while (!(node instanceof IASTDeclaration)) + node = node.getParent(); - public char[] getNameCharArray() { - IASTName name = getPrimaryDeclaration(); - if (name != null) - return name.toCharArray(); - return CVisitor.EMPTY_CHAR_ARRAY; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IBinding#getScope() - */ - public IScope getScope() { - //IASTParameterDeclaration or IASTSimpleDeclaration - for (int i = 0; i < declarations.length; i++) { - IASTNode parent = declarations[i].getParent(); - if (parent instanceof ICASTKnRFunctionDeclarator) { - parent = parent.getParent(); - return ((IASTCompoundStatement)((IASTFunctionDefinition) parent).getBody()).getScope(); - } - - IASTNode fdtorNode = parent.getParent().getParent(); - if (fdtorNode instanceof IASTFunctionDeclarator) { - IASTFunctionDeclarator fdtor = (IASTFunctionDeclarator) fdtorNode; - parent = fdtor.getParent(); - if (parent instanceof IASTFunctionDefinition) { - return ((IASTCompoundStatement)((IASTFunctionDefinition) parent).getBody()).getScope(); + if (node.getPropertyInParent() == ICASTKnRFunctionDeclarator.FUNCTION_PARAMETER + || node instanceof IASTFunctionDefinition) { + return declarations[i]; } - } - } - //TODO: if not definition, find definition + } + return declarations[0]; + } return null; } - /** - * @param name - */ + /* + * (non-Javadoc) + * + * @see org.eclipse.cdt.core.dom.ast.IBinding#getName() + */ + public String getName() { + IASTName name = getPrimaryDeclaration(); + if (name != null) + return name.toString(); + return CVisitor.EMPTY_STRING; + } + + public char[] getNameCharArray() { + IASTName name = getPrimaryDeclaration(); + if (name != null) + return name.toCharArray(); + return CVisitor.EMPTY_CHAR_ARRAY; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.cdt.core.dom.ast.IBinding#getScope() + */ + public IScope getScope() { + // IASTParameterDeclaration or IASTSimpleDeclaration + for (IASTName declaration : declarations) { + IASTNode parent = declaration.getParent(); + if (parent instanceof ICASTKnRFunctionDeclarator) { + parent = parent.getParent(); + return ((IASTCompoundStatement) ((IASTFunctionDefinition) parent).getBody()).getScope(); + } + + IASTNode fdtorNode = parent.getParent().getParent(); + if (fdtorNode instanceof IASTFunctionDeclarator) { + IASTFunctionDeclarator fdtor = (IASTFunctionDeclarator) fdtorNode; + parent = fdtor.getParent(); + if (parent instanceof IASTFunctionDefinition) { + return ((IASTCompoundStatement) ((IASTFunctionDefinition) parent).getBody()).getScope(); + } + } + } + // TODO: if not definition, find definition + return null; + } + + /** + * @param name + */ public void addDeclaration(IASTName name) { if (name != null && name.isActive()) declarations = (IASTName[]) ArrayUtil.append(IASTName.class, declarations, name); } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IVariable#isStatic() - */ - public boolean isStatic() { - return false; - } + /* + * (non-Javadoc) + * + * @see org.eclipse.cdt.core.dom.ast.IVariable#isStatic() + */ + public boolean isStatic() { + return false; + } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IVariable#isExtern() - */ - public boolean isExtern() { - return false; - } + /* + * (non-Javadoc) + * + * @see org.eclipse.cdt.core.dom.ast.IVariable#isExtern() + */ + public boolean isExtern() { + return false; + } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IVariable#isAuto() - */ - public boolean isAuto() { - return hasStorageClass(IASTDeclSpecifier.sc_auto); - } + /* + * (non-Javadoc) + * + * @see org.eclipse.cdt.core.dom.ast.IVariable#isAuto() + */ + public boolean isAuto() { + return hasStorageClass(IASTDeclSpecifier.sc_auto); + } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IVariable#isRegister() - */ - public boolean isRegister() { - return hasStorageClass(IASTDeclSpecifier.sc_register); - } + /* + * (non-Javadoc) + * + * @see org.eclipse.cdt.core.dom.ast.IVariable#isRegister() + */ + public boolean isRegister() { + return hasStorageClass(IASTDeclSpecifier.sc_register); + } - public boolean hasStorageClass(int storage) { + public boolean hasStorageClass(int storage) { if (declarations == null) return false; - + for (int i = 0; i < declarations.length && declarations[i] != null; i++) { - IASTNode parent= declarations[i].getParent(); + IASTNode parent = declarations[i].getParent(); while (!(parent instanceof IASTParameterDeclaration) && !(parent instanceof IASTDeclaration)) - parent= parent.getParent(); + parent = parent.getParent(); IASTDeclSpecifier declSpec = null; if (parent instanceof IASTSimpleDeclaration) { @@ -195,15 +190,15 @@ public class CParameter extends PlatformObject implements IParameter { } return false; } - + public ILinkage getLinkage() { return Linkage.C_LINKAGE; } - - public IBinding getOwner() throws DOMException { + + public IBinding getOwner() { if (declarations == null || declarations.length == 0) return null; - + return CVisitor.findEnclosingFunction(declarations[0]); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CScope.java index 48cc051427d..1f3ca719b5e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CScope.java @@ -17,7 +17,7 @@ import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.ILinkage; import org.eclipse.cdt.core.dom.IName; import org.eclipse.cdt.core.dom.ast.ASTNodeProperty; -import org.eclipse.cdt.core.dom.ast.DOMException; +import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.EScopeKind; import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement; @@ -27,6 +27,7 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier; +import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator; import org.eclipse.cdt.core.dom.ast.IASTForStatement; import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator; import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition; @@ -44,8 +45,6 @@ import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.ICompositeType; import org.eclipse.cdt.core.dom.ast.IEnumeration; import org.eclipse.cdt.core.dom.ast.IScope; -import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator; -import org.eclipse.cdt.core.dom.ast.c.CASTVisitor; import org.eclipse.cdt.core.dom.ast.c.ICASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.c.ICASTElaboratedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.c.ICASTEnumerationSpecifier; @@ -129,7 +128,7 @@ public class CScope implements ICScope, IASTInternalScope { return CVisitor.getContainingScope( physicalNode ); } - protected static class CollectNamesAction extends CASTVisitor { + protected static class CollectNamesAction extends ASTVisitor { private char [] name; private IASTName [] result = null; CollectNamesAction( char [] n ){ @@ -163,7 +162,7 @@ public class CScope implements ICScope, IASTInternalScope { /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String) */ - public IBinding[] find(String name) throws DOMException { + public IBinding[] find(String name) { return CVisitor.findBindings(this, name); } @@ -235,7 +234,7 @@ public class CScope implements ICScope, IASTInternalScope { return getBinding(name, resolve, IIndexFileSet.EMPTY); } - public final IBinding[] getBindings(IASTName name, boolean resolve, boolean prefix) throws DOMException { + public final IBinding[] getBindings(IASTName name, boolean resolve, boolean prefix) { return getBindings(name, resolve, prefix, IIndexFileSet.EMPTY); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CStructure.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CStructure.java index 76faee98833..bc7810c1c4f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CStructure.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CStructure.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 IBM Corporation and others. + * Copyright (c) 2005, 2010 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,25 +45,26 @@ import org.eclipse.core.runtime.PlatformObject; * Represents structs and unions. */ public class CStructure extends PlatformObject implements ICompositeType, ICInternalBinding { - + public static class CStructureProblem extends ProblemBinding implements ICompositeType { public CStructureProblem(IASTNode node, int id, char[] arg) { super(node, id, arg); } - public IField findField(String name) throws DOMException { - throw new DOMException(this); + + public IField findField(String name) { + return null; } - public IScope getCompositeScope() throws DOMException { - throw new DOMException(this); + + public IScope getCompositeScope() { + return this; } - public IField[] getFields() throws DOMException { - throw new DOMException(this); + + public IField[] getFields() { + return IField.EMPTY_FIELD_ARRAY; } - public int getKey() throws DOMException { - throw new DOMException(this); - } - public boolean isAnonymous() throws DOMException { - throw new DOMException(this); + + public int getKey() { + return k_struct; } } @@ -71,20 +72,20 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte private IASTName definition; private boolean checked; private ICompositeType typeInIndex; - + public CStructure(IASTName name) { - if (name.getPropertyInParent() == IASTCompositeTypeSpecifier.TYPE_NAME) { - definition = name; - } else { - declarations = new IASTName[] { name }; - } - name.setBinding(this); + if (name.getPropertyInParent() == IASTCompositeTypeSpecifier.TYPE_NAME) { + definition = name; + } else { + declarations = new IASTName[] { name }; + } + name.setBinding(this); } - - public IASTNode getPhysicalNode() { - return (definition != null) ? (IASTNode)definition : (IASTNode)declarations[0]; - } - + + public IASTNode getPhysicalNode() { + return (definition != null) ? (IASTNode) definition : (IASTNode) declarations[0]; + } + private void checkForDefinition() { if (!checked && definition == null) { IASTNode declSpec = declarations[0].getParent(); @@ -92,23 +93,25 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte IASTDeclSpecifier spec = CVisitor.findDefinition((ICASTElaboratedTypeSpecifier) declSpec); if (spec instanceof ICASTCompositeTypeSpecifier) { ICASTCompositeTypeSpecifier compTypeSpec = (ICASTCompositeTypeSpecifier) spec; - definition= compTypeSpec.getName(); + definition = compTypeSpec.getName(); definition.setBinding(this); } } if (definition == null && typeInIndex == null) { final IASTTranslationUnit translationUnit = declSpec.getTranslationUnit(); - IIndex index= translationUnit.getIndex(); + IIndex index = translationUnit.getIndex(); if (index != null) { - typeInIndex= (ICompositeType) index.adaptBinding(this); + typeInIndex = (ICompositeType) index.adaptBinding(this); } } } checked = true; } - - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see org.eclipse.cdt.core.dom.ast.IBinding#getName() */ public String getName() { @@ -117,6 +120,7 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte return declarations[0].toString(); } + public char[] getNameCharArray() { if (definition != null) return definition.toCharArray(); @@ -124,29 +128,33 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte return declarations[0].toCharArray(); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.eclipse.cdt.core.dom.ast.IBinding#getScope() */ public IScope getScope() throws DOMException { - IASTDeclSpecifier declSpec = (IASTDeclSpecifier) ((definition != null) ? (IASTNode)definition.getParent() : declarations[0].getParent()); + IASTDeclSpecifier declSpec = (IASTDeclSpecifier) ((definition != null) ? (IASTNode) definition + .getParent() : declarations[0].getParent()); IScope scope = CVisitor.getContainingScope(declSpec); - while(scope instanceof ICCompositeTypeScope) { + while (scope instanceof ICCompositeTypeScope) { scope = scope.getParent(); } return scope; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.eclipse.cdt.core.dom.ast.ICompositeType#getFields() */ - public IField[] getFields() throws DOMException { + public IField[] getFields() { checkForDefinition(); if (definition == null) { - return new IField[] { - new CField.CFieldProblem(declarations[0], IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, getNameCharArray()) - }; + return new IField[] { new CField.CFieldProblem(this, declarations[0], + IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, getNameCharArray()) }; } - ICASTCompositeTypeSpecifier compSpec = (ICASTCompositeTypeSpecifier) definition.getParent(); + ICASTCompositeTypeSpecifier compSpec = (ICASTCompositeTypeSpecifier) definition.getParent(); IField[] fields = collectFields(compSpec, null); return (IField[]) ArrayUtil.trim(IField.class, fields); } @@ -162,7 +170,7 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte if (declarators.length == 0) { IASTDeclSpecifier declspec = ((IASTSimpleDeclaration) node).getDeclSpecifier(); if (declspec instanceof ICASTCompositeTypeSpecifier) { - fields= collectFields((ICASTCompositeTypeSpecifier) declspec, fields); + fields = collectFields((ICASTCompositeTypeSpecifier) declspec, fields); } } else { for (IASTDeclarator declarator : declarators) { @@ -178,10 +186,11 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte return fields; } - public IField findField(String name) throws DOMException { + public IField findField(String name) { IScope scope = getCompositeScope(); if (scope == null) { - return new CField.CFieldProblem(declarations[0], IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, getNameCharArray()); + return new CField.CFieldProblem(this, declarations[0], + IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, getNameCharArray()); } final CASTName astName = new CASTName(name.toCharArray()); @@ -189,49 +198,49 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte IBinding binding = scope.getBinding(astName, true); if (binding instanceof IField) return (IField) binding; - + return null; } - - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see org.eclipse.cdt.core.dom.ast.ICompositeType#getKey() */ public int getKey() { - return (definition != null) ? ((IASTCompositeTypeSpecifier)definition.getParent()).getKey() - : ((IASTElaboratedTypeSpecifier)declarations[0].getParent()).getKind(); + return (definition != null) ? ((IASTCompositeTypeSpecifier) definition.getParent()).getKey() + : ((IASTElaboratedTypeSpecifier) declarations[0].getParent()).getKind(); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.eclipse.cdt.core.dom.ast.ICompositeType#getCompositeScope() */ public IScope getCompositeScope() { checkForDefinition(); if (definition != null) { - return ((IASTCompositeTypeSpecifier)definition.getParent()).getScope(); + return ((IASTCompositeTypeSpecifier) definition.getParent()).getScope(); } // fwd-declarations must be backed up from the index if (typeInIndex != null) { - try { - IScope scope = typeInIndex.getCompositeScope(); - if (scope instanceof ICCompositeTypeScope) - return scope; - } catch (DOMException e) { - // index bindings don't throw DOMExeptions. - } + IScope scope = typeInIndex.getCompositeScope(); + if (scope instanceof ICCompositeTypeScope) + return scope; } return null; } - - @Override + + @Override public Object clone() { - IType t = null; - try { - t = (IType) super.clone(); - } catch (CloneNotSupportedException e) { - //not going to happen - } - return t; - } + IType t = null; + try { + t = (IType) super.clone(); + } catch (CloneNotSupportedException e) { + // not going to happen + } + return t; + } public void addDefinition(ICASTCompositeTypeSpecifier compositeTypeSpec) { if (compositeTypeSpec.isActive()) { @@ -239,7 +248,7 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte compositeTypeSpec.getName().setBinding(this); } } - + public void addDeclaration(IASTName decl) { if (!decl.isActive() || decl.getPropertyInParent() != IASTElaboratedTypeSpecifier.TYPE_NAME) return; @@ -249,18 +258,19 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte declarations = new IASTName[] { decl }; return; } - IASTName first= declarations[0]; + IASTName first = declarations[0]; if (((ASTNode) first).getOffset() > ((ASTNode) decl).getOffset()) { - declarations[0]= decl; - decl= first; + declarations[0] = decl; + decl = first; } - declarations= (IASTName[]) ArrayUtil.append(IASTName.class, declarations, decl); + declarations = (IASTName[]) ArrayUtil.append(IASTName.class, declarations, decl); } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType) - */ + /* + * (non-Javadoc) + * + * @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType) + */ public boolean isSameType(IType type) { if (type == this) return true; @@ -268,7 +278,7 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte return type.isSameType(this); return false; } - + public ILinkage getLinkage() { return Linkage.C_LINKAGE; } @@ -280,31 +290,31 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte public IASTNode getDefinition() { return definition; } - - public IBinding getOwner() throws DOMException { - IASTNode node= definition; + + public IBinding getOwner() { + IASTNode node = definition; if (node == null) { - if (declarations != null && declarations.length > 0) { - node= declarations[0]; + if (declarations != null && declarations.length > 0) { + node = declarations[0]; } } - IBinding result= CVisitor.findEnclosingFunction(node); // local or global + IBinding result = CVisitor.findEnclosingFunction(node); // local or global if (result != null) return result; - + if (definition != null && isAnonymous()) { return CVisitor.findDeclarationOwner(definition, false); } return null; } - - public boolean isAnonymous() throws DOMException { - if (getNameCharArray().length > 0 || definition == null) + + public boolean isAnonymous() { + if (getNameCharArray().length > 0 || definition == null) return false; - - IASTCompositeTypeSpecifier spec= ((IASTCompositeTypeSpecifier)definition.getParent()); + + IASTCompositeTypeSpecifier spec = ((IASTCompositeTypeSpecifier) definition.getParent()); if (spec != null) { - IASTNode node= spec.getParent(); + IASTNode node = spec.getParent(); if (node instanceof IASTSimpleDeclaration) { if (((IASTSimpleDeclaration) node).getDeclarators().length == 0) { return true; 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 a622fbe2f0b..33d2115f1d2 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, 2009 IBM Corporation and others. + * Copyright (c) 2005, 2010 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 @@ -12,7 +12,6 @@ package org.eclipse.cdt.internal.core.dom.parser.c; import org.eclipse.cdt.core.dom.ILinkage; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; @@ -111,7 +110,7 @@ public class CTypedef extends PlatformObject implements ITypedef, ITypeContainer return name; } - public IBinding getOwner() throws DOMException { + public IBinding getOwner() { return CVisitor.findEnclosingFunction(name); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVariable.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVariable.java index d38d0ee63dd..68bd3200218 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVariable.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVariable.java @@ -12,7 +12,6 @@ package org.eclipse.cdt.internal.core.dom.parser.c; import org.eclipse.cdt.core.dom.ILinkage; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; @@ -40,39 +39,22 @@ import org.eclipse.core.runtime.PlatformObject; * Binding for a global or a local variable, serves as base class for fields. */ public class CVariable extends PlatformObject implements IInternalVariable, ICInternalBinding { - public static class CVariableProblem extends ProblemBinding implements IVariable { - public CVariableProblem(IASTNode node, int id, char[] arg) { - super(node, id, arg); - } - - public IType getType() throws DOMException { - throw new DOMException(this); - } - public boolean isStatic() throws DOMException { - throw new DOMException(this); - } - public boolean isExtern() throws DOMException { - throw new DOMException(this); - } - public boolean isAuto() throws DOMException { - throw new DOMException(this); - } - public boolean isRegister() throws DOMException { - throw new DOMException(this); - } - public IValue getInitialValue() { - return null; + public static class CVariableProblem extends ProblemBinding implements IVariable { + public CVariableProblem(IASTNode node, int id, char[] arg) { + super(node, id, arg); } - } + } + private IASTName[] declarations = null; private IType type = null; - + public CVariable(IASTName name) { declarations = new IASTName[] { name }; } - public IASTNode getPhysicalNode() { - return declarations[0]; - } + + public IASTNode getPhysicalNode() { + return declarations[0]; + } public void addDeclaration(IASTName name) { if (name != null && name.isActive()) { @@ -80,16 +62,20 @@ public class CVariable extends PlatformObject implements IInternalVariable, ICIn } } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.eclipse.cdt.core.dom.ast.IVariable#getType() */ public IType getType() { if (type == null && declarations[0].getParent() instanceof IASTDeclarator) - type = CVisitor.createType((IASTDeclarator)declarations[0].getParent()); + type = CVisitor.createType((IASTDeclarator) declarations[0].getParent()); return type; } - - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see org.eclipse.cdt.core.dom.ast.IBinding#getName() */ public String getName() { @@ -97,10 +83,12 @@ public class CVariable extends PlatformObject implements IInternalVariable, ICIn } public char[] getNameCharArray() { - return declarations[0].toCharArray(); + return declarations[0].toCharArray(); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.eclipse.cdt.core.dom.ast.IBinding#getScope() */ public IScope getScope() { @@ -108,109 +96,116 @@ public class CVariable extends PlatformObject implements IInternalVariable, ICIn return CVisitor.getContainingScope(declarator.getParent()); } - public boolean isStatic() { + public boolean isStatic() { return hasStorageClass(IASTDeclSpecifier.sc_static); } - public boolean hasStorageClass(int storage) { - if (declarations == null) - return false; - - for (int i = 0; i < declarations.length && declarations[i] != null; i++) { - final IASTName name = declarations[i]; + public boolean hasStorageClass(int storage) { + if (declarations == null) + return false; + + for (int i = 0; i < declarations.length && declarations[i] != null; i++) { + final IASTName name = declarations[i]; IASTNode parent = name.getParent(); - while (!(parent instanceof IASTDeclaration)) - parent = parent.getParent(); - - if (parent instanceof IASTSimpleDeclaration) { - IASTDeclSpecifier declSpec = ((IASTSimpleDeclaration) parent).getDeclSpecifier(); - if (declSpec.getStorageClass() == storage) { - return true; - } - } - } - return false; + while (!(parent instanceof IASTDeclaration)) + parent = parent.getParent(); + + if (parent instanceof IASTSimpleDeclaration) { + IASTDeclSpecifier declSpec = ((IASTSimpleDeclaration) parent).getDeclSpecifier(); + if (declSpec.getStorageClass() == storage) { + return true; + } + } + } + return false; } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IVariable#isExtern() - */ - public boolean isExtern() { - return hasStorageClass(IASTDeclSpecifier.sc_extern); - } + /* + * (non-Javadoc) + * + * @see org.eclipse.cdt.core.dom.ast.IVariable#isExtern() + */ + public boolean isExtern() { + return hasStorageClass(IASTDeclSpecifier.sc_extern); + } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IVariable#isAuto() - */ - public boolean isAuto() { - return hasStorageClass(IASTDeclSpecifier.sc_auto); - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IVariable#isRegister() - */ - public boolean isRegister() { - return hasStorageClass(IASTDeclSpecifier.sc_register); - } - - public ILinkage getLinkage() { + /* + * (non-Javadoc) + * + * @see org.eclipse.cdt.core.dom.ast.IVariable#isAuto() + */ + public boolean isAuto() { + return hasStorageClass(IASTDeclSpecifier.sc_auto); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.cdt.core.dom.ast.IVariable#isRegister() + */ + public boolean isRegister() { + return hasStorageClass(IASTDeclSpecifier.sc_register); + } + + public ILinkage getLinkage() { return Linkage.C_LINKAGE; } - public IASTNode[] getDeclarations() { + public IASTNode[] getDeclarations() { return declarations; } - public IASTNode getDefinition() { + public IASTNode getDefinition() { return getPhysicalNode(); } - public IBinding getOwner() throws DOMException { + public IBinding getOwner() { if (declarations == null || declarations.length == 0) return null; - + return CVisitor.findDeclarationOwner(declarations[0], true); } - + public IValue getInitialValue() { return getInitialValue(Value.MAX_RECURSION_DEPTH); } - + public IValue getInitialValue(int maxDepth) { if (declarations != null) { for (IASTName decl : declarations) { if (decl == null) break; - final IValue val= getInitialValue(decl, maxDepth); + final IValue val = getInitialValue(decl, maxDepth); if (val != null) return val; } - } + } return null; } - + private IValue getInitialValue(IASTName name, int maxDepth) { - IASTDeclarator dtor= findDeclarator(name); + IASTDeclarator dtor = findDeclarator(name); if (dtor != null) { - IASTInitializer init= dtor.getInitializer(); + IASTInitializer init = dtor.getInitializer(); if (init instanceof IASTEqualsInitializer) { - final IASTInitializerClause initClause = ((IASTEqualsInitializer) init).getInitializerClause(); + final IASTInitializerClause initClause = ((IASTEqualsInitializer) init) + .getInitializerClause(); if (initClause instanceof IASTExpression) { return Value.create((IASTExpression) initClause, maxDepth); } - } + } if (init != null) return Value.UNKNOWN; } return null; } - - private IASTDeclarator findDeclarator(IASTName name) { - IASTNode node = name.getParent(); - if (!(node instanceof IASTDeclarator)) - return null; - return ASTQueries.findOutermostDeclarator((IASTDeclarator) node); - } + private IASTDeclarator findDeclarator(IASTName name) { + IASTNode node = name.getParent(); + if (!(node instanceof IASTDeclarator)) + return null; + + return ASTQueries.findOutermostDeclarator((IASTDeclarator) node); + } } 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 f9ad8d19bdd..bab4ffcf75e 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 @@ -17,6 +17,7 @@ import java.util.ArrayList; import java.util.List; import org.eclipse.cdt.core.dom.ast.ASTNodeProperty; +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; @@ -69,7 +70,6 @@ import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.IVariable; -import org.eclipse.cdt.core.dom.ast.c.CASTVisitor; import org.eclipse.cdt.core.dom.ast.c.ICASTArrayModifier; import org.eclipse.cdt.core.dom.ast.c.ICASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.c.ICASTDeclSpecifier; @@ -99,7 +99,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; * Collection of methods to find information in an AST. */ public class CVisitor extends ASTQueries { - public static class CollectProblemsAction extends CASTVisitor { + public static class CollectProblemsAction extends ASTVisitor { { shouldVisitDeclarations = true; shouldVisitExpressions = true; @@ -188,7 +188,7 @@ public class CVisitor extends ASTQueries { } } - public static class CollectDeclarationsAction extends CASTVisitor { + public static class CollectDeclarationsAction extends ASTVisitor { { shouldVisitDeclarators = true; shouldVisitDeclSpecifiers = true; @@ -341,7 +341,7 @@ public class CVisitor extends ASTQueries { } } - public static class CollectReferencesAction extends CASTVisitor { + public static class CollectReferencesAction extends ASTVisitor { private static final int DEFAULT_LIST_SIZE = 8; private IASTName[] refs; private IBinding binding; @@ -476,10 +476,7 @@ public class CVisitor extends ASTQueries { IScope scope = getContainingScope(enumeration); IBinding binding= null; if (scope != null) { - try { - binding = scope.getBinding(name, false); - } catch (DOMException e) { - } + binding = scope.getBinding(name, false); } if (binding != null && !(binding instanceof IIndexBinding) && name.isActive()) { if (binding instanceof IEnumeration) { @@ -516,7 +513,7 @@ public class CVisitor extends ASTQueries { } } //label not found - return new CLabel.CLabelProblem(((IASTGotoStatement)statement).getName(), IProblemBinding.SEMANTIC_LABEL_STATEMENT_NOT_FOUND, gotoName); + return new ProblemBinding(((IASTGotoStatement)statement).getName(), IProblemBinding.SEMANTIC_LABEL_STATEMENT_NOT_FOUND, gotoName); } } else if (statement instanceof IASTLabelStatement) { IASTName name = ((IASTLabelStatement)statement).getName(); @@ -558,16 +555,13 @@ public class CVisitor extends ASTQueries { binding= resolveBinding(elabTypeSpec); if (binding == null) { insertIntoScope= elabTypeSpec.getTranslationUnit().getScope(); - try { - binding= insertIntoScope.getBinding(name, false); - if (binding != null && name.isActive()) { - if (binding instanceof CEnumeration) { - ((CEnumeration)binding).addDeclaration(name); - } else if (binding instanceof CStructure) { - ((CStructure) binding).addDeclaration(name); - } - } - } catch (DOMException e) { + binding= insertIntoScope.getBinding(name, false); + if (binding != null && name.isActive()) { + if (binding instanceof CEnumeration) { + ((CEnumeration)binding).addDeclaration(name); + } else if (binding instanceof CStructure) { + ((CStructure) binding).addDeclaration(name); + } } } } @@ -612,41 +606,30 @@ public class CVisitor extends ASTQueries { } if (prefix) { IBinding[] result = null; - try { - char[] p = fieldReference.getFieldName().toCharArray(); - IField[] fields = ((ICompositeType) type).getFields(); - for (IField field : fields) { - if (CharArrayUtils.equals(field.getNameCharArray(), 0, p.length, p, true)) { - result = (IBinding[]) ArrayUtil.append(IBinding.class, result, field); - } - } - return ArrayUtil.trim(IBinding.class, result); - } catch (DOMException e) { - return new IBinding[] { e.getProblem() }; - } + char[] p = fieldReference.getFieldName().toCharArray(); + IField[] fields = ((ICompositeType) type).getFields(); + for (IField field : fields) { + if (CharArrayUtils.equals(field.getNameCharArray(), 0, p.length, p, true)) { + result = (IBinding[]) ArrayUtil.append(IBinding.class, result, field); + } + } + return ArrayUtil.trim(IBinding.class, result); } - try { - return ((ICompositeType) type).findField(fieldReference.getFieldName().toString()); - } catch (DOMException e) { - return e.getProblem(); - } + return ((ICompositeType) type).findField(fieldReference.getFieldName().toString()); } return null; } static IType getPtrDiffType(IASTBinaryExpression expr) { IScope scope = getContainingScope(expr); - try { - IBinding[] bs = scope.find(PTRDIFF_T); - for (IBinding b : bs) { - if (b instanceof IType) { - if (b instanceof ICInternalBinding == false || - CVisitor.declaredBefore(((ICInternalBinding) b).getPhysicalNode(), expr)) { - return (IType) b; - } + IBinding[] bs = scope.find(PTRDIFF_T); + for (IBinding b : bs) { + if (b instanceof IType) { + if (b instanceof ICInternalBinding == false || + CVisitor.declaredBefore(((ICInternalBinding) b).getPhysicalNode(), expr)) { + return (IType) b; } } - } catch (DOMException e) { } return new CBasicType(Kind.eInt, 0, expr); @@ -654,17 +637,14 @@ public class CVisitor extends ASTQueries { static IType getSize_T(IASTExpression expr) { IScope scope = getContainingScope(expr); - try { - IBinding[] bs = scope.find(SIZE_T); - for (IBinding b : bs) { - if (b instanceof IType) { - if (b instanceof ICInternalBinding == false || - CVisitor.declaredBefore(((ICInternalBinding) b).getPhysicalNode(), expr)) { - return (IType) b; - } + IBinding[] bs = scope.find(SIZE_T); + for (IBinding b : bs) { + if (b instanceof IType) { + if (b instanceof ICInternalBinding == false || + CVisitor.declaredBefore(((ICInternalBinding) b).getPhysicalNode(), expr)) { + return (IType) b; } } - } catch (DOMException e) { } return new CBasicType(Kind.eInt, IBasicType.IS_LONG | IBasicType.IS_UNSIGNED); } @@ -685,10 +665,7 @@ public class CVisitor extends ASTQueries { if (declarator instanceof ICASTKnRFunctionDeclarator) { if (CharArrayUtils.equals(declarator.getName().toCharArray(), name.toCharArray())) { IScope scope= CVisitor.getContainingScope(declarator); - try { - binding = scope.getBinding(name, false); - } catch (DOMException e) { - } + binding = scope.getBinding(name, false); if (binding != null && !(binding instanceof IIndexBinding) && name.isActive()) { if (binding instanceof ICInternalFunction) ((ICInternalFunction)binding).addDeclarator(declarator); @@ -725,11 +702,7 @@ public class CVisitor extends ASTQueries { IASTName name = declarator.getName(); - IBinding binding = null; - try { - binding = (scope != null) ? scope.getBinding(name, false) : null; - } catch (DOMException e1) { - } + IBinding binding = (scope != null) ? scope.getBinding(name, false) : null; boolean isFunction= false; if (parent instanceof IASTParameterDeclaration || parent.getPropertyInParent() == ICASTKnRFunctionDeclarator.FUNCTION_PARAMETER) { @@ -830,51 +803,31 @@ public class CVisitor extends ASTQueries { IASTFunctionDeclarator functionDeclartor = functionDef.getDeclarator(); IASTName name = findInnermostDeclarator(functionDeclartor).getName(); IScope scope = getContainingScope(node); - try { - return lookup(scope, name); - } catch (DOMException e) { - return null; - } + return lookup(scope, name); } else if (node instanceof IASTIdExpression) { IScope scope = getContainingScope(node); - try { - IBinding binding = lookup(scope, ((IASTIdExpression) node).getName()); - if (binding instanceof IType && !(binding instanceof IProblemBinding) ) { - return new ProblemBinding(node, IProblemBinding.SEMANTIC_INVALID_TYPE, - binding.getNameCharArray(), new IBinding[] { binding }); - } - return binding; - } catch (DOMException e) { - return null; - } + IBinding binding = lookup(scope, ((IASTIdExpression) node).getName()); + if (binding instanceof IType && !(binding instanceof IProblemBinding) ) { + return new ProblemBinding(node, IProblemBinding.SEMANTIC_INVALID_TYPE, + binding.getNameCharArray(), new IBinding[] { binding }); + } + return binding; } else if (node instanceof ICASTTypedefNameSpecifier) { IScope scope = getContainingScope(node); - try { - IASTName name= ((ICASTTypedefNameSpecifier) node).getName(); - IBinding binding = lookup(scope, name); - if (binding == null) - return new ProblemBinding(node, IProblemBinding.SEMANTIC_NAME_NOT_FOUND, name.toCharArray()); - if (binding instanceof IType) - return binding; - return new ProblemBinding(node, IProblemBinding.SEMANTIC_INVALID_TYPE, binding.getNameCharArray(), - new IBinding[] { binding }); - } catch (DOMException e) { - return null; - } + IASTName name= ((ICASTTypedefNameSpecifier) node).getName(); + IBinding binding = lookup(scope, name); + if (binding == null) + return new ProblemBinding(node, IProblemBinding.SEMANTIC_NAME_NOT_FOUND, name.toCharArray()); + if (binding instanceof IType) + return binding; + return new ProblemBinding(node, IProblemBinding.SEMANTIC_INVALID_TYPE, binding.getNameCharArray(), + new IBinding[] { binding }); } else if (node instanceof ICASTElaboratedTypeSpecifier) { IScope scope = getContainingScope(node); - try { - return lookup(scope, ((ICASTElaboratedTypeSpecifier) node).getName()); - } catch (DOMException e) { - return null; - } + return lookup(scope, ((ICASTElaboratedTypeSpecifier) node).getName()); } else if (node instanceof ICASTCompositeTypeSpecifier) { IScope scope = getContainingScope(node); - try { - return lookup(scope, ((ICASTCompositeTypeSpecifier)node).getName()); - } catch (DOMException e) { - return null; - } + return lookup(scope, ((ICASTCompositeTypeSpecifier)node).getName()); } else if (node instanceof IASTTypeId) { IASTTypeId typeId = (IASTTypeId) node; IASTDeclSpecifier declSpec = typeId.getDeclSpecifier(); @@ -919,11 +872,7 @@ public class CVisitor extends ASTQueries { struct = ((IASTCompositeTypeSpecifier)simpleDecl.getDeclSpecifier()).getName().resolveBinding(); if (struct instanceof CStructure) { - try { - return ((CStructure)struct).findField(((ICASTFieldDesignator)node).getName().toString()); - } catch (DOMException e) { - return e.getProblem(); - } + return ((CStructure)struct).findField(((ICASTFieldDesignator)node).getName().toString()); } else if (struct instanceof ITypeContainer) { IType type; type = ((ITypeContainer)struct).getType(); @@ -933,11 +882,7 @@ public class CVisitor extends ASTQueries { if (type instanceof CStructure) - try { - return ((CStructure)type).findField(((ICASTFieldDesignator)node).getName().toString()); - } catch (DOMException e1) { - return e1.getProblem(); - } + return ((CStructure)type).findField(((ICASTFieldDesignator)node).getName().toString()); } } } @@ -1069,7 +1014,7 @@ public class CVisitor extends ASTQueries { /** * Lookup for a name starting from the given scope. */ - protected static IBinding lookup(IScope scope, IASTName name) throws DOMException{ + protected static IBinding lookup(IScope scope, IASTName name) { if (scope == null) return null; @@ -1086,15 +1031,16 @@ public class CVisitor extends ASTQueries { } while (scope != null) { - try { - if (!(scope instanceof ICCompositeTypeScope)) { - IBinding binding = scope.getBinding(name, true, fileSet); - if (binding != null) - return binding; - } - } catch (DOMException e) { + if (!(scope instanceof ICCompositeTypeScope)) { + IBinding binding = scope.getBinding(name, true, fileSet); + if (binding != null) + return binding; + } + try { + scope= scope.getParent(); + } catch (DOMException e) { + scope= null; } - scope= scope.getParent(); } return externalBinding(tu, name); @@ -1123,23 +1069,20 @@ public class CVisitor extends ASTQueries { IBinding[] result = null; CharArraySet handled= new CharArraySet(1); while (scope != null) { - try { - if (!(scope instanceof ICCompositeTypeScope)) { - IBinding[] bindings= scope.getBindings(name, true, true, fileSet); - for (IBinding b : bindings) { - final char[] n= b.getNameCharArray(); - // consider binding only if no binding with the same name was found in another scope. - if (!handled.containsKey(n)) { - result= (IBinding[]) ArrayUtil.append(IBinding.class, result, b); - } - } - // store names of bindings - for (IBinding b : bindings) { - final char[] n= b.getNameCharArray(); - handled.put(n); + if (!(scope instanceof ICCompositeTypeScope)) { + IBinding[] bindings= scope.getBindings(name, true, true, fileSet); + for (IBinding b : bindings) { + final char[] n= b.getNameCharArray(); + // consider binding only if no binding with the same name was found in another scope. + if (!handled.containsKey(n)) { + result= (IBinding[]) ArrayUtil.append(IBinding.class, result, b); } } - } catch (DOMException e) { + // store names of bindings + for (IBinding b : bindings) { + final char[] n= b.getNameCharArray(); + handled.put(n); + } } scope= scope.getParent(); } @@ -1534,7 +1477,7 @@ public class CVisitor extends ASTQueries { return (IBinding[]) ArrayUtil.trim(IBinding.class, result); } - public static IBinding[] findBindings(IScope scope, String name) throws DOMException { + public static IBinding[] findBindings(IScope scope, String name) { CASTName astName = new CASTName(name.toCharArray()); //normal names @@ -1573,7 +1516,11 @@ public class CVisitor extends ASTQueries { } break; } - scope = scope.getParent(); + try { + scope = scope.getParent(); + } catch (DOMException e) { + scope= null; + } } while (scope != null); int c = (b1 == null ? 0 : b1.length) + (b2 == null ? 0 : b2.length) + b3.size(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/ICInternalBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/ICInternalBinding.java index 36b24a1e76b..06adeb95f7a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/ICInternalBinding.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/ICInternalBinding.java @@ -1,26 +1,21 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2010 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 Rational Software) - Initial API and implementation *******************************************************************************/ - -/* - * Created on Jan 24, 2005 - */ package org.eclipse.cdt.internal.core.dom.parser.c; import org.eclipse.cdt.core.dom.ast.IASTNode; /** - * @author aniefer + * Methods needed by CVisitor but not meant for public interface */ public interface ICInternalBinding { - //methods needed by CVisitor but not meant for public interface public IASTNode getPhysicalNode(); /** diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/AbstractCPPClassSpecializationScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/AbstractCPPClassSpecializationScope.java index 815c7a67c60..e8c7d3f2bc2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/AbstractCPPClassSpecializationScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/AbstractCPPClassSpecializationScope.java @@ -54,15 +54,15 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat return specialClass.getSpecializedBinding(); } - public final IBinding getBinding(IASTName name, boolean resolve) throws DOMException { + public final IBinding getBinding(IASTName name, boolean resolve) { return getBinding(name, resolve, IIndexFileSet.EMPTY); } - public final IBinding[] getBindings(IASTName name, boolean resolve, boolean prefix) throws DOMException { + public final IBinding[] getBindings(IASTName name, boolean resolve, boolean prefix) { return getBindings(name, resolve, prefix, IIndexFileSet.EMPTY); } - public IBinding getBinding(IASTName name, boolean forceResolve, IIndexFileSet fileSet) throws DOMException { + public IBinding getBinding(IASTName name, boolean forceResolve, IIndexFileSet fileSet) { char[] c = name.getLookupKey(); if (CharArrayUtils.equals(c, specialClass.getNameCharArray()) @@ -86,12 +86,12 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat } final public IBinding[] getBindings(IASTName name, boolean forceResolve, boolean prefixLookup, - IIndexFileSet fileSet) throws DOMException { + IIndexFileSet fileSet) { return getBindings(name, forceResolve, prefixLookup, fileSet, true); } public IBinding[] getBindings(IASTName name, boolean forceResolve, boolean prefixLookup, - IIndexFileSet fileSet, boolean checkPointOfDecl) throws DOMException { + IIndexFileSet fileSet, boolean checkPointOfDecl) { ICPPClassType specialized = specialClass.getSpecializedBinding(); IScope classScope = specialized.getCompositeScope(); if (classScope == null) @@ -119,7 +119,7 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat return specialClass; } - public ICPPBase[] getBases() throws DOMException { + public ICPPBase[] getBases() { if (fBases == null) { ICPPBase[] result = null; ICPPBase[] bases = specialClass.getSpecializedBinding().getBases(); @@ -175,22 +175,18 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat return newArray; } - public ICPPField[] getDeclaredFields() throws DOMException { + public ICPPField[] getDeclaredFields() { ICPPField[] fields= specialClass.getSpecializedBinding().getDeclaredFields(); return specializeMembers(fields); } public ICPPMethod[] getImplicitMethods() { - try { - ICPPClassScope origClassScope= (ICPPClassScope) specialClass.getSpecializedBinding().getCompositeScope(); - if (origClassScope == null) { - return ICPPMethod.EMPTY_CPPMETHOD_ARRAY; - } - ICPPMethod[] methods= origClassScope.getImplicitMethods(); - return specializeMembers(methods); - } catch (DOMException e) { + ICPPClassScope origClassScope= (ICPPClassScope) specialClass.getSpecializedBinding().getCompositeScope(); + if (origClassScope == null) { return ICPPMethod.EMPTY_CPPMETHOD_ARRAY; } + ICPPMethod[] methods= origClassScope.getImplicitMethods(); + return specializeMembers(methods); } public IName getScopeName() { @@ -199,22 +195,22 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat return null; } - public ICPPConstructor[] getConstructors() throws DOMException { + public ICPPConstructor[] getConstructors() { ICPPConstructor[] ctors= specialClass.getSpecializedBinding().getConstructors(); return specializeMembers(ctors); } - public ICPPMethod[] getDeclaredMethods() throws DOMException { + public ICPPMethod[] getDeclaredMethods() { ICPPMethod[] bindings = specialClass.getSpecializedBinding().getDeclaredMethods(); return specializeMembers(bindings); } - public ICPPClassType[] getNestedClasses() throws DOMException { + public ICPPClassType[] getNestedClasses() { ICPPClassType[] bindings = specialClass.getSpecializedBinding().getNestedClasses(); return specializeMembers(bindings); } - public IBinding[] getFriends() throws DOMException { + public IBinding[] getFriends() { // not yet supported return IBinding.EMPTY_BINDING_ARRAY; } @@ -230,7 +226,7 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat return getOriginalClassType().getScope(); } - public IBinding[] find(String name) throws DOMException { + public IBinding[] find(String name) { return CPPSemantics.findBindings(this, name, false); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseSpecifier.java index d794996e91d..3e00dccd55c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseSpecifier.java @@ -16,7 +16,6 @@ import java.util.ArrayList; import java.util.List; import org.eclipse.cdt.core.dom.ast.ASTVisitor; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.ICPPASTCompletionContext; @@ -129,13 +128,10 @@ public class CPPASTBaseSpecifier extends ASTNode implements ICPPASTBaseSpecifier for (IBinding binding : bindings) { if (binding instanceof ICPPClassType) { ICPPClassType base = (ICPPClassType) binding; - try { - int key = base.getKey(); - if (key == ICPPClassType.k_class && - (classType == null || !base.isSameType(classType))) { - filtered.add(base); - } - } catch (DOMException e) { + int key = base.getKey(); + if (key == ICPPClassType.k_class && + (classType == null || !base.isSameType(classType))) { + filtered.add(base); } } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTName.java index d0946cbfad0..759dc7c5efc 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTName.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTName.java @@ -13,9 +13,7 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; -import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.ast.ASTVisitor; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTCompletionContext; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; import org.eclipse.cdt.core.dom.ast.IASTName; @@ -106,27 +104,22 @@ public class CPPASTName extends CPPASTNameBase implements ICPPASTCompletionConte if (bindings[i] instanceof ICPPNamespace) { } else if (bindings[i] instanceof ICPPClassType) { ICPPClassType type = (ICPPClassType) bindings[i]; - try { - switch (type.getKey()) { - case ICompositeType.k_struct: - if (kind != ICompositeType.k_struct) { - bindings[i] = null; - } - break; - case ICompositeType.k_union: - if (kind != ICompositeType.k_union) { - bindings[i] = null; - } - break; - case ICPPClassType.k_class: - if (kind != ICPPASTElaboratedTypeSpecifier.k_class) { - bindings[i] = null; - } - break; + switch (type.getKey()) { + case ICompositeType.k_struct: + if (kind != ICompositeType.k_struct) { + bindings[i] = null; } - } catch (DOMException e) { - bindings[i] = null; - CCorePlugin.log(e); + break; + case ICompositeType.k_union: + if (kind != ICompositeType.k_union) { + bindings[i] = null; + } + break; + case ICPPClassType.k_class: + if (kind != ICPPASTElaboratedTypeSpecifier.k_class) { + bindings[i] = null; + } + break; } } else { bindings[i]= null; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNamespaceDefinition.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNamespaceDefinition.java index 357b7774c22..a59343dc62e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNamespaceDefinition.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNamespaceDefinition.java @@ -12,7 +12,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.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; @@ -101,11 +100,7 @@ public class CPPASTNamespaceDefinition extends ASTNode implements } public IScope getScope() { - try { - return ((ICPPNamespace) fName.resolveBinding()).getNamespaceScope(); - } catch ( DOMException e ) { - return e.getProblem(); - } + return ((ICPPNamespace) fName.resolveBinding()).getNamespaceScope(); } @Override diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTQualifiedName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTQualifiedName.java index 40bfbe657a7..98ca1e8d652 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTQualifiedName.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTQualifiedName.java @@ -257,14 +257,11 @@ public class CPPASTQualifiedName extends CPPASTNameBase List filtered = filterClassScopeBindings(classType, bindings, isDeclaration); if (isDeclaration && nameMatches(classType.getNameCharArray(), n.getLookupKey(), isPrefix)) { - try { - ICPPConstructor[] constructors = classType.getConstructors(); - for (int i = 0; i < constructors.length; i++) { - if (!constructors[i].isImplicit()) { - filtered.add(constructors[i]); - } + ICPPConstructor[] constructors = classType.getConstructors(); + for (int i = 0; i < constructors.length; i++) { + if (!constructors[i].isImplicit()) { + filtered.add(constructors[i]); } - } catch (DOMException e) { } } return filtered.toArray(new IBinding[filtered.size()]); @@ -302,32 +299,29 @@ public class CPPASTQualifiedName extends CPPASTNameBase List filtered = new ArrayList(); final boolean canBeFieldAccess= canBeFieldAccess(classType); - try { - for (final IBinding binding : bindings) { - if (binding instanceof IField) { - IField field = (IField) binding; - if (!canBeFieldAccess && !field.isStatic()) + for (final IBinding binding : bindings) { + if (binding instanceof IField) { + IField field = (IField) binding; + if (!canBeFieldAccess && !field.isStatic()) + continue; + } else if (binding instanceof ICPPMethod) { + ICPPMethod method = (ICPPMethod) binding; + if (method.isImplicit()) + continue; + if (!isDeclaration) { + if (method.isDestructor() || method instanceof ICPPConstructor + || (!canBeFieldAccess && !method.isStatic())) continue; - } else if (binding instanceof ICPPMethod) { - ICPPMethod method = (ICPPMethod) binding; - if (method.isImplicit()) - continue; - if (!isDeclaration) { - if (method.isDestructor() || method instanceof ICPPConstructor - || (!canBeFieldAccess && !method.isStatic())) - continue; - } - } else if (binding instanceof IEnumerator || binding instanceof IEnumeration) { - if (isDeclaration) - continue; - } else if (binding instanceof IType) { - IType type = (IType) binding; - if (type.isSameType(classType)) - continue; - } - filtered.add(binding); - } - } catch (DOMException e) { + } + } else if (binding instanceof IEnumerator || binding instanceof IEnumeration) { + if (isDeclaration) + continue; + } else if (binding instanceof IType) { + IType type = (IType) binding; + if (type.isSameType(classType)) + continue; + } + filtered.add(binding); } return filtered; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBaseClause.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBaseClause.java index 0f8d8a3fb21..c377ea0a891 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBaseClause.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBaseClause.java @@ -6,64 +6,23 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Corporation - initial API and implementation + * Andrew Niefer (IBM Corporation) - initial API and implementation * Bryan Wilkinson (QNX) * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; import org.eclipse.cdt.core.dom.IName; -import org.eclipse.cdt.core.dom.ast.DOMException; -import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier; -import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; -/** - * @author aniefer - */ public class CPPBaseClause implements ICPPBase, ICPPInternalBase { - static public class CPPBaseProblem extends ProblemBinding implements ICPPBase, ICPPInternalBase { - private ICPPClassType classProblem; - - public CPPBaseProblem(IASTNode node, int id, char[] arg) { - super(node, id, arg); - } - - public IBinding getBaseClass() { - if (classProblem == null) { - classProblem = new CPPClassType.CPPClassTypeProblem(node, id, arg); - } - return classProblem; - } - - public int getVisibility() throws DOMException { - throw new DOMException(this); - } - - public boolean isVirtual() throws DOMException { - throw new DOMException(this); - } - - public IName getBaseClassSpecifierName() { - return (IName) node; - } - - public void setBaseClass(IBinding binding) { - } - - @Override - public ICPPBase clone() { - return this; - } - } - private ICPPASTBaseSpecifier base; private IBinding baseClass; @@ -74,7 +33,7 @@ public class CPPBaseClause implements ICPPBase, ICPPInternalBase { /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBase#getBaseClass() */ - public IBinding getBaseClass() throws DOMException { + public IBinding getBaseClass() { if (baseClass == null) { IBinding b = base.getName().resolveBinding(); while (b instanceof ITypedef && ((ITypedef) b).getType() instanceof IBinding) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBlockScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBlockScope.java index eaf23ab4af6..19d1267752c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBlockScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBlockScope.java @@ -1,18 +1,14 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2010 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 - * Markus Schorn (Wind River Systems) + * Andrew Niefer (IBM Corporation) - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ - -/* - * Created on Nov 29, 2004 - */ package org.eclipse.cdt.internal.core.dom.parser.cpp; import org.eclipse.cdt.core.dom.IName; @@ -22,11 +18,8 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclarator; import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope; -import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; +import org.eclipse.cdt.internal.core.dom.parser.ASTQueries; -/** - * @author aniefer - */ public class CPPBlockScope extends CPPNamespaceScope implements ICPPBlockScope { public CPPBlockScope( IASTNode physicalNode ){ super( physicalNode ); @@ -44,7 +37,7 @@ public class CPPBlockScope extends CPPNamespaceScope implements ICPPBlockScope { final IASTNode parent= node.getParent(); if (parent instanceof IASTFunctionDefinition) { IASTDeclarator dtor= ((IASTFunctionDefinition)parent).getDeclarator(); - dtor = CPPVisitor.findInnermostDeclarator(dtor); + dtor = ASTQueries.findInnermostDeclarator(dtor); return dtor.getName(); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBuiltinVariable.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBuiltinVariable.java index 6de75c90300..4dce03738c2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBuiltinVariable.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBuiltinVariable.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Wind River Systems Inc. and others. + * Copyright (c) 2008, 2010 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; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IScope; @@ -112,7 +111,7 @@ public class CPPBuiltinVariable extends CPPVariable { } @Override - public IBinding getOwner() throws DOMException { + public IBinding getOwner() { return null; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java index 9c4549166db..b0280a25dc4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java @@ -15,7 +15,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.IBinding; import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.dom.ast.IType; @@ -47,11 +46,7 @@ public class CPPClassInstance extends CPPClassSpecialization implements ICPPTemp } public boolean isExplicitSpecialization() { - try { - return !(getCompositeScope() instanceof ICPPClassSpecializationScope); - } catch (DOMException e) { - return false; - } + return !(getCompositeScope() instanceof ICPPClassSpecializationScope); } @Deprecated diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassScope.java index 0e8f0e6a363..1a2c49365cb 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassScope.java @@ -31,11 +31,11 @@ import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration; import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration; import org.eclipse.cdt.core.dom.ast.IASTTypeId; +import org.eclipse.cdt.core.dom.ast.IBasicType.Kind; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IType; -import org.eclipse.cdt.core.dom.ast.IBasicType.Kind; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier; @@ -161,7 +161,7 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope { } @Override - public void addName(IASTName name) throws DOMException { + public void addName(IASTName name) { // don't add names from inactive code branches if (!name.isActive()) return; @@ -213,7 +213,7 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope { * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#getBinding(int, char[]) */ @Override - public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) throws DOMException { + public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) { char[] c = name.getLookupKey(); ICPPASTCompositeTypeSpecifier compType = (ICPPASTCompositeTypeSpecifier) getPhysicalNode(); @@ -230,7 +230,7 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope { @Override public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet, - boolean checkPointOfDecl) throws DOMException { + boolean checkPointOfDecl) { char[] c = name.getLookupKey(); ICPPASTCompositeTypeSpecifier compType = (ICPPASTCompositeTypeSpecifier) getPhysicalNode(); @@ -314,7 +314,7 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope { * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String) */ @Override - public IBinding[] find(String name) throws DOMException { + public IBinding[] find(String name) { char[] n = name.toCharArray(); ICPPASTCompositeTypeSpecifier compType = (ICPPASTCompositeTypeSpecifier) getPhysicalNode(); IASTName compName = compType.getName().getLastName(); @@ -374,7 +374,8 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope { */ public ICPPMethod[] getImplicitMethods() { if (implicits == null) - implicits = new ICPPMethod[] { new CPPMethod.CPPMethodProblem(null, IProblemBinding.SEMANTIC_INVALID_TYPE, CharArrayUtils.EMPTY) }; + return ICPPMethod.EMPTY_CPPMETHOD_ARRAY; + return implicits; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java index 1b59e3ffe86..27b210b55de 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 IBM Corporation and others. + * Copyright (c) 2005, 2010 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 @@ -12,7 +12,7 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; -import org.eclipse.cdt.core.dom.ast.DOMException; +import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; @@ -25,7 +25,6 @@ import org.eclipse.cdt.core.dom.ast.IField; import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; -import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration; @@ -84,7 +83,7 @@ public class CPPClassSpecialization extends CPPSpecialization } } - private class FindDefinitionAction extends CPPASTVisitor { + private class FindDefinitionAction extends ASTVisitor { private char [] nameArray = CPPClassSpecialization.this.getNameCharArray(); public IASTName result = null; @@ -177,7 +176,7 @@ public class CPPClassSpecialization extends CPPSpecialization return null; } - public ICPPBase[] getBases() throws DOMException { + public ICPPBase[] getBases() { ICPPClassSpecializationScope scope= getSpecializationScope(); if (scope == null) return ClassTypeHelper.getBases(this); @@ -185,7 +184,7 @@ public class CPPClassSpecialization extends CPPSpecialization return scope.getBases(); } - public ICPPField[] getDeclaredFields() throws DOMException { + public ICPPField[] getDeclaredFields() { ICPPClassSpecializationScope scope= getSpecializationScope(); if (scope == null) return ClassTypeHelper.getDeclaredFields(this); @@ -193,7 +192,7 @@ public class CPPClassSpecialization extends CPPSpecialization return scope.getDeclaredFields(); } - public ICPPMethod[] getDeclaredMethods() throws DOMException { + public ICPPMethod[] getDeclaredMethods() { ICPPClassSpecializationScope scope= getSpecializationScope(); if (scope == null) return ClassTypeHelper.getDeclaredMethods(this); @@ -201,7 +200,7 @@ public class CPPClassSpecialization extends CPPSpecialization return scope.getDeclaredMethods(); } - public ICPPConstructor[] getConstructors() throws DOMException { + public ICPPConstructor[] getConstructors() { ICPPClassSpecializationScope scope= getSpecializationScope(); if (scope == null) return ClassTypeHelper.getConstructors(this); @@ -209,7 +208,7 @@ public class CPPClassSpecialization extends CPPSpecialization return scope.getConstructors(); } - public IBinding[] getFriends() throws DOMException { + public IBinding[] getFriends() { ICPPClassSpecializationScope scope= getSpecializationScope(); if (scope == null) return ClassTypeHelper.getFriends(this); @@ -217,7 +216,7 @@ public class CPPClassSpecialization extends CPPSpecialization return scope.getFriends(); } - public ICPPClassType[] getNestedClasses() throws DOMException { + public ICPPClassType[] getNestedClasses() { ICPPClassSpecializationScope scope= getSpecializationScope(); if (scope == null) return ClassTypeHelper.getNestedClasses(this); @@ -226,19 +225,19 @@ public class CPPClassSpecialization extends CPPSpecialization } - public IField[] getFields() throws DOMException { + public IField[] getFields() { return ClassTypeHelper.getFields(this); } - public IField findField(String name) throws DOMException { + public IField findField(String name) { return ClassTypeHelper.findField(this, name); } - public ICPPMethod[] getMethods() throws DOMException { + public ICPPMethod[] getMethods() { return ClassTypeHelper.getMethods(this); } - public ICPPMethod[] getAllDeclaredMethods() throws DOMException { + public ICPPMethod[] getAllDeclaredMethods() { return ClassTypeHelper.getAllDeclaredMethods(this); } @@ -246,7 +245,7 @@ public class CPPClassSpecialization extends CPPSpecialization /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.ICompositeType#getKey() */ - public int getKey() throws DOMException { + public int getKey() { if (getDefinition() != null) return getCompositeTypeSpecifier().getKey(); @@ -256,7 +255,7 @@ public class CPPClassSpecialization extends CPPSpecialization /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.ICompositeType#getCompositeScope() */ - public ICPPClassScope getCompositeScope() throws DOMException { + public ICPPClassScope getCompositeScope() { final ICPPClassScope specScope= getSpecializationScope(); if (specScope != null) return specScope; @@ -297,7 +296,7 @@ public class CPPClassSpecialization extends CPPSpecialization return this; } - public boolean isAnonymous() throws DOMException { + public boolean isAnonymous() { if (getNameCharArray().length > 0) return false; @@ -322,26 +321,22 @@ public class CPPClassSpecialization extends CPPSpecialization t2 instanceof IProblemBinding) return false; - try { - if (t1.getKey() != t2.getKey()) - return false; - - if (!CharArrayUtils.equals(t1.getNameCharArray(), t2.getNameCharArray())) - return false; - - // the argument map is not significant for comparing specializations, the map is - // determined by the owner of the specialization. This is different for instances, - // which have a separate implementation for isSameType(). - final IBinding owner1= t1.getOwner(); - final IBinding owner2= t2.getOwner(); - - // for a specialization that is not an instance the owner has to be a class-type - if (owner1 instanceof ICPPClassType == false || owner2 instanceof ICPPClassType == false) - return false; - - return ((ICPPClassType) owner1).isSameType((ICPPClassType) owner2); - } catch (DOMException e) { + if (t1.getKey() != t2.getKey()) return false; - } + + if (!CharArrayUtils.equals(t1.getNameCharArray(), t2.getNameCharArray())) + return false; + + // the argument map is not significant for comparing specializations, the map is + // determined by the owner of the specialization. This is different for instances, + // which have a separate implementation for isSameType(). + final IBinding owner1= t1.getOwner(); + final IBinding owner2= t2.getOwner(); + + // for a specialization that is not an instance the owner has to be a class-type + if (owner1 instanceof ICPPClassType == false || owner2 instanceof ICPPClassType == false) + return false; + + return ((ICPPClassType) owner1).isSameType((ICPPClassType) owner2); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java index 7d6f66f2368..fec1948046d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 IBM Corporation and others. + * Copyright (c) 2005, 2010 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 @@ -14,6 +14,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; +import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; @@ -27,7 +28,6 @@ import org.eclipse.cdt.core.dom.ast.IField; import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; -import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; @@ -60,7 +60,7 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements ICPPClass private boolean checkedIndex= false; private boolean checkedDefinition= false; - private class FindDefinitionAction extends CPPASTVisitor { + private class FindDefinitionAction extends ASTVisitor { private char[] nameArray = CPPClassTemplate.this.getNameCharArray(); public IASTName result = null; @@ -170,13 +170,9 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements ICPPClass // Forward declarations must be backed up from the index. checkForIndexBinding(); if (fIndexBinding != null) { - try { - IScope scope = fIndexBinding.getCompositeScope(); - if (scope instanceof ICPPClassScope) - return (ICPPClassScope) scope; - } catch (DOMException e) { - // index bindings don't throw DOMExeptions. - } + IScope scope = fIndexBinding.getCompositeScope(); + if (scope instanceof ICPPClassScope) + return (ICPPClassScope) scope; } return null; } @@ -220,27 +216,27 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements ICPPClass return ClassTypeHelper.getBases(this); } - public IField[] getFields() throws DOMException { + public IField[] getFields() { return ClassTypeHelper.getFields(this); } - public ICPPField[] getDeclaredFields() throws DOMException { + public ICPPField[] getDeclaredFields() { return ClassTypeHelper.getDeclaredFields(this); } - public ICPPMethod[] getMethods() throws DOMException { + public ICPPMethod[] getMethods() { return ClassTypeHelper.getMethods(this); } - public ICPPMethod[] getAllDeclaredMethods() throws DOMException { + public ICPPMethod[] getAllDeclaredMethods() { return ClassTypeHelper.getAllDeclaredMethods(this); } - public ICPPMethod[] getDeclaredMethods() throws DOMException { + public ICPPMethod[] getDeclaredMethods() { return ClassTypeHelper.getDeclaredMethods(this); } - public ICPPConstructor[] getConstructors() throws DOMException { + public ICPPConstructor[] getConstructors() { return ClassTypeHelper.getConstructors(this); } @@ -252,7 +248,7 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements ICPPClass return ClassTypeHelper.getNestedClasses(this); } - public IField findField(String name) throws DOMException { + public IField findField(String name) { return ClassTypeHelper.findField(this, name); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java index 82fd727fb79..33f3fd3c6d7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 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 @@ -15,6 +15,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp; import org.eclipse.cdt.core.dom.ILinkage; +import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; @@ -29,7 +30,6 @@ import org.eclipse.cdt.core.dom.ast.IField; import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; -import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; @@ -65,60 +65,48 @@ public class CPPClassType extends PlatformObject implements ICPPInternalClassTyp public CPPClassTypeProblem(IASTNode node, int id, char[] arg) { super(node, id, arg); } - public ICPPBase[] getBases() throws DOMException { - throw new DOMException(this); + public ICPPBase[] getBases() { + return ICPPBase.EMPTY_BASE_ARRAY; } - public IField[] getFields() throws DOMException { - throw new DOMException(this); + public IField[] getFields() { + return IField.EMPTY_FIELD_ARRAY; } - public ICPPField[] getDeclaredFields() throws DOMException { - throw new DOMException(this); + public ICPPField[] getDeclaredFields() { + return ICPPField.EMPTY_CPPFIELD_ARRAY; } - public ICPPMethod[] getMethods() throws DOMException { - throw new DOMException(this); + public ICPPMethod[] getMethods() { + return ICPPMethod.EMPTY_CPPMETHOD_ARRAY; } - public ICPPMethod[] getAllDeclaredMethods() throws DOMException { - throw new DOMException(this); + public ICPPMethod[] getAllDeclaredMethods() { + return ICPPMethod.EMPTY_CPPMETHOD_ARRAY; } - public ICPPMethod[] getDeclaredMethods() throws DOMException { - throw new DOMException(this); + public ICPPMethod[] getDeclaredMethods() { + return ICPPMethod.EMPTY_CPPMETHOD_ARRAY; } - public ICPPConstructor[] getConstructors() throws DOMException { - throw new DOMException(this); + public ICPPConstructor[] getConstructors() { + return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY; } public ICPPMethod[] getDeclaredConversionOperators() throws DOMException { throw new DOMException(this); } - public int getKey() throws DOMException { - throw new DOMException(this); + public int getKey() { + return k_class; } - public IField findField(String name) throws DOMException { - throw new DOMException(this); + public IField findField(String name) { + return null; } - public IScope getCompositeScope() throws DOMException { - throw new DOMException(this); + public IScope getCompositeScope() { + return this; } - public IBinding[] getFriends() throws DOMException { - throw new DOMException(this); + public IBinding[] getFriends() { + return IBinding.EMPTY_BINDING_ARRAY; } - public String[] getQualifiedName() throws DOMException { - throw new DOMException(this); - } - public char[][] getQualifiedNameCharArray() throws DOMException { - throw new DOMException(this); - } - public boolean isGloballyQualified() throws DOMException { - throw new DOMException(this); - } - public ICPPClassType[] getNestedClasses() throws DOMException { - throw new DOMException(this); - } - public boolean isAnonymous() throws DOMException { - throw new DOMException(this); + public ICPPClassType[] getNestedClasses() { + return ICPPClassType.EMPTY_CLASS_ARRAY; } } - private class FindDefinitionAction extends CPPASTVisitor { + private class FindDefinitionAction extends ASTVisitor { private char[] nameArray = CPPClassType.this.getNameCharArray(); public IASTName result = null; @@ -287,13 +275,9 @@ public class CPPClassType extends PlatformObject implements ICPPInternalClassTyp } // fwd-declarations must be backed up from the index if (typeInIndex != null) { - try { - IScope scope = typeInIndex.getCompositeScope(); - if (scope instanceof ICPPClassScope) - return (ICPPClassScope) scope; - } catch (DOMException e) { - // index bindings don't throw DOMExeptions. - } + IScope scope = typeInIndex.getCompositeScope(); + if (scope instanceof ICPPClassScope) + return (ICPPClassScope) scope; } return null; } @@ -367,27 +351,27 @@ public class CPPClassType extends PlatformObject implements ICPPInternalClassTyp return ClassTypeHelper.getBases(this); } - public IField[] getFields() throws DOMException { + public IField[] getFields() { return ClassTypeHelper.getFields(this); } - public ICPPField[] getDeclaredFields() throws DOMException { + public ICPPField[] getDeclaredFields() { return ClassTypeHelper.getDeclaredFields(this); } - public ICPPMethod[] getMethods() throws DOMException { + public ICPPMethod[] getMethods() { return ClassTypeHelper.getMethods(this); } - public ICPPMethod[] getAllDeclaredMethods() throws DOMException { + public ICPPMethod[] getAllDeclaredMethods() { return ClassTypeHelper.getAllDeclaredMethods(this); } - public ICPPMethod[] getDeclaredMethods() throws DOMException { + public ICPPMethod[] getDeclaredMethods() { return ClassTypeHelper.getDeclaredMethods(this); } - public ICPPConstructor[] getConstructors() throws DOMException { + public ICPPConstructor[] getConstructors() { return ClassTypeHelper.getConstructors(this); } @@ -399,7 +383,7 @@ public class CPPClassType extends PlatformObject implements ICPPInternalClassTyp return ClassTypeHelper.getNestedClasses(this); } - public IField findField(String name) throws DOMException { + public IField findField(String name) { return ClassTypeHelper.findField(this, name); } @@ -420,14 +404,14 @@ public class CPPClassType extends PlatformObject implements ICPPInternalClassTyp return getName(); } - public IBinding getOwner() throws DOMException { + public IBinding getOwner() { if (definition != null) { return CPPVisitor.findNameOwner(definition, true); } return CPPVisitor.findDeclarationOwner(declarations[0], true); } - public boolean isAnonymous() throws DOMException { + public boolean isAnonymous() { if (getNameCharArray().length > 0) return false; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPCompositeBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPCompositeBinding.java index 6d69f2f355b..c0b20a6eca3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPCompositeBinding.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPCompositeBinding.java @@ -1,17 +1,14 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2010 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 16, 2004 - */ package org.eclipse.cdt.internal.core.dom.parser.cpp; import org.eclipse.cdt.core.dom.ILinkage; @@ -23,9 +20,6 @@ import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.internal.core.dom.Linkage; import org.eclipse.core.runtime.PlatformObject; -/** - * @author aniefer - */ public class CPPCompositeBinding extends PlatformObject implements IBinding { IBinding [] bindings = null; @@ -55,7 +49,7 @@ public class CPPCompositeBinding extends PlatformObject implements IBinding { return bindings[0].getScope(); } - public IBinding getOwner() throws DOMException { + public IBinding getOwner() { return bindings[0].getOwner(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructor.java index 90eea907cd7..95e3fe44163 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructor.java @@ -1,38 +1,32 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 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 21, 2004 - */ package org.eclipse.cdt.internal.core.dom.parser.cpp; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; -/** - * @author aniefer - */ public class CPPConstructor extends CPPMethod implements ICPPConstructor { static public class CPPConstructorProblem extends CPPMethod.CPPMethodProblem implements ICPPConstructor { - public CPPConstructorProblem(IASTNode node, int id, char[] arg) { - super(node, id, arg); + public CPPConstructorProblem(ICPPClassType owner, IASTNode node, int id, char[] arg) { + super(owner, node, id, arg); } - public boolean isExplicit() throws DOMException{ - throw new DOMException( this ); + public boolean isExplicit() { + return false; } } @@ -46,7 +40,7 @@ public class CPPConstructor extends CPPMethod implements ICPPConstructor { /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor#isExplicit() */ - public boolean isExplicit() throws DOMException { + public boolean isExplicit() { IASTDeclaration decl= getPrimaryDeclaration(); if (decl != null) { ICPPASTDeclSpecifier declspec= getDeclSpec(decl); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorInstance.java index 7b0d7675861..a62d8ff66d3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorInstance.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorInstance.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.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument; @@ -26,7 +25,7 @@ public class CPPConstructorInstance extends CPPMethodInstance implements ICPPCon super(orig, owner, tpmap, args); } - public boolean isExplicit() throws DOMException { + public boolean isExplicit() { return ((ICPPConstructor) getTemplateDefinition()).isExplicit(); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorSpecialization.java index 7b44b13adf5..9f067d52179 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorSpecialization.java @@ -1,5 +1,5 @@ /************************************************************************* - * Copyright (c) 2005, 2009 IBM Corporation and others. + * Copyright (c) 2005, 2010 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 @@ -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.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap; @@ -30,7 +29,7 @@ public class CPPConstructorSpecialization extends CPPMethodSpecialization /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor#isExplicit() */ - public boolean isExplicit() throws DOMException { + public boolean isExplicit() { return ((ICPPConstructor)getSpecializedBinding()).isExplicit(); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorTemplate.java index 30b18017132..6c8add94b5c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorTemplate.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorTemplate.java @@ -1,39 +1,29 @@ /******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. + * Copyright (c) 2005, 2010 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 - Initial API and implementation + * Andrew Niefer (IBM Corporation) - Initial API and implementation *******************************************************************************/ -/* - * Created on Mar 31, 2005 - */ package org.eclipse.cdt.internal.core.dom.parser.cpp; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; -/** - * @author aniefer - */ -public class CPPConstructorTemplate extends CPPMethodTemplate implements - ICPPConstructor { +public class CPPConstructorTemplate extends CPPMethodTemplate implements ICPPConstructor { - /** - * @param name - */ public CPPConstructorTemplate(IASTName name) { super(name); - // TODO Auto-generated constructor stub } /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor#isExplicit() */ public boolean isExplicit() { + // mstodo fix that // TODO Auto-generated method stub return false; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorTemplateSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorTemplateSpecialization.java index d643f89abf9..1dd24745147 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorTemplateSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorTemplateSpecialization.java @@ -1,5 +1,5 @@ /************************************************************************* - * Copyright (c) 2005, 2009 IBM Corporation and others. + * Copyright (c) 2005, 2010 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 @@ -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.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap; @@ -30,7 +29,7 @@ public class CPPConstructorTemplateSpecialization extends CPPMethodTemplateSpeci /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor#isExplicit() */ - public boolean isExplicit() throws DOMException { + public boolean isExplicit() { return ((ICPPConstructor)getSpecializedBinding()).isExplicit(); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredClassInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredClassInstance.java index 7a420c80655..afb12fc617a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredClassInstance.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredClassInstance.java @@ -51,11 +51,7 @@ public class CPPDeferredClassInstance extends CPPUnknownClass implements ICPPDef @Override public IBinding getOwner() { - try { - return fClassTemplate.getOwner(); - } catch (DOMException e) { - return e.getProblem(); - } + return fClassTemplate.getOwner(); } public ICPPClassTemplate getClassTemplate() { @@ -93,7 +89,7 @@ public class CPPDeferredClassInstance extends CPPUnknownClass implements ICPPDef } @Override - public int getKey() throws DOMException { + public int getKey() { return getClassTemplate().getKey(); } @@ -138,7 +134,7 @@ public class CPPDeferredClassInstance extends CPPUnknownClass implements ICPPDef } @Override - public ICPPScope asScope() throws DOMException { + public ICPPScope asScope() { if (fLookupScope != null) return fLookupScope; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumeration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumeration.java index 123b68ff3c4..773ef53d257 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumeration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumeration.java @@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp; import org.eclipse.cdt.core.dom.ILinkage; +import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; @@ -29,7 +30,6 @@ import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.IValue; -import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTEnumerationSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId; @@ -78,7 +78,7 @@ public class CPPEnumeration extends PlatformObject implements ICPPEnumeration, I return fDeclarations; } - private class FindDefinitionAction extends CPPASTVisitor { + private class FindDefinitionAction extends ASTVisitor { private char[] nameArray = CPPEnumeration.this.getNameCharArray(); public IASTName result = null; @@ -197,7 +197,7 @@ public class CPPEnumeration extends PlatformObject implements ICPPEnumeration, I return Linkage.CPP_LINKAGE; } - public IBinding getOwner() throws DOMException { + public IBinding getOwner() { return CPPVisitor.findDeclarationOwner(getADeclaration(), true); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumerator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumerator.java index 471a68f8f5f..1a89f15b764 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumerator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumerator.java @@ -131,7 +131,7 @@ public class CPPEnumerator extends PlatformObject implements IEnumerator, ICPPIn return Linkage.CPP_LINKAGE; } - public IBinding getOwner() throws DOMException { + public IBinding getOwner() { return CPPVisitor.findDeclarationOwner(enumName, true); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPField.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPField.java index 1f20d09302d..7df5ae65272 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPField.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPField.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2010 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 @@ -11,8 +11,8 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier; +import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; import org.eclipse.cdt.core.dom.ast.IASTName; @@ -20,7 +20,6 @@ import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration; import org.eclipse.cdt.core.dom.ast.ICompositeType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope; @@ -34,26 +33,19 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTInternal; */ public class CPPField extends CPPVariable implements ICPPField { public static class CPPFieldProblem extends CPPVariable.CPPVariableProblem implements ICPPField { - /** - * @param id - * @param arg - */ - public CPPFieldProblem( IASTNode node, int id, char[] arg ) { + private ICPPClassType fOwner; + + public CPPFieldProblem(ICPPClassType owner, IASTNode node, int id, char[] arg ) { super( node, id, arg ); + fOwner= owner; } - - public int getVisibility() throws DOMException { - throw new DOMException( this ); + public int getVisibility() { + return v_private; } - public ICPPClassType getClassOwner() throws DOMException { - throw new DOMException( this ); + public ICPPClassType getClassOwner() { + return fOwner; } - @Override - public boolean isStatic() throws DOMException { - throw new DOMException( this ); - } - - public ICompositeType getCompositeTypeOwner() throws DOMException { + public ICompositeType getCompositeTypeOwner() { return getClassOwner(); } } @@ -62,7 +54,7 @@ public class CPPField extends CPPVariable implements ICPPField { super( name ); } - public IASTDeclaration getPrimaryDeclaration() throws DOMException{ + public IASTDeclaration getPrimaryDeclaration() { //first check if we already know it IASTDeclaration decl= findDeclaration(getDefinition()); if (decl != null) { @@ -108,7 +100,7 @@ public class CPPField extends CPPVariable implements ICPPField { return null; } - public int getVisibility() throws DOMException { + public int getVisibility() { ICPPASTVisibilityLabel vis = null; IASTDeclaration decl = getPrimaryDeclaration(); if( decl != null ) { @@ -131,7 +123,7 @@ public class CPPField extends CPPVariable implements ICPPField { return ICPPASTVisibilityLabel.v_public; } - public ICPPClassType getClassOwner() throws DOMException { + public ICPPClassType getClassOwner() { ICPPClassScope scope = (ICPPClassScope) getScope(); return scope.getClassType(); } @@ -151,7 +143,7 @@ public class CPPField extends CPPVariable implements ICPPField { @Override public boolean isMutable() { - return hasStorageClass( ICPPASTDeclSpecifier.sc_mutable); + return hasStorageClass( IASTDeclSpecifier.sc_mutable); } @Override @@ -160,7 +152,7 @@ public class CPPField extends CPPVariable implements ICPPField { return false; } - public ICompositeType getCompositeTypeOwner() throws DOMException { + public ICompositeType getCompositeTypeOwner() { return getClassOwner(); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFieldSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFieldSpecialization.java index 5afae0f97df..1d2614dd1fb 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFieldSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFieldSpecialization.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. + * Copyright (c) 2005, 2010 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 @@ -37,11 +37,11 @@ public class CPPFieldSpecialization extends CPPSpecialization implements ICPPFie return (ICPPField) getSpecializedBinding(); } - public int getVisibility() throws DOMException { + public int getVisibility() { return getField().getVisibility(); } - public ICPPClassType getClassOwner() throws DOMException { + public ICPPClassType getClassOwner() { return getField().getClassOwner(); } @@ -52,23 +52,23 @@ public class CPPFieldSpecialization extends CPPSpecialization implements ICPPFie return type; } - public boolean isStatic() throws DOMException { + public boolean isStatic() { return getField().isStatic(); } - public boolean isExtern() throws DOMException { + public boolean isExtern() { return getField().isExtern(); } - public boolean isAuto() throws DOMException { + public boolean isAuto() { return getField().isAuto(); } - public boolean isRegister() throws DOMException { + public boolean isRegister() { return getField().isRegister(); } - public boolean isMutable() throws DOMException { + public boolean isMutable() { return getField().isMutable(); } @@ -76,7 +76,7 @@ public class CPPFieldSpecialization extends CPPSpecialization implements ICPPFie return false; } - public ICompositeType getCompositeTypeOwner() throws DOMException { + public ICompositeType getCompositeTypeOwner() { return getClassOwner(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java index b79811985df..7070db72482 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java @@ -61,63 +61,19 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt public CPPFunctionProblem(IASTNode node, int id, char[] arg) { super(node, id, arg); } - + @Override + public ICPPFunctionType getType() throws DOMException { + throw new DOMException(this); + } public ICPPParameter[] getParameters() throws DOMException { throw new DOMException(this); } - public IScope getFunctionScope() throws DOMException { throw new DOMException(this); } - - public ICPPFunctionType getType() throws DOMException { - throw new DOMException(this); - } - public boolean isStatic() throws DOMException { - throw new DOMException(this); - } - public String[] getQualifiedName() throws DOMException { - throw new DOMException(this); - } - public char[][] getQualifiedNameCharArray() throws DOMException { - throw new DOMException(this); - } - public boolean isGloballyQualified() throws DOMException { - throw new DOMException(this); - } - public boolean isDeleted() { - return false; - } - public boolean isMutable() throws DOMException { - throw new DOMException(this); - } - public boolean isInline() throws DOMException { - throw new DOMException(this); - } - public boolean isExternC() throws DOMException { - throw new DOMException(this); - } - public boolean isExtern() throws DOMException { - throw new DOMException(this); - } - public boolean isAuto() throws DOMException { - throw new DOMException(this); - } - public boolean isRegister() throws DOMException { - throw new DOMException(this); - } - public boolean takesVarArgs() throws DOMException { - throw new DOMException(this); - } - public IType[] getExceptionSpecification() throws DOMException { - throw new DOMException(this); - } public int getRequiredArgumentCount() throws DOMException { throw new DOMException(this); } - public boolean hasParameterPack() { - return false; - } public boolean hasSameFunctionParameterTypeList(ICPPFunction function) { return false; } @@ -158,13 +114,10 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt } else { //implicit binding IScope scope = getScope(); - try { - IASTNode node = ASTInternal.getPhysicalNodeOfScope(scope); - if (node != null) { - tu = node.getTranslationUnit(); - } - } catch (DOMException e) { - } + IASTNode node = ASTInternal.getPhysicalNodeOfScope(scope); + if (node != null) { + tu = node.getTranslationUnit(); + } } if (tu != null) { CPPVisitor.getDeclarations(tu, this); @@ -493,7 +446,7 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt return false; } - public boolean isInline() throws DOMException { + public boolean isInline() { IASTDeclarator dtor = getDefinition(); IASTDeclarator[] ds = getDeclarations(); int i = -1; @@ -520,7 +473,7 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt return false; } - public boolean isExternC() throws DOMException { + public boolean isExternC() { if (CPPVisitor.isExternC(getDefinition())) { return true; } @@ -565,11 +518,11 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt return result.toString(); } - public IBinding getOwner() throws DOMException { + public IBinding getOwner() { return CPPVisitor.findNameOwner(getASTName(), false); } - public IType[] getExceptionSpecification() throws DOMException { + public IType[] getExceptionSpecification() { ICPPASTFunctionDeclarator declarator = getPreferredDtor(); if (declarator != null) { IASTTypeId[] astTypeIds= declarator.getExceptionSpecification(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionScope.java index 5c53881f64a..2c74766f7a4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionScope.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 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 @@ -77,7 +77,7 @@ public class CPPFunctionScope extends CPPScope implements ICPPFunctionScope { * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String) */ @Override - public IBinding[] find(String name) throws DOMException { + public IBinding[] find(String name) { char[] n = name.toCharArray(); List bindings = new ArrayList(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionSpecialization.java index 06efc960fd9..c2b6d194244 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionSpecialization.java @@ -113,7 +113,7 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP return false; } - public boolean isInline() throws DOMException { + public boolean isInline() { if (getDefinition() != null) { IASTNode def = getDefinition(); while (!(def instanceof IASTFunctionDefinition)) @@ -123,7 +123,7 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP return getFunction().isInline(); } - public boolean isExternC() throws DOMException { + public boolean isExternC() { if (CPPVisitor.isExternC(getDefinition())) { return true; } @@ -139,35 +139,33 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP if (f instanceof ICPPInternalFunction) return ((ICPPInternalFunction)f).isStatic(resolveAll); if (f instanceof IIndexBinding && f instanceof ICPPFunction) { - try { - return ((ICPPFunction) f).isStatic(); - } catch(DOMException de) { /* cannot occur as we query the index */} + return ((ICPPFunction) f).isStatic(); } return CPPFunction.hasStorageClass(this, IASTDeclSpecifier.sc_static); } - public boolean isExtern() throws DOMException { + public boolean isExtern() { ICPPFunction f = (ICPPFunction) getSpecializedBinding(); if (f != null) return f.isExtern(); return CPPFunction.hasStorageClass(this, IASTDeclSpecifier.sc_extern); } - public boolean isAuto() throws DOMException { + public boolean isAuto() { ICPPFunction f = (ICPPFunction) getSpecializedBinding(); if (f != null) return f.isAuto(); return CPPFunction.hasStorageClass(this, IASTDeclSpecifier.sc_auto); } - public boolean isRegister() throws DOMException { + public boolean isRegister() { ICPPFunction f = (ICPPFunction) getSpecializedBinding(); if (f != null) return f.isRegister(); return CPPFunction.hasStorageClass(this, IASTDeclSpecifier.sc_register); } - public boolean takesVarArgs() throws DOMException { + public boolean takesVarArgs() { ICPPFunction f = (ICPPFunction) getSpecializedBinding(); if (f != null) return f.takesVarArgs(); @@ -295,7 +293,7 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP return result.toString(); } - public IType[] getExceptionSpecification() throws DOMException { + public IType[] getExceptionSpecification() { if (specializedExceptionSpec == null) { ICPPFunction function = (ICPPFunction) getSpecializedBinding(); IType[] types = function.getExceptionSpecification(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplate.java index 9e0e31ac8c5..eb06acaedea 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplate.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplate.java @@ -57,60 +57,19 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition public ICPPClassTemplatePartialSpecialization[] getTemplateSpecializations() throws DOMException { throw new DOMException(this); } - public String[] getQualifiedName() throws DOMException { - throw new DOMException(this); - } - public char[][] getQualifiedNameCharArray() throws DOMException { - throw new DOMException(this); - } - public boolean isGloballyQualified() throws DOMException { - throw new DOMException(this); - } - public boolean isDeleted() { - return false; - } - public boolean isMutable() throws DOMException { - throw new DOMException(this); - } - public boolean isInline() throws DOMException { - throw new DOMException(this); - } - public boolean isExternC() throws DOMException { - throw new DOMException(this); - } public ICPPParameter[] getParameters() throws DOMException { throw new DOMException(this); } public IScope getFunctionScope() throws DOMException { throw new DOMException(this); } + @Override public ICPPFunctionType getType() throws DOMException { throw new DOMException(this); } - public boolean isStatic() throws DOMException { - throw new DOMException(this); - } - public boolean isExtern() throws DOMException { - throw new DOMException(this); - } - public boolean isAuto() throws DOMException { - throw new DOMException(this); - } - public boolean isRegister() throws DOMException { - throw new DOMException(this); - } - public boolean takesVarArgs() throws DOMException { - throw new DOMException(this); - } - public IType[] getExceptionSpecification() throws DOMException { - throw new DOMException( this ); - } public int getRequiredArgumentCount() throws DOMException { throw new DOMException( this ); } - public boolean hasParameterPack() { - return false; - } } protected ICPPFunctionType type = null; @@ -316,7 +275,7 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition return hasStorageClass(IASTDeclSpecifier.sc_mutable); } - public boolean isInline() throws DOMException { + public boolean isInline() { IASTName name = (IASTName) getDefinition(); IASTNode[] ns = getDeclarations(); int i = -1; @@ -344,7 +303,7 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition return false; } - public boolean isExternC() throws DOMException { + public boolean isExternC() { if (CPPVisitor.isExternC(getDefinition())) { return true; } @@ -407,7 +366,7 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition return result.toString(); } - public IType[] getExceptionSpecification() throws DOMException { + public IType[] getExceptionSpecification() { ICPPASTFunctionDeclarator declarator = getFirstFunctionDtor(); if (declarator != null) { IASTTypeId[] astTypeIds = declarator.getExceptionSpecification(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitMethod.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitMethod.java index 6635e53cd66..ad901405539 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitMethod.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitMethod.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 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 @@ -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.IASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; @@ -46,7 +45,7 @@ public class CPPImplicitMethod extends CPPImplicitFunction implements ICPPMethod super(name, scope, type, params, false); } - public int getVisibility() throws DOMException { + public int getVisibility() { IASTDeclaration decl= getPrimaryDeclaration(); if (decl == null) { // 12.1-5, 12.8-10 Implicit constructors and assignment operators are public @@ -82,7 +81,7 @@ public class CPPImplicitMethod extends CPPImplicitFunction implements ICPPMethod return scope.getClassType(); } - public IASTDeclaration getPrimaryDeclaration() throws DOMException { + public IASTDeclaration getPrimaryDeclaration() { // first check if we already know it if (declarations != null) { for (IASTDeclarator dtor : declarations) { @@ -170,11 +169,7 @@ public class CPPImplicitMethod extends CPPImplicitFunction implements ICPPMethod } public boolean isImplicit() { - try { - return getPrimaryDeclaration() == null; - } catch (DOMException e) { - } - return true; + return getPrimaryDeclaration() == null; } public boolean isPureVirtual() { @@ -187,7 +182,7 @@ public class CPPImplicitMethod extends CPPImplicitFunction implements ICPPMethod } @Override - public IType[] getExceptionSpecification() throws DOMException { + public IType[] getExceptionSpecification() { return ClassTypeHelper.getInheritedExceptionSpecification(this); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPLabel.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPLabel.java index 7f37a03015e..e4e0f57baf6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPLabel.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPLabel.java @@ -1,18 +1,17 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 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 - * Markus Schorn (Wind River Systems) + * 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.ILinkage; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTLabelStatement; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; @@ -23,9 +22,6 @@ import org.eclipse.cdt.internal.core.dom.Linkage; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.core.runtime.PlatformObject; -/** - * @author aniefer - */ public class CPPLabel extends PlatformObject implements ILabel, ICPPInternalBinding { private IASTName statement; @@ -93,7 +89,7 @@ public class CPPLabel extends PlatformObject implements ILabel, ICPPInternalBind return Linkage.CPP_LINKAGE; } - public IBinding getOwner() throws DOMException { + public IBinding getOwner() { return CPPVisitor.findEnclosingFunction(statement); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethod.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethod.java index 18fefacb7fa..e9a5d0423b1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethod.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethod.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 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 @@ -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.IASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; @@ -29,6 +28,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.core.parser.util.CharArrayUtils; import org.eclipse.cdt.internal.core.dom.parser.ASTInternal; @@ -40,21 +40,13 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; */ public class CPPMethod extends CPPFunction implements ICPPMethod { public static class CPPMethodProblem extends CPPFunctionProblem implements ICPPMethod { - public CPPMethodProblem(IASTNode node, int id, char[] arg) { + private ICPPClassType fOwner; + public CPPMethodProblem(ICPPClassType owner, IASTNode node, int id, char[] arg) { super(node, id, arg); + fOwner= owner; } - - public int getVisibility() throws DOMException { - throw new DOMException(this); - } - public ICPPClassType getClassOwner() throws DOMException { - throw new DOMException(this); - } - public boolean isVirtual() throws DOMException { - throw new DOMException(this); - } - public boolean isPureVirtual() throws DOMException { - throw new DOMException(this); + public ICPPClassType getClassOwner() { + return fOwner; } public boolean isDestructor() { char[] name = getNameCharArray(); @@ -63,8 +55,8 @@ public class CPPMethod extends CPPFunction implements ICPPMethod { return false; } - public boolean isImplicit() { - return false; + public int getVisibility() { + return ICPPMember.v_private; } } @@ -72,7 +64,7 @@ public class CPPMethod extends CPPFunction implements ICPPMethod { super(declarator); } - public IASTDeclaration getPrimaryDeclaration() throws DOMException{ + public IASTDeclaration getPrimaryDeclaration() { //first check if we already know it if (declarations != null) { for (IASTDeclarator dtor : declarations) { @@ -120,7 +112,7 @@ public class CPPMethod extends CPPFunction implements ICPPMethod { /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMember#getVisibility() */ - public int getVisibility() throws DOMException { + public int getVisibility() { IASTDeclaration decl = getPrimaryDeclaration(); if( decl == null ){ IScope scope = getScope(); @@ -149,7 +141,7 @@ public class CPPMethod extends CPPFunction implements ICPPMethod { return ICPPASTVisibilityLabel.v_public; } - public ICPPClassType getClassOwner() throws DOMException { + public ICPPClassType getClassOwner() { ICPPClassScope scope = (ICPPClassScope)getScope(); return scope.getClassType(); } @@ -174,7 +166,7 @@ public class CPPMethod extends CPPFunction implements ICPPMethod { /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod#isVirtual() */ - public boolean isVirtual() throws DOMException { + public boolean isVirtual() { IASTDeclaration decl = getPrimaryDeclaration(); if( decl != null ){ ICPPASTDeclSpecifier declSpec = getDeclSpec(decl); @@ -198,7 +190,7 @@ public class CPPMethod extends CPPFunction implements ICPPMethod { * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction#isInline() */ @Override - public boolean isInline() throws DOMException { + public boolean isInline() { IASTDeclaration decl = getPrimaryDeclaration(); if( decl instanceof IASTFunctionDefinition ) return true; @@ -214,7 +206,7 @@ public class CPPMethod extends CPPFunction implements ICPPMethod { */ @Override public boolean isMutable() { - return hasStorageClass( this, ICPPASTDeclSpecifier.sc_mutable ); + return hasStorageClass( this, IASTDeclSpecifier.sc_mutable ); } /* (non-Javadoc) @@ -235,7 +227,7 @@ public class CPPMethod extends CPPFunction implements ICPPMethod { /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod#isPureVirtual() */ - public boolean isPureVirtual() throws DOMException { + public boolean isPureVirtual() { if (declarations != null) { for (IASTDeclarator dtor : declarations) { if (dtor == null) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodInstance.java index a24beb76902..1c687d96f0e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodInstance.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodInstance.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 IBM Corporation and others. + * Copyright (c) 2005, 2010 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 @@ -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.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument; @@ -28,25 +27,25 @@ public class CPPMethodInstance extends CPPFunctionInstance implements ICPPMethod /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMember#getVisibility() */ - public int getVisibility() throws DOMException { + public int getVisibility() { return ((ICPPMethod)getTemplateDefinition()).getVisibility(); } - public ICPPClassType getClassOwner() throws DOMException { + public ICPPClassType getClassOwner() { return (ICPPClassType) getOwner(); } /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod#isVirtual() */ - public boolean isVirtual() throws DOMException { + public boolean isVirtual() { return ((ICPPMethod)getTemplateDefinition()).isVirtual(); } /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod#isPureVirtual() */ - public boolean isPureVirtual() throws DOMException { + public boolean isPureVirtual() { return ((ICPPMethod)getTemplateDefinition()).isPureVirtual(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodSpecialization.java index d5531f13e80..a56ac19b637 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodSpecialization.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 IBM Corporation and others. + * Copyright (c) 2005, 2010 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 @@ -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.IASTDeclarator; import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition; import org.eclipse.cdt.core.dom.ast.IASTNode; @@ -32,7 +31,7 @@ public class CPPMethodSpecialization extends CPPFunctionSpecialization super(orig, owner, argMap ); } - public boolean isVirtual() throws DOMException { + public boolean isVirtual() { ICPPMethod f = (ICPPMethod) getSpecializedBinding(); if( f != null ) return f.isVirtual(); @@ -55,14 +54,14 @@ public class CPPMethodSpecialization extends CPPFunctionSpecialization return false; } - public int getVisibility() throws DOMException { + public int getVisibility() { ICPPMethod f = (ICPPMethod) getSpecializedBinding(); if( f != null ) return f.getVisibility(); return 0; } - public ICPPClassType getClassOwner() throws DOMException { + public ICPPClassType getClassOwner() { return (ICPPClassType) getOwner(); } @@ -78,7 +77,7 @@ public class CPPMethodSpecialization extends CPPFunctionSpecialization return ((ICPPMethod) getSpecializedBinding()).isImplicit(); } - public boolean isPureVirtual() throws DOMException { + public boolean isPureVirtual() { ICPPMethod f = (ICPPMethod) getSpecializedBinding(); if (f != null) return f.isPureVirtual(); @@ -87,7 +86,7 @@ public class CPPMethodSpecialization extends CPPFunctionSpecialization } @Override - public IType[] getExceptionSpecification() throws DOMException { + public IType[] getExceptionSpecification() { if (isImplicit()) { return ClassTypeHelper.getInheritedExceptionSpecification(this); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodTemplate.java index bccfd93b3f9..bd2f6ff79e2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodTemplate.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodTemplate.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 IBM Corporation and others. + * Copyright (c) 2005, 2010 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 @@ -40,7 +40,7 @@ public class CPPMethodTemplate extends CPPFunctionTemplate implements ICPPMethod super(name); } - public IASTDeclaration getPrimaryDeclaration() throws DOMException{ + public IASTDeclaration getPrimaryDeclaration() { //first check if we already know it if (declarations != null) { for (IASTName declaration : declarations) { @@ -65,8 +65,13 @@ public class CPPMethodTemplate extends CPPFunctionTemplate implements ICPPMethod final char[] myName = getTemplateName().getLookupKey(); IScope scope = getScope(); - if (scope instanceof ICPPTemplateScope) - scope = scope.getParent(); + if (scope instanceof ICPPTemplateScope) { + try { + scope = scope.getParent(); + } catch (DOMException e) { + return null; + } + } ICPPClassScope clsScope = (ICPPClassScope) scope; ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier) ASTInternal.getPhysicalNodeOfScope(clsScope); IASTDeclaration[] members = compSpec.getMembers(); @@ -92,7 +97,7 @@ public class CPPMethodTemplate extends CPPFunctionTemplate implements ICPPMethod return null; } - public int getVisibility() throws DOMException { + public int getVisibility() { IASTDeclaration decl = getPrimaryDeclaration(); if( decl == null ){ ICPPClassType cls = getClassOwner(); @@ -118,10 +123,14 @@ public class CPPMethodTemplate extends CPPFunctionTemplate implements ICPPMethod return ICPPASTVisibilityLabel.v_public; } - public ICPPClassType getClassOwner() throws DOMException { + public ICPPClassType getClassOwner() { IScope scope= getScope(); if (scope instanceof ICPPTemplateScope) { - scope= scope.getParent(); + try { + scope= scope.getParent(); + } catch (DOMException e) { + return null; + } } if( scope instanceof ICPPClassScope ){ return ((ICPPClassScope)scope).getClassType(); @@ -135,7 +144,7 @@ public class CPPMethodTemplate extends CPPFunctionTemplate implements ICPPMethod } @Override - public boolean isInline() throws DOMException { + public boolean isInline() { IASTDeclaration decl = getPrimaryDeclaration(); if( decl instanceof ICPPASTTemplateDeclaration && ((ICPPASTTemplateDeclaration)decl).getDeclaration() instanceof IASTFunctionDefinition ) return true; @@ -155,7 +164,7 @@ public class CPPMethodTemplate extends CPPFunctionTemplate implements ICPPMethod return false; } - public boolean isPureVirtual() throws DOMException { + public boolean isPureVirtual() { return false; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodTemplateSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodTemplateSpecialization.java index 14058959a5d..5ec15ba6be2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodTemplateSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodTemplateSpecialization.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 IBM Corporation and others. + * Copyright (c) 2005, 2010 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 @@ -11,7 +11,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; @@ -33,14 +32,14 @@ public class CPPMethodTemplateSpecialization extends CPPFunctionTemplateSpeciali return false; } - public int getVisibility() throws DOMException { + public int getVisibility() { IBinding m = getSpecializedBinding(); if( m instanceof ICPPMethod ) return ((ICPPMethod)m).getVisibility(); return 0; } - public ICPPClassType getClassOwner() throws DOMException { + public ICPPClassType getClassOwner() { return (ICPPClassType) getOwner(); } @@ -56,7 +55,7 @@ public class CPPMethodTemplateSpecialization extends CPPFunctionTemplateSpeciali return false; } - public boolean isPureVirtual() throws DOMException { + public boolean isPureVirtual() { return false; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNamespace.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNamespace.java index aea25ed1f52..9bf75fe1f2a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNamespace.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNamespace.java @@ -6,13 +6,13 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Corporation - initial API and implementation - * Markus Schorn (Wind River Systems) + * 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.ILinkage; -import org.eclipse.cdt.core.dom.ast.DOMException; +import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; @@ -23,7 +23,6 @@ import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.dom.ast.IScope; -import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification; @@ -32,6 +31,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTranslationUnit; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration; import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace; import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDirective; import org.eclipse.cdt.core.parser.Keywords; import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.parser.util.CharArrayUtils; @@ -43,31 +43,24 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.core.model.ASTStringUtil; import org.eclipse.core.runtime.PlatformObject; -/** - * @author aniefer - */ public class CPPNamespace extends PlatformObject implements ICPPNamespace, ICPPInternalBinding { - public static class CPPNamespaceProblem extends ProblemBinding implements ICPPNamespace{ + public static class CPPNamespaceProblem extends ProblemBinding implements ICPPNamespace, ICPPNamespaceScope{ public CPPNamespaceProblem(IASTNode node, int id, char[] arg) { super(node, id, arg); } - public ICPPNamespaceScope getNamespaceScope() throws DOMException { - throw new DOMException(this); + public ICPPNamespaceScope getNamespaceScope() { + return this; } - public IBinding[] getMemberBindings() throws DOMException { - throw new DOMException(this); + public IBinding[] getMemberBindings() { + return IBinding.EMPTY_BINDING_ARRAY; } - public String[] getQualifiedName() throws DOMException { - throw new DOMException(this); + public void addUsingDirective(ICPPUsingDirective usingDirective) { } - public char[][] getQualifiedNameCharArray() throws DOMException { - throw new DOMException(this); + public ICPPUsingDirective[] getUsingDirectives() { + return ICPPUsingDirective.EMPTY_ARRAY; } - public boolean isGloballyQualified() throws DOMException { - throw new DOMException(this); - } - public boolean isInline() { - return false; + public ICPPNamespaceScope[] getInlineNamespaces() { + return ICPPNamespaceScope.EMPTY_NAMESPACE_SCOPE_ARRAY; } } @@ -98,7 +91,7 @@ public class CPPNamespace extends PlatformObject implements ICPPNamespace, ICPPI return (tu != null) ? tu : (IASTNode) namespaceDefinitions[0]; } - static private class NamespaceCollector extends CPPASTVisitor { + static private class NamespaceCollector extends ASTVisitor { private ICPPASTNamespaceDefinition namespaceDef = null; private IASTName[] namespaces = null; @@ -142,7 +135,7 @@ public class CPPNamespace extends PlatformObject implements ICPPNamespace, ICPPI } } - static private class NamespaceMemberCollector extends CPPASTVisitor { + static private class NamespaceMemberCollector extends ASTVisitor { public ObjectSet members = new ObjectSet(8); public NamespaceMemberCollector() { shouldVisitNamespaces = true; @@ -365,7 +358,7 @@ public class CPPNamespace extends PlatformObject implements ICPPNamespace, ICPPI return ASTStringUtil.join(names, String.valueOf(Keywords.cpCOLONCOLON)); } - public IBinding getOwner() throws DOMException { + public IBinding getOwner() { if (namespaceDefinitions != null && namespaceDefinitions.length > 0) { return CPPVisitor.findDeclarationOwner(namespaceDefinitions[0], false); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNamespaceAlias.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNamespaceAlias.java index 32ed7b07638..4bec0e288bd 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNamespaceAlias.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNamespaceAlias.java @@ -36,7 +36,7 @@ public class CPPNamespaceAlias extends PlatformObject implements ICPPNamespaceAl this.alias = aliasName; } - public ICPPNamespaceScope getNamespaceScope() throws DOMException { + public ICPPNamespaceScope getNamespaceScope() { return namespace.getNamespaceScope(); } @@ -88,7 +88,7 @@ public class CPPNamespaceAlias extends PlatformObject implements ICPPNamespaceAl public void addDeclaration(IASTNode node) { } - public IBinding[] getMemberBindings() throws DOMException { + public IBinding[] getMemberBindings() { return namespace.getMemberBindings(); } @@ -96,7 +96,7 @@ public class CPPNamespaceAlias extends PlatformObject implements ICPPNamespaceAl return Linkage.CPP_LINKAGE; } - public IBinding getOwner() throws DOMException { + public IBinding getOwner() { return CPPVisitor.findDeclarationOwner(alias, false); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNamespaceScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNamespaceScope.java index 2eb1ea268c5..09f5bc21a16 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNamespaceScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNamespaceScope.java @@ -18,13 +18,13 @@ import java.util.Set; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.IName; +import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.EScopeKind; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.dom.ast.IScope; -import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition; import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace; @@ -106,7 +106,7 @@ public class CPPNamespaceScope extends CPPScope implements ICPPInternalNamespace public IScope findNamespaceScope(IIndexScope scope) { final String[] qname= scope.getScopeBinding().getQualifiedName(); final IScope[] result= {null}; - final CPPASTVisitor visitor= new CPPASTVisitor () { + final ASTVisitor visitor= new ASTVisitor () { private int depth= 0; { shouldVisitNamespaces= shouldVisitDeclarations= true; @@ -242,7 +242,6 @@ public class CPPNamespaceScope extends CPPScope implements ICPPInternalNamespace } else if (getKind() == EScopeKind.eGlobal) { inlineScopes= index.getInlineNamespaces(); } - } catch (DOMException e) { } catch (CoreException e) { } if (inlineScopes != null) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameter.java index e4de53cd6f9..5dc9c2e1c08 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameter.java @@ -12,7 +12,6 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp; import org.eclipse.cdt.core.dom.ILinkage; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; @@ -46,45 +45,6 @@ public class CPPParameter extends PlatformObject implements ICPPParameter, ICPPI public CPPParameterProblem(IASTNode node, int id, char[] arg) { super(node, id, arg); } - public IType getType() throws DOMException { - throw new DOMException(this); - } - public boolean isStatic() throws DOMException { - throw new DOMException(this); - } - public boolean isExtern() throws DOMException { - throw new DOMException(this); - } - public boolean isAuto() throws DOMException { - throw new DOMException(this); - } - public boolean isRegister() throws DOMException { - throw new DOMException(this); - } - public boolean hasDefaultValue() { - return false; - } - public boolean isMutable() throws DOMException { - throw new DOMException(this); - } - public String[] getQualifiedName() throws DOMException { - throw new DOMException(this); - } - public char[][] getQualifiedNameCharArray() throws DOMException { - throw new DOMException(this); - } - public boolean isGloballyQualified() throws DOMException { - throw new DOMException(this); - } - public boolean isExternC() { - return false; - } - public IValue getInitialValue() { - return null; - } - public boolean isParameterPack() { - return false; - } } private IType fType = null; @@ -315,7 +275,7 @@ public class CPPParameter extends PlatformObject implements ICPPParameter, ICPPI return name.length() != 0 ? name : ""; //$NON-NLS-1$ } - public IBinding getOwner() throws DOMException { + public IBinding getOwner() { return CPPVisitor.findEnclosingFunction(fDeclarations[0]); } 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 b7bd1409b5d..23ab59c190d 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, 2009 IBM Corporation and others. + * Copyright (c) 2005, 2010 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 @@ -68,14 +68,14 @@ public class CPPParameterSpecialization extends CPPSpecialization implements ICP /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IVariable#isAuto() */ - public boolean isAuto() throws DOMException { + public boolean isAuto() { return getParameter().isAuto(); } /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IVariable#isRegister() */ - public boolean isRegister() throws DOMException { + public boolean isRegister() { return getParameter().isRegister(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScope.java index 8fd5fb47976..43b600965d7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScope.java @@ -82,7 +82,7 @@ abstract public class CPPScope implements ICPPASTInternalScope { } @SuppressWarnings({ "unchecked" }) - public void addName(IASTName name) throws DOMException { + public void addName(IASTName name) { // don't add inactive names to the scope if (!name.isActive()) return; @@ -141,7 +141,7 @@ abstract public class CPPScope implements ICPPASTInternalScope { } } - public IBinding getBinding(IASTName name, boolean forceResolve, IIndexFileSet fileSet) throws DOMException { + public IBinding getBinding(IASTName name, boolean forceResolve, IIndexFileSet fileSet) { IBinding binding= getBindingInAST(name, forceResolve); if (binding == null && forceResolve) { final IASTTranslationUnit tu = name.getTranslationUnit(); @@ -190,17 +190,17 @@ abstract public class CPPScope implements ICPPASTInternalScope { return fIndexNamespace; } - public IBinding getBindingInAST(IASTName name, boolean forceResolve) throws DOMException { + public IBinding getBindingInAST(IASTName name, boolean forceResolve) { IBinding[] bs= getBindingsInAST(name, forceResolve, false, false, true); return CPPSemantics.resolveAmbiguities(name, bs); } - public final IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet) throws DOMException { + public final IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet) { return getBindings(name, resolve, prefixLookup, fileSet, true); } public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet, - boolean checkPointOfDecl) throws DOMException { + boolean checkPointOfDecl) { IBinding[] result = getBindingsInAST(name, resolve, prefixLookup, checkPointOfDecl, true); final IASTTranslationUnit tu = name.getTranslationUnit(); if (tu != null) { @@ -243,7 +243,7 @@ abstract public class CPPScope implements ICPPASTInternalScope { } public IBinding[] getBindingsInAST(IASTName name, boolean forceResolve, boolean prefixLookup, - boolean checkPointOfDecl, boolean expandUsingDirectives) throws DOMException { + boolean checkPointOfDecl, boolean expandUsingDirectives) { populateCache(); final char[] c = name.getLookupKey(); IBinding[] result = null; @@ -327,7 +327,7 @@ abstract public class CPPScope implements ICPPASTInternalScope { /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String) */ - public IBinding[] find(String name) throws DOMException { + public IBinding[] find(String name) { return CPPSemantics.findBindings(this, name, false); } @@ -354,26 +354,21 @@ abstract public class CPPScope implements ICPPASTInternalScope { } } - public final IBinding getBinding(IASTName name, boolean resolve) throws DOMException { + public final IBinding getBinding(IASTName name, boolean resolve) { return getBinding(name, resolve, IIndexFileSet.EMPTY); } - public final IBinding[] getBindings(IASTName name, boolean resolve, boolean prefix) throws DOMException { + public final IBinding[] getBindings(IASTName name, boolean resolve, boolean prefix) { return getBindings(name, resolve, prefix, IIndexFileSet.EMPTY, true); } - public IName getScopeName() throws DOMException { + public IName getScopeName() { return null; } @Override public String toString() { - IName name = null; - try { - name = getScopeName(); - } catch (DOMException e) { - } - + IName name = getScopeName(); final String n= name != null ? name.toString() : ""; //$NON-NLS-1$ return getKind().toString() + ' ' + n + ' ' + '(' + super.toString() + ')'; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScopeMapper.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScopeMapper.java index 479d90d1ad5..42929385ba8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScopeMapper.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScopeMapper.java @@ -88,19 +88,19 @@ public class CPPScopeMapper { return fScope.getKind(); } - public IBinding[] find(String name) throws DOMException { + public IBinding[] find(String name) { return fScope.find(name); } - public IBinding getBinding(IASTName name, boolean resolve) throws DOMException { + public IBinding getBinding(IASTName name, boolean resolve) { return fScope.getBinding(name, resolve); } - public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet acceptLocalBindings) throws DOMException { + public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet acceptLocalBindings) { return fScope.getBinding(name, resolve, acceptLocalBindings); } - public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup) throws DOMException { + public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup) { return fScope.getBindings(name, resolve, prefixLookup); } - public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet acceptLocalBindings) throws DOMException { + public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet acceptLocalBindings) { return fScope.getBindings(name, resolve, prefixLookup, acceptLocalBindings); } public IScope getParent() throws DOMException { @@ -111,7 +111,7 @@ public class CPPScopeMapper { return fTu.getScope(); } - public IName getScopeName() throws DOMException { + public IName getScopeName() { return fScope.getScopeName(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateDefinition.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateDefinition.java index c7ed9ffeaa8..28b40013700 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateDefinition.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateDefinition.java @@ -1,12 +1,12 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 IBM Corporation and others. + * Copyright (c) 2005, 2010 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 - 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; @@ -43,9 +43,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.core.runtime.PlatformObject; -/** - * @author aniefer - */ public abstract class CPPTemplateDefinition extends PlatformObject implements ICPPTemplateDefinition, ICPPInternalTemplate { public static final class CPPTemplateProblem extends ProblemBinding implements ICPPTemplateDefinition { public CPPTemplateProblem(IASTNode node, int id, char[] arg) { @@ -57,15 +54,6 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC public ICPPClassTemplatePartialSpecialization[] getTemplateSpecializations() throws DOMException { throw new DOMException(this); } - public String[] getQualifiedName() throws DOMException { - throw new DOMException(this); - } - public char[][] getQualifiedNameCharArray() throws DOMException { - throw new DOMException(this); - } - public boolean isGloballyQualified() throws DOMException { - throw new DOMException(this); - } } protected IASTName[] declarations; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeParameter.java index 83a4ecb3424..7a05f896c98 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeParameter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeParameter.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.IASTDeclarator; import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer; import org.eclipse.cdt.core.dom.ast.IASTExpression; @@ -115,16 +114,16 @@ public class CPPTemplateNonTypeParameter extends CPPTemplateParameter implements return getType() instanceof ICPPParameterPackType; } - public boolean isStatic() throws DOMException { + public boolean isStatic() { return false; } - public boolean isExtern() throws DOMException { + public boolean isExtern() { return false; } - public boolean isAuto() throws DOMException { + public boolean isAuto() { return false; } - public boolean isRegister() throws DOMException { + public boolean isRegister() { return false; } public IValue getInitialValue() { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateParameter.java index a1a4cb5c6db..e53e0ff548a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateParameter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateParameter.java @@ -218,7 +218,7 @@ public abstract class CPPTemplateParameter extends PlatformObject return getName(); } - public IBinding getOwner() throws DOMException { + public IBinding getOwner() { if (declarations == null || declarations.length == 0) return null; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateScope.java index 702635cfdfe..6057105f843 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateScope.java @@ -1,12 +1,12 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. + * Copyright (c) 2005, 2010 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 - 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; @@ -21,9 +21,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; -/** - * @author aniefer - */ public class CPPTemplateScope extends CPPScope implements ICPPTemplateScope { public CPPTemplateScope(IASTNode physicalNode) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTemplateParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTemplateParameter.java index ac1d745c24f..104449d07c2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTemplateParameter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTemplateParameter.java @@ -126,39 +126,39 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement public ICPPBase[] getBases() { return ICPPBase.EMPTY_BASE_ARRAY; } - public IField[] getFields() throws DOMException { + public IField[] getFields() { return IField.EMPTY_FIELD_ARRAY; } - public IField findField(String name) throws DOMException { + public IField findField(String name) { return null; } - public ICPPField[] getDeclaredFields() throws DOMException { + public ICPPField[] getDeclaredFields() { return ICPPField.EMPTY_CPPFIELD_ARRAY; } - public ICPPMethod[] getMethods() throws DOMException { + public ICPPMethod[] getMethods() { return ICPPMethod.EMPTY_CPPMETHOD_ARRAY; } - public ICPPMethod[] getAllDeclaredMethods() throws DOMException { + public ICPPMethod[] getAllDeclaredMethods() { return ICPPMethod.EMPTY_CPPMETHOD_ARRAY; } - public ICPPMethod[] getDeclaredMethods() throws DOMException { + public ICPPMethod[] getDeclaredMethods() { return ICPPMethod.EMPTY_CPPMETHOD_ARRAY; } public ICPPConstructor[] getConstructors() { return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY; } - public IBinding[] getFriends() throws DOMException { + public IBinding[] getFriends() { return IBinding.EMPTY_BINDING_ARRAY; } public ICPPClassType[] getNestedClasses() { return ICPPClassType.EMPTY_CLASS_ARRAY; } - public int getKey() throws DOMException { + public int getKey() { return 0; } - public IScope getCompositeScope() throws DOMException { + public IScope getCompositeScope() { return null; } 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 b05ea3a7db7..39d7862d36f 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 @@ -1,13 +1,13 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 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 - * Markus Schorn (Wind River Systems) + * Andrew Niefer (IBM Corporation) - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -29,9 +29,6 @@ import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.core.runtime.PlatformObject; -/** - * @author aniefer - */ public class CPPTypedef extends PlatformObject implements ITypedef, ITypeContainer, ICPPInternalBinding { private IASTName[] declarations = null; @@ -195,7 +192,7 @@ public class CPPTypedef extends PlatformObject implements ITypedef, ITypeContain return getName(); } - public IBinding getOwner() throws DOMException { + public IBinding getOwner() { if (declarations != null && declarations.length > 0) { return CPPVisitor.findDeclarationOwner(declarations[0], true); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownBinding.java index cb87541778b..406f9392e78 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownBinding.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownBinding.java @@ -92,7 +92,7 @@ public class CPPUnknownBinding extends PlatformObject return null; } - public ICPPScope asScope() throws DOMException { + public ICPPScope asScope() { if (unknownScope == null) { unknownScope = new CPPUnknownScope(this, name); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownClass.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownClass.java index 6e759f5ec3c..d73abf4e428 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownClass.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownClass.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 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 @@ -12,7 +12,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IField; import org.eclipse.cdt.core.dom.ast.IScope; @@ -73,11 +72,11 @@ public class CPPUnknownClass extends CPPUnknownBinding implements ICPPUnknownCla return IBinding.EMPTY_BINDING_ARRAY; } - public int getKey() throws DOMException{ + public int getKey(){ return 0; } - public final IScope getCompositeScope() throws DOMException { + public final IScope getCompositeScope() { return asScope(); } @@ -93,13 +92,10 @@ public class CPPUnknownClass extends CPPUnknownBinding implements ICPPUnknownCla && !(type instanceof ICPPDeferredClassInstance)) { ICPPUnknownClassType rhs= (ICPPUnknownClassType) type; if (CharArrayUtils.equals(getNameCharArray(), rhs.getNameCharArray())) { - try { - final IBinding lhsContainer = getOwner(); - final IBinding rhsContainer = rhs.getOwner(); - if (lhsContainer instanceof IType && rhsContainer instanceof IType) { - return ((IType) lhsContainer).isSameType((IType) rhsContainer); - } - } catch (DOMException e) { + final IBinding lhsContainer = getOwner(); + final IBinding rhsContainer = rhs.getOwner(); + if (lhsContainer instanceof IType && rhsContainer instanceof IType) { + return ((IType) lhsContainer).isSameType((IType) rhsContainer); } } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownClassInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownClassInstance.java index 470ac4028ff..0f3c3af4587 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownClassInstance.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownClassInstance.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Google, Inc and others. + * Copyright (c) 2008, 2010 Google, 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 @@ -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.IBinding; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; @@ -67,13 +66,10 @@ public class CPPUnknownClassInstance extends CPPUnknownClass implements ICPPUnkn return false; } } - try { - final IBinding lhsContainer = getOwner(); - final IBinding rhsContainer = rhs.getOwner(); - if (lhsContainer instanceof IType && rhsContainer instanceof IType) { - return (((IType)lhsContainer).isSameType((IType) rhsContainer)); - } - } catch (DOMException e) { + final IBinding lhsContainer = getOwner(); + final IBinding rhsContainer = rhs.getOwner(); + if (lhsContainer instanceof IType && rhsContainer instanceof IType) { + return (((IType)lhsContainer).isSameType((IType) rhsContainer)); } } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownConstructor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownConstructor.java index b056ad673e9..85bf91bb0c9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownConstructor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownConstructor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2010 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; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; @@ -24,7 +23,7 @@ public class CPPUnknownConstructor extends CPPUnknownFunction implements ICPPCon super(owner, owner.getNameCharArray()); } - public boolean isExplicit() throws DOMException { + public boolean isExplicit() { return false; } @@ -36,19 +35,19 @@ public class CPPUnknownConstructor extends CPPUnknownFunction implements ICPPCon return false; } - public boolean isPureVirtual() throws DOMException { + public boolean isPureVirtual() { return false; } - public boolean isVirtual() throws DOMException { + public boolean isVirtual() { return false; } - public ICPPClassType getClassOwner() throws DOMException { + public ICPPClassType getClassOwner() { return (ICPPClassType) getOwner(); } - public int getVisibility() throws DOMException { + public int getVisibility() { return v_public; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownFunction.java index a023ffe4103..183fc520df6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownFunction.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownFunction.java @@ -39,7 +39,7 @@ public class CPPUnknownFunction extends CPPUnknownBinding implements ICPPFunctio super(owner, name); } - public IType[] getExceptionSpecification() throws DOMException { + public IType[] getExceptionSpecification() { return null; } @@ -47,15 +47,15 @@ public class CPPUnknownFunction extends CPPUnknownBinding implements ICPPFunctio return false; } - public boolean isExternC() throws DOMException { + public boolean isExternC() { return false; } - public boolean isInline() throws DOMException { + public boolean isInline() { return false; } - public boolean isMutable() throws DOMException { + public boolean isMutable() { return false; } @@ -63,38 +63,38 @@ public class CPPUnknownFunction extends CPPUnknownBinding implements ICPPFunctio return asScope(); } - public ICPPParameter[] getParameters() throws DOMException { + public ICPPParameter[] getParameters() { return ICPPParameter.EMPTY_CPPPARAMETER_ARRAY; } - public ICPPFunctionType getType() throws DOMException { + public ICPPFunctionType getType() { if (fType == null) { fType= new CPPUnknownFunctionType(); } return fType; } - public boolean isAuto() throws DOMException { + public boolean isAuto() { return false; } - public boolean isExtern() throws DOMException { + public boolean isExtern() { return false; } - public boolean isRegister() throws DOMException { + public boolean isRegister() { return false; } - public boolean isStatic() throws DOMException { + public boolean isStatic() { return false; } - public boolean takesVarArgs() throws DOMException { + public boolean takesVarArgs() { return false; } - public int getRequiredArgumentCount() throws DOMException { + public int getRequiredArgumentCount() { return 0; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownScope.java index f90408c2f8c..6bfd13c52f2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownScope.java @@ -13,7 +13,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; -import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.IName; import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.EScopeKind; @@ -22,13 +21,13 @@ import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IScope; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier; import org.eclipse.cdt.core.index.IIndexFileSet; import org.eclipse.cdt.core.parser.util.CharArrayObjectMap; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics; @@ -86,7 +85,7 @@ public class CPPUnknownScope implements ICPPInternalUnknownScope { public void addName(IASTName name) { } - public final IBinding getBinding(IASTName name, boolean resolve) throws DOMException { + public final IBinding getBinding(IASTName name, boolean resolve) { return getBinding(name, resolve, IIndexFileSet.EMPTY); } @@ -157,7 +156,7 @@ public class CPPUnknownScope implements ICPPInternalUnknownScope { return result; } - public final IBinding[] getBindings(IASTName name, boolean resolve, boolean prefix) throws DOMException { + public final IBinding[] getBindings(IASTName name, boolean resolve, boolean prefix) { return getBindings(name, resolve, prefix, IIndexFileSet.EMPTY); } @@ -168,15 +167,11 @@ public class CPPUnknownScope implements ICPPInternalUnknownScope { public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet acceptLocalBindings, boolean checkPointOfDecl) { if (prefixLookup) { if (binding instanceof ICPPDeferredClassInstance) { - try { - ICPPDeferredClassInstance instance = (ICPPDeferredClassInstance) binding; - IScope scope = instance.getClassTemplate().getCompositeScope(); - if (scope != null) { - return scope.getBindings(name, resolve, prefixLookup, acceptLocalBindings); - } - } catch (DOMException exc) { - CCorePlugin.log(exc); - } + ICPPDeferredClassInstance instance = (ICPPDeferredClassInstance) binding; + IScope scope = instance.getClassTemplate().getCompositeScope(); + if (scope != null) { + return scope.getBindings(name, resolve, prefixLookup, acceptLocalBindings); + } } return IBinding.EMPTY_BINDING_ARRAY; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUsingDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUsingDeclaration.java index f13a4db0211..d4807ecdfdf 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUsingDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUsingDeclaration.java @@ -1,13 +1,13 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 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 - * Markus Schorn (Wind River Systems) + * Andrew Niefer (IBM Corporation) - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -25,9 +25,6 @@ import org.eclipse.cdt.internal.core.dom.Linkage; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.core.runtime.PlatformObject; -/** - * @author aniefer - */ public class CPPUsingDeclaration extends PlatformObject implements ICPPUsingDeclaration, ICPPInternalBinding { private IASTName name; private IBinding[] delegates; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVariable.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVariable.java index f3072075cc2..e196cfb1a0b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVariable.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVariable.java @@ -6,9 +6,9 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Corporation - initial API and implementation - * Markus Schorn (Wind River Systems) - * Ed Swartz (Nokia) + * Andrew Niefer (IBM Corporation) - Initial API and implementation + * Markus Schorn (Wind River Systems) + * Ed Swartz (Nokia) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -47,49 +47,11 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil; import org.eclipse.core.runtime.PlatformObject; -/** - * @author aniefer - */ public class CPPVariable extends PlatformObject implements ICPPVariable, ICPPInternalBinding, IInternalVariable { public static class CPPVariableProblem extends ProblemBinding implements ICPPVariable { public CPPVariableProblem(IASTNode node, int id, char[] arg) { super(node, id, arg); } - - public IType getType() throws DOMException { - throw new DOMException(this); - } - - public boolean isStatic() throws DOMException { - throw new DOMException(this); - } - public String[] getQualifiedName() throws DOMException { - throw new DOMException(this); - } - public char[][] getQualifiedNameCharArray() throws DOMException { - throw new DOMException(this); - } - public boolean isGloballyQualified() throws DOMException { - throw new DOMException(this); - } - public boolean isMutable() throws DOMException { - throw new DOMException(this); - } - public boolean isExtern() throws DOMException { - throw new DOMException(this); - } - public boolean isExternC() throws DOMException { - throw new DOMException(this); - } - public boolean isAuto() throws DOMException { - throw new DOMException(this); - } - public boolean isRegister() throws DOMException { - throw new DOMException(this); - } - public IValue getInitialValue() { - return null; - } } private IASTName fDefinition = null; @@ -362,7 +324,7 @@ public class CPPVariable extends PlatformObject implements ICPPVariable, ICPPInt return Linkage.CPP_LINKAGE; } - public IBinding getOwner() throws DOMException { + public IBinding getOwner() { IASTName node = fDefinition != null ? fDefinition : fDeclarations[0]; return CPPVisitor.findNameOwner(node, !hasStorageClass(IASTDeclSpecifier.sc_extern)); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ClassTypeHelper.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ClassTypeHelper.java index 07dc5eda2a6..7e91d3e0253 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ClassTypeHelper.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ClassTypeHelper.java @@ -63,7 +63,6 @@ import org.eclipse.cdt.core.parser.util.ObjectSet; import org.eclipse.cdt.internal.core.dom.parser.ASTInternal; import org.eclipse.cdt.internal.core.dom.parser.ASTQueries; import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassType.CPPClassTypeProblem; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil; @@ -81,11 +80,9 @@ public class ClassTypeHelper { if (host.getDefinition() == null) { host.checkForDefinition(); if (host.getDefinition() == null) { - try { - ICPPClassType backup= getBackupDefinition(host); - if (backup != null) - return backup.getFriends(); - } catch (DOMException e) {} + ICPPClassType backup= getBackupDefinition(host); + if (backup != null) + return backup.getFriends(); IASTNode[] declarations= host.getDeclarations(); IASTNode node = (declarations != null && declarations.length > 0) ? declarations[0] : null; return new IBinding[] { new ProblemBinding(node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, host.getNameCharArray()) }; @@ -163,7 +160,7 @@ public class ClassTypeHelper { * A host maybe backed up with a definition from the index. * @throws DOMException */ - private static ICPPClassType getBackupDefinition(ICPPInternalClassTypeMixinHost host) throws DOMException { + private static ICPPClassType getBackupDefinition(ICPPInternalClassTypeMixinHost host) { ICPPClassScope scope = host.getCompositeScope(); if (scope != null) { ICPPClassType b = scope.getClassType(); @@ -177,15 +174,11 @@ public class ClassTypeHelper { if (host.getDefinition() == null) { host.checkForDefinition(); if (host.getDefinition() == null) { - try { - ICPPClassType backup= getBackupDefinition(host); - if (backup != null) - return backup.getBases(); - } catch (DOMException e) {} + ICPPClassType backup= getBackupDefinition(host); + if (backup != null) + return backup.getBases(); - IASTNode[] declarations= host.getDeclarations(); - IASTNode node = (declarations != null && declarations.length > 0) ? declarations[0] : null; - return new ICPPBase[] { new CPPBaseClause.CPPBaseProblem(node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, host.getNameCharArray()) }; + return ICPPBase.EMPTY_BASE_ARRAY; } } ICPPASTBaseSpecifier[] bases = host.getCompositeTypeSpecifier().getBaseSpecifiers(); @@ -200,19 +193,15 @@ public class ClassTypeHelper { return bindings; } - public static ICPPField[] getDeclaredFields(ICPPInternalClassTypeMixinHost host) throws DOMException { + public static ICPPField[] getDeclaredFields(ICPPInternalClassTypeMixinHost host) { if (host.getDefinition() == null) { host.checkForDefinition(); if (host.getDefinition() == null) { - try { - ICPPClassType backup= getBackupDefinition(host); - if (backup != null) - return backup.getDeclaredFields(); - } catch (DOMException e) {} + ICPPClassType backup= getBackupDefinition(host); + if (backup != null) + return backup.getDeclaredFields(); - IASTNode[] declarations= host.getDeclarations(); - IASTNode node = (declarations != null && declarations.length > 0) ? declarations[0] : null; - return new ICPPField[] { new CPPField.CPPFieldProblem(node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, host.getNameCharArray()) }; + return ICPPField.EMPTY_CPPFIELD_ARRAY; } } IBinding binding = null; @@ -248,9 +237,8 @@ public class ClassTypeHelper { * Returns all direct and indirect base classes that have at least a given visibility level. * @param classType a class * @return An array of visible base classes in arbitrary order. - * @throws DOMException */ - public static ICPPClassType[] getAllBases(ICPPClassType classType) throws DOMException { + public static ICPPClassType[] getAllBases(ICPPClassType classType) { HashSet result= new HashSet(); result.add(classType); getAllBases(classType, result); @@ -258,7 +246,7 @@ public class ClassTypeHelper { return result.toArray(new ICPPClassType[result.size()]); } - private static void getAllBases(ICPPClassType classType, HashSet result) throws DOMException { + private static void getAllBases(ICPPClassType classType, HashSet result) { ICPPBase[] bases= classType.getBases(); for (ICPPBase base : bases) { IBinding b= base.getBaseClass(); @@ -271,7 +259,7 @@ public class ClassTypeHelper { } } - public static ICPPMethod[] getAllDeclaredMethods(ICPPClassType ct) throws DOMException { + public static ICPPMethod[] getAllDeclaredMethods(ICPPClassType ct) { ICPPMethod[] methods= ct.getDeclaredMethods(); ICPPClassType[] bases= getAllBases(ct); for (ICPPClassType base : bases) { @@ -280,7 +268,7 @@ public class ClassTypeHelper { return (ICPPMethod[]) ArrayUtil.trim(ICPPMethod.class, methods); } - public static ICPPMethod[] getMethods(ICPPClassType ct) throws DOMException { + public static ICPPMethod[] getMethods(ICPPClassType ct) { ObjectSet set= new ObjectSet(4); set.addAll(ct.getDeclaredMethods()); ICPPClassScope scope= (ICPPClassScope) ct.getCompositeScope(); @@ -297,7 +285,7 @@ public class ClassTypeHelper { return set.keyArray(ICPPMethod.class); } - public static ICPPMethod[] getDeclaredMethods(ICPPInternalClassTypeMixinHost host) throws DOMException { + public static ICPPMethod[] getDeclaredMethods(ICPPInternalClassTypeMixinHost host) { if (host.getDefinition() == null) { host.checkForDefinition(); if (host.getDefinition() == null) { @@ -305,9 +293,7 @@ public class ClassTypeHelper { if (backup != null) return backup.getDeclaredMethods(); - IASTNode[] declarations= host.getDeclarations(); - IASTNode node = (declarations != null && declarations.length > 0) ? declarations[0] : null; - return new ICPPMethod[] { new CPPMethod.CPPMethodProblem(node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, host.getNameCharArray()) }; + return ICPPMethod.EMPTY_CPPMETHOD_ARRAY; } } IBinding binding = null; @@ -357,12 +343,10 @@ public class ClassTypeHelper { /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getConstructors() */ - public static ICPPConstructor[] getConstructors(ICPPInternalClassTypeMixinHost host) throws DOMException { + public static ICPPConstructor[] getConstructors(ICPPInternalClassTypeMixinHost host) { ICPPClassScope scope = host.getCompositeScope(); if (scope == null) { - IASTNode[] declarations= host.getDeclarations(); - IASTNode node = (declarations != null && declarations.length > 0) ? declarations[0] : null; - return new ICPPConstructor[] { new CPPConstructor.CPPConstructorProblem(node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, host.getNameCharArray()) }; + return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY; } return scope.getConstructors(); } @@ -371,15 +355,11 @@ public class ClassTypeHelper { if (host.getDefinition() == null) { host.checkForDefinition(); if (host.getDefinition() == null) { - try { - ICPPClassType backup= getBackupDefinition(host); - if (backup != null) - return backup.getNestedClasses(); - } catch (DOMException e) {} + ICPPClassType backup= getBackupDefinition(host); + if (backup != null) + return backup.getNestedClasses(); - IASTNode[] declarations= host.getDeclarations(); - IASTNode node = (declarations != null && declarations.length > 0) ? declarations[0] : null; - return new ICPPClassType[] { new CPPClassTypeProblem(node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, host.getNameCharArray()) }; + return ICPPClassType.EMPTY_CLASS_ARRAY; } } @@ -405,7 +385,7 @@ public class ClassTypeHelper { return (ICPPClassType[]) ArrayUtil.trim(ICPPClassType.class, result); } - public static IField[] getFields(ICPPClassType ct) throws DOMException { + public static IField[] getFields(ICPPClassType ct) { IField[] fields = ct.getDeclaredFields(); ICPPClassType[] bases = getAllBases(ct); for (ICPPClassType base : bases) { @@ -414,7 +394,7 @@ public class ClassTypeHelper { return (IField[]) ArrayUtil.trim(IField.class, fields); } - public static IField findField(ICPPClassType ct, String name) throws DOMException { + public static IField findField(ICPPClassType ct, String name) { IBinding[] bindings = CPPSemantics.findBindings(ct.getCompositeScope(), name, true); IField field = null; for (IBinding binding : bindings) { @@ -424,7 +404,7 @@ public class ClassTypeHelper { } else { IASTNode[] decls= ASTInternal.getDeclarationsOfBinding(ct); IASTNode node= (decls != null && decls.length > 0) ? decls[0] : null; - return new CPPField.CPPFieldProblem(node, IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, name.toCharArray()); + return new CPPField.CPPFieldProblem(ct, node, IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, name.toCharArray()); } } } @@ -659,9 +639,8 @@ public class ClassTypeHelper { /** * For implicit methods the exception specification is inherited, search it - * @throws DOMException */ - public static IType[] getInheritedExceptionSpecification(ICPPMethod implicitMethod) throws DOMException { + public static IType[] getInheritedExceptionSpecification(ICPPMethod implicitMethod) { // See 15.4.13 ICPPClassType owner= implicitMethod.getClassOwner(); if (owner == null || owner.getBases().length == 0) @@ -690,40 +669,43 @@ public class ClassTypeHelper { return inheritedTypeids.toArray(new IType[inheritedTypeids.size()]); } - private static int getImplicitMethodKind(ICPPClassType ct, ICPPMethod method) throws DOMException { - if (method instanceof ICPPConstructor) { - final IFunctionType type= method.getType(); - final IType[] params= type.getParameterTypes(); - if (params.length == 0) - return KIND_DEFAULT_CTOR; - if (params.length == 1) { - IType t= SemanticUtil.getNestedType(params[0], SemanticUtil.TDEF); - if (SemanticUtil.isVoidType(t)) + private static int getImplicitMethodKind(ICPPClassType ct, ICPPMethod method) { + try { + if (method instanceof ICPPConstructor) { + final IFunctionType type= method.getType(); + final IType[] params= type.getParameterTypes(); + if (params.length == 0) return KIND_DEFAULT_CTOR; + if (params.length == 1) { + IType t= SemanticUtil.getNestedType(params[0], SemanticUtil.TDEF); + if (SemanticUtil.isVoidType(t)) + return KIND_DEFAULT_CTOR; - if (isRefToConstClass(ct, t)) - return KIND_COPY_CTOR; + if (isRefToConstClass(ct, t)) + return KIND_COPY_CTOR; + } + return KIND_OTHER; } - return KIND_OTHER; - } - - if (method.isDestructor()) - return KIND_DTOR; - - if (CharArrayUtils.equals(method.getNameCharArray(), OverloadableOperator.ASSIGN.toCharArray())) { - final IFunctionType type= method.getType(); - final IType[] params= type.getParameterTypes(); - if (params.length == 1) { - IType t= params[0]; - if (isRefToConstClass(ct, t)) - return KIND_ASSIGNMENT_OP; + + if (method.isDestructor()) + return KIND_DTOR; + + if (CharArrayUtils.equals(method.getNameCharArray(), OverloadableOperator.ASSIGN.toCharArray())) { + final IFunctionType type= method.getType(); + final IType[] params= type.getParameterTypes(); + if (params.length == 1) { + IType t= params[0]; + if (isRefToConstClass(ct, t)) + return KIND_ASSIGNMENT_OP; + } + return KIND_OTHER; } - return KIND_OTHER; + } catch (DOMException e) { } return KIND_OTHER; } - private static boolean isRefToConstClass(ICPPClassType ct, IType t) throws DOMException { + private static boolean isRefToConstClass(ICPPClassType ct, IType t) { while (t instanceof ITypedef) t= ((ITypedef) t).getType(); @@ -739,7 +721,7 @@ public class ClassTypeHelper { return false; } - private static ICPPMethod getMethodInClass(ICPPClassType ct, int kind) throws DOMException { + private static ICPPMethod getMethodInClass(ICPPClassType ct, int kind) { switch(kind) { case KIND_DEFAULT_CTOR: case KIND_COPY_CTOR: @@ -772,7 +754,7 @@ public class ClassTypeHelper { * no private or protected non-static data members (Clause 11), * no base classes (Clause 10), and no virtual functions (10.3). */ - public static boolean isAggregateClass(ICPPClassType classTarget) throws DOMException { + public static boolean isAggregateClass(ICPPClassType classTarget) { if (classTarget.getBases().length > 0) return false; ICPPMethod[] methods = classTarget.getDeclaredMethods(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPASTInternalScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPASTInternalScope.java index bb8d357c4f1..7e22d3b3a52 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPASTInternalScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPASTInternalScope.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2010 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; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IScope; @@ -28,5 +27,5 @@ public interface ICPPASTInternalScope extends IASTInternalScope, ICPPScope { * dependent bindings, where the points of declaration may be reversed. */ public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, - IIndexFileSet acceptLocalBindings, boolean checkPointOfDecl) throws DOMException; + IIndexFileSet acceptLocalBindings, boolean checkPointOfDecl); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPClassSpecializationScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPClassSpecializationScope.java index 925c298ff4c..3a086562752 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPClassSpecializationScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPClassSpecializationScope.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2010 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; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope; @@ -39,25 +38,25 @@ public interface ICPPClassSpecializationScope extends ICPPClassScope { /** * Computes the bases via the original class. */ - ICPPBase[] getBases() throws DOMException; + ICPPBase[] getBases(); /** * Computes the methods via the original class. */ - ICPPMethod[] getDeclaredMethods() throws DOMException; + ICPPMethod[] getDeclaredMethods(); /** * Computes the fields via the original class. */ - ICPPField[] getDeclaredFields() throws DOMException; + ICPPField[] getDeclaredFields(); /** * Computes the friends via the original class. */ - IBinding[] getFriends() throws DOMException; + IBinding[] getFriends(); /** * Computes the nested classes via the original class. */ - ICPPClassType[] getNestedClasses() throws DOMException; + ICPPClassType[] getNestedClasses(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalClassTypeMixinHost.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalClassTypeMixinHost.java index 9fc715d74a8..187a3a94e19 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalClassTypeMixinHost.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalClassTypeMixinHost.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Symbian Software Systems and others. + * Copyright (c) 2007, 2010 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.dom.parser.cpp; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; @@ -27,7 +26,7 @@ interface ICPPInternalClassTypeMixinHost extends ICPPClassType, ICPPInternalBind /** * {@inheritDoc} */ - ICPPClassScope getCompositeScope() throws DOMException; + ICPPClassScope getCompositeScope(); /** * Ensures the ICPPInternalBinding definition is set, if this is possible. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/AccessContext.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/AccessContext.java index 2b66eb2e022..11af1fb58f0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/AccessContext.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/AccessContext.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Google, Inc and others. + * Copyright (c) 2009, 2010 Google, 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 @@ -111,11 +111,7 @@ public class AccessContext { return false; } } - try { - namingClass = getNamingClass(accessOwner); - } catch (DOMException e) { - return false; - } + namingClass = getNamingClass(accessOwner); return true; } @@ -222,7 +218,7 @@ public class AccessContext { } - private ICPPClassType getNamingClass(ICPPClassType accessOwner) throws DOMException { + private ICPPClassType getNamingClass(ICPPClassType accessOwner) { ICPPClassType classType = firstCandidateForNamingClass; if (classType != null && isUnqualifiedLookup) { IBinding owner = classType.getOwner(); @@ -239,28 +235,22 @@ public class AccessContext { return true; } if (maxdepth > 0) { - try { - for (ICPPBase cppBase : derived.getBases()) { - try { - IBinding base= cppBase.getBaseClass(); - if (base instanceof ICPPClassType) { - ICPPClassType tbase= (ICPPClassType) base; - if (tbase.isSameType(target)) { - return true; - } - if (derivesFrom(tbase, target, maxdepth - 1)) - return true; - } - } catch (DOMException e) { + for (ICPPBase cppBase : derived.getBases()) { + IBinding base= cppBase.getBaseClass(); + if (base instanceof ICPPClassType) { + ICPPClassType tbase= (ICPPClassType) base; + if (tbase.isSameType(target)) { + return true; } + if (derivesFrom(tbase, target, maxdepth - 1)) + return true; } - } catch (DOMException e) { } } return false; } - private static IBinding[] getContext(IASTName name) throws DOMException { + private static IBinding[] getContext(IASTName name) { IBinding[] accessibilityContext = IBinding.EMPTY_BINDING_ARRAY; for (IBinding binding = CPPVisitor.findEnclosingFunctionOrClass(name); binding != null; binding = binding.getOwner()) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/AutoTypeResolver.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/AutoTypeResolver.java index 9c90dff47e3..5b9c33ecc6b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/AutoTypeResolver.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/AutoTypeResolver.java @@ -51,15 +51,15 @@ class AutoTypeResolver implements ICPPFunctionTemplate { return functionType; } - public boolean isMutable() throws DOMException { + public boolean isMutable() { return false; } - public boolean isInline() throws DOMException { + public boolean isInline() { return false; } - public boolean isExternC() throws DOMException { + public boolean isExternC() { return false; } @@ -67,8 +67,8 @@ class AutoTypeResolver implements ICPPFunctionTemplate { return false; } - public IType[] getExceptionSpecification() throws DOMException { - return IType.EMPTY_TYPE_ARRAY; + public IType[] getExceptionSpecification() { + return null; } public ICPPParameter[] getParameters() throws DOMException { @@ -87,23 +87,23 @@ class AutoTypeResolver implements ICPPFunctionTemplate { throw new UnsupportedOperationException(UNEXPECTED_CALL); } - public boolean isStatic() throws DOMException { + public boolean isStatic() { return false; } - public boolean isExtern() throws DOMException { + public boolean isExtern() { return false; } - public boolean isAuto() throws DOMException { + public boolean isAuto() { return false; } - public boolean isRegister() throws DOMException { + public boolean isRegister() { return false; } - public boolean takesVarArgs() throws DOMException { + public boolean takesVarArgs() { return false; } @@ -119,7 +119,7 @@ class AutoTypeResolver implements ICPPFunctionTemplate { throw new UnsupportedOperationException(UNEXPECTED_CALL); } - public IBinding getOwner() throws DOMException { + public IBinding getOwner() { throw new UnsupportedOperationException(UNEXPECTED_CALL); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/BaseClassLookup.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/BaseClassLookup.java index 33ef875bb64..c71f933b237 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/BaseClassLookup.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/BaseClassLookup.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2009, 2010 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 @@ -124,12 +124,8 @@ class BaseClassLookup { if (binding == null) return false; if (binding instanceof ICPPMember) { - try { - if (!((ICPPMember) binding).isStatic()) - return true; - } catch (DOMException e) { - // treat as non-static - } + if (!((ICPPMember) binding).isStatic()) + return true; } } return false; @@ -158,11 +154,7 @@ class BaseClassLookup { IBinding[] matches= IBinding.EMPTY_BINDING_ARRAY; if (baseClassScope == null) { result= new BaseClassLookup(root); - try { - infoMap.put(root.getCompositeScope(), result); - } catch (DOMException e) { - // ignore - } + infoMap.put(root.getCompositeScope(), result); } else { result= new BaseClassLookup(baseClassScope.getClassType()); infoMap.put(baseClassScope, result); @@ -186,11 +178,7 @@ class BaseClassLookup { ICPPClassType baseClass= result.getClassType(); if (baseClass != null) { ICPPBase[] grandBases= null; - try { - grandBases= baseClass.getBases(); - } catch (DOMException e) { - // assume that there are no bases - } + grandBases= baseClass.getBases(); if (grandBases != null && grandBases.length > 0) { HashSet grandBaseBindings= null; BitSet selectedBases= null; @@ -207,38 +195,34 @@ class BaseClassLookup { if (selectedBases != null && !selectedBases.get(i)) continue; - try { - IBinding grandBaseBinding = grandBase.getBaseClass(); - if (!(grandBaseBinding instanceof ICPPClassType)) { - // 14.6.2.3 scope is not examined - if (grandBaseBinding instanceof ICPPUnknownBinding) { - if (data.skippedScope == null) - data.skippedScope= root; - } - continue; - } - - final ICPPClassType grandBaseClass = (ICPPClassType) grandBaseBinding; - if (grandBaseBindings != null && !grandBaseBindings.add(grandBaseClass)) - continue; - - final IScope grandBaseScope= grandBaseClass.getCompositeScope(); - if (grandBaseScope == null || grandBaseScope instanceof ICPPInternalUnknownScope) { - // 14.6.2.3 scope is not examined + IBinding grandBaseBinding = grandBase.getBaseClass(); + if (!(grandBaseBinding instanceof ICPPClassType)) { + // 14.6.2.3 scope is not examined + if (grandBaseBinding instanceof ICPPUnknownBinding) { if (data.skippedScope == null) data.skippedScope= root; - continue; } - if (!(grandBaseScope instanceof ICPPClassScope)) - continue; - - BaseClassLookup baseInfo= lookupInBaseClass(data, (ICPPClassScope) grandBaseScope, - grandBase.isVirtual(), root, fileSet, infoMap, depth); - if (baseInfo != null) - result.addBase(grandBase.isVirtual(), baseInfo); - } catch (DOMException e) { - // move on to next base + continue; } + + final ICPPClassType grandBaseClass = (ICPPClassType) grandBaseBinding; + if (grandBaseBindings != null && !grandBaseBindings.add(grandBaseClass)) + continue; + + final IScope grandBaseScope= grandBaseClass.getCompositeScope(); + if (grandBaseScope == null || grandBaseScope instanceof ICPPInternalUnknownScope) { + // 14.6.2.3 scope is not examined + if (data.skippedScope == null) + data.skippedScope= root; + continue; + } + if (!(grandBaseScope instanceof ICPPClassScope)) + continue; + + BaseClassLookup baseInfo= lookupInBaseClass(data, (ICPPClassScope) grandBaseScope, + grandBase.isVirtual(), root, fileSet, infoMap, depth); + if (baseInfo != null) + result.addBase(grandBase.isVirtual(), baseInfo); } } } @@ -295,41 +279,33 @@ class BaseClassLookup { if (fClassType != null) { ICPPBase[] bases= null; - try { - bases= fClassType.getBases(); - } catch (DOMException e) { - // assume that there are no bases - } + bases= fClassType.getBases(); if (bases != null && bases.length > 0) { for (ICPPBase base : bases) { if (base instanceof IProblemBinding) continue; - try { - IBinding baseBinding = base.getBaseClass(); - if (!(baseBinding instanceof ICPPClassType)) { - continue; + IBinding baseBinding = base.getBaseClass(); + if (!(baseBinding instanceof ICPPClassType)) { + continue; + } + + final ICPPClassType baseClass = (ICPPClassType) baseBinding; + final IScope baseScope= baseClass.getCompositeScope(); + if (!(baseScope instanceof ICPPClassScope)) + continue; + + BaseClassLookup baseInfo= infoMap.get(baseScope); + if (baseInfo != null) { + if (base.isVirtual()) { + baseInfo.setHiddenAsVirtualBase(); } - - final ICPPClassType baseClass = (ICPPClassType) baseBinding; - final IScope baseScope= baseClass.getCompositeScope(); - if (!(baseScope instanceof ICPPClassScope)) - continue; - - BaseClassLookup baseInfo= infoMap.get(baseScope); - if (baseInfo != null) { - if (base.isVirtual()) { - baseInfo.setHiddenAsVirtualBase(); - } - baseInfo.propagateHiddenAsVirtual(); - } else { - // mark to catch recursions - baseInfo= new BaseClassLookup(baseClass); - infoMap.put(baseScope, baseInfo); - baseInfo.hideVirtualBases(infoMap, depth); - } - } catch (DOMException e) { - // move on to next base + baseInfo.propagateHiddenAsVirtual(); + } else { + // mark to catch recursions + baseInfo= new BaseClassLookup(baseClass); + infoMap.put(baseScope, baseInfo); + baseInfo.hideVirtualBases(infoMap, depth); } } } @@ -381,20 +357,16 @@ class BaseClassLookup { ICPPClassType uniqueOwner= null; for (IBinding b : bindings) { if (!(b instanceof IType)) { - try { - IBinding owner= b.getOwner(); - if (owner instanceof ICPPClassType) { - final ICPPClassType classOwner = (ICPPClassType) owner; - if (uniqueOwner == null) { - uniqueOwner= classOwner; - } else if (!uniqueOwner.isSameType(classOwner)) { - data.problem= new ProblemBinding(data.astName, - IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, bindings); - return; - } + IBinding owner= b.getOwner(); + if (owner instanceof ICPPClassType) { + final ICPPClassType classOwner = (ICPPClassType) owner; + if (uniqueOwner == null) { + uniqueOwner= classOwner; + } else if (!uniqueOwner.isSameType(classOwner)) { + data.problem= new ProblemBinding(data.astName, + IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, bindings); + return; } - } catch (DOMException e) { - // ignore } } } 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 adfe0de5c70..658abb8b37b 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 @@ -1070,15 +1070,12 @@ public class CPPSemantics { } if (b instanceof ICPPMember) { ICPPMember mem= (ICPPMember) b; - try { - if (!mem.isStatic()) { - ICPPClassType owner= mem.getClassOwner(); - if (owner instanceof ICPPUnknownBinding || owner instanceof ICPPTemplateDefinition) { - result[0]= true; - return PROCESS_ABORT; - } + if (!mem.isStatic()) { + ICPPClassType owner= mem.getClassOwner(); + if (owner instanceof ICPPUnknownBinding || owner instanceof ICPPTemplateDefinition) { + result[0]= true; + return PROCESS_ABORT; } - } catch (DOMException e) { } } if (b instanceof IVariable) { @@ -1308,12 +1305,7 @@ public class CPPSemantics { public static void populateCache(ICPPASTInternalScope scope) { IASTNode[] nodes = null; - IASTNode parent; - try { - parent = ASTInternal.getPhysicalNodeOfScope(scope); - } catch (DOMException e) { - return; - } + IASTNode parent= ASTInternal.getPhysicalNodeOfScope(scope); IASTName[] namespaceDefs = null; int namespaceIdx = -1; @@ -2991,12 +2983,7 @@ public class CPPSemantics { if (cls == null) return null; - IScope scope = null; - try { - scope = cls.getCompositeScope(); - } catch (DOMException e) { - return null; - } + IScope scope = cls.getCompositeScope(); if (scope == null) return null; @@ -3275,15 +3262,15 @@ public class CPPSemantics { return type instanceof ICPPClassType || type instanceof IEnumeration; } - public static IBinding[] findBindings(IScope scope, String name, boolean qualified) throws DOMException { + public static IBinding[] findBindings(IScope scope, String name, boolean qualified) { return findBindings(scope, name.toCharArray(), qualified, null); } - public static IBinding[] findBindings(IScope scope, char[] name, boolean qualified) throws DOMException { + public static IBinding[] findBindings(IScope scope, char[] name, boolean qualified) { return findBindings(scope, name, qualified, null); } - public static IBinding[] findBindings(IScope scope, char[] name, boolean qualified, IASTNode beforeNode) throws DOMException { + public static IBinding[] findBindings(IScope scope, char[] name, boolean qualified, IASTNode beforeNode) { CPPASTName astName = new CPPASTName(); astName.setName(name); astName.setParent(ASTInternal.getPhysicalNodeOfScope(scope)); 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 31882671096..7f15d18e676 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 @@ -806,70 +806,66 @@ public class CPPTemplates { } private static int determinePackSize(IType type, ICPPTemplateParameterMap tpMap) { - try { - if (type instanceof ICPPFunctionType) { - final ICPPFunctionType ft = (ICPPFunctionType) type; - final IType rt = ft.getReturnType(); - int r = determinePackSize(rt, tpMap); - if (r < 0) - return r; - IType[] ps = ft.getParameterTypes(); - for (IType pt : ps) { - r= combine(r, determinePackSize(pt, tpMap)); - if (r < 0) - return r; - } + if (type instanceof ICPPFunctionType) { + final ICPPFunctionType ft = (ICPPFunctionType) type; + final IType rt = ft.getReturnType(); + int r = determinePackSize(rt, tpMap); + if (r < 0) return r; - } - - if (type instanceof ICPPTemplateParameter) { - final ICPPTemplateParameter tpar = (ICPPTemplateParameter) type; - if (tpar.isParameterPack()) { - ICPPTemplateArgument[] args= tpMap.getPackExpansion(tpar); - if (args != null) - return args.length; - return PACK_SIZE_DEFER; - } - return PACK_SIZE_NOT_FOUND; - } - - int r= PACK_SIZE_NOT_FOUND; - if (type instanceof ICPPUnknownBinding) { - if (type instanceof ICPPDeferredClassInstance) { - ICPPDeferredClassInstance dcl= (ICPPDeferredClassInstance) type; - ICPPTemplateArgument[] args = dcl.getTemplateArguments(); - for (ICPPTemplateArgument arg : args) { - r= combine(r, determinePackSize(arg, tpMap)); - if (r < 0) - return r; - } - } - IBinding binding= ((ICPPUnknownBinding) type).getOwner(); - if (binding instanceof IType) - r= combine(r, determinePackSize((IType) binding, tpMap)); - - return r; - } - - if (type instanceof ICPPParameterPackType) - return PACK_SIZE_NOT_FOUND; - - if (type instanceof IArrayType) { - IArrayType at= (IArrayType) type; - IValue asize= at.getSize(); - r= determinePackSize(asize, tpMap); + IType[] ps = ft.getParameterTypes(); + for (IType pt : ps) { + r= combine(r, determinePackSize(pt, tpMap)); if (r < 0) return r; } - - if (type instanceof ITypeContainer) { - final ITypeContainer typeContainer = (ITypeContainer) type; - r= combine(r, determinePackSize(typeContainer.getType(), tpMap)); - } return r; - } catch (DOMException e) { - return PACK_SIZE_FAIL; + } + + if (type instanceof ICPPTemplateParameter) { + final ICPPTemplateParameter tpar = (ICPPTemplateParameter) type; + if (tpar.isParameterPack()) { + ICPPTemplateArgument[] args= tpMap.getPackExpansion(tpar); + if (args != null) + return args.length; + return PACK_SIZE_DEFER; + } + return PACK_SIZE_NOT_FOUND; + } + + int r= PACK_SIZE_NOT_FOUND; + if (type instanceof ICPPUnknownBinding) { + if (type instanceof ICPPDeferredClassInstance) { + ICPPDeferredClassInstance dcl= (ICPPDeferredClassInstance) type; + ICPPTemplateArgument[] args = dcl.getTemplateArguments(); + for (ICPPTemplateArgument arg : args) { + r= combine(r, determinePackSize(arg, tpMap)); + if (r < 0) + return r; + } + } + IBinding binding= ((ICPPUnknownBinding) type).getOwner(); + if (binding instanceof IType) + r= combine(r, determinePackSize((IType) binding, tpMap)); + + return r; } + + if (type instanceof ICPPParameterPackType) + return PACK_SIZE_NOT_FOUND; + + if (type instanceof IArrayType) { + IArrayType at= (IArrayType) type; + IValue asize= at.getSize(); + r= determinePackSize(asize, tpMap); + if (r < 0) + return r; + } + + if (type instanceof ITypeContainer) { + final ITypeContainer typeContainer = (ITypeContainer) type; + r= combine(r, determinePackSize(typeContainer.getType(), tpMap)); + } + return r; } private static int combine(int ps1, int ps2) { 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 18562160336..b21c6d35227 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 @@ -214,6 +214,9 @@ public class CPPVisitor extends ASTQueries { parent instanceof ICPPASTBaseSpecifier || parent instanceof ICPPASTConstructorChainInitializer || name.getPropertyInParent() == ICPPASTNamespaceAlias.MAPPING_NAME) { + if (name.getLookupKey().length == 0) + return null; + binding = CPPSemantics.resolveBinding(name); if (binding instanceof IProblemBinding && parent instanceof ICPPASTQualifiedName && !(parent.getParent() instanceof ICPPASTNamespaceAlias)) { @@ -222,6 +225,9 @@ public class CPPVisitor extends ASTQueries { if (ns[ns.length - 1] != name) return binding; + if (ns.length > 1 && ns[ns.length-2].getBinding() instanceof IProblemBinding) + return binding; + parent = parent.getParent(); if (((IProblemBinding) binding).getID() == IProblemBinding.SEMANTIC_MEMBER_DECLARATION_NOT_FOUND) { IASTNode node = getContainingBlockItem(name.getParent()); @@ -294,15 +300,11 @@ public class CPPVisitor extends ASTQueries { ICPPFunctionScope functionScope = (ICPPFunctionScope) getContainingScope(gotoStatement.getName()); IASTName name = gotoStatement.getName(); IBinding binding; - try { - binding = functionScope.getBinding(name, false); - if (binding == null || !(binding instanceof ILabel)) { - binding = new CPPLabel(name); - ASTInternal.addName(functionScope, name); - } - } catch (DOMException e) { - binding = e.getProblem(); - } + binding = functionScope.getBinding(name, false); + if (binding == null || !(binding instanceof ILabel)) { + binding = new CPPLabel(name); + ASTInternal.addName(functionScope, name); + } return binding; } @@ -311,17 +313,13 @@ public class CPPVisitor extends ASTQueries { ICPPFunctionScope functionScope = (ICPPFunctionScope) getContainingScope(labelStatement.getName()); IASTName name = labelStatement.getName(); IBinding binding; - try { - binding = functionScope.getBinding(name, false); - if (binding == null || !(binding instanceof ILabel)) { - binding = new CPPLabel(name); - ASTInternal.addName(functionScope, name); - } else { - ((CPPLabel) binding).setLabelStatement(name); - } - } catch (DOMException e) { - binding = e.getProblem(); - } + binding = functionScope.getBinding(name, false); + if (binding == null || !(binding instanceof ILabel)) { + binding = new CPPLabel(name); + ASTInternal.addName(functionScope, name); + } else { + ((CPPLabel) binding).setLabelStatement(name); + } return binding; } @@ -329,45 +327,37 @@ public class CPPVisitor extends ASTQueries { private static IBinding createBinding(IASTEnumerator enumerator) { ICPPScope scope = (ICPPScope) getContainingScope(enumerator); IBinding enumtor; - try { - enumtor = scope.getBinding(enumerator.getName(), false); - if (enumtor == null || !(enumtor instanceof IEnumerator)) { - enumtor = new CPPEnumerator(enumerator.getName()); - } - } catch (DOMException e) { - enumtor = e.getProblem(); - } + enumtor = scope.getBinding(enumerator.getName(), false); + if (enumtor == null || !(enumtor instanceof IEnumerator)) { + enumtor = new CPPEnumerator(enumerator.getName()); + } return enumtor; } private static IBinding createBinding(ICPPASTEnumerationSpecifier specifier) { ICPPScope scope = (ICPPScope) getContainingScope(specifier); - try { - final IASTName name = specifier.getName(); - IType fixedType= createEnumBaseType(specifier); - IBinding binding = scope.getBinding(name, false); - if (binding instanceof CPPEnumeration) { - CPPEnumeration e= (CPPEnumeration) binding; - if (e.isScoped() == specifier.isScoped()) { - IType ft2= e.getFixedType(); - if (fixedType == ft2 || (fixedType != null && fixedType.isSameType(ft2))) { - if (specifier.isOpaque()) { - e.addDeclaration(specifier); - } else if (e.getDefinition() == null) { - e.addDefinition(specifier); - } else { - return new ProblemBinding(name, IProblemBinding.SEMANTIC_INVALID_REDEFINITION); - } - return e; + final IASTName name = specifier.getName(); + IType fixedType= createEnumBaseType(specifier); + IBinding binding = scope.getBinding(name, false); + if (binding instanceof CPPEnumeration) { + CPPEnumeration e= (CPPEnumeration) binding; + if (e.isScoped() == specifier.isScoped()) { + IType ft2= e.getFixedType(); + if (fixedType == ft2 || (fixedType != null && fixedType.isSameType(ft2))) { + if (specifier.isOpaque()) { + e.addDeclaration(specifier); + } else if (e.getDefinition() == null) { + e.addDefinition(specifier); + } else { + return new ProblemBinding(name, IProblemBinding.SEMANTIC_INVALID_REDEFINITION); } + return e; } - return new ProblemBinding(name, IProblemBinding.SEMANTIC_INVALID_REDECLARATION); - } - return new CPPEnumeration(specifier, fixedType); - } catch (DOMException e) { - return e.getProblem(); - } + } + return new ProblemBinding(name, IProblemBinding.SEMANTIC_INVALID_REDECLARATION); + } + return new CPPEnumeration(specifier, fixedType); } private static IType createEnumBaseType(ICPPASTEnumerationSpecifier specifier) { @@ -517,15 +507,11 @@ public class CPPVisitor extends ASTQueries { ICPPASTNamespaceDefinition namespaceDef = (ICPPASTNamespaceDefinition) declaration; ICPPScope scope = (ICPPScope) getContainingScope(namespaceDef); IBinding binding; - try { - binding = scope.getBinding(namespaceDef.getName(), false); - if (!(binding instanceof ICPPInternalBinding) || binding instanceof IProblemBinding - || !(binding instanceof ICPPNamespace)) { - binding = new CPPNamespace(namespaceDef); - } - } catch (DOMException e) { - binding = e.getProblem(); - } + binding = scope.getBinding(namespaceDef.getName(), false); + if (!(binding instanceof ICPPInternalBinding) || binding instanceof IProblemBinding + || !(binding instanceof ICPPNamespace)) { + binding = new CPPNamespace(namespaceDef); + } return binding; } else if (declaration instanceof ICPPASTUsingDirective) { return CPPSemantics.resolveBinding(((ICPPASTUsingDirective) declaration).getQualifiedName()); @@ -533,24 +519,20 @@ public class CPPVisitor extends ASTQueries { ICPPASTNamespaceAlias alias = (ICPPASTNamespaceAlias) declaration; ICPPScope scope = (ICPPScope) getContainingScope(declaration); IBinding binding; - try { - binding = scope.getBinding(alias.getAlias(), false); - if (!(binding instanceof ICPPInternalBinding)) { - IBinding namespace = alias.getMappingName().resolveBinding(); - if (namespace instanceof IProblemBinding) { - IProblemBinding problem = (IProblemBinding) namespace; - namespace = new CPPNamespace.CPPNamespaceProblem(problem.getASTNode(), - problem.getID(), alias.getMappingName().toCharArray()); - } - if (namespace instanceof ICPPNamespace) { - binding = new CPPNamespaceAlias(alias.getAlias(), (ICPPNamespace) namespace); - } else { - binding = new ProblemBinding(alias.getAlias(), IProblemBinding.SEMANTIC_NAME_NOT_FOUND); - } - } - } catch (DOMException e) { - binding = e.getProblem(); - } + binding = scope.getBinding(alias.getAlias(), false); + if (!(binding instanceof ICPPInternalBinding)) { + IBinding namespace = alias.getMappingName().resolveBinding(); + if (namespace instanceof IProblemBinding) { + IProblemBinding problem = (IProblemBinding) namespace; + namespace = new CPPNamespace.CPPNamespaceProblem(problem.getASTNode(), + problem.getID(), alias.getMappingName().toCharArray()); + } + if (namespace instanceof ICPPNamespace) { + binding = new CPPNamespaceAlias(alias.getAlias(), (ICPPNamespace) namespace); + } else { + binding = new ProblemBinding(alias.getAlias(), IProblemBinding.SEMANTIC_NAME_NOT_FOUND); + } + } return binding; } @@ -637,31 +619,27 @@ public class CPPVisitor extends ASTQueries { final boolean template= tmplDecl != null; boolean isFriendDecl= false; ICPPScope scope = (ICPPScope) getContainingNonTemplateScope(name); - try { - if (scope instanceof ICPPClassScope) { - if (parent instanceof IASTSimpleDeclaration) { - ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTSimpleDeclaration) parent).getDeclSpecifier(); - isFriendDecl= declSpec.isFriend(); - } else if (parent instanceof IASTFunctionDefinition) { - ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTFunctionDefinition) parent).getDeclSpecifier(); - isFriendDecl= declSpec.isFriend(); - } - if (isFriendDecl) { - try { - while (scope.getKind() == EScopeKind.eClassType) { - scope = (ICPPScope) getParentScope(scope, name.getTranslationUnit()); - } - } catch (DOMException e1) { + if (scope instanceof ICPPClassScope) { + if (parent instanceof IASTSimpleDeclaration) { + ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTSimpleDeclaration) parent).getDeclSpecifier(); + isFriendDecl= declSpec.isFriend(); + } else if (parent instanceof IASTFunctionDefinition) { + ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTFunctionDefinition) parent).getDeclSpecifier(); + isFriendDecl= declSpec.isFriend(); + } + if (isFriendDecl) { + try { + while (scope.getKind() == EScopeKind.eClassType) { + scope = (ICPPScope) getParentScope(scope, name.getTranslationUnit()); } + } catch (DOMException e1) { } } - boolean forceResolve= isFriendDecl && name instanceof ICPPASTTemplateId; - if (name.getLookupKey().length != 0 && scope != null) { - binding = scope.getBinding(name, forceResolve); - } - } catch (DOMException e) { - return e.getProblem(); - } + } + boolean forceResolve= isFriendDecl && name instanceof ICPPASTTemplateId; + if (name.getLookupKey().length != 0 && scope != null) { + binding = scope.getBinding(name, forceResolve); + } boolean isFunction= false; if (parent instanceof ICPPASTFunctionDefinition) { @@ -769,16 +747,12 @@ public class CPPVisitor extends ASTQueries { if (containingScope == null || !(containingScope instanceof ICPPClassScope)) return false; - ICPPASTCompositeTypeSpecifier clsTypeSpec; - try { - IASTNode node = ASTInternal.getPhysicalNodeOfScope(containingScope); - if (node instanceof ICPPASTCompositeTypeSpecifier) - clsTypeSpec = (ICPPASTCompositeTypeSpecifier) node; - else - return false; - } catch (DOMException e) { - return false; - } + IASTNode node = ASTInternal.getPhysicalNodeOfScope(containingScope); + if (!(node instanceof ICPPASTCompositeTypeSpecifier)) { + return false; + } + + ICPPASTCompositeTypeSpecifier clsTypeSpec = (ICPPASTCompositeTypeSpecifier) node; IASTName clsName = clsTypeSpec.getName(); if (clsName instanceof ICPPASTQualifiedName) { IASTName[] names = ((ICPPASTQualifiedName) clsName).getNames(); @@ -1898,11 +1872,7 @@ public class CPPVisitor extends ASTQueries { if (name != null) { IBinding binding = name.resolvePreBinding(); if (binding instanceof ICPPConstructor) { - try { - type= ((ICPPConstructor) binding).getClassOwner(); - } catch (DOMException e) { - type = e.getProblem(); - } + type= ((ICPPConstructor) binding).getClassOwner(); } else if (binding instanceof IType) { type = (IType) binding; } else if (binding instanceof ICPPTemplateNonTypeParameter) { @@ -2053,16 +2023,13 @@ public class CPPVisitor extends ASTQueries { public static IType getPointerDiffType(final IASTBinaryExpression binary) { CPPBasicType basicType; IScope scope = getContainingScope(binary); - try { - IBinding[] bs= CPPSemantics.findBindings(scope, PTRDIFF_T, false, binary); - if (bs.length > 0) { - for (IBinding b : bs) { - if (b instanceof IType && CPPSemantics.declaredBefore(b, binary, false)) { - return (IType) b; - } + IBinding[] bs= CPPSemantics.findBindings(scope, PTRDIFF_T, false, binary); + if (bs.length > 0) { + for (IBinding b : bs) { + if (b instanceof IType && CPPSemantics.declaredBefore(b, binary, false)) { + return (IType) b; } } - } catch (DOMException e) { } basicType= new CPPBasicType(Kind.eInt, 0); basicType.setFromExpression(binary); @@ -2070,49 +2037,40 @@ public class CPPVisitor extends ASTQueries { } public static IType get_type_info(IASTExpression expression) { - try { - IBinding[] std= expression.getTranslationUnit().getScope().find(STD); - for (IBinding binding : std) { - if (binding instanceof ICPPNamespace) { - IBinding[] typeInfo= ((ICPPNamespace) binding).getNamespaceScope().find(TYPE_INFO); - for (IBinding t : typeInfo) { - if (t instanceof ICPPClassType) { - return (ICPPClassType) t; - } + IBinding[] std= expression.getTranslationUnit().getScope().find(STD); + for (IBinding binding : std) { + if (binding instanceof ICPPNamespace) { + IBinding[] typeInfo= ((ICPPNamespace) binding).getNamespaceScope().find(TYPE_INFO); + for (IBinding t : typeInfo) { + if (t instanceof ICPPClassType) { + return (ICPPClassType) t; } } } - } catch (DOMException e) { } return new CPPBasicType(Kind.eInt, 0); } public static IType get_SIZE_T(IASTNode sizeofExpr) { IScope scope = getContainingScope(sizeofExpr); - try { - IBinding[] bs = CPPSemantics.findBindings(scope, SIZE_T, false, sizeofExpr); - if (bs.length > 0 && bs[0] instanceof IType) { - return (IType) bs[0]; - } - } catch (DOMException e) { + IBinding[] bs = CPPSemantics.findBindings(scope, SIZE_T, false, sizeofExpr); + if (bs.length > 0 && bs[0] instanceof IType) { + return (IType) bs[0]; } return new CPPBasicType(Kind.eInt, IBasicType.IS_LONG | IBasicType.IS_UNSIGNED); } public static ICPPClassTemplate get_initializer_list(IASTNode node) { - try { - IBinding[] std= node.getTranslationUnit().getScope().find(STD); - for (IBinding binding : std) { - if (binding instanceof ICPPNamespace) { - IBinding[] initializer_list= ((ICPPNamespace) binding).getNamespaceScope().find(INITIALIZER_LIST); - for (IBinding t : initializer_list) { - if (t instanceof ICPPClassTemplate) { - return (ICPPClassTemplate) t; - } + IBinding[] std= node.getTranslationUnit().getScope().find(STD); + for (IBinding binding : std) { + if (binding instanceof ICPPNamespace) { + IBinding[] initializer_list= ((ICPPNamespace) binding).getNamespaceScope().find(INITIALIZER_LIST); + for (IBinding t : initializer_list) { + if (t instanceof ICPPClassTemplate) { + return (ICPPClassTemplate) t; } } } - } catch (DOMException e) { } return null; } @@ -2184,25 +2142,22 @@ public class CPPVisitor extends ASTQueries { public static String[] getQualifiedName(IBinding binding) { String[] ns = null; - try { - for (IBinding owner= binding.getOwner(); owner != null; owner= owner.getOwner()) { - if (owner instanceof ICPPEnumeration && !((ICPPEnumeration) owner).isScoped()) { - continue; - } - String n= owner.getName(); - if (n == null) - break; - if (owner instanceof ICPPFunction) - break; - if (owner instanceof ICPPNamespace && n.length() == 0) { - // TODO(sprigogin): Do not ignore anonymous namespaces. - continue; - } - - ns = (String[]) ArrayUtil.append(String.class, ns, n); - } - } catch (DOMException e) { - } + for (IBinding owner= binding.getOwner(); owner != null; owner= owner.getOwner()) { + if (owner instanceof ICPPEnumeration && !((ICPPEnumeration) owner).isScoped()) { + continue; + } + String n= owner.getName(); + if (n == null) + break; + if (owner instanceof ICPPFunction) + break; + if (owner instanceof ICPPNamespace && n.length() == 0) { + // TODO(sprigogin): Do not ignore anonymous namespaces. + continue; + } + + ns = (String[]) ArrayUtil.append(String.class, ns, n); + } ns = (String[]) ArrayUtil.trim(String.class, ns); String[] result = new String[ns.length + 1]; for (int i = ns.length - 1; i >= 0; i--) { @@ -2214,20 +2169,17 @@ public class CPPVisitor extends ASTQueries { public static char[][] getQualifiedNameCharArray(IBinding binding) { char[][] ns = null; - try { - for (IBinding owner= binding.getOwner(); owner != null; owner= owner.getOwner()) { - char[] n= owner.getNameCharArray(); - if (n == null) - break; - if (owner instanceof ICPPFunction) - break; - if (owner instanceof ICPPNamespace && n.length == 0) - continue; - - ns = (char[][]) ArrayUtil.append(n.getClass(), ns, n); - } - } catch (DOMException e) { - } + for (IBinding owner= binding.getOwner(); owner != null; owner= owner.getOwner()) { + char[] n= owner.getNameCharArray(); + if (n == null) + break; + if (owner instanceof ICPPFunction) + break; + if (owner instanceof ICPPNamespace && n.length == 0) + continue; + + ns = (char[][]) ArrayUtil.append(n.getClass(), ns, n); + } final char[] bname = binding.getNameCharArray(); ns = (char[][]) ArrayUtil.trim(bname.getClass(), ns); char[][] result = new char[ns.length + 1][]; 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 ec1cf3da698..74fd02b0e89 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 @@ -15,7 +15,6 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CVQualifier.*; -import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; @@ -495,32 +494,28 @@ public class SemanticUtil { * Returns true if two bindings have the same owner. */ public static boolean isSameOwner(IBinding owner1, IBinding owner2) { - try { - // Ignore anonymous namespaces - while (owner1 instanceof ICPPNamespace && owner1.getNameCharArray().length == 0) - owner1= owner1.getOwner(); - // Ignore anonymous namespaces - while (owner2 instanceof ICPPNamespace && owner2.getNameCharArray().length == 0) - owner2= owner2.getOwner(); - - if (owner1 == null) - return owner2 == null; - if (owner2 == null) - return false; - - if (owner1 instanceof IType) { - if (owner2 instanceof IType) { - return ((IType) owner1).isSameType((IType) owner2); - } - } else if (owner1 instanceof ICPPNamespace) { - if (owner2 instanceof ICPPNamespace) { - if (!CharArrayUtils.equals(owner1.getNameCharArray(), owner2.getNameCharArray())) - return false; - return isSameOwner(owner1.getOwner(), owner2.getOwner()); - } + // Ignore anonymous namespaces + while (owner1 instanceof ICPPNamespace && owner1.getNameCharArray().length == 0) + owner1= owner1.getOwner(); + // Ignore anonymous namespaces + while (owner2 instanceof ICPPNamespace && owner2.getNameCharArray().length == 0) + owner2= owner2.getOwner(); + + if (owner1 == null) + return owner2 == null; + if (owner2 == null) + return false; + + if (owner1 instanceof IType) { + if (owner2 instanceof IType) { + return ((IType) owner1).isSameType((IType) owner2); + } + } else if (owner1 instanceof ICPPNamespace) { + if (owner2 instanceof ICPPNamespace) { + if (!CharArrayUtils.equals(owner1.getNameCharArray(), owner2.getNameCharArray())) + return false; + return isSameOwner(owner1.getOwner(), owner2.getOwner()); } - } catch (DOMException e) { - CCorePlugin.log(e); } return false; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java index 11276d4cc40..02d6abf38be 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java @@ -28,7 +28,6 @@ import java.util.regex.Pattern; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.ILinkage; import org.eclipse.cdt.core.dom.IName; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace; @@ -650,23 +649,18 @@ public class CIndex implements IIndex { } IIndexFragmentBinding[][] preresult = new IIndexFragmentBinding[fPrimaryFragmentCount][]; - try { - for (int i = 0; i < fPrimaryFragmentCount; i++) { - IIndexScope[] raw = fFragments[i].getInlineNamespaces(); - IIndexFragmentBinding[] arr = preresult[i] = new IIndexFragmentBinding[raw.length]; - for (int j=0; j 0) { - for (ICPPClassType ct : nested) { - if (ct instanceof ICPPClassSpecialization && - !(ct.getCompositeScope() instanceof ICPPClassSpecializationScope)) { - ICPPClassSpecialization cspec= (ICPPClassSpecialization) cf.getCompositeBinding((IIndexFragmentBinding) ct); - newMap.put(cspec.getSpecializedBinding(), cspec); - } + // in any fragment explicit specializations may be defined. + IIndexFragmentBinding[] frags= cf.findEquivalentBindings(rbinding); + for (IIndexFragmentBinding fb : frags) { + if (fb instanceof ICPPClassType) { + final ICPPClassType[] nested = ((ICPPClassType)fb).getNestedClasses(); + if (nested.length > 0) { + for (ICPPClassType ct : nested) { + if (ct instanceof ICPPClassSpecialization && + !(ct.getCompositeScope() instanceof ICPPClassSpecializationScope)) { + ICPPClassSpecialization cspec= (ICPPClassSpecialization) cf.getCompositeBinding((IIndexFragmentBinding) ct); + newMap.put(cspec.getSpecializedBinding(), cspec); } - if (!newMap.isEmpty()) - break; } + if (!newMap.isEmpty()) + break; } } - } catch (DOMException e) { - CCorePlugin.log(e); } specializationMap= (ObjectMap) frag.putCachedResult(key, newMap, false); } @@ -114,7 +105,7 @@ public class CompositeCPPClassSpecialization extends CompositeCPPClassType imple } @Override - public ICPPBase[] getBases() throws DOMException { + public ICPPBase[] getBases() { IScope scope= getCompositeScope(); if (scope instanceof ICPPClassSpecializationScope) { return ((ICPPClassSpecializationScope) scope).getBases(); @@ -123,7 +114,7 @@ public class CompositeCPPClassSpecialization extends CompositeCPPClassType imple } @Override - public ICPPConstructor[] getConstructors() throws DOMException { + public ICPPConstructor[] getConstructors() { IScope scope= getCompositeScope(); if (scope instanceof ICPPClassSpecializationScope) { return ((ICPPClassSpecializationScope) scope).getConstructors(); @@ -132,7 +123,7 @@ public class CompositeCPPClassSpecialization extends CompositeCPPClassType imple } @Override - public ICPPMethod[] getDeclaredMethods() throws DOMException { + public ICPPMethod[] getDeclaredMethods() { IScope scope= getCompositeScope(); if (scope instanceof ICPPClassSpecializationScope) { return ((ICPPClassSpecializationScope) scope).getDeclaredMethods(); @@ -141,7 +132,7 @@ public class CompositeCPPClassSpecialization extends CompositeCPPClassType imple } @Override - public ICPPField[] getDeclaredFields() throws DOMException { + public ICPPField[] getDeclaredFields() { IScope scope= getCompositeScope(); if (scope instanceof ICPPClassSpecializationScope) { return ((ICPPClassSpecializationScope) scope).getDeclaredFields(); @@ -150,7 +141,7 @@ public class CompositeCPPClassSpecialization extends CompositeCPPClassType imple } @Override - public IBinding[] getFriends() throws DOMException { + public IBinding[] getFriends() { IScope scope= getCompositeScope(); if (scope instanceof ICPPClassSpecializationScope) { return ((ICPPClassSpecializationScope) scope).getFriends(); @@ -159,7 +150,7 @@ public class CompositeCPPClassSpecialization extends CompositeCPPClassType imple } @Override - public ICPPClassType[] getNestedClasses() throws DOMException { + public ICPPClassType[] getNestedClasses() { IScope scope= getCompositeScope(); if (scope instanceof ICPPClassSpecializationScope) { return ((ICPPClassSpecializationScope) scope).getNestedClasses(); @@ -168,22 +159,22 @@ public class CompositeCPPClassSpecialization extends CompositeCPPClassType imple } @Override - public IField findField(String name) throws DOMException { + public IField findField(String name) { return ClassTypeHelper.findField(this, name); } @Override - public ICPPMethod[] getAllDeclaredMethods() throws DOMException { + public ICPPMethod[] getAllDeclaredMethods() { return ClassTypeHelper.getAllDeclaredMethods(this); } @Override - public IField[] getFields() throws DOMException { + public IField[] getFields() { return ClassTypeHelper.getFields(this); } @Override - public ICPPMethod[] getMethods() throws DOMException { + public ICPPMethod[] getMethods() { return ClassTypeHelper.getMethods(this); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassSpecializationScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassSpecializationScope.java index 4ea171ea512..ab0b7216893 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassSpecializationScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassSpecializationScope.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Symbian Software Systems and others. + * Copyright (c) 2008, 2010 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 @@ -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.EScopeKind; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IBinding; @@ -67,49 +66,48 @@ public class CompositeCPPClassSpecializationScope extends CompositeScope impleme return fDelegate.getImplicitMethods(); } - public IBinding[] find(String name) throws DOMException { + public IBinding[] find(String name) { createDelegate(); return fDelegate.find(name); } - public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet acceptLocalBindings) - throws DOMException { + public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet acceptLocalBindings) { createDelegate(); return fDelegate.getBinding(name, resolve, acceptLocalBindings); } public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, - IIndexFileSet acceptLocalBindings) throws DOMException { + IIndexFileSet acceptLocalBindings) { createDelegate(); return fDelegate.getBindings(name, resolve, prefixLookup, acceptLocalBindings); } - public ICPPConstructor[] getConstructors() throws DOMException { + public ICPPConstructor[] getConstructors() { createDelegate(); return fDelegate.getConstructors(); } - public ICPPMethod[] getDeclaredMethods() throws DOMException { + public ICPPMethod[] getDeclaredMethods() { createDelegate(); return fDelegate.getDeclaredMethods(); } - public ICPPBase[] getBases() throws DOMException { + public ICPPBase[] getBases() { createDelegate(); return fDelegate.getBases(); } - public ICPPField[] getDeclaredFields() throws DOMException { + public ICPPField[] getDeclaredFields() { createDelegate(); return fDelegate.getDeclaredFields(); } - public IBinding[] getFriends() throws DOMException { + public IBinding[] getFriends() { createDelegate(); return fDelegate.getFriends(); } - public ICPPClassType[] getNestedClasses() throws DOMException { + public ICPPClassType[] getNestedClasses() { createDelegate(); return fDelegate.getNestedClasses(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassTemplatePartialSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassTemplatePartialSpecialization.java index db1afccec38..dd557c0ead0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassTemplatePartialSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassTemplatePartialSpecialization.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Symbian Software Systems and others. + * Copyright (c) 2007, 2010 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 @@ -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.IBinding; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate; @@ -31,7 +30,7 @@ public class CompositeCPPClassTemplatePartialSpecialization extends CompositeCPP super(cf, delegate); } - public ICPPClassTemplate getPrimaryClassTemplate() throws DOMException { + public ICPPClassTemplate getPrimaryClassTemplate() { ICPPClassTemplate preresult= ((ICPPClassTemplatePartialSpecialization)rbinding).getPrimaryClassTemplate(); return (ICPPClassTemplate) cf.getCompositeBinding((IIndexFragmentBinding)preresult); } @@ -45,12 +44,9 @@ public class CompositeCPPClassTemplatePartialSpecialization extends CompositeCPP } public ICPPTemplateParameterMap getTemplateParameterMap() { - try { - IBinding owner= getOwner(); - if (owner instanceof ICPPSpecialization) { - return ((ICPPSpecialization) owner).getTemplateParameterMap(); - } - } catch (DOMException e) { + IBinding owner= getOwner(); + if (owner instanceof ICPPSpecialization) { + return ((ICPPSpecialization) owner).getTemplateParameterMap(); } return CPPTemplateParameterMap.EMPTY; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassTemplatePartialSpecializationSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassTemplatePartialSpecializationSpecialization.java index 9021844388d..9eaa6def0b8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassTemplatePartialSpecializationSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassTemplatePartialSpecializationSpecialization.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2009, 2010 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 @@ -52,7 +52,7 @@ public class CompositeCPPClassTemplatePartialSpecializationSpecialization extend return CompositeInstanceCache.getCache(cf, rbinding).getAllInstances(); } - public ICPPClassTemplate getPrimaryClassTemplate() throws DOMException { + public ICPPClassTemplate getPrimaryClassTemplate() { return (ICPPClassTemplate) cf.getCompositeBinding((IIndexFragmentBinding) ((ICPPClassTemplatePartialSpecializationSpecialization) rbinding).getPrimaryClassTemplate()); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassType.java index c551bbe11f2..d6a42aecf8e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassType.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Symbian Software Systems and others. + * Copyright (c) 2007, 2010 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 @@ -12,7 +12,6 @@ package org.eclipse.cdt.internal.core.index.composite.cpp; import org.eclipse.cdt.core.dom.IName; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IField; import org.eclipse.cdt.core.dom.ast.IType; @@ -36,12 +35,12 @@ class CompositeCPPClassType extends CompositeCPPBinding implements ICPPClassType fail(); return null; } - public IField findField(String name) throws DOMException { + public IField findField(String name) { IField preResult = ((ICPPClassType)rbinding).findField(name); return (IField) cf.getCompositeBinding((IIndexFragmentBinding)preResult); } - public ICPPMethod[] getAllDeclaredMethods() throws DOMException { + public ICPPMethod[] getAllDeclaredMethods() { ICPPMethod[] result = ((ICPPClassType)rbinding).getAllDeclaredMethods(); for(int i=0; i list = new ArrayList(); for (PDOMCPPFriend friend = getFirstFriend(); @@ -355,19 +341,19 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO } } - public ICPPMethod[] getMethods() throws DOMException { + public ICPPMethod[] getMethods() { return ClassTypeHelper.getMethods(this); } - public ICPPMethod[] getAllDeclaredMethods() throws DOMException { + public ICPPMethod[] getAllDeclaredMethods() { return ClassTypeHelper.getAllDeclaredMethods(this); } - public IField[] getFields() throws DOMException { + public IField[] getFields() { return ClassTypeHelper.getFields(this); } - public IField findField(String name) throws DOMException { + public IField findField(String name) { return ClassTypeHelper.findField(this, name); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPConstructor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPConstructor.java index 170ff494a46..ddd8db8fb6f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPConstructor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPConstructor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2010 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 @@ -29,7 +29,7 @@ class PDOMCPPConstructor extends PDOMCPPMethod implements ICPPConstructor { super(linkage, record); } - public boolean isExplicit() throws DOMException { + public boolean isExplicit() { return getBit(getAnnotation1(), PDOMCPPAnnotation.EXPLICIT_CONSTRUCTOR_OFFSET); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPConstructorInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPConstructorInstance.java index b3af609e159..2759f273c66 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPConstructorInstance.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPConstructorInstance.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 QNX Software Systems and others. + * Copyright (c) 2007, 2010 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 @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom.dom.cpp; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants; @@ -51,7 +50,7 @@ public class PDOMCPPConstructorInstance extends PDOMCPPMethodInstance implements return IIndexCPPBindingConstants.CPP_CONSTRUCTOR_INSTANCE; } - public boolean isExplicit() throws DOMException { + public boolean isExplicit() { return ((ICPPConstructor)getTemplateDefinition()).isExplicit(); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPConstructorSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPConstructorSpecialization.java index 3f9a10905fc..01cf06f8353 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPConstructorSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPConstructorSpecialization.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 QNX Software Systems and others. + * Copyright (c) 2007, 2010 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 @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom.dom.cpp; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants; import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding; @@ -49,7 +48,7 @@ class PDOMCPPConstructorSpecialization extends return IIndexCPPBindingConstants.CPP_CONSTRUCTOR_SPECIALIZATION; } - public boolean isExplicit() throws DOMException { + public boolean isExplicit() { return getBit(getByte(record + ANNOTATION1), PDOMCPPAnnotation.EXPLICIT_CONSTRUCTOR_OFFSET); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPConstructorTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPConstructorTemplate.java index 9642d8909e0..76c8c45c831 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPConstructorTemplate.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPConstructorTemplate.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 QNX Software Systems and others. + * Copyright (c) 2007, 2010 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 @@ -33,7 +33,7 @@ class PDOMCPPConstructorTemplate extends PDOMCPPMethodTemplate implements super(linkage, record); } - public boolean isExplicit() throws DOMException { + public boolean isExplicit() { return getBit(getAnnotation1(), PDOMCPPAnnotation.EXPLICIT_CONSTRUCTOR_OFFSET); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPConstructorTemplateSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPConstructorTemplateSpecialization.java index e787307f4ab..2155a317ad7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPConstructorTemplateSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPConstructorTemplateSpecialization.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 QNX Software Systems and others. + * Copyright (c) 2007, 2010 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 @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom.dom.cpp; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants; import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding; @@ -50,7 +49,7 @@ class PDOMCPPConstructorTemplateSpecialization extends return IIndexCPPBindingConstants.CPP_CONSTRUCTOR_TEMPLATE_SPECIALIZATION; } - public boolean isExplicit() throws DOMException { + public boolean isExplicit() { return ((ICPPConstructor)getSpecializedBinding()).isExplicit(); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPDeferredClassInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPDeferredClassInstance.java index e6fc9322bd1..f5cf030d33e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPDeferredClassInstance.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPDeferredClassInstance.java @@ -85,7 +85,7 @@ class PDOMCPPDeferredClassInstance extends PDOMCPPSpecialization implements ICPP return false; } - public IScope getCompositeScope() throws DOMException { + public IScope getCompositeScope() { return asScope(); } @@ -169,14 +169,14 @@ class PDOMCPPDeferredClassInstance extends PDOMCPPSpecialization implements ICPP return ICPPClassType.EMPTY_CLASS_ARRAY; } - public int getKey() throws DOMException{ + public int getKey(){ return getClassTemplate().getKey(); } @Override public Object clone() {fail();return null;} - public ICPPScope asScope() throws DOMException { + public ICPPScope asScope() { if (unknownScope == null) { unknownScope= new PDOMCPPUnknownScope(this, getUnknownName()); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumScope.java index 83b1a99e351..c9633d6b9e9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumScope.java @@ -18,7 +18,6 @@ import java.util.List; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.IPDOMVisitor; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.EScopeKind; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IBinding; @@ -49,15 +48,15 @@ class PDOMCPPEnumScope implements ICPPScope, IIndexScope { return EScopeKind.eEnumeration; } - public IBinding getBinding(IASTName name, boolean resolve) throws DOMException { + public IBinding getBinding(IASTName name, boolean resolve) { return getBinding(name, resolve, null); } - public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup) throws DOMException { + public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup) { return getBindings(name, resolve, prefixLookup, null); } - public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) throws DOMException { + public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) { try { CharArrayMap map= getBindingMap(fBinding); return map.get(name.toCharArray()); @@ -67,7 +66,7 @@ class PDOMCPPEnumScope implements ICPPScope, IIndexScope { } } - public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet) throws DOMException { + public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet) { try { CharArrayMap map= getBindingMap(fBinding); if (prefixLookup) { @@ -90,7 +89,7 @@ class PDOMCPPEnumScope implements ICPPScope, IIndexScope { return IBinding.EMPTY_BINDING_ARRAY; } - public IBinding[] find(String name) throws DOMException { + public IBinding[] find(String name) { return CPPSemantics.findBindings(this, name, false); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumeration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumeration.java index c4c707c0cdc..6f3b3cbe6d0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumeration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumeration.java @@ -16,7 +16,6 @@ import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.IPDOMNode; import org.eclipse.cdt.core.dom.IPDOMVisitor; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IEnumeration; import org.eclipse.cdt.core.dom.ast.IEnumerator; @@ -135,20 +134,16 @@ class PDOMCPPEnumeration extends PDOMCPPBinding implements IPDOMCPPEnumType, IPD } } - try { - if (type instanceof IEnumeration) { - IEnumeration etype= (IEnumeration) type; - char[] nchars = etype.getNameCharArray(); - if (nchars.length == 0) { - nchars= ASTTypeUtil.createNameForAnonymous(etype); - } - if (nchars == null || !CharArrayUtils.equals(nchars, getNameCharArray())) - return false; - - return SemanticUtil.isSameOwner(getOwner(), etype.getOwner()); + if (type instanceof IEnumeration) { + IEnumeration etype= (IEnumeration) type; + char[] nchars = etype.getNameCharArray(); + if (nchars.length == 0) { + nchars= ASTTypeUtil.createNameForAnonymous(etype); } - } catch (DOMException e) { - CCorePlugin.log(e); + if (nchars == null || !CharArrayUtils.equals(nchars, getNameCharArray())) + return false; + + return SemanticUtil.isSameOwner(getOwner(), etype.getOwner()); } return false; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFieldSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFieldSpecialization.java index 94fb13b9fa7..0eaa5bfa30b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFieldSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFieldSpecialization.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 QNX Software Systems and others. + * Copyright (c) 2007, 2010 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 @@ -71,7 +71,7 @@ class PDOMCPPFieldSpecialization extends PDOMCPPSpecialization implements ICPPFi return (ICPPField) getSpecializedBinding(); } - public ICompositeType getCompositeTypeOwner() throws DOMException { + public ICompositeType getCompositeTypeOwner() { return getClassOwner(); } @@ -95,11 +95,11 @@ class PDOMCPPFieldSpecialization extends PDOMCPPSpecialization implements ICPPFi } } - public boolean isAuto() throws DOMException { + public boolean isAuto() { return getField().isAuto(); } - public boolean isExtern() throws DOMException { + public boolean isExtern() { return getField().isExtern(); } @@ -107,23 +107,23 @@ class PDOMCPPFieldSpecialization extends PDOMCPPSpecialization implements ICPPFi return false; } - public boolean isRegister() throws DOMException { + public boolean isRegister() { return getField().isRegister(); } - public boolean isStatic() throws DOMException { + public boolean isStatic() { return getField().isStatic(); } - public ICPPClassType getClassOwner() throws DOMException { + public ICPPClassType getClassOwner() { return (ICPPClassType) getOwner(); } - public int getVisibility() throws DOMException { + public int getVisibility() { return getField().getVisibility(); } - public boolean isMutable() throws DOMException { + public boolean isMutable() { return getField().isMutable(); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunction.java index c972adea008..0dcaf92dd7d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunction.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunction.java @@ -99,7 +99,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl } } - private short getAnnotation(ICPPFunction function) throws DOMException { + private short getAnnotation(ICPPFunction function) { int annot= PDOMCPPAnnotation.encodeAnnotation(function) & 0xff; if (function.hasParameterPack()) { annot |= (1< 0) { - break; - } - owner= owner.getOwner(); - } - } - - if (owner == null) - return this; + if (binding instanceof IIndexBinding) { + IIndexBinding ib= (IIndexBinding) binding; + // don't adapt file local bindings from other fragments to this one. + if (ib.isFileLocal()) { + return null; + } + } else { + // skip unnamed namespaces + while (owner instanceof ICPPNamespace) { + char[] name= owner.getNameCharArray(); + if (name.length > 0) { + break; + } + owner= owner.getOwner(); + } + } + + if (owner == null) + return this; - return adaptOrAddBinding(add, owner); - } catch (DOMException e) { - throw new CoreException(Util.createStatus(e)); - } + return adaptOrAddBinding(add, owner); } private PDOMBinding adaptOrAddBinding(boolean add, IBinding binding) throws CoreException { @@ -864,33 +860,29 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { name = (IASTName) parent; } IScope container= CPPVisitor.getContainingScope(name); - try { - boolean doit= false; - PDOMCPPNamespace containerNS= null; - - IASTNode node= ASTInternal.getPhysicalNodeOfScope(container); - if (node instanceof IASTTranslationUnit) { - doit= true; - } - else if (node instanceof ICPPASTNamespaceDefinition) { - ICPPASTNamespaceDefinition nsDef= (ICPPASTNamespaceDefinition) node; - IASTName nsContainerName= nsDef.getName(); - if (nsContainerName != null) { - PDOMBinding binding= adaptBinding(nsContainerName.resolveBinding()); - if (binding instanceof PDOMCPPNamespace) { - containerNS= (PDOMCPPNamespace) binding; - doit= true; - } + boolean doit= false; + PDOMCPPNamespace containerNS= null; + + IASTNode node= ASTInternal.getPhysicalNodeOfScope(container); + if (node instanceof IASTTranslationUnit) { + doit= true; + } + else if (node instanceof ICPPASTNamespaceDefinition) { + ICPPASTNamespaceDefinition nsDef= (ICPPASTNamespaceDefinition) node; + IASTName nsContainerName= nsDef.getName(); + if (nsContainerName != null) { + PDOMBinding binding= adaptBinding(nsContainerName.resolveBinding()); + if (binding instanceof PDOMCPPNamespace) { + containerNS= (PDOMCPPNamespace) binding; + doit= true; } } - if (doit) { - long rec= file.getLastUsingDirectiveRec(); - PDOMCPPUsingDirective ud= new PDOMCPPUsingDirective(this, rec, containerNS, - pdomName.getBinding(), pdomName.getFileLocation().getNodeOffset()); - file.setFirstUsingDirectiveRec(ud.getRecord()); - } - } catch (DOMException e) { - CCorePlugin.log(e); + } + if (doit) { + long rec= file.getLastUsingDirectiveRec(); + PDOMCPPUsingDirective ud= new PDOMCPPUsingDirective(this, rec, containerNS, + pdomName.getBinding(), pdomName.getFileLocation().getNodeOffset()); + file.setFirstUsingDirectiveRec(ud.getRecord()); } } else if (parentNode instanceof ICPPASTElaboratedTypeSpecifier) { ICPPASTElaboratedTypeSpecifier elaboratedSpecifier = (ICPPASTElaboratedTypeSpecifier)parentNode; @@ -994,17 +986,14 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { } } if (file == null && !(binding instanceof IIndexBinding)) { - try { - IBinding owner= binding.getOwner(); - if (owner instanceof ICPPNamespace) { - if (owner.getNameCharArray().length == 0) { - String path= ASTInternal.getDeclaredInSourceFileOnly(owner, false, glob); - if (path != null) { - file= wpdom.getFileForASTPath(getLinkageID(), path); - } + IBinding owner= binding.getOwner(); + if (owner instanceof ICPPNamespace) { + if (owner.getNameCharArray().length == 0) { + String path= ASTInternal.getDeclaredInSourceFileOnly(owner, false, glob); + if (path != null) { + file= wpdom.getFileForASTPath(getLinkageID(), path); } } - } catch (DOMException e) { } } if (file != null) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethod.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethod.java index 8817e580a76..8b6e95ecd4f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethod.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethod.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2009 QNX Software Systems and others. + * Copyright (c) 2006, 2010 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 @@ -103,7 +103,7 @@ class PDOMCPPMethod extends PDOMCPPFunction implements ICPPMethod { return IIndexCPPBindingConstants.CPPMETHOD; } - public boolean isVirtual() throws DOMException { + public boolean isVirtual() { return getBit(getAnnotation1(), PDOMCPPAnnotation.VIRTUAL_OFFSET); } @@ -113,7 +113,7 @@ class PDOMCPPMethod extends PDOMCPPFunction implements ICPPMethod { return annotation1; } - public boolean isPureVirtual() throws DOMException { + public boolean isPureVirtual() { return getBit(getAnnotation1(), PDOMCPPAnnotation.PURE_VIRTUAL_OFFSET); } @@ -122,7 +122,7 @@ class PDOMCPPMethod extends PDOMCPPFunction implements ICPPMethod { } @Override - public boolean isMutable() throws DOMException { + public boolean isMutable() { throw new PDOMNotImplementedError(); } @@ -158,11 +158,11 @@ class PDOMCPPMethod extends PDOMCPPFunction implements ICPPMethod { return false; } - public int getVisibility() throws DOMException { + public int getVisibility() { return PDOMCPPAnnotation.getVisibility(getAnnotation()); } - public ICPPClassType getClassOwner() throws DOMException { + public ICPPClassType getClassOwner() { return (ICPPClassType) getOwner(); } @@ -210,7 +210,7 @@ class PDOMCPPMethod extends PDOMCPPFunction implements ICPPMethod { } @Override - public IType[] getExceptionSpecification() throws DOMException { + public IType[] getExceptionSpecification() { if (isImplicit()) { return ClassTypeHelper.getInheritedExceptionSpecification(this); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodInstance.java index 4daded16b7c..95f32619c90 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodInstance.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodInstance.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 QNX Software Systems and others. + * Copyright (c) 2007, 2010 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 @@ -11,7 +11,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom.dom.cpp; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants; @@ -64,19 +63,19 @@ class PDOMCPPMethodInstance extends PDOMCPPFunctionInstance implements ICPPMetho return ((ICPPMethod)getTemplateDefinition()).isImplicit(); } - public boolean isVirtual() throws DOMException { + public boolean isVirtual() { return ((ICPPMethod)getTemplateDefinition()).isVirtual(); } - public boolean isPureVirtual() throws DOMException { + public boolean isPureVirtual() { return ((ICPPMethod)getTemplateDefinition()).isPureVirtual(); } - public ICPPClassType getClassOwner() throws DOMException { + public ICPPClassType getClassOwner() { return (ICPPClassType) getOwner(); } - public int getVisibility() throws DOMException { + public int getVisibility() { return ((ICPPMethod)getTemplateDefinition()).getVisibility(); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodSpecialization.java index f7ae8fc32c2..797bccd6a47 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodSpecialization.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 QNX Software Systems and others. + * Copyright (c) 2007, 2010 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 @@ -86,16 +86,16 @@ class PDOMCPPMethodSpecialization extends PDOMCPPFunctionSpecialization return getBit(getByte(record + ANNOTATION1), PDOMCPPAnnotation.IMPLICIT_METHOD_OFFSET); } - public boolean isVirtual() throws DOMException { + public boolean isVirtual() { return getBit(getByte(record + ANNOTATION1), PDOMCPPAnnotation.VIRTUAL_OFFSET); } - public boolean isPureVirtual() throws DOMException { + public boolean isPureVirtual() { return getBit(getByte(record + ANNOTATION1), PDOMCPPAnnotation.PURE_VIRTUAL_OFFSET); } @Override - public boolean isExtern() throws DOMException { + public boolean isExtern() { // ISO/IEC 14882:2003 9.2.6 return false; } @@ -105,11 +105,11 @@ class PDOMCPPMethodSpecialization extends PDOMCPPFunctionSpecialization return false; } - public ICPPClassType getClassOwner() throws DOMException { + public ICPPClassType getClassOwner() { return (ICPPClassType) getOwner(); } - public int getVisibility() throws DOMException { + public int getVisibility() { return PDOMCPPAnnotation.getVisibility(getByte(record + ANNOTATION_OFFSET)); } @@ -124,7 +124,7 @@ class PDOMCPPMethodSpecialization extends PDOMCPPFunctionSpecialization } @Override - public IType[] getExceptionSpecification() throws DOMException { + public IType[] getExceptionSpecification() { if (isImplicit()) { return ClassTypeHelper.getInheritedExceptionSpecification(this); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodTemplate.java index a867040f200..599649a873b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodTemplate.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodTemplate.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 QNX Software Systems and others. + * Copyright (c) 2007, 2010 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 @@ -93,15 +93,15 @@ class PDOMCPPMethodTemplate extends PDOMCPPFunctionTemplate implements ICPPMetho return getBit(getAnnotation1(), PDOMCPPAnnotation.IMPLICIT_METHOD_OFFSET); } - public boolean isVirtual() throws DOMException { + public boolean isVirtual() { return getBit(getAnnotation1(), PDOMCPPAnnotation.VIRTUAL_OFFSET); } - public ICPPClassType getClassOwner() throws DOMException { + public ICPPClassType getClassOwner() { return (ICPPClassType) getOwner(); } - public int getVisibility() throws DOMException { + public int getVisibility() { return PDOMCPPAnnotation.getVisibility(getAnnotation()); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodTemplateSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodTemplateSpecialization.java index c7529e96e90..c9bcf33a9cd 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodTemplateSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodTemplateSpecialization.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 QNX Software Systems and others. + * Copyright (c) 2007, 2010 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 @@ -11,7 +11,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom.dom.cpp; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate; @@ -59,7 +58,7 @@ class PDOMCPPMethodTemplateSpecialization extends return false; } - public boolean isVirtual() throws DOMException { + public boolean isVirtual() { IBinding spec = getSpecializedBinding(); if (spec instanceof ICPPMethod) { ((ICPPMethod)spec).isVirtual(); @@ -67,11 +66,11 @@ class PDOMCPPMethodTemplateSpecialization extends return false; } - public ICPPClassType getClassOwner() throws DOMException { + public ICPPClassType getClassOwner() { return (ICPPClassType) getOwner(); } - public int getVisibility() throws DOMException { + public int getVisibility() { IBinding spec = getSpecializedBinding(); if (spec instanceof ICPPMethod) { ((ICPPMethod)spec).getVisibility(); @@ -84,7 +83,7 @@ class PDOMCPPMethodTemplateSpecialization extends return false; } - public boolean isPureVirtual() throws DOMException { + public boolean isPureVirtual() { return false; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPNamespace.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPNamespace.java index 8e6af112efd..799959c45a8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPNamespace.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPNamespace.java @@ -18,7 +18,6 @@ import java.util.List; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.IPDOMVisitor; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.EScopeKind; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IBinding; @@ -162,7 +161,7 @@ class PDOMCPPNamespace extends PDOMCPPBinding } @Override - public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) throws DOMException { + public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) { try { IBinding[] bindings= getBindingsViaCache(name.getLookupKey()); if (fileSet != null) { @@ -176,8 +175,7 @@ class PDOMCPPNamespace extends PDOMCPPBinding } @Override - public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet) - throws DOMException { + public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet) { IBinding[] result = null; try { if (!prefixLookup) { @@ -217,7 +215,7 @@ class PDOMCPPNamespace extends PDOMCPPBinding return true; } - public IBinding[] getMemberBindings() throws DOMException { + public IBinding[] getMemberBindings() { IBinding[] result = null; final List preresult = new ArrayList(); try { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPNamespaceAlias.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPNamespaceAlias.java index 9395d567685..9f93d1e31ba 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPNamespaceAlias.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPNamespaceAlias.java @@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp; import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias; import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope; @@ -69,7 +68,7 @@ class PDOMCPPNamespaceAlias extends PDOMCPPBinding implements ICPPNamespaceAlias return IIndexCPPBindingConstants.CPPNAMESPACEALIAS; } - public ICPPNamespaceScope getNamespaceScope() throws DOMException { + public ICPPNamespaceScope getNamespaceScope() { return getNamespaceScope(this, 20); // avoid an infinite loop. } @@ -88,7 +87,7 @@ class PDOMCPPNamespaceAlias extends PDOMCPPBinding implements ICPPNamespaceAlias return null; } - public IBinding[] getMemberBindings() throws DOMException { + public IBinding[] getMemberBindings() { throw new PDOMNotImplementedError(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPParameter.java index 4f37726fd58..8705bb7cbaa 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPParameter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPParameter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2009 QNX Software Systems and others. + * Copyright (c) 2006, 2010 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 @@ -67,12 +67,8 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBind } private void storeAnnotations(Database db, ICPPParameter param) throws CoreException { - try { - byte annotations = PDOMCPPAnnotation.encodeAnnotation(param); - db.putByte(record + ANNOTATIONS, annotations); - } catch (DOMException e) { - // ignore and miss out on some properties of the parameter - } + byte annotations = PDOMCPPAnnotation.encodeAnnotation(param); + db.putByte(record + ANNOTATIONS, annotations); } public void update(ICPPParameter newPar) throws CoreException { @@ -113,7 +109,7 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBind return false; } - public boolean isMutable() throws DOMException { + public boolean isMutable() { // ISO/IEC 14882:2003 7.1.1.8 return false; } @@ -122,13 +118,13 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBind return fType; } - public boolean isAuto() throws DOMException { + public boolean isAuto() { // ISO/IEC 14882:2003 7.1.1.2 byte flag = 1< getUsingChain(IBinding binding) { ArrayList chain = new ArrayList(4); - try { - for (; binding != null; binding = binding.getOwner()) { - String name = binding.getName(); - if (binding instanceof ICPPNamespace) { - if (name.length() == 0) { - continue; - } - } else { - chain.clear(); + for (; binding != null; binding = binding.getOwner()) { + String name = binding.getName(); + if (binding instanceof ICPPNamespace) { + if (name.length() == 0) { + continue; } - chain.add(name); + } else { + chain.clear(); } - } catch (DOMException e) { - CUIPlugin.log(e); + chain.add(name); } return chain; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java index 7b1aec94966..e57f1af21bc 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java @@ -260,13 +260,7 @@ public class SemanticHighlightings { } IBinding binding= token.getBinding(); if (binding instanceof IField && !(binding instanceof IProblemBinding)) { - try { - return ((IField)binding).isStatic(); - } catch (DOMException exc) { - CUIPlugin.log(exc); - } catch (Error e) /* PDOMNotImplementedError */ { - // ignore - } + return ((IField)binding).isStatic(); } } return false; @@ -514,13 +508,7 @@ public class SemanticHighlightings { } IBinding binding= token.getBinding(); if (binding instanceof ICPPMethod && !(binding instanceof IProblemBinding)) { - try { - return ((ICPPMethod)binding).isStatic(); - } catch (DOMException exc) { - CUIPlugin.log(exc); - } catch (Error e) /* PDOMNotImplementedError */ { - // ignore - } + return ((ICPPMethod)binding).isStatic(); } } return false; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexLabelProvider.java index 77a50c6f3eb..57037922c4f 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexLabelProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexLabelProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 QNX Software Systems and others. + * Copyright (c) 2006, 2010 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 @@ -169,20 +169,16 @@ public class IndexLabelProvider extends LabelProvider { else if (element instanceof IFunction) desc = CElementImageProvider.getFunctionImageDescriptor(); else if (element instanceof ICPPClassType) { - try { - switch (((ICPPClassType)element).getKey()) { - case ICPPClassType.k_class: - desc = CElementImageProvider.getClassImageDescriptor(); - break; - case ICompositeType.k_struct: - desc = CElementImageProvider.getStructImageDescriptor(); - break; - case ICompositeType.k_union: - desc = CElementImageProvider.getUnionImageDescriptor(); - break; - } - } catch (DOMException e) { - CUIPlugin.log(e); + switch (((ICPPClassType)element).getKey()) { + case ICPPClassType.k_class: + desc = CElementImageProvider.getClassImageDescriptor(); + break; + case ICompositeType.k_struct: + desc = CElementImageProvider.getStructImageDescriptor(); + break; + case ICompositeType.k_union: + desc = CElementImageProvider.getUnionImageDescriptor(); + break; } } else if (element instanceof ICompositeType) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/MethodContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/MethodContext.java index 357e4ab04c7..3219ec3735d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/MethodContext.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/MethodContext.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -23,7 +23,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember; -import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.internal.core.dom.parser.ASTInternal; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTVisibilityLabel; @@ -69,11 +68,7 @@ public class MethodContext { ICPPASTVisibilityLabel label = new CPPASTVisibilityLabel(); ICPPMember member = ((ICPPMember)qname.resolveBinding()); - try { - label.setVisibility(member.getVisibility()); - } catch (DOMException e) { - CUIPlugin.log(e); - } + label.setVisibility(member.getVisibility()); return label; } @@ -108,11 +103,7 @@ public class MethodContext { if (subclassBind instanceof ICPPClassType) { ICPPClassType classType = (ICPPClassType) subclassBind; ICPPBase[] bases; - try { - bases = classType.getBases(); - } catch (DOMException e) { - return false; - } + bases = classType.getBases(); for (ICPPBase base : bases) { if(isSameClass(base,bind1)){ return true; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Visibility.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Visibility.java index d0d5f50a364..5c17dff2c76 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Visibility.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Visibility.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -11,7 +11,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.ui.refactoring; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember; @@ -74,8 +73,6 @@ public class Visibility { return UNKNOWN; } - } catch (DOMException e) { - return UNKNOWN; } catch (RuntimeException e){ return UNKNOWN; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoring.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoring.java index baf1d4eaff2..243d317a37f 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoring.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoring.java @@ -26,7 +26,7 @@ import org.eclipse.ltk.core.refactoring.RefactoringDescriptor; import org.eclipse.ltk.core.refactoring.RefactoringStatus; import org.eclipse.text.edits.TextEditGroup; -import org.eclipse.cdt.core.dom.ast.DOMException; +import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement; import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; @@ -46,7 +46,6 @@ import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.INodeFactory; import org.eclipse.cdt.core.dom.ast.IScope; -import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.rewrite.ASTRewrite; import org.eclipse.cdt.core.dom.rewrite.DeclarationGenerator; @@ -237,7 +236,7 @@ public class ExtractLocalVariableRefactoring extends CRefactoring { private NodeContainer findAllExpressions() { final NodeContainer container = new NodeContainer(); - unit.accept(new CPPASTVisitor() { + unit.accept(new ASTVisitor() { { shouldVisitExpressions = true; } @@ -358,7 +357,7 @@ public class ExtractLocalVariableRefactoring extends CRefactoring { } if (target != null) { - target.accept(new CPPASTVisitor() { + target.accept(new ASTVisitor() { { shouldVisitNames = true; shouldVisitExpressions = true; @@ -437,13 +436,9 @@ public class ExtractLocalVariableRefactoring extends CRefactoring { info.getUsedNames().contains(name)) { return false; } - try { - if (scope != null) { - IBinding[] bindings = scope.find(name); - return bindings == null || bindings.length == 0; - } - } catch (DOMException e) { - // fall-through + if (scope != null) { + IBinding[] bindings = scope.find(name); + return bindings == null || bindings.length == 0; } return true; // no name references found } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java index 505c19b6138..fe660f1e18e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java @@ -385,19 +385,15 @@ public class ASTManager { public static String getName(IScope s1) { String name= null; - try { - if (s1 instanceof IIndexScope) { - IIndexScope indexScope= (IIndexScope) s1; - final IIndexName scopeName = indexScope.getScopeName(); - if (scopeName != null) { - name= scopeName.toString(); - } - } else { - name= getNameOrNull(ASTInternal.getPhysicalNodeOfScope(s1)); - } - } - catch (DOMException e) { - } + if (s1 instanceof IIndexScope) { + IIndexScope indexScope= (IIndexScope) s1; + final IIndexName scopeName = indexScope.getScopeName(); + if (scopeName != null) { + name= scopeName.toString(); + } + } else { + name= getNameOrNull(ASTInternal.getPhysicalNodeOfScope(s1)); + } return name == null ? s1.toString() : name; } @@ -587,7 +583,7 @@ public class ASTManager { return UNKNOWN; } - private static boolean getSigned(IBasicType a2) throws DOMException { + private static boolean getSigned(IBasicType a2) { if (a2.isSigned()) { return true; } @@ -630,7 +626,7 @@ public class ASTManager { return null; } - private static int hasSameLocation(IASTNode node1, IASTNode node2, boolean fileStatic) throws DOMException { + private static int hasSameLocation(IASTNode node1, IASTNode node2, boolean fileStatic) { if (node1 == null || node2 == null) { return UNKNOWN; } @@ -1341,12 +1337,9 @@ public class ASTManager { } what= RenameMessages.CRenameLocalProcessor_localVariable; } else { - try { - if (conflictingVar.isStatic()) { - what= RenameMessages.CRenameProcessorDelegate_fileStaticVariable; - } - } catch (DOMException e) { - } + if (conflictingVar.isStatic()) { + what= RenameMessages.CRenameProcessorDelegate_fileStaticVariable; + } } } } else if (conflict instanceof ICPPConstructor) { @@ -1396,11 +1389,7 @@ public class ASTManager { } } - boolean isStatic= false; - try { - isStatic= conflictingFunction.isStatic(); - } catch (DOMException e) { - } + boolean isStatic= conflictingFunction.isStatic(); if (isStatic) { what= RenameMessages.CRenameProcessorDelegate_fileStaticFunction; } else { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringArgument.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringArgument.java index e5df4cfb35b..96e57d03d0d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringArgument.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringArgument.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2004, 2010 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 @@ -115,10 +115,7 @@ public class CRefactoringArgument { fKind= CRefactory.ARGUMENT_LOCAL_VAR; } else { boolean isStatic= false; - try { - isStatic= var.isStatic(); - } catch (DOMException e) { - } + isStatic= var.isStatic(); if (isStatic) { fKind= CRefactory.ARGUMENT_FILE_LOCAL_VAR; } else { @@ -143,10 +140,7 @@ public class CRefactoringArgument { } } else { boolean isStatic= false; - try { - isStatic= func.isStatic(); - } catch (DOMException e) { - } + isStatic= func.isStatic(); if (isStatic) { fKind= CRefactory.ARGUMENT_FILE_LOCAL_FUNCTION; } else { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameClassProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameClassProcessor.java index fb3b3f6df16..222d6de2ba5 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameClassProcessor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameClassProcessor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 Wind River Systems, Inc. and others. + * Copyright (c) 2005, 2010 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 @@ -15,7 +15,6 @@ import java.util.Arrays; import org.eclipse.ltk.core.refactoring.RefactoringStatus; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; @@ -41,22 +40,18 @@ public class CRenameClassProcessor extends CRenameTypeProcessor { } if (binding instanceof ICPPClassType) { ICPPClassType ctype= (ICPPClassType) binding; - try { - ICPPConstructor[] ctors= ctype.getConstructors(); - if (ctors != null) { - bindings.addAll(Arrays.asList(ctors)); - } - - IScope scope= ctype.getCompositeScope(); - if (scope != null) { - IBinding[] dtors= scope.find("~" + argument.getName()); //$NON-NLS-1$ - if (dtors != null) { - bindings.addAll(Arrays.asList(dtors)); - } - } - } catch (DOMException e) { - getAstManager().handleDOMException(argument.getTranslationUnit(), e, status); - } + ICPPConstructor[] ctors= ctype.getConstructors(); + if (ctors != null) { + bindings.addAll(Arrays.asList(ctors)); + } + + IScope scope= ctype.getCompositeScope(); + if (scope != null) { + IBinding[] dtors= scope.find("~" + argument.getName()); //$NON-NLS-1$ + if (dtors != null) { + bindings.addAll(Arrays.asList(dtors)); + } + } } return bindings.toArray(new IBinding[bindings.size()]); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameLocalProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameLocalProcessor.java index 60b064d340e..27ab306124c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameLocalProcessor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameLocalProcessor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 Wind River Systems, Inc. and others. + * Copyright (c) 2004, 2010 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 @@ -16,7 +16,6 @@ import java.util.Iterator; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.ltk.core.refactoring.RefactoringStatus; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTFileLocation; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IParameter; @@ -55,18 +54,13 @@ public class CRenameLocalProcessor extends CRenameProcessorDelegate { super.analyzeTextMatches(matches, monitor, status); if (fScope != null) { CRefactoringArgument argument = getArgument(); - ASTManager r = getAstManager(); int[] result= new int[] {0, Integer.MAX_VALUE}; IScope scope= argument.getScope(); IASTNode node= null; - try { - node = ASTInternal.getPhysicalNodeOfScope(scope); - if (argument.getBinding() instanceof IParameter) { - node= node.getParent(); - } - } catch (DOMException e) { - r.handleDOMException(argument.getTranslationUnit(), e, status); - } + node = ASTInternal.getPhysicalNodeOfScope(scope); + if (argument.getBinding() instanceof IParameter) { + node= node.getParent(); + } if (node != null) { IASTFileLocation loc= ASTManager.getLocationInTranslationUnit(node); if (loc != null) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMethodProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMethodProcessor.java index 435ac06b9f3..a28e636fcf3 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMethodProcessor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMethodProcessor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2005, 2010 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 @@ -69,12 +69,7 @@ public class CRenameMethodProcessor extends CRenameGlobalProcessor { RefactoringStatus result= new RefactoringStatus(); IScope scope= argument.getScope(); if (scope != null) { - IASTNode node= null; - try { - node = ASTInternal.getPhysicalNodeOfScope(scope); - } catch (DOMException e) { - getAstManager().handleDOMException(argument.getTranslationUnit(), e, result); - } + IASTNode node= ASTInternal.getPhysicalNodeOfScope(scope); if (node instanceof IASTCompositeTypeSpecifier) { IASTCompositeTypeSpecifier se= (IASTCompositeTypeSpecifier) node; IASTName name= ASTManager.getSimpleName(se.getName()); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LinkedNamesFinder.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LinkedNamesFinder.java index 0eb79982e00..70a7e9248a7 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LinkedNamesFinder.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LinkedNamesFinder.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Google, Inc and others. + * Copyright (c) 2007, 2010 Google, 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 @@ -17,7 +17,6 @@ import java.util.List; import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.Region; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTComment; import org.eclipse.cdt.core.dom.ast.IASTFileLocation; import org.eclipse.cdt.core.dom.ast.IASTName; @@ -74,30 +73,24 @@ public class LinkedNamesFinder { return; } - try { - if (target instanceof ICPPConstructor || - target instanceof ICPPMethod && ((ICPPMethod) target).isDestructor()) { - target = ((ICPPMethod) target).getClassOwner(); - } - } catch (DOMException e1) { + if (target instanceof ICPPConstructor || + target instanceof ICPPMethod && ((ICPPMethod) target).isDestructor()) { + target = ((ICPPMethod) target).getClassOwner(); } findBinding(target); if (target instanceof ICPPClassType) { - try { - ICPPConstructor[] constructors = ((ICPPClassType) target).getConstructors(); - for (ICPPConstructor ctor : constructors) { - if (!ctor.isImplicit()) { - findBinding(ctor); - } + ICPPConstructor[] constructors = ((ICPPClassType) target).getConstructors(); + for (ICPPConstructor ctor : constructors) { + if (!ctor.isImplicit()) { + findBinding(ctor); } - ICPPMethod[] methods = ((ICPPClassType) target).getDeclaredMethods(); - for (ICPPMethod method : methods) { - if (method.isDestructor()) { - findBinding(method); - } + } + ICPPMethod[] methods = ((ICPPClassType) target).getDeclaredMethods(); + for (ICPPMethod method : methods) { + if (method.isDestructor()) { + findBinding(method); } - } catch (DOMException e) { } } } @@ -111,15 +104,13 @@ public class LinkedNamesFinder { private void findBinding(IBinding target) { IASTName[] names= root.getDeclarationsInAST(target); - for (int i= 0; i < names.length; i++) { - IASTName candidate= names[i]; + for (IASTName candidate : names) { if (candidate.isPartOfTranslationUnitFile()) { addLocation(candidate); } } names= root.getReferences(target); - for (int i= 0; i < names.length; i++) { - IASTName candidate= names[i]; + for (IASTName candidate : names) { if (candidate.isPartOfTranslationUnitFile()) { addLocation(candidate); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchPatternQuery.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchPatternQuery.java index 4cbe2ae5e09..46f174dabd6 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchPatternQuery.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchPatternQuery.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2009 QNX Software Systems and others. + * Copyright (c) 2006, 2010 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 @@ -25,7 +25,6 @@ import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.Status; import org.eclipse.osgi.util.NLS; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.ICompositeType; import org.eclipse.cdt.core.dom.ast.IEnumeration; import org.eclipse.cdt.core.dom.ast.IEnumerator; @@ -42,8 +41,6 @@ import org.eclipse.cdt.core.index.IIndexBinding; import org.eclipse.cdt.core.index.IndexFilter; import org.eclipse.cdt.core.model.ICElement; -import org.eclipse.cdt.internal.core.Util; - /** * @author Doug Schaefer @@ -197,8 +194,6 @@ public class PDOMSearchPatternQuery extends PDOMSearchQuery { createMatches(index, matchedBindings.toArray(new IIndexBinding[matchedBindings.size()])); } catch (CoreException e) { return e.getStatus(); - } catch (DOMException e) { - return Util.createStatus(e); } return Status.OK_STATUS; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java index 9425d4cf792..176a7887e71 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java @@ -257,13 +257,9 @@ class OpenDeclarationsJob extends Job implements ASTRunnable { // Bug 86829, handle implicit methods. ICPPMethod method= (ICPPMethod) binding; if (method.isImplicit()) { - try { - IBinding clsBinding= method.getClassOwner(); - if (clsBinding != null && !(clsBinding instanceof IProblemBinding)) { - declNames= findNames(fIndex, ast, NameKind.REFERENCE, clsBinding); - } - } catch (DOMException e) { - // Don't log problem bindings. + IBinding clsBinding= method.getClassOwner(); + if (clsBinding != null && !(clsBinding instanceof IProblemBinding)) { + declNames= findNames(fIndex, ast, NameKind.REFERENCE, clsBinding); } } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionProposalComputer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionProposalComputer.java index 943b1cc2dcd..23472d496e1 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionProposalComputer.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionProposalComputer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 QNX Software Systems and others. + * Copyright (c) 2007, 2010 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 @@ -332,28 +332,22 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer private void handleClass(ICPPClassType classType, IASTCompletionContext astContext, CContentAssistInvocationContext context, int baseRelevance, List proposals) { if (context.isContextInformationStyle()) { - try { - ICPPConstructor[] constructors = classType.getConstructors(); - for (ICPPConstructor constructor : constructors) { - handleFunction(constructor, context, baseRelevance, proposals); - } - } catch (DOMException e) { + ICPPConstructor[] constructors = classType.getConstructors(); + for (ICPPConstructor constructor : constructors) { + handleFunction(constructor, context, baseRelevance, proposals); } } else { int relevance= 0; - try { - switch (classType.getKey()) { - case ICPPClassType.k_class: - relevance= RelevanceConstants.CLASS_TYPE_RELEVANCE; - break; - case ICompositeType.k_struct: - relevance= RelevanceConstants.STRUCT_TYPE_RELEVANCE; - break; - case ICompositeType.k_union: - relevance= RelevanceConstants.UNION_TYPE_RELEVANCE; - break; - } - } catch (DOMException exc) { + switch (classType.getKey()) { + case ICPPClassType.k_class: + relevance= RelevanceConstants.CLASS_TYPE_RELEVANCE; + break; + case ICompositeType.k_struct: + relevance= RelevanceConstants.STRUCT_TYPE_RELEVANCE; + break; + case ICompositeType.k_union: + relevance= RelevanceConstants.UNION_TYPE_RELEVANCE; + break; } if (astContext instanceof IASTName && !(astContext instanceof ICPPASTQualifiedName)) { IASTName name= (IASTName)astContext; @@ -582,60 +576,57 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer private Image getImage(IBinding binding) { ImageDescriptor imageDescriptor = null; - try { - if (binding instanceof ITypedef) { - imageDescriptor = CElementImageProvider.getTypedefImageDescriptor(); - } else if (binding instanceof ICompositeType) { - if (((ICompositeType)binding).getKey() == ICPPClassType.k_class || binding instanceof ICPPClassTemplate) - imageDescriptor = CElementImageProvider.getClassImageDescriptor(); - else if (((ICompositeType)binding).getKey() == ICompositeType.k_struct) - imageDescriptor = CElementImageProvider.getStructImageDescriptor(); - else if (((ICompositeType)binding).getKey() == ICompositeType.k_union) - imageDescriptor = CElementImageProvider.getUnionImageDescriptor(); - } else if (binding instanceof ICPPMethod) { - switch (((ICPPMethod)binding).getVisibility()) { - case ICPPMember.v_private: - imageDescriptor = CElementImageProvider.getMethodImageDescriptor(ASTAccessVisibility.PRIVATE); - break; - case ICPPMember.v_protected: - imageDescriptor = CElementImageProvider.getMethodImageDescriptor(ASTAccessVisibility.PROTECTED); - break; - default: - imageDescriptor = CElementImageProvider.getMethodImageDescriptor(ASTAccessVisibility.PUBLIC); - break; - } - } else if (binding instanceof IFunction) { - imageDescriptor = CElementImageProvider.getFunctionImageDescriptor(); - } else if (binding instanceof ICPPField) { - switch (((ICPPField)binding).getVisibility()) { - case ICPPMember.v_private: - imageDescriptor = CElementImageProvider.getFieldImageDescriptor(ASTAccessVisibility.PRIVATE); - break; - case ICPPMember.v_protected: - imageDescriptor = CElementImageProvider.getFieldImageDescriptor(ASTAccessVisibility.PROTECTED); - break; - default: - imageDescriptor = CElementImageProvider.getFieldImageDescriptor(ASTAccessVisibility.PUBLIC); - break; - } - } else if (binding instanceof IField) { - imageDescriptor = CElementImageProvider.getFieldImageDescriptor(ASTAccessVisibility.PUBLIC); - } else if (binding instanceof IVariable) { - imageDescriptor = CElementImageProvider.getVariableImageDescriptor(); - } else if (binding instanceof IEnumeration) { - imageDescriptor = CElementImageProvider.getEnumerationImageDescriptor(); - } else if (binding instanceof IEnumerator) { - imageDescriptor = CElementImageProvider.getEnumeratorImageDescriptor(); - } else if (binding instanceof ICPPNamespace) { - imageDescriptor = CElementImageProvider.getNamespaceImageDescriptor(); - } else if (binding instanceof ICPPFunctionTemplate) { - imageDescriptor = CElementImageProvider.getFunctionImageDescriptor(); - } else if (binding instanceof ICPPUsingDeclaration) { - IBinding[] delegates = ((ICPPUsingDeclaration) binding).getDelegates(); - if (delegates.length > 0) - return getImage(delegates[0]); + if (binding instanceof ITypedef) { + imageDescriptor = CElementImageProvider.getTypedefImageDescriptor(); + } else if (binding instanceof ICompositeType) { + if (((ICompositeType)binding).getKey() == ICPPClassType.k_class || binding instanceof ICPPClassTemplate) + imageDescriptor = CElementImageProvider.getClassImageDescriptor(); + else if (((ICompositeType)binding).getKey() == ICompositeType.k_struct) + imageDescriptor = CElementImageProvider.getStructImageDescriptor(); + else if (((ICompositeType)binding).getKey() == ICompositeType.k_union) + imageDescriptor = CElementImageProvider.getUnionImageDescriptor(); + } else if (binding instanceof ICPPMethod) { + switch (((ICPPMethod)binding).getVisibility()) { + case ICPPMember.v_private: + imageDescriptor = CElementImageProvider.getMethodImageDescriptor(ASTAccessVisibility.PRIVATE); + break; + case ICPPMember.v_protected: + imageDescriptor = CElementImageProvider.getMethodImageDescriptor(ASTAccessVisibility.PROTECTED); + break; + default: + imageDescriptor = CElementImageProvider.getMethodImageDescriptor(ASTAccessVisibility.PUBLIC); + break; } - } catch (DOMException e) { + } else if (binding instanceof IFunction) { + imageDescriptor = CElementImageProvider.getFunctionImageDescriptor(); + } else if (binding instanceof ICPPField) { + switch (((ICPPField)binding).getVisibility()) { + case ICPPMember.v_private: + imageDescriptor = CElementImageProvider.getFieldImageDescriptor(ASTAccessVisibility.PRIVATE); + break; + case ICPPMember.v_protected: + imageDescriptor = CElementImageProvider.getFieldImageDescriptor(ASTAccessVisibility.PROTECTED); + break; + default: + imageDescriptor = CElementImageProvider.getFieldImageDescriptor(ASTAccessVisibility.PUBLIC); + break; + } + } else if (binding instanceof IField) { + imageDescriptor = CElementImageProvider.getFieldImageDescriptor(ASTAccessVisibility.PUBLIC); + } else if (binding instanceof IVariable) { + imageDescriptor = CElementImageProvider.getVariableImageDescriptor(); + } else if (binding instanceof IEnumeration) { + imageDescriptor = CElementImageProvider.getEnumerationImageDescriptor(); + } else if (binding instanceof IEnumerator) { + imageDescriptor = CElementImageProvider.getEnumeratorImageDescriptor(); + } else if (binding instanceof ICPPNamespace) { + imageDescriptor = CElementImageProvider.getNamespaceImageDescriptor(); + } else if (binding instanceof ICPPFunctionTemplate) { + imageDescriptor = CElementImageProvider.getFunctionImageDescriptor(); + } else if (binding instanceof ICPPUsingDeclaration) { + IBinding[] delegates = ((ICPPUsingDeclaration) binding).getDelegates(); + if (delegates.length > 0) + return getImage(delegates[0]); } return imageDescriptor != null diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THGraph.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THGraph.java index 91194de53b9..85ee76f8ffe 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THGraph.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THGraph.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2010 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 @@ -14,7 +14,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import org.eclipse.core.runtime.CoreException; @@ -97,8 +96,7 @@ class THGraph { while (!stack.isEmpty()) { THGraphNode node= stack.remove(stack.size()-1); List out= node.getOutgoing(); - for (Iterator iterator = out.iterator(); iterator.hasNext();) { - THGraphEdge edge= iterator.next(); + for (THGraphEdge edge : out) { node= edge.getEndNode(); if (node == from) { return true; @@ -110,8 +108,7 @@ class THGraph { } // check if edge is already there. List out= from.getOutgoing(); - for (Iterator iterator = out.iterator(); iterator.hasNext();) { - THGraphEdge edge = iterator.next(); + for (THGraphEdge edge : out) { if (edge.getEndNode() == to) { return true; } @@ -163,16 +160,14 @@ class THGraph { if (binding instanceof ICPPClassType) { ICPPClassType ct= (ICPPClassType) binding; ICPPBase[] bases= ct.getBases(); - for (int i = 0; i < bases.length; i++) { + for (ICPPBase base : bases) { if (monitor.isCanceled()) { return; } - ICPPBase base= bases[i]; IName name= base.getBaseClassSpecifierName(); IBinding basecl= name != null ? index.findBinding(name) : base.getBaseClass(); ICElementHandle[] baseElems= IndexUI.findRepresentative(index, basecl); - for (int j = 0; j < baseElems.length; j++) { - ICElementHandle baseElem = baseElems[j]; + for (ICElementHandle baseElem : baseElems) { THGraphNode baseGraphNode= addNode(baseElem); addMembers(index, baseGraphNode, basecl); addEdge(graphNode, baseGraphNode); @@ -199,9 +194,6 @@ class THGraph { } } } - } catch (DOMException e) { - // index bindings should not throw this kind of exception, might as well log it. - CUIPlugin.log(e); } catch (CoreException e) { CUIPlugin.log(e); } @@ -227,11 +219,10 @@ class THGraph { IBinding binding = IndexUI.elementToBinding(index, elem); if (binding != null) { IIndexName[] names= index.findNames(binding, IIndex.FIND_REFERENCES | IIndex.FIND_DEFINITIONS); - for (int i = 0; i < names.length; i++) { + for (IIndexName indexName : names) { if (monitor.isCanceled()) { return; } - IIndexName indexName = names[i]; if (indexName.isBaseSpecifier()) { IIndexName subClassDef= indexName.getEnclosingDefinition(); if (subClassDef != null) { @@ -291,8 +282,7 @@ class THGraph { private void addMemberElements(IIndex index, IBinding[] members, List memberList) throws CoreException { - for (int i = 0; i < members.length; i++) { - IBinding binding = members[i]; + for (IBinding binding : members) { ICElement[] elems= IndexUI.findRepresentative(index, binding); if (elems.length > 0) { memberList.add(elems[0]); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexUI.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexUI.java index 191090d73cd..acf74188773 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexUI.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexUI.java @@ -33,7 +33,6 @@ import org.eclipse.ui.IEditorInput; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.IPositionConverter; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTFileLocation; @@ -124,57 +123,53 @@ public class IndexUI { } private static boolean checkBinding(IIndexBinding binding, ICElement element) { - try { - switch(element.getElementType()) { - case ICElement.C_ENUMERATION: - return binding instanceof IEnumeration; - case ICElement.C_NAMESPACE: - return binding instanceof ICPPNamespace; - case ICElement.C_STRUCT_DECLARATION: - case ICElement.C_STRUCT: - return binding instanceof ICompositeType && - ((ICompositeType) binding).getKey() == ICompositeType.k_struct; - case ICElement.C_CLASS: - case ICElement.C_CLASS_DECLARATION: - return binding instanceof ICPPClassType && - ((ICompositeType) binding).getKey() == ICPPClassType.k_class; - case ICElement.C_UNION: - case ICElement.C_UNION_DECLARATION: - return binding instanceof ICompositeType && - ((ICompositeType) binding).getKey() == ICompositeType.k_union; - case ICElement.C_TYPEDEF: - return binding instanceof ITypedef; - case ICElement.C_METHOD: - case ICElement.C_METHOD_DECLARATION: - return binding instanceof ICPPMethod; - case ICElement.C_FIELD: - return binding instanceof IField; - case ICElement.C_FUNCTION: - case ICElement.C_FUNCTION_DECLARATION: - return binding instanceof ICPPFunction && !(binding instanceof ICPPMethod); - case ICElement.C_VARIABLE: - case ICElement.C_VARIABLE_DECLARATION: - return binding instanceof IVariable; - case ICElement.C_ENUMERATOR: - return binding instanceof IEnumerator; - case ICElement.C_TEMPLATE_CLASS: - case ICElement.C_TEMPLATE_CLASS_DECLARATION: - case ICElement.C_TEMPLATE_STRUCT: - case ICElement.C_TEMPLATE_STRUCT_DECLARATION: - case ICElement.C_TEMPLATE_UNION: - case ICElement.C_TEMPLATE_UNION_DECLARATION: - return binding instanceof ICPPClassTemplate; - case ICElement.C_TEMPLATE_FUNCTION: - case ICElement.C_TEMPLATE_FUNCTION_DECLARATION: - return binding instanceof ICPPFunctionTemplate && !(binding instanceof ICPPMethod); - case ICElement.C_TEMPLATE_METHOD_DECLARATION: - case ICElement.C_TEMPLATE_METHOD: - return binding instanceof ICPPFunctionTemplate && binding instanceof ICPPMethod; - case ICElement.C_TEMPLATE_VARIABLE: - return binding instanceof ICPPTemplateParameter; - } - } catch (DOMException e) { - // index bindings don't throw the DOMException. + switch(element.getElementType()) { + case ICElement.C_ENUMERATION: + return binding instanceof IEnumeration; + case ICElement.C_NAMESPACE: + return binding instanceof ICPPNamespace; + case ICElement.C_STRUCT_DECLARATION: + case ICElement.C_STRUCT: + return binding instanceof ICompositeType && + ((ICompositeType) binding).getKey() == ICompositeType.k_struct; + case ICElement.C_CLASS: + case ICElement.C_CLASS_DECLARATION: + return binding instanceof ICPPClassType && + ((ICompositeType) binding).getKey() == ICPPClassType.k_class; + case ICElement.C_UNION: + case ICElement.C_UNION_DECLARATION: + return binding instanceof ICompositeType && + ((ICompositeType) binding).getKey() == ICompositeType.k_union; + case ICElement.C_TYPEDEF: + return binding instanceof ITypedef; + case ICElement.C_METHOD: + case ICElement.C_METHOD_DECLARATION: + return binding instanceof ICPPMethod; + case ICElement.C_FIELD: + return binding instanceof IField; + case ICElement.C_FUNCTION: + case ICElement.C_FUNCTION_DECLARATION: + return binding instanceof ICPPFunction && !(binding instanceof ICPPMethod); + case ICElement.C_VARIABLE: + case ICElement.C_VARIABLE_DECLARATION: + return binding instanceof IVariable; + case ICElement.C_ENUMERATOR: + return binding instanceof IEnumerator; + case ICElement.C_TEMPLATE_CLASS: + case ICElement.C_TEMPLATE_CLASS_DECLARATION: + case ICElement.C_TEMPLATE_STRUCT: + case ICElement.C_TEMPLATE_STRUCT_DECLARATION: + case ICElement.C_TEMPLATE_UNION: + case ICElement.C_TEMPLATE_UNION_DECLARATION: + return binding instanceof ICPPClassTemplate; + case ICElement.C_TEMPLATE_FUNCTION: + case ICElement.C_TEMPLATE_FUNCTION_DECLARATION: + return binding instanceof ICPPFunctionTemplate && !(binding instanceof ICPPMethod); + case ICElement.C_TEMPLATE_METHOD_DECLARATION: + case ICElement.C_TEMPLATE_METHOD: + return binding instanceof ICPPFunctionTemplate && binding instanceof ICPPMethod; + case ICElement.C_TEMPLATE_VARIABLE: + return binding instanceof ICPPTemplateParameter; } return false; } @@ -495,42 +490,39 @@ public class IndexUI { * Searches for all specializations that depend on the definition of the given binding. */ public static List findSpecializations(IBinding binding) throws CoreException { - try { - List result= null; + List result= null; - IBinding owner = binding.getOwner(); - if (owner != null) { - List specializedOwners= findSpecializations(owner); - if (!specializedOwners.isEmpty()) { - result= new ArrayList(specializedOwners.size()); + IBinding owner = binding.getOwner(); + if (owner != null) { + List specializedOwners= findSpecializations(owner); + if (!specializedOwners.isEmpty()) { + result= new ArrayList(specializedOwners.size()); - for (IBinding specOwner : specializedOwners) { - if (specOwner instanceof ICPPClassSpecialization) { - result.add(((ICPPClassSpecialization) specOwner).specializeMember(binding)); - } + for (IBinding specOwner : specializedOwners) { + if (specOwner instanceof ICPPClassSpecialization) { + result.add(((ICPPClassSpecialization) specOwner).specializeMember(binding)); } } } - - if (binding instanceof ICPPInstanceCache) { - final List instances= Arrays.asList(((ICPPInstanceCache) binding).getAllInstances()); - if (!instances.isEmpty()) { - if (result == null) - result= new ArrayList(instances.size()); + } + + if (binding instanceof ICPPInstanceCache) { + final List instances= Arrays.asList(((ICPPInstanceCache) binding).getAllInstances()); + if (!instances.isEmpty()) { + if (result == null) + result= new ArrayList(instances.size()); - for (ICPPTemplateInstance inst : instances) { - if (!IndexFilter.ALL_DECLARED.acceptBinding(inst)) { - result.add(inst); - } + for (ICPPTemplateInstance inst : instances) { + if (!IndexFilter.ALL_DECLARED.acceptBinding(inst)) { + result.add(inst); } } } - - if (result != null) { - return result; - } - } catch (DOMException e) { + } + + if (result != null) { + return result; } return Collections.emptyList(); } diff --git a/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/action/deprecated/C99ResolveParserAction.java b/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/action/deprecated/C99ResolveParserAction.java index f141fefbe98..922ad9724f1 100644 --- a/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/action/deprecated/C99ResolveParserAction.java +++ b/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/action/deprecated/C99ResolveParserAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2009 IBM Corporation and others. + * Copyright (c) 2006, 2010 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 @@ -20,7 +20,6 @@ import java.util.List; import lpg.lpgjavaruntime.IToken; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.EScopeKind; import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression; import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier; @@ -1327,21 +1326,19 @@ import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; * eg) x.a; computes the type of a */ private C99Field computeFieldBinding(IType identType, String memberName, boolean isPointerDereference) { - try { - IType type = identType; - if(isPointerDereference) { - if(type instanceof IPointerType) - type = ((ITypeContainer)type).getType(); // do the dereference - else - return null; - } - - type = rawType(type); - if(type instanceof ICompositeType) { - ICompositeType struct = (ICompositeType) type; - return (C99Field) struct.findField(memberName); - } - } catch(DOMException _) {} + IType type = identType; + if(isPointerDereference) { + if(type instanceof IPointerType) + type = ((ITypeContainer)type).getType(); // do the dereference + else + return null; + } + + type = rawType(type); + if(type instanceof ICompositeType) { + ICompositeType struct = (ICompositeType) type; + return (C99Field) struct.findField(memberName); + } return null; } diff --git a/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99CompositeTypeScope.java b/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99CompositeTypeScope.java index 5ca2c946e79..398a2f62798 100644 --- a/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99CompositeTypeScope.java +++ b/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99CompositeTypeScope.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. + * Copyright (c) 2006, 2010 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 @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.EScopeKind; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.ICompositeType; @@ -31,7 +30,7 @@ public class C99CompositeTypeScope extends C99Scope implements ICCompositeTypeSc return struct; } - public IBinding getBinding(@SuppressWarnings("unused") char[] name) throws DOMException { + public IBinding getBinding(@SuppressWarnings("unused") char[] name) { throw new UnsupportedOperationException(); } } diff --git a/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Enumeration.java b/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Enumeration.java index 47b97f648a1..ee669909627 100644 --- a/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Enumeration.java +++ b/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Enumeration.java @@ -14,7 +14,6 @@ import java.util.ArrayList; import java.util.List; import org.eclipse.cdt.core.dom.ILinkage; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IEnumeration; @@ -107,7 +106,7 @@ public class C99Enumeration extends PlatformObject implements IC99Binding, IEnum this.scope = scope; } - public IBinding getOwner() throws DOMException { + public IBinding getOwner() { if (scope != null) { return CVisitor.findEnclosingFunction((IASTNode) scope.getScopeName()); // local or global } diff --git a/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Enumerator.java b/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Enumerator.java index 6a509d7f00c..1e5b68d5e90 100644 --- a/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Enumerator.java +++ b/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Enumerator.java @@ -11,7 +11,6 @@ package org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings; import org.eclipse.cdt.core.dom.ILinkage; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IEnumerator; import org.eclipse.cdt.core.dom.ast.IScope; @@ -68,7 +67,7 @@ public class C99Enumerator extends PlatformObject implements IC99Binding, IEnume this.scope = scope; } - public IBinding getOwner() throws DOMException { + public IBinding getOwner() { if (type instanceof IBinding) return (IBinding) type; return null; diff --git a/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Field.java b/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Field.java index 502aed0de41..e17259e5da3 100644 --- a/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Field.java +++ b/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Field.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. + * Copyright (c) 2006, 2010 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 @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.ICompositeType; import org.eclipse.cdt.core.dom.ast.IField; import org.eclipse.cdt.core.dom.ast.IScope; @@ -37,11 +36,7 @@ public class C99Field extends C99Variable implements IC99Binding, IField, ITypea @Override public IScope getScope() { - try { - return compositeTypeOwner.getCompositeScope(); - } catch (DOMException e) { - return null; // should never happen - } + return compositeTypeOwner.getCompositeScope(); } diff --git a/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Label.java b/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Label.java index 17e3db6f3b8..af6f4438930 100644 --- a/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Label.java +++ b/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Label.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. + * Copyright (c) 2006, 2010 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 @@ -11,7 +11,6 @@ package org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings; import org.eclipse.cdt.core.dom.ILinkage; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTLabelStatement; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IBinding; @@ -64,7 +63,7 @@ public class C99Label extends PlatformObject implements IC99Binding, ILabel { this.scope = scope; } - public IBinding getOwner() throws DOMException { + public IBinding getOwner() { if (scope != null) { return CVisitor.findEnclosingFunction((IASTNode) scope.getScopeName()); // local or global } diff --git a/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Scope.java b/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Scope.java index af22d736608..58251314dd2 100644 --- a/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Scope.java +++ b/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Scope.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2009 IBM Corporation and others. + * Copyright (c) 2006, 2010 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 @@ -11,7 +11,6 @@ package org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings; import org.eclipse.cdt.core.dom.IName; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.EScopeKind; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; @@ -94,14 +93,13 @@ public class C99Scope implements IC99Scope, IASTInternalScope { } public IBinding getBinding(IASTName name, boolean resolve, - IIndexFileSet acceptLocalBindings) throws DOMException { + IIndexFileSet acceptLocalBindings) { // TODO Auto-generated method stub return null; } public IBinding[] getBindings(IASTName name, boolean resolve, - boolean prefixLookup, IIndexFileSet acceptLocalBindings) - throws DOMException { + boolean prefixLookup, IIndexFileSet acceptLocalBindings) { // TODO Auto-generated method stub return null; } diff --git a/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Structure.java b/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Structure.java index 57db1054b06..bc1ed79321a 100644 --- a/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Structure.java +++ b/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Structure.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. + * Copyright (c) 2006, 2010 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 @@ -14,7 +14,6 @@ import java.util.LinkedHashMap; import java.util.Map; import org.eclipse.cdt.core.dom.ILinkage; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.ICompositeType; @@ -148,7 +147,7 @@ public class C99Structure extends PlatformObject implements IC99Binding, ICompos this.scope = scope; } - public IBinding getOwner() throws DOMException { + public IBinding getOwner() { if (scope != null) { return CVisitor.findEnclosingFunction((IASTNode) scope.getScopeName()); // local or global } diff --git a/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Typedef.java b/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Typedef.java index e0fc274a87e..985902b3b52 100644 --- a/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Typedef.java +++ b/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Typedef.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2009 IBM Corporation and others. + * Copyright (c) 2006, 2010 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 @@ -11,7 +11,6 @@ package org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings; import org.eclipse.cdt.core.dom.ILinkage; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IScope; @@ -99,7 +98,7 @@ public class C99Typedef extends PlatformObject implements IC99Binding, ITypedef, this.scope = scope; } - public IBinding getOwner() throws DOMException { + public IBinding getOwner() { if (scope != null) { return CVisitor.findEnclosingFunction((IASTNode) scope.getScopeName()); // local or global } diff --git a/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Variable.java b/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Variable.java index 42c141b42d8..a185634d97b 100644 --- a/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Variable.java +++ b/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Variable.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. + * Copyright (c) 2006, 2010 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 @@ -11,7 +11,6 @@ package org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings; import org.eclipse.cdt.core.dom.ILinkage; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IScope; @@ -114,7 +113,7 @@ public class C99Variable extends PlatformObject implements IC99Binding, IVariabl this.scope = scope; } - public IBinding getOwner() throws DOMException { + public IBinding getOwner() { if (scope == null) return null; diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/BuildASTParserAction.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/BuildASTParserAction.java index 364aee71da3..0ff7eb74b49 100644 --- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/BuildASTParserAction.java +++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/BuildASTParserAction.java @@ -10,13 +10,14 @@ *******************************************************************************/ package org.eclipse.cdt.core.dom.lrparser.action; -import static org.eclipse.cdt.core.dom.lrparser.action.ParserUtil.*; +import static org.eclipse.cdt.core.dom.lrparser.action.ParserUtil.endOffset; +import static org.eclipse.cdt.core.dom.lrparser.action.ParserUtil.length; +import static org.eclipse.cdt.core.dom.lrparser.action.ParserUtil.offset; import java.util.List; import lpg.lpgjavaruntime.IToken; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTASMDeclaration; import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator; import org.eclipse.cdt.core.dom.ast.IASTArrayModifier; @@ -35,6 +36,7 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclarator; import org.eclipse.cdt.core.dom.ast.IASTDefaultStatement; import org.eclipse.cdt.core.dom.ast.IASTDoStatement; import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier; +import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator; import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTExpressionList; @@ -67,11 +69,9 @@ import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.INodeFactory; import org.eclipse.cdt.core.dom.ast.IScope; -import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCastExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLiteralExpression; import org.eclipse.cdt.core.dom.lrparser.ISecondaryParser; -import org.eclipse.cdt.core.dom.lrparser.LRParserPlugin; import org.eclipse.cdt.core.dom.lrparser.LRParserProperties; import org.eclipse.cdt.core.dom.parser.IBuiltinBindingsProvider; import org.eclipse.cdt.core.index.IIndex; @@ -136,12 +136,8 @@ public abstract class BuildASTParserAction extends AbstractParserAction { if (builtinBindingsProvider != null) { IScope tuScope = tu.getScope(); IBinding[] bindings = builtinBindingsProvider.getBuiltinBindings(tuScope); - try { - for (IBinding binding : bindings) { - ASTInternal.addBinding(tuScope, binding); - } - } catch (DOMException e) { - LRParserPlugin.logError(e); + for (IBinding binding : bindings) { + ASTInternal.addBinding(tuScope, binding); } } @@ -914,8 +910,8 @@ public abstract class BuildASTParserAction extends AbstractParserAction { declarator.setName(name); IASTPointerOperator[] pointers = decl.getPointerOperators(); - for(int i = 0; i < pointers.length; i++) { - declarator.addPointerOperator(pointers[i]); + for (IASTPointerOperator pointer : pointers) { + declarator.addPointerOperator(pointer); } int offset = offset(name); // TODO