1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Patch for Jason - 160884. Change DOMException to not be a CoreException.

This commit is contained in:
Doug Schaefer 2006-10-18 19:17:11 +00:00
parent c12e07dd19
commit 780f7df35c
25 changed files with 284 additions and 169 deletions

View file

@ -14,6 +14,7 @@ package org.eclipse.cdt.internal.pdom.tests;
import junit.framework.Test;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IBasicType;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IField;
@ -120,7 +121,7 @@ public class CPPFieldTests extends PDOMTestBase {
assertFieldType(pdom, "Class2::c2b", IBasicType.t_float);
}
private void assertFieldType(PDOM pdom, String name, int type) throws CoreException {
private void assertFieldType(PDOM pdom, String name, int type) throws CoreException, DOMException {
IBinding[] bindings = findQualifiedName(pdom, name);
assertEquals(1, bindings.length);
IField field = (IField) bindings[0];

View file

@ -14,6 +14,7 @@ package org.eclipse.cdt.internal.pdom.tests;
import junit.framework.Test;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IBasicType;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IFunction;
@ -177,7 +178,7 @@ public class CPPFunctionTests extends PDOMTestBase {
}
}
private void assertReturnType(PDOM pdom, String name, int type) throws CoreException {
private void assertReturnType(PDOM pdom, String name, int type) throws CoreException, DOMException {
IBinding[] bindings = findQualifiedName(pdom, name);
assertEquals(1, bindings.length);
IFunction function = (IFunction) bindings[0];

View file

@ -21,6 +21,7 @@ import java.util.regex.Pattern;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.IPDOMManager;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember;
import org.eclipse.cdt.core.index.IndexFilter;
@ -167,7 +168,7 @@ public class PDOMTestBase extends BaseTestCase {
assertTrue(c.isAssignableFrom(bindings[0].getClass()));
}
protected void assertVisibility(PDOM pdom, String name, int visibility) throws CoreException {
protected void assertVisibility(PDOM pdom, String name, int visibility) throws CoreException, DOMException {
IBinding[] bindings = findQualifiedName(pdom, name);
assertEquals(1, bindings.length);
ICPPMember member = (ICPPMember) bindings[0];

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others.
* Copyright (c) 2004, 2006 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,10 +14,6 @@
*/
package org.eclipse.cdt.core.dom.ast;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
/**
* This is the general purpose exception that is thrown for resolving semantic
@ -25,7 +21,7 @@ import org.eclipse.core.runtime.Status;
*
* @author aniefer
*/
public class DOMException extends CoreException {
public class DOMException extends Exception {
private static final long serialVersionUID = 0;
@ -37,8 +33,6 @@ public class DOMException extends CoreException {
*
*/
public DOMException(IProblemBinding problem) {
super(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID,
0, "DOMException", new Exception()));
problemBinding = problem;
}

View file

@ -8,6 +8,7 @@
* Contributors:
* QNX - Initial API and implementation
* Markus Schorn (Wind River Systems)
* IBM Corporation
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom;
@ -15,6 +16,7 @@ package org.eclipse.cdt.internal.core.pdom.dom;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.IPDOMVisitor;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
@ -27,6 +29,7 @@ import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.index.IIndexLinkage;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.BTree;
@ -149,50 +152,53 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
public abstract PDOMBinding resolveBinding(IASTName name) throws CoreException;
public PDOMNode getAdaptedParent(IBinding binding) throws CoreException {
IScope scope = binding.getScope();
if (scope == null)
return null;
if (scope instanceof IIndexBinding) {
IIndexBinding parent= ((IIndexBinding) scope).getParentBinding();
if (parent == null) {
return this;
}
return adaptBinding(parent);
}
try {
IScope scope = binding.getScope();
if (scope == null)
return null;
// the scope is from the ast
// mstodo revisit unnamed namespaces
IScope testScope= scope;
while (testScope instanceof ICPPNamespaceScope) {
IName name= testScope.getScopeName();
if (name != null && name.toCharArray().length == 0) {
testScope= scope.getParent();
if (testScope != null) {
scope= testScope;
if (scope instanceof IIndexBinding) {
IIndexBinding parent= ((IIndexBinding) scope).getParentBinding();
if (parent == null) {
return this;
}
return adaptBinding(parent);
}
// the scope is from the ast
// mstodo revisit unnamed namespaces
IScope testScope= scope;
while (testScope instanceof ICPPNamespaceScope) {
IName name= testScope.getScopeName();
if (name != null && name.toCharArray().length == 0) {
testScope= scope.getParent();
if (testScope != null) {
scope= testScope;
}
}
else {
testScope= null;
}
}
else {
testScope= null;
}
}
IASTNode scopeNode = ASTInternal.getPhysicalNodeOfScope(scope);
if (scopeNode instanceof IASTCompoundStatement)
return null;
else if (scopeNode instanceof IASTTranslationUnit)
return this;
else {
IName scopeName = scope.getScopeName();
if (scopeName instanceof IASTName) {
IBinding scopeBinding = ((IASTName) scopeName).resolveBinding();
PDOMBinding scopePDOMBinding = adaptBinding(scopeBinding);
if (scopePDOMBinding != null)
return scopePDOMBinding;
}
}
IASTNode scopeNode = ASTInternal.getPhysicalNodeOfScope(scope);
if (scopeNode instanceof IASTCompoundStatement)
return null;
else if (scopeNode instanceof IASTTranslationUnit)
return this;
else {
IName scopeName = scope.getScopeName();
if (scopeName instanceof IASTName) {
IBinding scopeBinding = ((IASTName) scopeName).resolveBinding();
PDOMBinding scopePDOMBinding = adaptBinding(scopeBinding);
if (scopePDOMBinding != null)
return scopePDOMBinding;
}
}
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}
return null;
}
}

View file

@ -8,6 +8,7 @@
* Contributors:
* QNX - Initial API and implementation
* Markus Schorn (Wind River Systems)
* IBM Corporation
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom;
@ -16,6 +17,7 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IPointerType;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.Database;
@ -44,23 +46,27 @@ public class PDOMPointerType extends PDOMNode implements IPointerType,
Database db = pdom.getDB();
// type
IType targetType = ((ITypeContainer)type).getType();
int typeRec = 0;
if (type != null) {
PDOMNode targetTypeNode = getLinkageImpl().addType(this, targetType);
if (targetTypeNode != null)
typeRec = targetTypeNode.getRecord();
try {
// type
IType targetType = ((ITypeContainer)type).getType();
int typeRec = 0;
if (type != null) {
PDOMNode targetTypeNode = getLinkageImpl().addType(this, targetType);
if (targetTypeNode != null)
typeRec = targetTypeNode.getRecord();
}
db.putInt(record + TYPE, typeRec);
// flags
byte flags = 0;
if (type.isConst())
flags |= CONST;
if (type.isVolatile())
flags |= VOLATILE;
db.putByte(record + FLAGS, flags);
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}
db.putInt(record + TYPE, typeRec);
// flags
byte flags = 0;
if (type.isConst())
flags |= CONST;
if (type.isVolatile())
flags |= VOLATILE;
db.putByte(record + FLAGS, flags);
}
protected int getRecordSize() {

View file

@ -8,6 +8,7 @@
* Contributors:
* QNX - Initial API and implementation
* Markus Schorn (Wind River Systems)
* IBM Corporation
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom;
@ -16,6 +17,7 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IQualifierType;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.Database;
@ -46,21 +48,26 @@ public class PDOMQualifierType extends PDOMNode implements IQualifierType,
Database db = pdom.getDB();
// type
IType targetType = ((ITypeContainer)type).getType();
if (type != null) {
PDOMNode targetTypeNode = getLinkageImpl().addType(this, targetType);
if (targetTypeNode != null) {
db.putInt(record + TYPE, targetTypeNode.getRecord());
try {
IType targetType = ((ITypeContainer)type).getType();
if (type != null) {
PDOMNode targetTypeNode = getLinkageImpl().addType(this, targetType);
if (targetTypeNode != null) {
db.putInt(record + TYPE, targetTypeNode.getRecord());
}
}
// flags
byte flags = 0;
if (type.isConst())
flags |= CONST;
if (type.isVolatile())
flags |= VOLATILE;
db.putByte(record + FLAGS, flags);
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}
// flags
byte flags = 0;
if (type.isConst())
flags |= CONST;
if (type.isVolatile())
flags |= VOLATILE;
db.putByte(record + FLAGS, flags);
}
protected int getRecordSize() {

View file

@ -18,6 +18,7 @@ import org.eclipse.cdt.core.dom.ast.IFunction;
import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.IParameter;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
@ -42,7 +43,11 @@ class PDOMCFunction extends PDOMBinding implements IFunction {
public PDOMCFunction(PDOM pdom, PDOMNode parent, IASTName name) throws CoreException {
super(pdom, parent, name);
pdom.getDB().putByte(record + ANNOTATIONS, PDOMCAnnotation.encodeAnnotation(name.resolveBinding()));
try {
pdom.getDB().putByte(record + ANNOTATIONS, PDOMCAnnotation.encodeAnnotation(name.resolveBinding()));
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}
}
public PDOMCFunction(PDOM pdom, int record) {

View file

@ -8,12 +8,14 @@
* Contributors:
* QNX - Initial API and implementation
* Markus Schorn (Wind River Systems)
* IBM Corporation
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.c;
import org.eclipse.cdt.core.dom.IPDOMNode;
import org.eclipse.cdt.core.dom.IPDOMVisitor;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
import org.eclipse.cdt.core.dom.ast.IASTName;
@ -32,6 +34,7 @@ import org.eclipse.cdt.core.dom.ast.IVariable;
import org.eclipse.cdt.core.dom.ast.c.ICASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.gnu.c.GCCLanguage;
import org.eclipse.cdt.core.model.ILanguage;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
@ -109,11 +112,15 @@ class PDOMCLinkage extends PDOMLinkage {
else if (binding instanceof IEnumeration)
pdomBinding = new PDOMCEnumeration(pdom, parent, name);
else if (binding instanceof IEnumerator) {
IEnumeration enumeration = (IEnumeration)((IEnumerator)binding).getType();
PDOMBinding pdomEnumeration = adaptBinding(enumeration);
if (pdomEnumeration instanceof PDOMCEnumeration)
pdomBinding = new PDOMCEnumerator(pdom, parent, name,
(PDOMCEnumeration)pdomEnumeration);
try {
IEnumeration enumeration = (IEnumeration)((IEnumerator)binding).getType();
PDOMBinding pdomEnumeration = adaptBinding(enumeration);
if (pdomEnumeration instanceof PDOMCEnumeration)
pdomBinding = new PDOMCEnumerator(pdom, parent, name,
(PDOMCEnumeration)pdomEnumeration);
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}
} else if (binding instanceof ITypedef)
pdomBinding = new PDOMCTypedef(pdom, parent, name, (ITypedef)binding);
}

View file

@ -8,6 +8,7 @@
* Contributors:
* QNX - Initial API and implementation
* Markus Schorn (Wind River Systems)
* IBM Corporation
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.c;
@ -16,6 +17,7 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
@ -35,10 +37,14 @@ class PDOMCTypedef extends PDOMBinding implements ITypedef {
throws CoreException {
super(pdom, parent, name);
IType type = typedef.getType();
PDOMNode typeNode = parent.getLinkageImpl().addType(this, type);
if (typeNode != null)
pdom.getDB().putInt(record + TYPE, typeNode.getRecord());
try {
IType type = typedef.getType();
PDOMNode typeNode = parent.getLinkageImpl().addType(this, type);
if (typeNode != null)
pdom.getDB().putInt(record + TYPE, typeNode.getRecord());
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}
}
public PDOMCTypedef(PDOM pdom, int record) {

View file

@ -16,6 +16,7 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IVariable;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
@ -41,10 +42,12 @@ class PDOMCVariable extends PDOMBinding implements IVariable {
public PDOMCVariable(PDOM pdom, PDOMNode parent, IASTName name) throws CoreException {
super(pdom, parent, name);
IVariable binding = (IVariable)name.getBinding();
if (binding != null) {
IType type = binding.getType();
try {
pdom.getDB().putByte(record + ANNOTATIONS, PDOMCAnnotation.encodeAnnotation(binding));
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}
pdom.getDB().putByte(record + ANNOTATIONS, PDOMCAnnotation.encodeAnnotation(binding));
}
public PDOMCVariable(PDOM pdom, int record) {

View file

@ -16,6 +16,7 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
@ -46,19 +47,23 @@ class PDOMCPPBasicType extends PDOMNode implements ICPPBasicType {
Database db = pdom.getDB();
db.putChar(record + TYPE_ID, (char)type.getType());
char flags = 0;
if (type.isLong())
flags |= IS_LONG;
if (type.isShort())
flags |= IS_SHORT;
if (type.isSigned())
flags |= IS_SIGNED;
if (type.isUnsigned())
flags |= IS_UNSIGNED;
db.putChar(record + FLAGS, flags);
try {
db.putChar(record + TYPE_ID, (char)type.getType());
char flags = 0;
if (type.isLong())
flags |= IS_LONG;
if (type.isShort())
flags |= IS_SHORT;
if (type.isSigned())
flags |= IS_SIGNED;
if (type.isUnsigned())
flags |= IS_UNSIGNED;
db.putChar(record + FLAGS, flags);
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}
}
protected int getRecordSize() {

View file

@ -23,7 +23,6 @@ import org.eclipse.cdt.core.dom.IPDOMNode;
import org.eclipse.cdt.core.dom.IPDOMVisitor;
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;
import org.eclipse.cdt.core.dom.ast.IField;
import org.eclipse.cdt.core.dom.ast.IScope;
@ -35,6 +34,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
@ -63,10 +63,14 @@ class PDOMCPPClassType extends PDOMCPPBinding implements ICPPClassType,
super(pdom, parent, name);
IBinding binding = name.resolveBinding();
int key = 0;
if (binding instanceof ICPPClassType) // not sure why it wouldn't
key = ((ICPPClassType) binding).getKey();
pdom.getDB().putByte(record + KEY, (byte) key);
try {
int key = 0;
if (binding instanceof ICPPClassType) // not sure why it wouldn't
key = ((ICPPClassType) binding).getKey();
pdom.getDB().putByte(record + KEY, (byte) key);
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}
// linked list is initialized by storage being zero'd by malloc
}
@ -189,9 +193,13 @@ class PDOMCPPClassType extends PDOMCPPBinding implements ICPPClassType,
// Visit my base classes
for (PDOMCPPBase base = getFirstBase(); base != null; base = base.getNextBase()) {
IBinding baseClass = base.getBaseClass();
if (baseClass != null && baseClass instanceof PDOMCPPClassType)
((PDOMCPPClassType)baseClass).visitAllDeclaredMethods(visited, methods);
try {
IBinding baseClass = base.getBaseClass();
if (baseClass != null && baseClass instanceof PDOMCPPClassType)
((PDOMCPPClassType)baseClass).visitAllDeclaredMethods(visited, methods);
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}
}
}

View file

@ -19,6 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.Database;
@ -47,8 +48,12 @@ class PDOMCPPField extends PDOMCPPBinding implements ICPPField {
throws CoreException {
super(pdom, parent, name);
IBinding binding = name.resolveBinding();
Database db = pdom.getDB();
db.putByte(record + ANNOTATION, PDOMCPPAnnotation.encodeAnnotation(binding));
try {
Database db = pdom.getDB();
db.putByte(record + ANNOTATION, PDOMCPPAnnotation.encodeAnnotation(binding));
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}
}
public PDOMCPPField(PDOM pdom, int bindingRecord) {

View file

@ -27,6 +27,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
@ -83,7 +84,11 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, ICPPFuncti
}
}
IBinding binding = name.resolveBinding();
db.putByte(record + ANNOTATION, PDOMCPPAnnotation.encodeAnnotation(binding));
try {
db.putByte(record + ANNOTATION, PDOMCPPAnnotation.encodeAnnotation(binding));
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}
}
public PDOMCPPFunction(PDOM pdom, int bindingRecord) {

View file

@ -14,6 +14,7 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.dom.IPDOMNode;
import org.eclipse.cdt.core.dom.IPDOMVisitor;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
import org.eclipse.cdt.core.dom.ast.IASTName;
@ -42,6 +43,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
import org.eclipse.cdt.core.model.ILanguage;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBlockScope;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPImplicitMethod;
import org.eclipse.cdt.internal.core.pdom.PDOM;
@ -115,42 +117,46 @@ class PDOMCPPLinkage extends PDOMLinkage {
return null;
PDOMBinding pdomBinding = adaptBinding(binding);
if (pdomBinding == null) {
PDOMNode parent = getAdaptedParent(binding);
if (parent != null) {
if (binding instanceof ICPPField && parent instanceof PDOMCPPClassType)
pdomBinding = new PDOMCPPField(pdom, (PDOMCPPClassType)parent, name);
else if (binding instanceof ICPPVariable) {
if (!(binding.getScope() instanceof CPPBlockScope))
pdomBinding = new PDOMCPPVariable(pdom, parent, name);
} else if (binding instanceof ICPPMethod && parent instanceof PDOMCPPClassType) {
pdomBinding = new PDOMCPPMethod(pdom, parent, name);
} else if (binding instanceof CPPImplicitMethod && parent instanceof PDOMCPPClassType) {
if(!name.isReference()) {
//because we got the implicit method off of an IASTName that is not a reference,
//it is no longer completly implicit and it should be treated as a normal method.
try {
if (pdomBinding == null) {
PDOMNode parent = getAdaptedParent(binding);
if (parent != null) {
if (binding instanceof ICPPField && parent instanceof PDOMCPPClassType)
pdomBinding = new PDOMCPPField(pdom, (PDOMCPPClassType)parent, name);
else if (binding instanceof ICPPVariable) {
if (!(binding.getScope() instanceof CPPBlockScope))
pdomBinding = new PDOMCPPVariable(pdom, parent, name);
} else if (binding instanceof ICPPMethod && parent instanceof PDOMCPPClassType) {
pdomBinding = new PDOMCPPMethod(pdom, parent, name);
} else if (binding instanceof CPPImplicitMethod && parent instanceof PDOMCPPClassType) {
if(!name.isReference()) {
//because we got the implicit method off of an IASTName that is not a reference,
//it is no longer completly implicit and it should be treated as a normal method.
pdomBinding = new PDOMCPPMethod(pdom, parent, name);
}
} else if (binding instanceof ICPPFunction) {
pdomBinding = new PDOMCPPFunction(pdom, parent, name);
} else if (binding instanceof ICPPClassType) {
pdomBinding = new PDOMCPPClassType(pdom, parent, name);
} else if (binding instanceof ICPPNamespaceAlias) {
pdomBinding = new PDOMCPPNamespaceAlias(pdom, parent, name);
} else if (binding instanceof ICPPNamespace) {
pdomBinding = new PDOMCPPNamespace(pdom, parent, name);
} else if (binding instanceof IEnumeration) {
pdomBinding = new PDOMCPPEnumeration(pdom, parent, name);
} else if (binding instanceof IEnumerator) {
IEnumeration enumeration = (IEnumeration)((IEnumerator)binding).getType();
PDOMBinding pdomEnumeration = adaptBinding(enumeration);
if (pdomEnumeration instanceof PDOMCPPEnumeration)
pdomBinding = new PDOMCPPEnumerator(pdom, parent, name,
(PDOMCPPEnumeration)pdomEnumeration);
} else if (binding instanceof ITypedef) {
pdomBinding = new PDOMCPPTypedef(pdom, parent, name, (ITypedef)binding);
}
} else if (binding instanceof ICPPFunction) {
pdomBinding = new PDOMCPPFunction(pdom, parent, name);
} else if (binding instanceof ICPPClassType) {
pdomBinding = new PDOMCPPClassType(pdom, parent, name);
} else if (binding instanceof ICPPNamespaceAlias) {
pdomBinding = new PDOMCPPNamespaceAlias(pdom, parent, name);
} else if (binding instanceof ICPPNamespace) {
pdomBinding = new PDOMCPPNamespace(pdom, parent, name);
} else if (binding instanceof IEnumeration) {
pdomBinding = new PDOMCPPEnumeration(pdom, parent, name);
} else if (binding instanceof IEnumerator) {
IEnumeration enumeration = (IEnumeration)((IEnumerator)binding).getType();
PDOMBinding pdomEnumeration = adaptBinding(enumeration);
if (pdomEnumeration instanceof PDOMCPPEnumeration)
pdomBinding = new PDOMCPPEnumerator(pdom, parent, name,
(PDOMCPPEnumeration)pdomEnumeration);
} else if (binding instanceof ITypedef) {
pdomBinding = new PDOMCPPTypedef(pdom, parent, name, (ITypedef)binding);
}
}
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}
// final processing
@ -314,8 +320,12 @@ class PDOMCPPLinkage extends PDOMLinkage {
return resolveBinding(names[0]);
IASTName lastName = names[names.length - 1];
PDOMBinding nsBinding = adaptBinding(names[names.length - 2].resolveBinding());
if (nsBinding instanceof IScope) {
return (PDOMBinding) ((IScope)nsBinding).getBinding(lastName, true);
try {
if (nsBinding instanceof IScope) {
return (PDOMBinding) ((IScope)nsBinding).getBinding(lastName, true);
}
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}
}
IASTNode parent = name.getParent();

View file

@ -28,6 +28,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
@ -94,10 +95,14 @@ class PDOMCPPMethod extends PDOMCPPBinding implements ICPPMethod, ICPPFunctionTy
}
annotation |= PDOMCAnnotation.encodeCVQualifiers(funcDecl) << CV_OFFSET;
}
IBinding binding = name.resolveBinding();
annotation |= PDOMCPPAnnotation.encodeExtraAnnotation(binding);
db.putByte(record + ANNOTATION0, PDOMCPPAnnotation.encodeAnnotation(binding));
db.putByte(record + ANNOTATION1, annotation);
try {
IBinding binding = name.resolveBinding();
annotation |= PDOMCPPAnnotation.encodeExtraAnnotation(binding);
db.putByte(record + ANNOTATION0, PDOMCPPAnnotation.encodeAnnotation(binding));
db.putByte(record + ANNOTATION1, annotation);
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}
}
public PDOMCPPMethod(PDOM pdom, int record) {

View file

@ -20,6 +20,7 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNamedNode;
@ -63,10 +64,14 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter {
db.putInt(record + NEXT_PARAM, 0);
IType type = param.getType();
if (type != null) {
PDOMNode typeNode = getLinkageImpl().addType(this, type);
db.putInt(record + TYPE, typeNode != null ? typeNode.getRecord() : 0);
try {
IType type = param.getType();
if (type != null) {
PDOMNode typeNode = getLinkageImpl().addType(this, type);
db.putInt(record + TYPE, typeNode != null ? typeNode.getRecord() : 0);
}
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}
}

View file

@ -16,6 +16,7 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
@ -34,10 +35,14 @@ class PDOMCPPTypedef extends PDOMBinding implements ITypedef {
public PDOMCPPTypedef(PDOM pdom, PDOMNode parent, IASTName name, ITypedef typedef)
throws CoreException {
super(pdom, parent, name);
IType type = typedef.getType();
PDOMNode typeNode = parent.getLinkageImpl().addType(this, type);
if (typeNode != null)
pdom.getDB().putInt(record + TYPE, typeNode.getRecord());
try {
IType type = typedef.getType();
PDOMNode typeNode = parent.getLinkageImpl().addType(this, type);
if (typeNode != null)
pdom.getDB().putInt(record + TYPE, typeNode.getRecord());
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}
}
public PDOMCPPTypedef(PDOM pdom, int record) {

View file

@ -20,6 +20,7 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.Database;
@ -64,7 +65,11 @@ class PDOMCPPVariable extends PDOMCPPBinding implements ICPPVariable {
if (typeNode != null)
db.putInt(record + TYPE_OFFSET, typeNode.getRecord());
}
db.putByte(record + ANNOTATIONS, PDOMCPPAnnotation.encodeAnnotation(name.resolveBinding()));
try {
db.putByte(record + ANNOTATIONS, PDOMCPPAnnotation.encodeAnnotation(name.resolveBinding()));
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}
}
public PDOMCPPVariable(PDOM pdom, int record) {

View file

@ -21,9 +21,12 @@ import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
public class Util {
@ -365,7 +368,16 @@ public class Util {
return true;
return false;
}
/**
* Returns an IStatus object with severity IStatus.ERROR based on the
* given Throwable.
* @param t the Throwable that caused the error.
* @return an IStatus object based on the given Throwable.
*/
public static IStatus createStatus(Throwable t) {
return new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, 0, t.getMessage(), t);
}
}

View file

@ -8,10 +8,12 @@
* Contributors:
* QNX - Initial API and implementation
* Markus Schorn (Wind River Systems)
* IBM Corporation
*******************************************************************************/
package org.eclipse.cdt.internal.ui;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.ICompositeType;
import org.eclipse.cdt.core.dom.ast.IFunction;
import org.eclipse.cdt.core.dom.ast.IVariable;
@ -71,7 +73,7 @@ public class IndexLabelProvider extends LabelProvider {
desc = CElementImageProvider.getUnionImageDescriptor();
break;
}
} catch (CoreException e) {
} catch (DOMException e) {
CUIPlugin.getDefault().log(e);
}
}

View file

@ -12,7 +12,9 @@
package org.eclipse.cdt.internal.ui.editor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.util.PropertyChangeEvent;
@ -312,7 +314,7 @@ public class SemanticHighlightings {
try {
return ((IField)binding).isStatic();
} catch (DOMException exc) {
CUIPlugin.getDefault().log(exc.getStatus());
CUIPlugin.getDefault().log(exc);
} catch (Error e) /* PDOMNotImplementedError */ {
// ignore
}
@ -945,7 +947,7 @@ public class SemanticHighlightings {
return true;
}
} catch (DOMException exc) {
CUIPlugin.getDefault().log(exc.getStatus());
CUIPlugin.getDefault().log(exc);
} catch (Error e) /* PDOMNotImplementedError */ {
// ignore
}
@ -1023,7 +1025,7 @@ public class SemanticHighlightings {
return true;
}
} catch (DOMException exc) {
CUIPlugin.getDefault().log(exc.getStatus());
CUIPlugin.getDefault().log(exc);
} catch (Error e) /* PDOMNotImplementedError */ {
// ignore
}
@ -1112,7 +1114,7 @@ public class SemanticHighlightings {
return true;
}
} catch (DOMException exc) {
CUIPlugin.getDefault().log(exc.getStatus());
CUIPlugin.getDefault().log(exc);
} catch (Error e) /* PDOMNotImplementedError */ {
// ignore
}

View file

@ -24,6 +24,7 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
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;
@ -40,6 +41,8 @@ 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;
import org.eclipse.cdt.internal.ui.util.Messages;
/**
@ -177,7 +180,10 @@ public class PDOMSearchPatternQuery extends PDOMSearchQuery {
}
} catch (CoreException e) {
return e.getStatus();
} catch (DOMException e) {
return Util.createStatus(e);
}
return Status.OK_STATUS;
}

View file

@ -40,6 +40,7 @@ import org.eclipse.cdt.core.browser.ITypeInfo;
import org.eclipse.cdt.core.browser.ITypeReference;
import org.eclipse.cdt.core.browser.TypeSearchScope;
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.IEnumeration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
@ -448,6 +449,8 @@ public class NewClassWizardUtil {
}
} catch (CoreException e) {
return SEARCH_MATCH_ERROR;
} catch (DOMException e) {
return SEARCH_MATCH_ERROR;
}
return SEARCH_MATCH_NOTFOUND;
}