1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Bug 323723: Removes the remaining throw declarations from IVariable and IFunction.

This commit is contained in:
Markus Schorn 2010-10-12 11:29:00 +00:00
parent 7f684f342a
commit 0dea806506
98 changed files with 672 additions and 1020 deletions

View file

@ -16,7 +16,6 @@ import java.util.HashSet;
import java.util.Set;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
@ -257,14 +256,10 @@ public final class CxxAstUtils {
for (IBinding b : bindings) {
if (b instanceof IFunction) {
IFunction f = (IFunction) b;
try {
if (f.getParameters().length == expectedParametersNum) {
// Consider this overload
IIndexName[] decls = index.findDeclarations(b);
declSet.addAll(Arrays.asList(decls));
}
} catch (DOMException e) {
continue;
if (f.getParameters().length == expectedParametersNum) {
// Consider this overload
IIndexName[] decls = index.findDeclarations(b);
declSet.addAll(Arrays.asList(decls));
}
}
}

View file

@ -221,18 +221,14 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
}
protected static void assertVariable(IBinding b, String qn, Class expType, String expTypeQN) {
try {
assertInstance(b, IVariable.class);
IVariable variable = (IVariable) b;
assertQNEquals(qn, variable);
assertInstance(variable.getType(), expType);
if (expTypeQN != null) {
IType type= variable.getType();
assertInstance(type, IBinding.class);
assertQNEquals(expTypeQN, (IBinding) type);
}
} catch (DOMException de) {
fail(de.getMessage());
assertInstance(b, IVariable.class);
IVariable variable = (IVariable) b;
assertQNEquals(qn, variable);
assertInstance(variable.getType(), expType);
if (expTypeQN != null) {
IType type= variable.getType();
assertInstance(type, IBinding.class);
assertQNEquals(expTypeQN, (IBinding) type);
}
}

View file

@ -1592,18 +1592,14 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
String qn,
Class expType,
String expTypeQN) {
try {
assertTrue(binding instanceof ICPPField);
ICPPField field = (ICPPField) binding;
assertQNEquals(qn, field);
assertTrue(expType.isInstance(field.getType()));
if (expTypeQN != null) {
assert(field.getType() instanceof ICPPBinding);
ICPPBinding tyBinding = (ICPPBinding) field.getType();
assertQNEquals(expTypeQN, tyBinding);
}
} catch (DOMException de) {
fail(de.getMessage());
assertTrue(binding instanceof ICPPField);
ICPPField field = (ICPPField) binding;
assertQNEquals(qn, field);
assertTrue(expType.isInstance(field.getType()));
if (expTypeQN != null) {
assert(field.getType() instanceof ICPPBinding);
ICPPBinding tyBinding = (ICPPBinding) field.getType();
assertQNEquals(expTypeQN, tyBinding);
}
}
@ -1647,7 +1643,7 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
assertEquals(methods, classType.getMethods().length);
assertEquals(declaredMethods, classType.getDeclaredMethods().length);
assertEquals(allDeclaredMethods, classType.getAllDeclaredMethods().length);
// assertEquals(friends, classType.getFriends().length); (PDOMNotImplementedError)
assertEquals(friends, classType.getFriends().length);
assertEquals(constructors, classType.getConstructors().length);
assertEquals(nestedClasses, classType.getNestedClasses().length);
}

View file

@ -35,7 +35,6 @@ import org.eclipse.cdt.core.testplugin.CProjectHelper;
import org.eclipse.cdt.core.testplugin.CTestPlugin;
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.index.IIndexFragment;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.core.resources.IWorkspace;
@ -187,8 +186,8 @@ public class PDOMTestBase extends BaseTestCase {
*/
private void assertUniqueNameCount(IName[] names, int count) {
Set offsets = new HashSet();
for (int i = 0; i < names.length; i++) {
offsets.add(names[i].getFileLocation());
for (IName name : names) {
offsets.add(name.getFileLocation());
}
assertEquals(count, offsets.size());
}
@ -217,27 +216,23 @@ public class PDOMTestBase extends BaseTestCase {
// this is only approximate - composite types are not supported
public static IBinding[] findIFunctions(Class[] paramTypes, IBinding[] bindings) throws CoreException {
try {
List preresult = new ArrayList();
for(int i=0; i<bindings.length; i++) {
if(bindings[i] instanceof IFunction) {
IFunction function = (IFunction) bindings[i];
IType[] candidate = function.getType().getParameterTypes();
boolean areEqual = candidate.length == paramTypes.length;
for(int j=0; areEqual && j<paramTypes.length; j++) {
if(!paramTypes[j].isAssignableFrom(candidate[j].getClass())) {
areEqual = false;
}
}
if(areEqual) {
preresult.add(bindings[i]);
List preresult = new ArrayList();
for (IBinding binding : bindings) {
if(binding instanceof IFunction) {
IFunction function = (IFunction) binding;
IType[] candidate = function.getType().getParameterTypes();
boolean areEqual = candidate.length == paramTypes.length;
for(int j=0; areEqual && j<paramTypes.length; j++) {
if(!paramTypes[j].isAssignableFrom(candidate[j].getClass())) {
areEqual = false;
}
}
if(areEqual) {
preresult.add(binding);
}
}
return (IBinding[]) preresult.toArray(new IBinding[preresult.size()]);
} catch(DOMException e) {
throw new CoreException(Util.createStatus(e));
}
return (IBinding[]) preresult.toArray(new IBinding[preresult.size()]);
}
protected void assertInstance(Object o, Class c) {
@ -247,8 +242,8 @@ public class PDOMTestBase extends BaseTestCase {
public static Pattern[] makePatternArray(String[] args) {
List preresult = new ArrayList();
for(int i=0; i<args.length; i++) {
preresult.add(Pattern.compile(args[i]));
for (String arg : args) {
preresult.add(Pattern.compile(arg));
}
return (Pattern[]) preresult.toArray(new Pattern[preresult.size()]);
}

View file

@ -38,7 +38,6 @@ import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
import org.eclipse.cdt.internal.core.browser.IndexModelUtil;
import org.eclipse.cdt.internal.core.browser.IndexTypeReference;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
import org.eclipse.core.filesystem.URIUtil;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
@ -475,7 +474,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
*/
@Deprecated
public void addDerivedReference(ITypeReference location) {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
/**
@ -484,7 +483,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
*/
@Deprecated
public void addReference(ITypeReference location) {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
/**
@ -493,7 +492,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
*/
@Deprecated
public boolean canSubstituteFor(ITypeInfo info) {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
/**
@ -502,7 +501,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
*/
@Deprecated
public boolean encloses(ITypeInfo info) {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
/**
@ -511,7 +510,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
*/
@Deprecated
public boolean exists() {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
/**
@ -520,7 +519,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
*/
@Deprecated
public ITypeReference[] getDerivedReferences() {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
/**
@ -529,7 +528,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
*/
@Deprecated
public ITypeInfo[] getEnclosedTypes() {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
/**
@ -538,7 +537,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
*/
@Deprecated
public ITypeInfo[] getEnclosedTypes(int[] kinds) {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
/**
@ -547,7 +546,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
*/
@Deprecated
public ITypeInfo getEnclosingNamespace(boolean includeGlobalNamespace) {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
@ -567,7 +566,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
*/
@Deprecated
public ITypeInfo getEnclosingType(int[] kinds) {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
@ -577,7 +576,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
*/
@Deprecated
public ITypeInfo getRootNamespace(boolean includeGlobalNamespace) {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
/**
@ -586,7 +585,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
*/
@Deprecated
public ITypeInfo[] getSubTypes() {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
/**
@ -595,7 +594,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
*/
@Deprecated
public ASTAccessVisibility getSuperTypeAccess(ITypeInfo subType) {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
/**
@ -604,7 +603,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
*/
@Deprecated
public ITypeInfo[] getSuperTypes() {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
/**
@ -613,7 +612,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
*/
@Deprecated
public boolean hasEnclosedTypes() {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
/**
@ -622,7 +621,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
*/
@Deprecated
public boolean hasSubTypes() {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
/**
@ -631,7 +630,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
*/
@Deprecated
public boolean hasSuperTypes() {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
/**
@ -640,7 +639,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
*/
@Deprecated
public boolean isClass() {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
/**
@ -649,7 +648,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
*/
@Deprecated
public boolean isEnclosed(ITypeInfo info) {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
/**
@ -658,7 +657,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
*/
@Deprecated
public boolean isEnclosed(ITypeSearchScope scope) {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
/**
@ -667,7 +666,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
*/
@Deprecated
public boolean isEnclosedType() {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
/**
@ -676,7 +675,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
*/
@Deprecated
public boolean isEnclosingType() {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
/**
@ -685,7 +684,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
*/
@Deprecated
public boolean isReferenced(ITypeSearchScope scope) {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
/**
@ -694,7 +693,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
*/
@Deprecated
public boolean isUndefinedType() {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
/**
@ -703,6 +702,6 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
*/
@Deprecated
public void setCElementType(int type) {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
}

View file

@ -31,7 +31,6 @@ import org.eclipse.cdt.core.index.IIndexFileLocation;
import org.eclipse.cdt.core.index.IndexLocationFactory;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
import org.eclipse.core.filesystem.URIUtil;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
@ -209,47 +208,47 @@ public class ASTTypeInfo implements ITypeInfo, IFunctionInfo {
@Deprecated
public void addDerivedReference(ITypeReference location) {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
@Deprecated
public void addReference(ITypeReference location) {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
@Deprecated
public boolean canSubstituteFor(ITypeInfo info) {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
@Deprecated
public boolean encloses(ITypeInfo info) {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
@Deprecated
public boolean exists() {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
@Deprecated
public ITypeReference[] getDerivedReferences() {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
@Deprecated
public ITypeInfo[] getEnclosedTypes() {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
@Deprecated
public ITypeInfo[] getEnclosedTypes(int[] kinds) {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
@Deprecated
public ITypeInfo getEnclosingNamespace(boolean includeGlobalNamespace) {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
@Deprecated
@ -260,81 +259,81 @@ public class ASTTypeInfo implements ITypeInfo, IFunctionInfo {
@Deprecated
public ITypeInfo getEnclosingType(int[] kinds) {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
@Deprecated
public ITypeInfo getRootNamespace(boolean includeGlobalNamespace) {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
@Deprecated
public ITypeInfo[] getSubTypes() {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
@Deprecated
public ASTAccessVisibility getSuperTypeAccess(ITypeInfo subType) {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
@Deprecated
public ITypeInfo[] getSuperTypes() {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
@Deprecated
public boolean hasEnclosedTypes() {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
@Deprecated
public boolean hasSubTypes() {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
@Deprecated
public boolean hasSuperTypes() {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
@Deprecated
public boolean isClass() {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
@Deprecated
public boolean isEnclosed(ITypeInfo info) {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
@Deprecated
public boolean isEnclosed(ITypeSearchScope scope) {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
@Deprecated
public boolean isEnclosedType() {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
@Deprecated
public boolean isEnclosingType() {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
@Deprecated
public boolean isReferenced(ITypeSearchScope scope) {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
@Deprecated
public boolean isUndefinedType() {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
@Deprecated
public void setCElementType(int type) {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
}

View file

@ -18,7 +18,6 @@ import java.util.List;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.IPositionConverter;
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.IFunction;
import org.eclipse.cdt.core.dom.ast.IParameter;
@ -261,7 +260,7 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
return EMPTY_STRING_ARRAY;
}
protected String[] extractParameterTypes(IFunction func) throws DOMException {
protected String[] extractParameterTypes(IFunction func) {
IParameter[] params= func.getParameters();
String[] parameterTypes= new String[params.length];
for (int i = 0; i < params.length; i++) {

View file

@ -10,9 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.model.ext;
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.IField;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement;
@ -26,12 +24,7 @@ public class FieldHandle extends CElementHandle implements org.eclipse.cdt.core.
public FieldHandle(ICElement parent, IField field) {
super(parent, ICElement.C_FIELD, field.getName());
try {
fTypeName= ASTTypeUtil.getType(field.getType(), false);
} catch (DOMException e) {
CCorePlugin.log(e);
fTypeName= ""; //$NON-NLS-1$
}
fTypeName= ASTTypeUtil.getType(field.getType(), false);
fVisibility= getVisibility(field);
fIsStatic= field.isStatic();
}

View file

@ -12,7 +12,6 @@
package org.eclipse.cdt.internal.core.model.ext;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IFunction;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement;
@ -25,11 +24,11 @@ public class FunctionDeclarationHandle extends CElementHandle implements IFuncti
private String fReturnType;
private boolean fIsStatic;
public FunctionDeclarationHandle(ICElement parent, IFunction func) throws DOMException {
public FunctionDeclarationHandle(ICElement parent, IFunction func) {
this(parent, ICElement.C_FUNCTION_DECLARATION, func);
}
protected FunctionDeclarationHandle(ICElement parent, int type, IFunction func) throws DOMException {
protected FunctionDeclarationHandle(ICElement parent, int type, IFunction func) {
super(parent, type, func.getName());
fParameterTypes= extractParameterTypes(func);
fReturnType= ASTTypeUtil.getType(func.getType().getReturnType(), false);

View file

@ -11,13 +11,12 @@
package org.eclipse.cdt.internal.core.model.ext;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IFunction;
import org.eclipse.cdt.core.model.ICElement;
public class FunctionHandle extends FunctionDeclarationHandle implements org.eclipse.cdt.core.model.IFunction {
public FunctionHandle(ICElement parent, IFunction func) throws DOMException {
public FunctionHandle(ICElement parent, IFunction func) {
super(parent, ICElement.C_FUNCTION, func);
}
}

View file

@ -11,7 +11,6 @@
package org.eclipse.cdt.internal.core.model.ext;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
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.core.model.CModelException;
@ -29,11 +28,11 @@ public class MethodDeclarationHandle extends CElementHandle implements IMethodDe
private boolean fIsConstructor;
private boolean fIsDestructor;
public MethodDeclarationHandle(ICElement parent, ICPPMethod method) throws DOMException {
public MethodDeclarationHandle(ICElement parent, ICPPMethod method) {
this(parent, ICElement.C_METHOD_DECLARATION, method);
}
protected MethodDeclarationHandle(ICElement parent, int type, ICPPMethod method) throws DOMException {
protected MethodDeclarationHandle(ICElement parent, int type, ICPPMethod method) {
super(parent, type, method.getName());
fParameterTypes= extractParameterTypes(method);
fReturnType= ASTTypeUtil.getType(method.getType().getReturnType(), false);

View file

@ -11,14 +11,13 @@
package org.eclipse.cdt.internal.core.model.ext;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IMethod;
public class MethodHandle extends MethodDeclarationHandle implements IMethod {
public MethodHandle(ICElement parent, ICPPMethod method) throws DOMException {
public MethodHandle(ICElement parent, ICPPMethod method) {
super(parent, ICElement.C_METHOD, method);
}
}

View file

@ -11,14 +11,13 @@
package org.eclipse.cdt.internal.core.model.ext;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.INamespace;
public class NamespaceHandle extends CElementHandle implements INamespace {
public NamespaceHandle(ICElement parent, ICPPNamespace ns) throws DOMException {
public NamespaceHandle(ICElement parent, ICPPNamespace ns) {
super(parent, ICElement.C_NAMESPACE, ns.getName());
}

View file

@ -11,7 +11,6 @@
package org.eclipse.cdt.internal.core.model.ext;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.ICompositeType;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement;
@ -23,7 +22,7 @@ public class StructureHandle extends CElementHandle implements IStructure {
private static final IField[] EMPTY_FIELDS = new IField[0];
private static final IMethodDeclaration[] EMPTY_METHODS = new IMethodDeclaration[0];
public StructureHandle(ICElement parent, ICompositeType type) throws DOMException {
public StructureHandle(ICElement parent, ICompositeType type) {
super(parent, convertKey(type.getKey()), type.getName());
}

View file

@ -10,9 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.model.ext;
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.IVariable;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement;
@ -23,12 +21,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 {
fTypeName= ASTTypeUtil.getType(var.getType(), false);
} catch (DOMException e) {
CCorePlugin.log(e);
fTypeName= ""; //$NON-NLS-1$
}
fTypeName= ASTTypeUtil.getType(var.getType(), false);
fIsStatic= var.isStatic();
}

View file

@ -91,12 +91,10 @@ public class ASTTypeUtil {
/**
* @return Whether the function matching the given function binding takes
* parameters or not.
* @throws DOMException
*
* @since 5.1
*/
public static boolean functionTakesParameters(IFunction function)
throws DOMException {
public static boolean functionTakesParameters(IFunction function) {
IParameter[] parameters = function.getParameters();
if (parameters.length == 0) {
@ -624,20 +622,16 @@ public class ASTTypeUtil {
* @noreference This method is not intended to be referenced by clients.
*/
public static String getNodeType(IASTNode node) {
try {
if (node instanceof IASTDeclarator)
return getType((IASTDeclarator) node);
if (node instanceof IASTName && ((IASTName) node).resolveBinding() instanceof IVariable)
return getType(((IVariable)((IASTName) node).resolveBinding()).getType());
if (node instanceof IASTName && ((IASTName) node).resolveBinding() instanceof IFunction)
return getType(((IFunction)((IASTName) node).resolveBinding()).getType());
if (node instanceof IASTName && ((IASTName) node).resolveBinding() instanceof IType)
return getType((IType)((IASTName) node).resolveBinding());
if (node instanceof IASTTypeId)
return getType((IASTTypeId) node);
} catch (DOMException e) {
return EMPTY_STRING;
}
if (node instanceof IASTDeclarator)
return getType((IASTDeclarator) node);
if (node instanceof IASTName && ((IASTName) node).resolveBinding() instanceof IVariable)
return getType(((IVariable)((IASTName) node).resolveBinding()).getType());
if (node instanceof IASTName && ((IASTName) node).resolveBinding() instanceof IFunction)
return getType(((IFunction)((IASTName) node).resolveBinding()).getType());
if (node instanceof IASTName && ((IASTName) node).resolveBinding() instanceof IType)
return getType((IType)((IASTName) node).resolveBinding());
if (node instanceof IASTTypeId)
return getType((IASTTypeId) node);
return EMPTY_STRING;
}

View file

@ -22,24 +22,18 @@ public interface IFunction extends IBinding {
/**
* Returns the formal parameters of the function.
*
* @return array of IParameter
* @throws DOMException if this is a problem binding.
*/
public IParameter[] getParameters() throws DOMException;
public IParameter[] getParameters();
/**
* Get the function scope
*
* @throws DOMException if this is a problem binding.
*/
public IScope getFunctionScope() throws DOMException;
public IScope getFunctionScope();
/**
* Get the IFunctionType for this function
* @throws DOMException if this is a problem binding.
*/
public IFunctionType getType() throws DOMException;
public IFunctionType getType();
/**
* Returns {@code true} if the function has the static storage-class specifier

View file

@ -22,7 +22,7 @@ public interface IVariable extends IBinding {
/**
* Returns the type of the variable
*/
public IType getType() throws DOMException;
public IType getType();
/**
* Returns the value for a variable with an initializer,

View file

@ -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.IFunction;
import org.eclipse.cdt.core.dom.ast.IType;
@ -50,17 +49,17 @@ public interface ICPPFunction extends IFunction, ICPPBinding {
* {@inheritDoc}
* @since 5.1
*/
public ICPPFunctionType getType() throws DOMException;
public ICPPFunctionType getType();
/**
* @since 5.2
*/
public ICPPParameter[] getParameters() throws DOMException;
public ICPPParameter[] getParameters();
/**
* @since 5.2
*/
public int getRequiredArgumentCount() throws DOMException;
public int getRequiredArgumentCount();
/**
* @since 5.2

View file

@ -13,7 +13,6 @@ package org.eclipse.cdt.core.parser.util;
import java.io.PrintStream;
import org.eclipse.cdt.core.dom.ast.ASTGenericVisitor;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTComment;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
@ -262,13 +261,9 @@ public class ASTPrinter {
} else if (n instanceof IVariable) {
IVariable var = (IVariable) n;
IType t;
try {
t = var.getType();
out.println();
print(out, indentLevel, t);
} catch (DOMException e) {
//e.printStackTrace();
}
t = var.getType();
out.println();
print(out, indentLevel, t);
} else if (n instanceof IProblemBinding) {
IProblemBinding problem = (IProblemBinding)n;

View file

@ -278,8 +278,8 @@ public class ProblemBinding extends PlatformObject implements IProblemBinding, I
// Dummy methods for derived classes
public IType getType() throws DOMException {
throw new DOMException(this);
public IType getType() {
return new ProblemType(getID());
}
public boolean isStatic() {
return false;

View file

@ -0,0 +1,62 @@
/*******************************************************************************
* Copyright (c) 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser;
import org.eclipse.cdt.core.dom.ast.IPointerType;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType;
import org.eclipse.core.runtime.CoreException;
/**
* Implementation of problem types.
*/
public class ProblemFunctionType extends ProblemType implements ICPPFunctionType {
public ProblemFunctionType(int id) {
super(id);
}
@Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
buffer.putByte((byte) (ITypeMarshalBuffer.PROBLEM_TYPE | ITypeMarshalBuffer.FLAG1));
buffer.putShort((short) getID());
}
public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
return new ProblemFunctionType(buffer.getShort());
}
public IType getReturnType() {
return new ProblemType(getID());
}
public IType[] getParameterTypes() {
return new IType[] {new ProblemType(getID())};
}
public boolean isConst() {
return false;
}
public boolean isVolatile() {
return false;
}
public boolean takesVarArgs() {
return false;
}
public IPointerType getThisType() {
return new CPPPointerType(new ProblemType(getID()));
}
}

View file

@ -53,6 +53,9 @@ public class ProblemType implements IProblemType, ISerializableType {
}
public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
return new ProblemType(buffer.getShort() & 0xffff);
if ((firstByte & ITypeMarshalBuffer.FLAG1) != 0)
return ProblemFunctionType.unmarshal(firstByte, buffer);
return new ProblemType(buffer.getShort());
}
}

View file

@ -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.IASTArrayModifier;
import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression;
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
@ -75,15 +74,12 @@ public abstract class VariableReadWriteFlags {
}
protected int rwInInitializerExpression(int indirection, IASTNode parent) {
try {
IASTNode grand= parent.getParent();
if (grand instanceof IASTDeclarator) {
IBinding binding= ((IASTDeclarator) grand).getName().getBinding();
if (binding instanceof IVariable) {
return rwAssignmentToType(((IVariable) binding).getType(), indirection);
}
IASTNode grand= parent.getParent();
if (grand instanceof IASTDeclarator) {
IBinding binding= ((IASTDeclarator) grand).getName().getBinding();
if (binding instanceof IVariable) {
return rwAssignmentToType(((IVariable) binding).getType(), indirection);
}
} catch (DOMException e) {
}
return READ | WRITE; // fallback
}

View file

@ -14,7 +14,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.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
@ -137,11 +136,7 @@ public class CASTFieldReference extends ASTNode implements IASTFieldReference, I
public IType getExpressionType() {
IBinding binding = getFieldName().resolveBinding();
if (binding instanceof IVariable) {
try {
return ((IVariable)binding).getType();
} catch (DOMException e) {
return e.getProblem();
}
return ((IVariable)binding).getType();
}
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
}

View file

@ -15,9 +15,10 @@ 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;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
public class CField extends CVariable implements IField {
public static class CFieldProblem extends CVariable.CVariableProblem implements IField {
public static class CFieldProblem extends ProblemBinding implements IField {
private ICompositeType fOwner;
public CFieldProblem(ICompositeType owner, IASTNode node, int id, char[] arg) {
@ -38,5 +39,4 @@ public class CField extends CVariable implements IField {
ICCompositeTypeScope scope = (ICCompositeTypeScope) getScope();
return scope.getCompositeType();
}
}

View file

@ -26,12 +26,10 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
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.dom.ast.IVariable;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
import org.eclipse.cdt.internal.core.dom.parser.IInternalVariable;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.cdt.internal.core.dom.parser.Value;
import org.eclipse.core.runtime.PlatformObject;
@ -39,12 +37,6 @@ 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);
}
}
private IASTName[] declarations = null;
private IType type = null;

View file

@ -737,10 +737,7 @@ public class CVisitor extends ASTQueries {
if (binding instanceof IParameter) {
return new ProblemBinding(name, IProblemBinding.SEMANTIC_INVALID_REDECLARATION, name.toCharArray());
} else if (binding instanceof IVariable) {
try {
t2 = ((IVariable)binding).getType();
} catch (DOMException e1) {
}
t2 = ((IVariable)binding).getType();
if (t1 != null && t2 != null && (
t1.isSameType(t2) || isCompatibleArray(t1, t2) != null)) {
if (binding instanceof CVariable)

View file

@ -18,7 +18,6 @@ import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionT
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.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
import org.eclipse.cdt.core.dom.ast.IASTImplicitName;
@ -167,14 +166,13 @@ public class CPPASTExpressionList extends ASTNode implements ICPPASTExpressionLi
vcat= valueCat(e2);
} else {
overloads[i - 1] = overload;
try {
lookupType = overload.getType().getReturnType();
vcat= valueCategoryFromReturnType(lookupType);
lookupType= typeFromReturnType(lookupType);
} catch (DOMException e) {
lookupType = overload.getType().getReturnType();
vcat= valueCategoryFromReturnType(lookupType);
lookupType= typeFromReturnType(lookupType);
if (lookupType instanceof ISemanticProblem) {
lookupType = typeOrFunctionSet(e2);
vcat= valueCat(e2);
}
}
}
}
}

View file

@ -265,26 +265,23 @@ public class CPPASTFieldReference extends ASTNode implements ICPPASTFieldReferen
public ValueCategory getValueCategory() {
IASTName name= getFieldName();
IBinding binding = name.resolvePreBinding();
try {
if (binding instanceof IVariable) {
IType e2= ((IVariable) binding).getType();
e2= SemanticUtil.getNestedType(e2, TDEF);
if (e2 instanceof ICPPReferenceType) {
return LVALUE;
}
if (binding instanceof ICPPField && !((ICPPField) binding).isStatic()) {
if (isPointerDereference())
return LVALUE;
return owner.getValueCategory();
}
if (binding instanceof IVariable) {
IType e2= ((IVariable) binding).getType();
e2= SemanticUtil.getNestedType(e2, TDEF);
if (e2 instanceof ICPPReferenceType) {
return LVALUE;
}
if (binding instanceof IFunction) {
return LVALUE;
}
} catch (DOMException e) {
}
if (binding instanceof ICPPField && !((ICPPField) binding).isStatic()) {
if (isPointerDereference())
return LVALUE;
return owner.getValueCategory();
}
return LVALUE;
}
if (binding instanceof IFunction) {
return LVALUE;
}
return PRVALUE;
}

View file

@ -86,9 +86,6 @@ public class CPPClassType extends PlatformObject implements ICPPInternalClassTyp
public ICPPConstructor[] getConstructors() {
return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY;
}
public ICPPMethod[] getDeclaredConversionOperators() throws DOMException {
throw new DOMException(this);
}
public int getKey() {
return k_class;
}

View file

@ -11,19 +11,11 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.IASTNode;
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;
public class CPPConstructor extends CPPMethod implements ICPPConstructor {
static public class CPPConstructorProblem extends CPPMethod.CPPMethodProblem implements ICPPConstructor {
public CPPConstructorProblem(ICPPClassType owner, IASTNode node, int id, char[] arg) {
super(owner, node, id, arg);
}
}
public CPPConstructor(ICPPASTFunctionDeclarator declarator) {
super(declarator);
}

View file

@ -27,12 +27,13 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
/**
* Binding for a field.
*/
public class CPPField extends CPPVariable implements ICPPField {
public static class CPPFieldProblem extends CPPVariable.CPPVariableProblem implements ICPPField {
public static class CPPFieldProblem extends ProblemBinding implements ICPPField {
private ICPPClassType fOwner;
public CPPFieldProblem(ICPPClassType owner, IASTNode node, int id, char[] arg ) {

View file

@ -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.ICompositeType;
import org.eclipse.cdt.core.dom.ast.IType;
@ -45,7 +44,7 @@ public class CPPFieldSpecialization extends CPPSpecialization implements ICPPFie
return getField().getClassOwner();
}
public IType getType() throws DOMException {
public IType getType() {
if (type == null) {
type= specializeType(getField().getType());
}

View file

@ -32,6 +32,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
@ -47,7 +48,7 @@ import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.cdt.internal.core.dom.parser.ProblemFunctionType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
import org.eclipse.core.runtime.PlatformObject;
@ -57,28 +58,6 @@ import org.eclipse.core.runtime.PlatformObject;
*/
public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInternalFunction {
public static class CPPFunctionProblem extends ProblemBinding implements ICPPFunction {
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 int getRequiredArgumentCount() throws DOMException {
throw new DOMException(this);
}
public boolean hasSameFunctionParameterTypeList(ICPPFunction function) {
return false;
}
}
protected IASTDeclarator[] declarations;
protected ICPPASTFunctionDeclarator definition;
protected ICPPFunctionType type = null;
@ -264,8 +243,14 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
public ICPPFunctionType getType() {
if (type == null) {
final IType t = getNestedType(CPPVisitor.createType((definition != null) ? definition : declarations[0]), TDEF);
if (t instanceof ICPPFunctionType)
if (t instanceof ICPPFunctionType) {
type = (ICPPFunctionType) t;
} else if (t instanceof ISemanticProblem){
type= new ProblemFunctionType(((ISemanticProblem) t).getID());
} else {
// This case is unexpected
type = new ProblemFunctionType(ISemanticProblem.TYPE_UNRESOLVED_NAME);
}
}
return type;
}
@ -556,11 +541,11 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
return null;
}
public int getRequiredArgumentCount() throws DOMException {
public int getRequiredArgumentCount() {
return getRequiredArgumentCount(getParameters());
}
public static int getRequiredArgumentCount(ICPPParameter[] pars) throws DOMException {
public static int getRequiredArgumentCount(ICPPParameter[] pars) {
int result= pars.length;
while(result > 0) {
final ICPPParameter p = pars[result-1];

View file

@ -11,9 +11,7 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IType;
@ -72,17 +70,13 @@ public class CPPFunctionInstance extends CPPFunctionSpecialization implements IC
@Override
public boolean equals(Object obj) {
if( (obj instanceof ICPPTemplateInstance) && (obj instanceof ICPPFunction)){
try {
final ICPPTemplateInstance inst = (ICPPTemplateInstance)obj;
ICPPFunctionType ct1= ((ICPPFunction)getSpecializedBinding()).getType();
ICPPFunctionType ct2= ((ICPPFunction)inst.getTemplateDefinition()).getType();
if(!ct1.isSameType(ct2))
return false;
final ICPPTemplateInstance inst = (ICPPTemplateInstance)obj;
ICPPFunctionType ct1= ((ICPPFunction)getSpecializedBinding()).getType();
ICPPFunctionType ct2= ((ICPPFunction)inst.getTemplateDefinition()).getType();
if(!ct1.isSameType(ct2))
return false;
return CPPTemplates.haveSameArguments(this, inst);
} catch(DOMException de) {
CCorePlugin.log(de);
}
return CPPTemplates.haveSameArguments(this, inst);
}
return false;

View file

@ -13,7 +13,6 @@
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
@ -52,7 +51,7 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
return (ICPPFunction) getSpecializedBinding();
}
public ICPPParameter[] getParameters() throws DOMException {
public ICPPParameter[] getParameters() {
if (fParams == null) {
ICPPFunction function = getFunction();
ICPPParameter[] params = function.getParameters();
@ -76,7 +75,7 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
return fParams;
}
public int getRequiredArgumentCount() throws DOMException {
public int getRequiredArgumentCount() {
return ((ICPPFunction) getSpecializedBinding()).getRequiredArgumentCount();
}
@ -88,7 +87,7 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
return null;
}
public ICPPFunctionType getType() throws DOMException {
public ICPPFunctionType getType() {
if (type == null) {
ICPPFunction function = (ICPPFunction) getSpecializedBinding();
type = (ICPPFunctionType) specializeType(function.getType());
@ -279,11 +278,7 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
public String toString() {
StringBuilder result = new StringBuilder();
result.append(getName());
IFunctionType t = null;
try {
t = getType();
} catch (DOMException e) {
}
IFunctionType t = getType();
result.append(t != null ? ASTTypeUtil.getParameterTypeString(t) : "()"); //$NON-NLS-1$
ICPPTemplateParameterMap tpmap= getTemplateParameterMap();
if (tpmap != null) {

View file

@ -15,7 +15,6 @@ import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUti
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getNestedType;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
@ -29,17 +28,16 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.cdt.internal.core.dom.parser.ProblemFunctionType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
/**
@ -47,31 +45,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
*/
public class CPPFunctionTemplate extends CPPTemplateDefinition
implements ICPPFunctionTemplate, ICPPInternalFunction {
public static final class CPPFunctionTemplateProblem extends ProblemBinding
implements ICPPFunctionTemplate {
public CPPFunctionTemplateProblem(IASTNode node, int id, char[] arg) {
super(node, id, arg);
}
public ICPPTemplateParameter[] getTemplateParameters() throws DOMException {
throw new DOMException(this);
}
public ICPPClassTemplatePartialSpecialization[] getTemplateSpecializations() throws DOMException {
throw new DOMException(this);
}
public ICPPParameter[] getParameters() throws DOMException {
throw new DOMException(this);
}
public IScope getFunctionScope() throws DOMException {
throw new DOMException(this);
}
@Override
public ICPPFunctionType getType() throws DOMException {
throw new DOMException(this);
}
public int getRequiredArgumentCount() throws DOMException {
throw new DOMException( this );
}
}
protected ICPPFunctionType type = null;
@ -145,7 +118,7 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition
return CPPBuiltinParameter.createParameterList(getType());
}
public int getRequiredArgumentCount() throws DOMException {
public int getRequiredArgumentCount() {
return CPPFunction.getRequiredArgumentCount(getParameters());
}
@ -165,9 +138,15 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition
while (parent.getParent() instanceof IASTDeclarator)
parent = parent.getParent();
IType temp = getNestedType(CPPVisitor.createType((IASTDeclarator)parent), TDEF);
if (temp instanceof ICPPFunctionType)
type = (ICPPFunctionType) temp;
IType t = getNestedType(CPPVisitor.createType((IASTDeclarator)parent), TDEF);
if (t instanceof ICPPFunctionType) {
type = (ICPPFunctionType) t;
} else if (t instanceof ISemanticProblem){
type= new ProblemFunctionType(((ISemanticProblem) t).getID());
} else {
// This case is unexpected
type= new ProblemFunctionType(ISemanticProblem.TYPE_UNRESOLVED_NAME);
}
}
return type;
}

View file

@ -18,7 +18,6 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
@ -28,7 +27,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
@ -39,27 +37,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
* The binding for a method.
*/
public class CPPMethod extends CPPFunction implements ICPPMethod {
public static class CPPMethodProblem extends CPPFunctionProblem implements ICPPMethod {
private ICPPClassType fOwner;
public CPPMethodProblem(ICPPClassType owner, IASTNode node, int id, char[] arg) {
super(node, id, arg);
fOwner= owner;
}
public ICPPClassType getClassOwner() {
return fOwner;
}
public boolean isDestructor() {
char[] name = getNameCharArray();
if (name.length > 1 && name[0] == '~')
return true;
return false;
}
public int getVisibility() {
return ICPPMember.v_private;
}
}
public CPPMethod(IASTDeclarator declarator) {
super(declarator);
}

View file

@ -11,7 +11,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IValue;
@ -37,7 +36,7 @@ public class CPPParameterSpecialization extends CPPSpecialization implements ICP
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IVariable#getType()
*/
public IType getType() throws DOMException {
public IType getType() {
return fType;
}

View file

@ -59,7 +59,7 @@ public class CPPUnknownFunction extends CPPUnknownBinding implements ICPPFunctio
return false;
}
public IScope getFunctionScope() throws DOMException {
public IScope getFunctionScope() {
return asScope();
}

View file

@ -41,19 +41,12 @@ import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.IInternalVariable;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.cdt.internal.core.dom.parser.Value;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
import org.eclipse.core.runtime.PlatformObject;
public class CPPVariable extends PlatformObject implements ICPPVariable, ICPPInternalBinding, IInternalVariable {
public static class CPPVariableProblem extends ProblemBinding implements ICPPVariable {
public CPPVariableProblem(IASTNode node, int id, char[] arg) {
super(node, id, arg);
}
}
private IASTName fDefinition = null;
private IASTName fDeclarations[] = null;
private IType fType = null;

View file

@ -127,9 +127,8 @@ public class ClassTypeHelper {
* @param binding a binding.
* @param classType a class.
* @return <code>true</code> if <code>binding</code> is a friend of <code>classType</code>.
* @throws DOMException
*/
public static boolean isFriend(IBinding binding, ICPPClassType classType) throws DOMException {
public static boolean isFriend(IBinding binding, ICPPClassType classType) {
IType type;
if (binding instanceof ICPPClassType) {
type = (IType) binding;
@ -158,7 +157,6 @@ public class ClassTypeHelper {
/**
* A host maybe backed up with a definition from the index.
* @throws DOMException
*/
private static ICPPClassType getBackupDefinition(ICPPInternalClassTypeMixinHost host) {
ICPPClassScope scope = host.getCompositeScope();
@ -437,7 +435,7 @@ public class ClassTypeHelper {
* Returns whether {@code method} is virtual. This is the case if it is declared to be virtual or
* overrides another virtual method.
*/
public static boolean isVirtual(ICPPMethod m) throws DOMException {
public static boolean isVirtual(ICPPMethod m) {
if (m instanceof ICPPConstructor)
return false;
if (m.isVirtual())
@ -489,9 +487,8 @@ public class ClassTypeHelper {
/**
* Returns {@code true} if {@code source} overrides {@code target}.
* @throws DOMException
*/
public static boolean isOverrider(ICPPMethod source, ICPPMethod target) throws DOMException {
public static boolean isOverrider(ICPPMethod source, ICPPMethod target) {
if (source instanceof ICPPConstructor || target instanceof ICPPConstructor)
return false;
if (!isVirtual(target))
@ -515,9 +512,8 @@ public class ClassTypeHelper {
/**
* Returns all methods that are overridden by the given {@code method}.
* @throws DOMException
*/
public static ICPPMethod[] findOverridden(ICPPMethod method) throws DOMException {
public static ICPPMethod[] findOverridden(ICPPMethod method) {
if (method instanceof ICPPConstructor)
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
@ -551,7 +547,7 @@ public class ClassTypeHelper {
* Returns whether {@code cl} contains an overridden method.
*/
private static boolean findOverridden(ICPPClassType cl, char[] mname, ICPPFunctionType mft,
HashMap<ICPPClassType, Boolean> virtualInClass, ArrayList<ICPPMethod> result) throws DOMException {
HashMap<ICPPClassType, Boolean> virtualInClass, ArrayList<ICPPMethod> result) {
Boolean visitedBefore= virtualInClass.get(cl);
if (visitedBefore != null)
return visitedBefore;
@ -589,10 +585,9 @@ public class ClassTypeHelper {
/**
* Returns all methods found in the index, that override the given {@code method}.
* @throws DOMException
* @throws CoreException
*/
public static ICPPMethod[] findOverriders(IIndex index, ICPPMethod method) throws DOMException, CoreException {
public static ICPPMethod[] findOverriders(IIndex index, ICPPMethod method) throws CoreException {
if (!isVirtual(method))
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
@ -606,10 +601,8 @@ public class ClassTypeHelper {
/**
* Returns all methods belonging to the given set of classes that override the given {@code method}.
* @throws DOMException
*/
public static ICPPMethod[] findOverriders(ICPPClassType[] subclasses, ICPPMethod method)
throws DOMException {
public static ICPPMethod[] findOverriders(ICPPClassType[] subclasses, ICPPMethod method) {
final char[] mname= method.getNameCharArray();
final ICPPFunctionType mft= method.getType();
final ArrayList<ICPPMethod> result= new ArrayList<ICPPMethod>();
@ -700,37 +693,34 @@ public class ClassTypeHelper {
}
private static int getImplicitMethodKind(ICPPClassType ct, ICPPMethod method) {
try {
if (method instanceof ICPPConstructor) {
final IFunctionType type= method.getType();
final IType[] params= type.getParameterTypes();
if (params.length == 0)
if (method instanceof ICPPConstructor) {
final IFunctionType type= method.getType();
final IType[] params= type.getParameterTypes();
if (params.length == 0)
return KIND_DEFAULT_CTOR;
if (params.length == 1) {
IType t= SemanticUtil.getNestedType(params[0], SemanticUtil.TDEF);
if (SemanticUtil.isVoidType(t))
return KIND_DEFAULT_CTOR;
if (params.length == 1) {
IType t= SemanticUtil.getNestedType(params[0], SemanticUtil.TDEF);
if (SemanticUtil.isVoidType(t))
return KIND_DEFAULT_CTOR;
if (isRefToConstClass(ct, t))
return KIND_COPY_CTOR;
}
return KIND_OTHER;
if (isRefToConstClass(ct, t))
return KIND_COPY_CTOR;
}
return KIND_OTHER;
}
if (method.isDestructor())
return KIND_DTOR;
if (method.isDestructor())
return KIND_DTOR;
if (CharArrayUtils.equals(method.getNameCharArray(), OverloadableOperator.ASSIGN.toCharArray())) {
final IFunctionType type= method.getType();
final IType[] params= type.getParameterTypes();
if (params.length == 1) {
IType t= params[0];
if (isRefToConstClass(ct, t))
return KIND_ASSIGNMENT_OP;
}
return KIND_OTHER;
if (CharArrayUtils.equals(method.getNameCharArray(), OverloadableOperator.ASSIGN.toCharArray())) {
final IFunctionType type= method.getType();
final IType[] params= type.getParameterTypes();
if (params.length == 1) {
IType t= params[0];
if (isRefToConstClass(ct, t))
return KIND_ASSIGNMENT_OP;
}
} catch (DOMException e) {
return KIND_OTHER;
}
return KIND_OTHER;
}

View file

@ -71,27 +71,22 @@ public class AccessContext {
* @return <code>true</code> if the binding is accessible.
*/
public boolean isAccessible(IBinding binding) {
try {
IBinding owner;
while ((owner = binding.getOwner()) instanceof ICompositeType &&
((ICompositeType) owner).isAnonymous()) {
binding = owner;
}
if (!(owner instanceof ICPPClassType)) {
return true; // The binding is not a class member.
}
ICPPClassType accessOwner= (ICPPClassType) owner;
if (!initialize(accessOwner)) {
return true; // Assume visibility if anything goes wrong.
}
if (namingClass == null) {
return true;
}
return isAccessible(binding, (ICPPClassType) owner, namingClass, v_public, 0);
} catch (DOMException e) {
CCorePlugin.log(e);
IBinding owner;
while ((owner = binding.getOwner()) instanceof ICompositeType &&
((ICompositeType) owner).isAnonymous()) {
binding = owner;
}
return true;
if (!(owner instanceof ICPPClassType)) {
return true; // The binding is not a class member.
}
ICPPClassType accessOwner= (ICPPClassType) owner;
if (!initialize(accessOwner)) {
return true; // Assume visibility if anything goes wrong.
}
if (namingClass == null) {
return true;
}
return isAccessible(binding, (ICPPClassType) owner, namingClass, v_public, 0);
}
/**
@ -116,7 +111,7 @@ public class AccessContext {
}
private boolean isAccessible(IBinding binding, ICPPClassType owner, ICPPClassType derivedClass,
int accessLevel, int depth) throws DOMException {
int accessLevel, int depth) {
if (depth > CPPSemantics.MAX_INHERITANCE_DEPTH)
return false;
@ -156,7 +151,7 @@ public class AccessContext {
* v_private.
* @return One of: v_public, v_protected, v_private.
*/
private int getMemberAccessLevel(ICPPClassType classType, int inheritedAccessLevel) throws DOMException {
private int getMemberAccessLevel(ICPPClassType classType, int inheritedAccessLevel) {
int accessLevel = inheritedAccessLevel;
for (IBinding contextBinding : context) {
if (ClassTypeHelper.isFriend(contextBinding, classType))

View file

@ -71,11 +71,11 @@ class AutoTypeResolver implements ICPPFunctionTemplate {
return null;
}
public ICPPParameter[] getParameters() throws DOMException {
public ICPPParameter[] getParameters() {
throw new UnsupportedOperationException(UNEXPECTED_CALL);
}
public int getRequiredArgumentCount() throws DOMException {
public int getRequiredArgumentCount() {
return 1;
}
@ -83,7 +83,7 @@ class AutoTypeResolver implements ICPPFunctionTemplate {
return false;
}
public IScope getFunctionScope() throws DOMException {
public IScope getFunctionScope() {
throw new UnsupportedOperationException(UNEXPECTED_CALL);
}

View file

@ -553,10 +553,7 @@ class BuiltinOperators {
if (fGlobalCandidates != null) {
for (Object cand : fGlobalCandidates) {
if (cand instanceof IFunction && !(cand instanceof ICPPMethod)) {
try {
fSignatures.add(ASTTypeUtil.getType(((IFunction)cand).getType(), true));
} catch (DOMException e) {
}
fSignatures.add(ASTTypeUtil.getType(((IFunction)cand).getType(), true));
}
}
}

View file

@ -1106,13 +1106,10 @@ public class CPPSemantics {
}
}
if (b instanceof IVariable) {
try {
IType t= SemanticUtil.getUltimateType(((IVariable) b).getType(), true);
if (t instanceof ICPPUnknownBinding || t instanceof ICPPTemplateDefinition) {
result[0]= true;
return PROCESS_ABORT;
}
} catch (DOMException e) {
IType t= SemanticUtil.getUltimateType(((IVariable) b).getType(), true);
if (t instanceof ICPPUnknownBinding || t instanceof ICPPTemplateDefinition) {
result[0]= true;
return PROCESS_ABORT;
}
}
if (name instanceof ICPPASTTemplateId)
@ -2651,15 +2648,11 @@ public class CPPSemantics {
IFunction unknown= null;
for (IFunction function : fns) {
if (function != null) {
try {
IType t2= function.getType().getReturnType();
if (t.isSameType(t2))
return function;
if (unknown == null && function instanceof ICPPUnknownBinding) {
unknown= function;
}
} catch (DOMException e) {
// ignore, try other candidates
IType t2= function.getType().getReturnType();
if (t.isSameType(t2))
return function;
if (unknown == null && function instanceof ICPPUnknownBinding) {
unknown= function;
}
}
}
@ -2717,10 +2710,7 @@ public class CPPSemantics {
ICPPASTConstructorChainInitializer memInit= (ICPPASTConstructorChainInitializer) parentOfInit;
IBinding var= memInit.getMemberInitializerId().resolveBinding();
if (var instanceof IVariable) {
try {
targetType= ((IVariable) var).getType();
} catch (DOMException e) {
}
targetType= ((IVariable) var).getType();
}
}
}
@ -2783,11 +2773,8 @@ public class CPPSemantics {
dtor= ASTQueries.findInnermostDeclarator(dtor);
IBinding binding = dtor.getName().resolveBinding();
if (binding instanceof IFunction) {
try {
IFunctionType ft = ((IFunction) binding).getType();
targetType= ft.getReturnType();
} catch (DOMException e) {
}
IFunctionType ft = ((IFunction) binding).getType();
targetType= ft.getReturnType();
}
}
}
@ -2815,13 +2802,10 @@ public class CPPSemantics {
// First pass, consider functions
for (ICPPFunction fn : fns) {
try {
if (!(fn instanceof ICPPFunctionTemplate)) {
if (targetType.isSameType(fn.getType()))
return fn;
}
} catch (DOMException e) {
}
if (!(fn instanceof ICPPFunctionTemplate)) {
if (targetType.isSameType(fn.getType()))
return fn;
}
}
// Second pass, consider templates
@ -3328,14 +3312,11 @@ public class CPPSemantics {
for (Object object : items) {
if (object instanceof ICPPFunction) {
ICPPFunction func= (ICPPFunction) object;
try {
ICPPFunctionType ft = func.getType();
IType[] pts= ft.getParameterTypes();
if ((enum1 != null && pts.length > 0 && enum1.isSameType(getUltimateTypeUptoPointers(pts[0]))) ||
(enum2 != null && pts.length > 1 && enum2.isSameType(getUltimateTypeUptoPointers(pts[1])))) {
items[j++]= object;
}
} catch (DOMException e) {
ICPPFunctionType ft = func.getType();
IType[] pts= ft.getParameterTypes();
if ((enum1 != null && pts.length > 0 && enum1.isSameType(getUltimateTypeUptoPointers(pts[0]))) ||
(enum2 != null && pts.length > 1 && enum2.isSameType(getUltimateTypeUptoPointers(pts[1])))) {
items[j++]= object;
}
}
}
@ -3605,12 +3586,9 @@ public class CPPSemantics {
}
declarator= ASTQueries.findTypeRelevantDeclarator(declarator);
try {
if (declarator instanceof ICPPASTFunctionDeclarator) {
IType type = function.getType();
return type.isSameType(CPPVisitor.createType(declarator));
}
} catch (DOMException e) {
if (declarator instanceof ICPPASTFunctionDeclarator) {
IType type = function.getType();
return type.isSameType(CPPVisitor.createType(declarator));
}
return false;
}

View file

@ -1776,12 +1776,9 @@ public class CPPTemplates {
private static IType[] addImplicitObjectType(IType[] types, ICPPMethod f1) {
ICPPClassType ct = f1.getClassOwner();
if (ct != null) {
try {
ICPPFunctionType ft = f1.getType();
final CPPReferenceType t = new CPPReferenceType(addQualifiers(ct, ft.isConst(), ft.isVolatile()), false);
return concat(t, types);
} catch (DOMException e) {
}
ICPPFunctionType ft = f1.getType();
final CPPReferenceType t = new CPPReferenceType(addQualifiers(ct, ft.isConst(), ft.isVolatile()), false);
return concat(t, types);
}
return types;
}

View file

@ -681,10 +681,7 @@ public class CPPVisitor extends ASTQueries {
// Variable declaration
IType t2= null;
if (binding != null && binding instanceof IVariable && !(binding instanceof IIndexBinding)) {
try {
t2 = ((IVariable) binding).getType();
} catch (DOMException e1) {
}
t2 = ((IVariable) binding).getType();
}
if (t1 != null && t2 != null) {
if (t1.isSameType(t2) || isCompatibleArray(t1, t2) != null) {
@ -1578,22 +1575,18 @@ public class CPPVisitor extends ASTQueries {
IType pt = null;
for (int i = 0; i < parameters.length; i++) {
try {
pt = parameters[i].getType();
// remove qualifiers
if (pt instanceof IQualifierType) {
pt= ((IQualifierType) pt).getType();
}
pt = parameters[i].getType();
// remove qualifiers
if (pt instanceof IQualifierType) {
pt= ((IQualifierType) pt).getType();
}
if (pt instanceof IArrayType) {
pt = new CPPPointerType(((IArrayType) pt).getType());
} else if (pt instanceof IFunctionType) {
pt = new CPPPointerType(pt);
}
} catch (DOMException e) {
pt = e.getProblem();
}
if (pt instanceof IArrayType) {
pt = new CPPPointerType(((IArrayType) pt).getType());
} else if (pt instanceof IFunctionType) {
pt = new CPPPointerType(pt);
}
pTypes[i] = pt;
}
@ -1933,15 +1926,11 @@ public class CPPVisitor extends ASTQueries {
if (b instanceof IType) {
return (IType) b;
}
try {
if (b instanceof IVariable) {
return ((IVariable) b).getType();
}
if (b instanceof IFunction) {
return ((IFunction) b).getType();
}
} catch (DOMException e) {
return e.getProblem();
if (b instanceof IVariable) {
return ((IVariable) b).getType();
}
if (b instanceof IFunction) {
return ((IFunction) b).getType();
}
}
}

View file

@ -14,7 +14,6 @@ import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUti
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.REF;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory;
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
@ -44,12 +43,8 @@ public class ExpressionTypes {
public static ValueCategory valueCategoryFromFunctionCall(ICPPFunction function) {
try {
final ICPPFunctionType ft = function.getType();
return valueCategoryFromReturnType(ft.getReturnType());
} catch (DOMException e) {
return ValueCategory.PRVALUE;
}
final ICPPFunctionType ft = function.getType();
return valueCategoryFromReturnType(ft.getReturnType());
}
public static ValueCategory valueCategoryFromReturnType(IType r) {
@ -68,12 +63,8 @@ public class ExpressionTypes {
}
public static IType typeFromFunctionCall(ICPPFunction function) {
try {
final ICPPFunctionType ft = function.getType();
return typeFromReturnType(ft.getReturnType());
} catch (DOMException e) {
return e.getProblem();
}
final ICPPFunctionType ft = function.getType();
return typeFromReturnType(ft.getReturnType());
}
public static IType typeFromReturnType(IType r) {

View file

@ -18,6 +18,7 @@ import org.eclipse.cdt.core.dom.ast.IField;
import org.eclipse.cdt.core.dom.ast.IFunction;
import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.IParameter;
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.IValue;
@ -116,7 +117,7 @@ public class CCompositesFactory extends AbstractCompositeFactory {
}
return at;
}
if (rtype instanceof IBasicType || rtype == null) {
if (rtype instanceof IBasicType || rtype instanceof ISemanticProblem || rtype == null) {
return rtype;
}

View file

@ -10,14 +10,12 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.c;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IFunction;
import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.IParameter;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
import org.eclipse.cdt.internal.core.index.IIndexScope;
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
class CompositeCFunction extends CompositeCBinding implements IFunction {
@ -26,12 +24,11 @@ class CompositeCFunction extends CompositeCBinding implements IFunction {
super(cf, rbinding);
}
public IScope getFunctionScope() throws DOMException {
IScope scope= ((IFunction)rbinding).getFunctionScope();
return cf.getCompositeScope((IIndexScope)scope);
public IScope getFunctionScope() {
return null;
}
public IParameter[] getParameters() throws DOMException {
public IParameter[] getParameters() {
IParameter[] preResult = ((IFunction)rbinding).getParameters();
IParameter[] result = new IParameter[preResult.length];
for(int i=0; i<preResult.length; i++) {
@ -40,7 +37,7 @@ class CompositeCFunction extends CompositeCBinding implements IFunction {
return result;
}
public IFunctionType getType() throws DOMException {
public IFunctionType getType() {
IType rtype = ((IFunction)rbinding).getType();
return (IFunctionType) cf.getCompositeType(rtype);
}

View file

@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.c;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IParameter;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IValue;
@ -23,7 +22,7 @@ class CompositeCParameter extends CompositeCBinding implements IParameter {
super(cf, rbinding);
}
public IType getType() throws DOMException {
public IType getType() {
IType rtype = ((IParameter)rbinding).getType();
return cf.getCompositeType(rtype);
}

View file

@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.c;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IValue;
import org.eclipse.cdt.core.dom.ast.IVariable;
@ -23,7 +22,7 @@ class CompositeCVariable extends CompositeCBinding implements IVariable {
super(cf, rbinding);
}
public IType getType() throws DOMException {
public IType getType() {
IType rtype = ((IVariable)rbinding).getType();
return cf.getCompositeType(rtype);
}

View file

@ -12,7 +12,6 @@
package org.eclipse.cdt.internal.core.index.composite.cpp;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
@ -39,11 +38,11 @@ class CompositeCPPFunction extends CompositeCPPBinding implements ICPPFunction {
return ((ICPPFunction)rbinding).isMutable();
}
public IScope getFunctionScope() throws DOMException {
fail(); return null;
public IScope getFunctionScope() {
return null;
}
public ICPPParameter[] getParameters() throws DOMException {
public ICPPParameter[] getParameters() {
ICPPParameter[] result = ((ICPPFunction)rbinding).getParameters();
for(int i=0; i<result.length; i++) {
result[i] = (ICPPParameter) cf.getCompositeBinding((IIndexFragmentBinding) result[i]);
@ -51,7 +50,7 @@ class CompositeCPPFunction extends CompositeCPPBinding implements ICPPFunction {
return result;
}
public ICPPFunctionType getType() throws DOMException {
public ICPPFunctionType getType() {
IType rtype = ((ICPPFunction)rbinding).getType();
return (ICPPFunctionType) cf.getCompositeType(rtype);
}
@ -80,7 +79,7 @@ class CompositeCPPFunction extends CompositeCPPBinding implements ICPPFunction {
return ((ICPPFunction)rbinding).takesVarArgs();
}
public int getRequiredArgumentCount() throws DOMException {
public int getRequiredArgumentCount() {
return ((ICPPFunction)rbinding).getRequiredArgumentCount();
}
@ -96,11 +95,7 @@ class CompositeCPPFunction extends CompositeCPPBinding implements ICPPFunction {
@Override
public String toString() {
StringBuffer result = new StringBuffer();
try {
result.append(getName()+" "+ASTTypeUtil.getParameterTypeString(getType())); //$NON-NLS-1$
} catch(DOMException de) {
result.append(de);
}
result.append(getName()+" "+ASTTypeUtil.getParameterTypeString(getType())); //$NON-NLS-1$
return result.toString();
}

View file

@ -12,7 +12,6 @@
package org.eclipse.cdt.internal.core.index.composite.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.cpp.ICPPFunction;
@ -43,11 +42,7 @@ public class CompositeCPPFunctionSpecialization extends CompositeCPPFunction imp
@Override
public String toString() {
StringBuffer result = new StringBuffer();
try {
result.append(getName()+" "+ASTTypeUtil.getParameterTypeString(getType())); //$NON-NLS-1$
} catch(DOMException de) {
result.append(de);
}
result.append(getName()+" "+ASTTypeUtil.getParameterTypeString(getType())); //$NON-NLS-1$
return result.toString();
}

View file

@ -11,7 +11,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.cpp;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IValue;
import org.eclipse.cdt.core.dom.ast.IVariable;
@ -32,7 +31,7 @@ class CompositeCPPVariable extends CompositeCPPBinding implements ICPPVariable {
return ((ICPPVariable)rbinding).isExternC();
}
public IType getType() throws DOMException {
public IType getType() {
IType rtype = ((ICPPVariable)rbinding).getType();
return cf.getCompositeType(rtype);
}

View file

@ -52,7 +52,6 @@ import org.eclipse.cdt.internal.core.index.IWritableIndex;
import org.eclipse.cdt.internal.core.index.IndexBasedFileContentProvider;
import org.eclipse.cdt.internal.core.parser.scanner.InternalFileContentProvider;
import org.eclipse.cdt.internal.core.parser.scanner.StreamHasher;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
import org.eclipse.cdt.utils.EFSExtensionManager;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
@ -763,8 +762,6 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
th= e;
} catch (RuntimeException e) {
th= e;
} catch (PDOMNotImplementedError e) {
th= e;
} catch (StackOverflowError e) {
th= e;
} catch (AssertionError e) {

View file

@ -56,7 +56,6 @@ import org.eclipse.cdt.internal.core.index.IWritableIndex;
import org.eclipse.cdt.internal.core.index.IWritableIndex.IncludeInformation;
import org.eclipse.cdt.internal.core.parser.scanner.LocationMap;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMASTAdapter;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerASTVisitor;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
@ -211,8 +210,6 @@ abstract public class PDOMWriter {
contextIncludes, lock);
} catch (RuntimeException e) {
th= e;
} catch (PDOMNotImplementedError e) {
th= e;
} catch (StackOverflowError e) {
th= e;
} catch (AssertionError e) {
@ -281,8 +278,6 @@ abstract public class PDOMWriter {
}
} catch (RuntimeException e) {
th= e;
} catch (PDOMNotImplementedError e) {
th= e;
} catch (StackOverflowError e) {
th= e;
}

View file

@ -237,7 +237,7 @@ public class PDOMASTAdapter {
@Override
public Object clone() {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
@SuppressWarnings("rawtypes")
@ -293,7 +293,7 @@ public class PDOMASTAdapter {
@Override
public Object clone() {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
public IField findField(String name) {
@ -357,7 +357,7 @@ public class PDOMASTAdapter {
@Override
public Object clone() {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
public String getName() {

View file

@ -255,10 +255,7 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IPDOMBinding
return ASTTypeUtil.getType((IType) this);
} else if (this instanceof IFunction) {
IFunctionType t= null;
try {
t = ((IFunction) this).getType();
} catch (DOMException e) {
}
t = ((IFunction) this).getType();
if (t != null) {
return getName() + ASTTypeUtil.getParameterTypeString(t);
} else {
@ -296,13 +293,6 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IPDOMBinding
return Integer.toString(value);
}
/**
* Convenience method to shorten subclass file length
*/
protected final void fail() {
throw new PDOMNotImplementedError("in " + getClass().getCanonicalName()); //$NON-NLS-1$
}
public PDOMName getScopeName() {
try {
PDOMName name = getFirstDefinition();

View file

@ -1,28 +0,0 @@
/*******************************************************************************
* Copyright (c) 2005, 2006 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* QNX - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom;
/**
* @author Doug Schaefer
*
*/
public class PDOMNotImplementedError extends Error {
public static final long serialVersionUID = 0;
public PDOMNotImplementedError() {
super();
}
public PDOMNotImplementedError(String message) {
super(message);
}
}

View file

@ -28,7 +28,6 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMASTAdapter;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
import org.eclipse.core.runtime.CoreException;
/**
@ -162,7 +161,6 @@ class PDOMCEnumeration extends PDOMBinding implements IEnumeration, IIndexType {
@Override
public Object clone() {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
}

View file

@ -15,14 +15,14 @@
package org.eclipse.cdt.internal.core.pdom.dom.c;
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.IFunction;
import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.IParameter;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.dom.parser.ProblemFunctionType;
import org.eclipse.cdt.internal.core.index.IIndexCBindingConstants;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
@ -75,13 +75,9 @@ class PDOMCFunction extends PDOMBinding implements IFunction {
IFunctionType type;
IParameter[] parameters;
byte annotations;
try {
type = function.getType();
parameters = function.getParameters();
annotations = PDOMCAnnotation.encodeAnnotation(function);
} catch(DOMException e) {
throw new CoreException(Util.createStatus(e));
}
type = function.getType();
parameters = function.getParameters();
annotations = PDOMCAnnotation.encodeAnnotation(function);
setType(getLinkage(), type);
setParameters(parameters);
getDB().putByte(record + ANNOTATIONS, annotations);
@ -94,13 +90,9 @@ class PDOMCFunction extends PDOMBinding implements IFunction {
IFunctionType newType;
IParameter[] newParams;
byte newAnnotation;
try {
newType= func.getType();
newParams = func.getParameters();
newAnnotation = PDOMCAnnotation.encodeAnnotation(func);
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}
newType= func.getType();
newParams = func.getParameters();
newAnnotation = PDOMCAnnotation.encodeAnnotation(func);
setType(linkage, newType);
PDOMCParameter oldParams= getFirstParameter(null);
@ -148,7 +140,7 @@ class PDOMCFunction extends PDOMBinding implements IFunction {
return (IFunctionType) getLinkage().loadType(record + FUNCTION_TYPE);
} catch(CoreException ce) {
CCorePlugin.log(ce);
return null;
return new ProblemFunctionType(ISemanticProblem.TYPE_NOT_PERSISTED);
}
}
@ -160,7 +152,7 @@ class PDOMCFunction extends PDOMBinding implements IFunction {
return getBit(getByte(record + ANNOTATIONS), PDOMCAnnotation.EXTERN_OFFSET);
}
public IParameter[] getParameters() throws DOMException {
public IParameter[] getParameters() {
try {
PDOMLinkage linkage= getLinkage();
Database db= getDB();
@ -202,7 +194,7 @@ class PDOMCFunction extends PDOMBinding implements IFunction {
return getBit(getByte(record + ANNOTATIONS), PDOMCAnnotation.VARARGS_OFFSET);
}
public IScope getFunctionScope() throws DOMException {
public IScope getFunctionScope() {
return null;
}
}

View file

@ -13,7 +13,6 @@
package org.eclipse.cdt.internal.core.pdom.dom.c;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IParameter;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IValue;
@ -26,7 +25,6 @@ import org.eclipse.cdt.internal.core.pdom.dom.IPDOMBinding;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNamedNode;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
import org.eclipse.core.runtime.CoreException;
/**
@ -89,7 +87,7 @@ final class PDOMCParameter extends PDOMNamedNode implements IParameter, IPDOMBin
}
public IIndexScope getScope() {
throw new PDOMNotImplementedError();
return null;
}
@SuppressWarnings("rawtypes")
@ -121,22 +119,10 @@ final class PDOMCParameter extends PDOMNamedNode implements IParameter, IPDOMBin
return true;
}
public int compareTo(Object arg0) {
throw new PDOMNotImplementedError();
}
public String[] getQualifiedName() {
throw new PDOMNotImplementedError();
return new String[] {getName()};
}
public char[][] getQualifiedNameCharArray() throws DOMException {
throw new PDOMNotImplementedError();
}
public boolean isGloballyQualified() throws DOMException {
throw new PDOMNotImplementedError();
}
public int getBindingConstant() {
return getNodeType();
}

View file

@ -138,7 +138,12 @@ class PDOMCTypedef extends PDOMBinding implements ITypedef, ITypeContainer, IInd
return getName() + ": " + super.toStringBase(); //$NON-NLS-1$
}
public void setType(IType type) {fail();}
public void setType(IType type) {
throw new UnsupportedOperationException();
}
@Override
public Object clone() {fail(); return null;}
public Object clone() {
throw new UnsupportedOperationException();
}
}

View file

@ -13,13 +13,11 @@
package org.eclipse.cdt.internal.core.pdom.dom.c;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IValue;
import org.eclipse.cdt.core.dom.ast.IVariable;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.dom.parser.c.CVariableReadWriteFlags;
import org.eclipse.cdt.internal.core.index.IIndexCBindingConstants;
import org.eclipse.cdt.internal.core.pdom.db.Database;
@ -62,15 +60,11 @@ class PDOMCVariable extends PDOMBinding implements IVariable {
public PDOMCVariable(PDOMLinkage linkage, PDOMNode parent, IVariable variable) throws CoreException {
super(linkage, parent, variable.getNameCharArray());
try {
final Database db = getDB();
setType(parent.getLinkage(), variable.getType());
db.putByte(record + ANNOTATIONS, PDOMCAnnotation.encodeAnnotation(variable));
setValue(db, variable);
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}
final Database db = getDB();
setType(parent.getLinkage(), variable.getType());
db.putByte(record + ANNOTATIONS, PDOMCAnnotation.encodeAnnotation(variable));
setValue(db, variable);
}
private void setValue(final Database db, IVariable variable) throws CoreException {
@ -85,16 +79,12 @@ class PDOMCVariable extends PDOMBinding implements IVariable {
final Database db = getDB();
IVariable var= (IVariable) newBinding;
long valueRec= db.getRecPtr(record + VALUE_OFFSET);
try {
IType newType= var.getType();
setType(linkage, newType);
db.putByte(record + ANNOTATIONS, PDOMCAnnotation.encodeAnnotation(var));
setValue(db, var);
PDOMValue.delete(db, valueRec);
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}
IType newType= var.getType();
setType(linkage, newType);
db.putByte(record + ANNOTATIONS, PDOMCAnnotation.encodeAnnotation(var));
setValue(db, var);
PDOMValue.delete(db, valueRec);
}
}

View file

@ -20,7 +20,6 @@ import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
import org.eclipse.core.runtime.CoreException;
/**
@ -133,7 +132,7 @@ class PDOMCPPBase implements ICPPBase, ICPPInternalBase {
}
public void setBaseClass(IBinding binding) {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
@Override

View file

@ -33,7 +33,6 @@ import org.eclipse.cdt.internal.core.pdom.dom.IPDOMOverloader;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
import org.eclipse.core.runtime.CoreException;
/**
@ -150,7 +149,7 @@ class PDOMCPPClassTemplatePartialSpecialization extends PDOMCPPClassTemplate
CCorePlugin.log(ce);
}
} else {
throw new PDOMNotImplementedError();
assert false;
}
}
return cmp;

View file

@ -174,7 +174,9 @@ class PDOMCPPDeferredClassInstance extends PDOMCPPSpecialization implements ICPP
}
@Override
public Object clone() {fail();return null;}
public Object clone() {
throw new UnsupportedOperationException();
}
public ICPPScope asScope() {
if (unknownScope == null) {

View file

@ -12,14 +12,14 @@
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.ICompositeType;
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IValue;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
@ -43,14 +43,10 @@ class PDOMCPPFieldSpecialization extends PDOMCPPSpecialization implements ICPPFi
throws CoreException {
super(linkage, parent, (ICPPSpecialization) field, specialized);
try {
final Database db = getDB();
linkage.storeType(record + TYPE_OFFSET, field.getType());
long rec= PDOMValue.store(db, linkage, field.getInitialValue());
db.putRecPtr(record + VALUE_OFFSET, rec);
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}
final Database db = getDB();
linkage.storeType(record + TYPE_OFFSET, field.getType());
long rec= PDOMValue.store(db, linkage, field.getInitialValue());
db.putRecPtr(record + VALUE_OFFSET, rec);
}
public PDOMCPPFieldSpecialization(PDOMLinkage linkage, long bindingRecord) {
@ -75,13 +71,13 @@ class PDOMCPPFieldSpecialization extends PDOMCPPSpecialization implements ICPPFi
return getClassOwner();
}
public IType getType() throws DOMException {
public IType getType() {
try {
return getLinkage().loadType(record + TYPE_OFFSET);
} catch (CoreException e) {
CCorePlugin.log(e);
return new ProblemType(ISemanticProblem.TYPE_NOT_PERSISTED);
}
return null;
}
public IValue getInitialValue() {

View file

@ -16,12 +16,13 @@ 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.IScope;
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
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.dom.parser.ProblemFunctionType;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.index.IndexCPPSignatureUtil;
import org.eclipse.cdt.internal.core.pdom.db.Database;
@ -29,7 +30,6 @@ import org.eclipse.cdt.internal.core.pdom.dom.IPDOMOverloader;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
import org.eclipse.cdt.internal.core.pdom.dom.c.PDOMCAnnotation;
import org.eclipse.core.runtime.CoreException;
@ -128,14 +128,10 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
ICPPParameter[] newParams;
short newAnnotation;
int newBindingRequiredArgCount;
try {
newType= func.getType();
newParams = func.getParameters();
newAnnotation = getAnnotation(func);
newBindingRequiredArgCount= func.getRequiredArgumentCount();
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}
newType= func.getType();
newParams = func.getParameters();
newAnnotation = getAnnotation(func);
newBindingRequiredArgCount= func.getRequiredArgumentCount();
fType= null;
linkage.storeType(record+FUNCTION_TYPE, newType);
@ -244,7 +240,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
}
public int getRequiredArgumentCount() throws DOMException {
public int getRequiredArgumentCount() {
if (fRequiredArgCount == -1) {
try {
fRequiredArgCount= getDB().getInt(record + REQUIRED_ARG_COUNT);
@ -271,14 +267,14 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
}
public boolean isMutable() {
throw new PDOMNotImplementedError();
return false;
}
public IScope getFunctionScope() throws DOMException {
throw new PDOMNotImplementedError();
public IScope getFunctionScope() {
return null;
}
public ICPPParameter[] getParameters() throws DOMException {
public ICPPParameter[] getParameters() {
try {
PDOMLinkage linkage= getLinkage();
Database db= getDB();
@ -308,6 +304,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
fType= (ICPPFunctionType) getLinkage().loadType(record+FUNCTION_TYPE);
} catch (CoreException e) {
CCorePlugin.log(e);
fType= new ProblemFunctionType(ISemanticProblem.TYPE_NOT_PERSISTED);
}
}
return fType;
@ -345,7 +342,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
@Override
public Object clone() {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
@Override
@ -365,7 +362,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
CCorePlugin.log(ce);
}
} else {
throw new PDOMNotImplementedError(b.getClass().toString());
assert false;
}
return 0;
}

View file

@ -12,22 +12,21 @@
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.IFunctionType;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
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.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.dom.parser.ProblemFunctionType;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
import org.eclipse.cdt.internal.core.pdom.dom.c.PDOMCAnnotation;
import org.eclipse.core.runtime.CoreException;
@ -84,44 +83,40 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
super(linkage, parent, (ICPPSpecialization) astFunction, specialized);
Database db = getDB();
try {
ICPPParameter[] astParams= astFunction.getParameters();
IFunctionType astFt= astFunction.getType();
if (astFt != null) {
getLinkage().storeType(record + FUNCTION_TYPE, astFt);
}
ICPPFunction origAstFunc= (ICPPFunction) ((ICPPSpecialization)astFunction).getSpecializedBinding();
ICPPParameter[] origAstParams= origAstFunc.getParameters();
if (origAstParams.length == 0) {
db.putInt(record + NUM_PARAMS, 0);
db.putRecPtr(record + FIRST_PARAM, 0);
} else {
final int length= astParams.length;
db.putInt(record + NUM_PARAMS, length);
db.putRecPtr(record + FIRST_PARAM, 0);
PDOMCPPParameter origPar= null;
PDOMCPPParameterSpecialization next= null;
for (int i= length-1; i >= 0; --i) {
// There may be fewer or less original parameters, because of parameter packs.
if (i < origAstParams.length-1) {
// Normal case
origPar= new PDOMCPPParameter(linkage, specialized, origAstParams[i], null);
} else if (origPar == null) {
// Use last parameter
origPar= new PDOMCPPParameter(linkage, specialized, origAstParams[origAstParams.length-1], null);
}
next= new PDOMCPPParameterSpecialization(linkage, this, astParams[i], origPar, next);
}
db.putRecPtr(record + FIRST_PARAM, next == null ? 0 : next.getRecord());
}
fAnnotation = getAnnotation(astFunction);
db.putShort(record + ANNOTATION_OFFSET, fAnnotation);
db.putInt(record + REQUIRED_ARG_COUNT_OFFSET, astFunction.getRequiredArgumentCount());
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
ICPPParameter[] astParams= astFunction.getParameters();
IFunctionType astFt= astFunction.getType();
if (astFt != null) {
getLinkage().storeType(record + FUNCTION_TYPE, astFt);
}
ICPPFunction origAstFunc= (ICPPFunction) ((ICPPSpecialization)astFunction).getSpecializedBinding();
ICPPParameter[] origAstParams= origAstFunc.getParameters();
if (origAstParams.length == 0) {
db.putInt(record + NUM_PARAMS, 0);
db.putRecPtr(record + FIRST_PARAM, 0);
} else {
final int length= astParams.length;
db.putInt(record + NUM_PARAMS, length);
db.putRecPtr(record + FIRST_PARAM, 0);
PDOMCPPParameter origPar= null;
PDOMCPPParameterSpecialization next= null;
for (int i= length-1; i >= 0; --i) {
// There may be fewer or less original parameters, because of parameter packs.
if (i < origAstParams.length-1) {
// Normal case
origPar= new PDOMCPPParameter(linkage, specialized, origAstParams[i], null);
} else if (origPar == null) {
// Use last parameter
origPar= new PDOMCPPParameter(linkage, specialized, origAstParams[origAstParams.length-1], null);
}
next= new PDOMCPPParameterSpecialization(linkage, this, astParams[i], origPar, next);
}
db.putRecPtr(record + FIRST_PARAM, next == null ? 0 : next.getRecord());
}
fAnnotation = getAnnotation(astFunction);
db.putShort(record + ANNOTATION_OFFSET, fAnnotation);
db.putInt(record + REQUIRED_ARG_COUNT_OFFSET, astFunction.getRequiredArgumentCount());
long typelist= 0;
if (astFunction instanceof ICPPMethod && ((ICPPMethod) astFunction).isImplicit()) {
// don't store the exception specification, computed it on demand.
@ -176,11 +171,11 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
return false;
}
public IScope getFunctionScope() throws DOMException {
throw new PDOMNotImplementedError();
public IScope getFunctionScope() {
return null;
}
public ICPPParameter[] getParameters() throws DOMException {
public ICPPParameter[] getParameters() {
try {
PDOMLinkage linkage= getLinkage();
Database db= getDB();
@ -204,12 +199,13 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
}
}
public ICPPFunctionType getType() throws DOMException {
public ICPPFunctionType getType() {
if (fType == null) {
try {
fType= (ICPPFunctionType) getLinkage().loadType(record + FUNCTION_TYPE);
} catch(CoreException ce) {
CCorePlugin.log(ce);
fType= new ProblemFunctionType(ISemanticProblem.TYPE_NOT_PERSISTED);
}
}
return fType;
@ -242,7 +238,7 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
}
public int getRequiredArgumentCount() throws DOMException {
public int getRequiredArgumentCount() {
if (fRequiredArgCount == -1) {
try {
fRequiredArgCount= getDB().getInt(record + REQUIRED_ARG_COUNT_OFFSET);

View file

@ -35,7 +35,6 @@ import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
import org.eclipse.cdt.internal.core.pdom.dom.c.PDOMCAnnotation;
import org.eclipse.core.runtime.CoreException;
@ -126,7 +125,7 @@ class PDOMCPPMethod extends PDOMCPPFunction implements ICPPMethod {
@Override
public boolean isMutable() {
throw new PDOMNotImplementedError();
return false;
}
public boolean isImplicit() {
@ -138,8 +137,8 @@ class PDOMCPPMethod extends PDOMCPPFunction implements ICPPMethod {
}
@Override
public IScope getFunctionScope() throws DOMException {
throw new PDOMNotImplementedError();
public IScope getFunctionScope() {
return null;
}
@Override
@ -175,7 +174,7 @@ class PDOMCPPMethod extends PDOMCPPFunction implements ICPPMethod {
@Override
public Object clone() {
throw new PDOMNotImplementedError();
throw new UnsupportedOperationException();
}
public boolean isConst() {
@ -208,12 +207,8 @@ class PDOMCPPMethod extends PDOMCPPFunction implements ICPPMethod {
if (fieldOwner instanceof IASTIdExpression) {
IBinding b= ((IASTIdExpression) fieldOwner).getName().resolveBinding();
if (b instanceof IVariable) {
try {
IType t = ((IVariable) b).getType();
if (!(t instanceof ICPPReferenceType)) {
return 0;
}
} catch (DOMException e) {
IType t = ((IVariable) b).getType();
if (!(t instanceof ICPPReferenceType)) {
return 0;
}
}

View file

@ -235,7 +235,9 @@ class PDOMCPPNamespace extends PDOMCPPBinding
return result;
}
public void addUsingDirective(ICPPUsingDirective directive) { fail(); }
public void addUsingDirective(ICPPUsingDirective directive) {
throw new UnsupportedOperationException();
}
public IIndexBinding getScopeBinding() {
return this;

View file

@ -14,6 +14,7 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
@ -21,7 +22,6 @@ import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
import org.eclipse.core.runtime.CoreException;
/**
@ -88,7 +88,20 @@ class PDOMCPPNamespaceAlias extends PDOMCPPBinding implements ICPPNamespaceAlias
}
public IBinding[] getMemberBindings() {
throw new PDOMNotImplementedError();
ICPPNamespace ns= this;
for (int i = 0; i < 20; i++) {
if (ns instanceof ICPPNamespaceAlias) {
IBinding b= ((ICPPNamespaceAlias) ns).getBinding();
if (b instanceof ICPPNamespace) {
ns= (ICPPNamespace) b;
} else {
return IBinding.EMPTY_BINDING_ARRAY;
}
} else {
break;
}
}
return ns.getMemberBindings();
}
public IBinding getBinding() {

View file

@ -28,7 +28,6 @@ import org.eclipse.cdt.internal.core.pdom.dom.IPDOMBinding;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNamedNode;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
import org.eclipse.cdt.internal.core.pdom.dom.c.PDOMCAnnotation;
import org.eclipse.core.runtime.CoreException;
@ -198,10 +197,6 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBind
// parameter bindings do not span index fragments
return true;
}
public int compareTo(Object arg0) {
throw new PDOMNotImplementedError();
}
public int getBindingConstant() {
return getNodeType();

View file

@ -11,7 +11,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IParameter;
import org.eclipse.cdt.core.dom.ast.IType;
@ -77,28 +76,25 @@ class PDOMCPPParameterSpecialization extends PDOMCPPSpecialization implements IC
IType type= null;
IBinding parent = getParentBinding();
if (parent instanceof ICPPSpecialization && parent instanceof ICPPFunction) {
try {
IParameter[] pars= ((ICPPFunction) parent).getParameters();
int parPos= -1;
for (parPos= 0; parPos<pars.length; parPos++) {
IParameter par= pars[parPos];
if (equals(par)) {
break;
}
IParameter[] pars= ((ICPPFunction) parent).getParameters();
int parPos= -1;
for (parPos= 0; parPos<pars.length; parPos++) {
IParameter par= pars[parPos];
if (equals(par)) {
break;
}
if (parPos < pars.length) {
parent= ((ICPPSpecialization) parent).getSpecializedBinding();
if (parent instanceof ICPPFunction) {
ICPPFunctionType ftype = ((ICPPFunction) parent).getType();
if (ftype != null) {
IType[] ptypes= ftype.getParameterTypes();
if (parPos < ptypes.length) {
type= ptypes[parPos];
}
}
if (parPos < pars.length) {
parent= ((ICPPSpecialization) parent).getSpecializedBinding();
if (parent instanceof ICPPFunction) {
ICPPFunctionType ftype = ((ICPPFunction) parent).getType();
if (ftype != null) {
IType[] ptypes= ftype.getParameterTypes();
if (parPos < ptypes.length) {
type= ptypes[parPos];
}
}
}
} catch (DOMException e) {
}
}
return new PDOMCPPParameter(getLinkage(), record, type);

View file

@ -207,8 +207,7 @@ class PDOMCPPTemplateNonTypeParameter extends PDOMCPPBinding implements IPDOMMem
@Override
public Object clone() {
fail();
return null;
throw new UnsupportedOperationException();
}
/**
* @deprecated

View file

@ -166,7 +166,9 @@ public class PDOMCPPTemplateTemplateParameter extends PDOMCPPBinding
}
@Override
public Object clone() { fail(); return null; }
public Object clone() {
throw new UnsupportedOperationException();
}
public ICPPScope asScope() {

View file

@ -152,8 +152,9 @@ class PDOMCPPTemplateTypeParameter extends PDOMCPPBinding implements IPDOMMember
}
@Override
public Object clone() { fail(); return null; }
public Object clone() {
throw new UnsupportedOperationException();
}
public ICPPScope asScope() {
if (fUnknownScope == null) {

View file

@ -134,7 +134,9 @@ class PDOMCPPTypedef extends PDOMCPPBinding implements ITypedef, ITypeContainer,
return getName() + ": " + super.toStringBase(); //$NON-NLS-1$
}
public void setType(IType type) { fail(); }
public void setType(IType type) {
throw new UnsupportedOperationException();
}
@Override
public Object clone() {

View file

@ -98,7 +98,9 @@ class PDOMCPPTypedefSpecialization extends PDOMCPPSpecialization implements ITyp
return false;
}
public void setType(IType type) { fail(); }
public void setType(IType type) {
throw new UnsupportedOperationException();
}
/* (non-Javadoc)
* @see java.lang.Object#clone()

View file

@ -147,8 +147,13 @@ class PDOMCPPUnknownClassType extends PDOMCPPUnknownBinding implements ICPPClass
// Not implemented
@Override
public Object clone() { fail(); return null; }
public IField findField(String name) { fail(); return null; }
public Object clone() {
throw new UnsupportedOperationException();
}
public IField findField(String name) {
return null;
}
@Override
public boolean mayHaveChildren() {

View file

@ -13,14 +13,12 @@
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.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IValue;
import org.eclipse.cdt.core.dom.ast.IVariable;
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.semantics.CPPVariableReadWriteFlags;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.pdom.db.Database;
@ -45,15 +43,11 @@ class PDOMCPPVariable extends PDOMCPPBinding implements ICPPVariable {
public PDOMCPPVariable(PDOMLinkage linkage, PDOMNode parent, IVariable variable) throws CoreException {
super(linkage, parent, variable.getNameCharArray());
try {
// Find the type record
Database db = getDB();
setType(parent.getLinkage(), variable.getType());
db.putByte(record + ANNOTATIONS, encodeFlags(variable));
setValue(db, variable);
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}
// Find the type record
Database db = getDB();
setType(parent.getLinkage(), variable.getType());
db.putByte(record + ANNOTATIONS, encodeFlags(variable));
setValue(db, variable);
}
private void setValue(Database db, IVariable variable) throws CoreException {
@ -68,16 +62,11 @@ class PDOMCPPVariable extends PDOMCPPBinding implements ICPPVariable {
final Database db = getDB();
IVariable var= (IVariable) newBinding;
long valueRec= db.getRecPtr(record + VALUE_OFFSET);
try {
IType newType= var.getType();
setType(linkage, newType);
db.putByte(record + ANNOTATIONS, encodeFlags(var));
setValue(db, var);
PDOMValue.delete(db, valueRec);
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}
IType newType= var.getType();
setType(linkage, newType);
db.putByte(record + ANNOTATIONS, encodeFlags(var));
setValue(db, var);
PDOMValue.delete(db, valueRec);
}
}

View file

@ -19,7 +19,6 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.cdt.core.CCorePlugin;
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.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
@ -79,13 +78,9 @@ public class CHQueries {
if (calleeBinding != null) {
findCalledBy1(index, calleeBinding, true, project, result);
if (calleeBinding instanceof ICPPMethod) {
try {
IBinding[] overriddenBindings= ClassTypeHelper.findOverridden((ICPPMethod) calleeBinding);
for (IBinding overriddenBinding : overriddenBindings) {
findCalledBy1(index, overriddenBinding, false, project, result);
}
} catch (DOMException e) {
// index bindings don't throw DOMExceptions
IBinding[] overriddenBindings= ClassTypeHelper.findOverridden((ICPPMethod) calleeBinding);
for (IBinding overriddenBinding : overriddenBindings) {
findCalledBy1(index, overriddenBinding, false, project, result);
}
}
}
@ -157,18 +152,14 @@ public class CHQueries {
* Searches for overriders of method and converts them to ICElement, returns null, if there are none.
*/
static ICElement[] findOverriders(IIndex index, ICPPMethod binding) throws CoreException {
try {
IBinding[] virtualOverriders= ClassTypeHelper.findOverriders(index, binding);
if (virtualOverriders.length > 0) {
ArrayList<ICElementHandle> list= new ArrayList<ICElementHandle>();
list.addAll(Arrays.asList(IndexUI.findRepresentative(index, binding)));
for (IBinding overrider : virtualOverriders) {
list.addAll(Arrays.asList(IndexUI.findRepresentative(index, overrider)));
}
return list.toArray(new ICElement[list.size()]);
IBinding[] virtualOverriders= ClassTypeHelper.findOverriders(index, binding);
if (virtualOverriders.length > 0) {
ArrayList<ICElementHandle> list= new ArrayList<ICElementHandle>();
list.addAll(Arrays.asList(IndexUI.findRepresentative(index, binding)));
for (IBinding overrider : virtualOverriders) {
list.addAll(Arrays.asList(IndexUI.findRepresentative(index, overrider)));
}
} catch (DOMException e) {
// index bindings don't throw DOMExceptions
return list.toArray(new ICElement[list.size()]);
}
return null;
}

View file

@ -48,7 +48,6 @@ import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.texteditor.TextEditorAction;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNodeSelector;
@ -218,18 +217,14 @@ public class AddIncludeOnSelectionAction extends TextEditorAction {
char[] nameChars = name.toCharArray();
lookupName[0] = new String(nameChars);
IBinding binding = name.resolveBinding();
try {
if (binding instanceof ICPPVariable) {
IType type = ((ICPPVariable) binding).getType();
type = SemanticUtil.getNestedType(type,
SemanticUtil.ALLCVQ | SemanticUtil.PTR | SemanticUtil.ARRAY | SemanticUtil.REF);
if (type instanceof IBinding) {
binding = (IBinding) type;
nameChars = binding.getNameCharArray();
}
if (binding instanceof ICPPVariable) {
IType type = ((ICPPVariable) binding).getType();
type = SemanticUtil.getNestedType(type,
SemanticUtil.ALLCVQ | SemanticUtil.PTR | SemanticUtil.ARRAY | SemanticUtil.REF);
if (type instanceof IBinding) {
binding = (IBinding) type;
nameChars = binding.getNameCharArray();
}
} catch (DOMException e) {
CUIPlugin.log(e);
}
if (nameChars.length == 0) {
return;

View file

@ -835,9 +835,7 @@ public class SemanticHighlightings {
}
} catch (DOMException exc) {
CUIPlugin.log(exc);
} catch (Error e) /* PDOMNotImplementedError */ {
// ignore
}
}
}
}
}
@ -920,9 +918,7 @@ public class SemanticHighlightings {
}
} catch (DOMException exc) {
CUIPlugin.log(exc);
} catch (Error e) /* PDOMNotImplementedError */ {
// ignore
}
}
}
}
}
@ -1023,9 +1019,7 @@ public class SemanticHighlightings {
}
} catch (DOMException exc) {
CUIPlugin.log(exc);
} catch (Error e) /* PDOMNotImplementedError */ {
// ignore
}
}
}
}
return false;

View file

@ -146,11 +146,7 @@ public class IndexLabelProvider extends LabelProvider {
* we don't currently store return types
*/
if(element instanceof IFunction) {
try {
result += " "+ASTTypeUtil.getParameterTypeString(((IFunction) element).getType()); //$NON-NLS-1$
} catch(DOMException de) {
/* NO-OP: just use plain name as label */
}
result += " "+ASTTypeUtil.getParameterTypeString(((IFunction) element).getType()); //$NON-NLS-1$
}
return result;

View file

@ -22,20 +22,16 @@ import java.util.Vector;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.text.edits.TextEditGroup;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
import org.eclipse.cdt.core.dom.ast.IASTComment;
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
@ -78,7 +74,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.rewrite.ASTRewrite;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.internal.core.dom.parser.c.CASTBinaryExpression;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTBinaryExpression;
@ -584,56 +579,48 @@ public class ExtractFunctionRefactoring extends CRefactoring {
String name = new String(declarator.getName().toCharArray());
if (bind instanceof ICPPClassType) {
ICPPClassType classBind = (ICPPClassType) bind;
try {
IField[] fields = classBind.getFields();
for (IField field : fields) {
if (field.getName().equals(name)) {
return true;
}
IField[] fields = classBind.getFields();
for (IField field : fields) {
if (field.getName().equals(name)) {
return true;
}
ICPPMethod[] methods = classBind.getAllDeclaredMethods();
for (ICPPMethod method : methods) {
if (!method.takesVarArgs() && name.equals(method.getName())) {
IParameter[] parameters = method.getParameters();
if (parameters.length == declarator.getParameters().length) {
for (int i = 0; i < parameters.length; i++) {
IASTName[] origParameterName = unit
.getDeclarationsInAST(parameters[i]);
}
ICPPMethod[] methods = classBind.getAllDeclaredMethods();
for (ICPPMethod method : methods) {
if (!method.takesVarArgs() && name.equals(method.getName())) {
IParameter[] parameters = method.getParameters();
if (parameters.length == declarator.getParameters().length) {
for (int i = 0; i < parameters.length; i++) {
IASTName[] origParameterName = unit
.getDeclarationsInAST(parameters[i]);
IASTParameterDeclaration origParameter = (IASTParameterDeclaration) origParameterName[0]
.getParent().getParent();
IASTParameterDeclaration newParameter = declarator
.getParameters()[i];
IASTParameterDeclaration origParameter = (IASTParameterDeclaration) origParameterName[0]
.getParent().getParent();
IASTParameterDeclaration newParameter = declarator
.getParameters()[i];
// if not the same break;
if (!(equalityChecker.isEquals(origParameter
.getDeclSpecifier(), newParameter
.getDeclSpecifier()) && ASTHelper
.samePointers(origParameter
.getDeclarator()
.getPointerOperators(),
newParameter.getDeclarator()
.getPointerOperators(),
equalityChecker))) {
break;
}
// if not the same break;
if (!(equalityChecker.isEquals(origParameter
.getDeclSpecifier(), newParameter
.getDeclSpecifier()) && ASTHelper
.samePointers(origParameter
.getDeclarator()
.getPointerOperators(),
newParameter.getDeclarator()
.getPointerOperators(),
equalityChecker))) {
break;
}
if (!(i < (parameters.length - 1))) {
return true;
}
if (!(i < (parameters.length - 1))) {
return true;
}
}
}
}
return false;
} catch (DOMException e) {
ILog logger = CUIPlugin.getDefault().getLog();
IStatus status = new Status(IStatus.WARNING,
CUIPlugin.PLUGIN_ID, IStatus.OK, e.getMessage(), e);
logger.log(status);
}
}
return false;
}
return true;
}

View file

@ -18,7 +18,6 @@ import java.util.Map;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTASMDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
@ -434,12 +433,9 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
}
private IType getType(IBinding binding) {
try {
if (binding instanceof ICPPVariable) {
ICPPVariable var = (ICPPVariable) binding;
return var.getType();
}
} catch (DOMException e) {
if (binding instanceof ICPPVariable) {
ICPPVariable var = (ICPPVariable) binding;
return var.getType();
}
return null;
}

View file

@ -20,7 +20,6 @@ import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
@ -113,8 +112,6 @@ public class CRenameMethodProcessor extends CRenameGlobalProcessor {
bindings.addAll(Arrays.asList(bs));
bs= ClassTypeHelper.findOverriders(getIndex(), m);
bindings.addAll(Arrays.asList(bs));
} catch (DOMException e) {
getAstManager().handleDOMException(argument.getTranslationUnit(), e, status);
} catch (CoreException e) {
status.addError(e.getMessage());
}

View file

@ -17,7 +17,6 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.IBinding;
@ -26,7 +25,6 @@ import org.eclipse.cdt.core.dom.ast.IVariable;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
import org.eclipse.cdt.core.parser.Keywords;
import org.eclipse.cdt.core.parser.util.CharArrayIntMap;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTQualifiedName;
@ -144,13 +142,9 @@ public class NameHelper {
IASTName name = parameter.getDeclarator().getName();
IBinding binding = name.resolveBinding();
if (binding instanceof IVariable) {
try {
IType type = ((IVariable) binding).getType();
if (type != null) {
return ASTTypeUtil.getType(type);
}
} catch (DOMException e) {
CUIPlugin.log(e);
IType type = ((IVariable) binding).getType();
if (type != null) {
return ASTTypeUtil.getType(type);
}
}
return ""; //$NON-NLS-1$

View file

@ -99,12 +99,8 @@ public class LinkedNamesFinder {
}
} else if (target instanceof ICPPMethod) {
ICPPMethod method= (ICPPMethod) target;
try {
for (ICPPMethod m : ClassTypeHelper.findOverridden(method)) {
findBinding(m);
}
} catch (DOMException e) {
// Ignore.
for (ICPPMethod m : ClassTypeHelper.findOverridden(method)) {
findBinding(m);
}
try {
for (ICPPMethod m : findOverridersInAST(method)) {

View file

@ -44,7 +44,6 @@ import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.IPositionConverter;
import org.eclipse.cdt.core.browser.ITypeReference;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
@ -330,20 +329,16 @@ public abstract class PDOMSearchQuery implements ISearchQuery {
if (binding instanceof ICPPMethod) {
ICPPMethod m= (ICPPMethod) binding;
try {
ICPPMethod[] msInBases = ClassTypeHelper.findOverridden(m);
if (msInBases.length > 0) {
if (polymorphicNames == null) {
polymorphicNames= new ArrayList<IIndexName>();
}
for (ICPPMethod mInBase : msInBases) {
if (mInBase != null && handled.add(mInBase)) {
createMatches1(index, mInBase, polymorphicNames);
}
ICPPMethod[] msInBases = ClassTypeHelper.findOverridden(m);
if (msInBases.length > 0) {
if (polymorphicNames == null) {
polymorphicNames= new ArrayList<IIndexName>();
}
for (ICPPMethod mInBase : msInBases) {
if (mInBase != null && handled.add(mInBase)) {
createMatches1(index, mInBase, polymorphicNames);
}
}
} catch (DOMException e) {
CUIPlugin.log(e);
}
}
}

View file

@ -74,7 +74,6 @@ import org.eclipse.cdt.core.model.ILanguage;
import org.eclipse.cdt.core.model.ISourceRange;
import org.eclipse.cdt.core.model.ISourceReference;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.ui.CUIPlugin;
@ -93,6 +92,7 @@ import org.eclipse.cdt.internal.core.model.ext.ICElementHandle;
import org.eclipse.cdt.internal.ui.actions.OpenActionUtil;
import org.eclipse.cdt.internal.ui.editor.ASTProvider;
import org.eclipse.cdt.internal.ui.editor.CEditorMessages;
import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
import org.eclipse.cdt.internal.ui.viewsupport.IndexUI;
class OpenDeclarationsJob extends Job implements ASTRunnable {
@ -730,27 +730,22 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
// For c++ we can check the number of parameters.
if (binding instanceof ICPPFunction) {
ICPPFunction f= (ICPPFunction) binding;
try {
if (f.getRequiredArgumentCount() > funcArgCount) {
if (f.getRequiredArgumentCount() > funcArgCount) {
iterator.remove();
result.add(binding);
continue;
}
if (!f.takesVarArgs() && !f.hasParameterPack()) {
final IType[] parameterTypes = f.getType().getParameterTypes();
int maxArgs= parameterTypes.length;
if (maxArgs == 1 && SemanticUtil.isVoidType(parameterTypes[0])) {
maxArgs= 0;
}
if (maxArgs < funcArgCount) {
iterator.remove();
result.add(binding);
continue;
}
if (!f.takesVarArgs() && !f.hasParameterPack()) {
final IType[] parameterTypes = f.getType().getParameterTypes();
int maxArgs= parameterTypes.length;
if (maxArgs == 1 && SemanticUtil.isVoidType(parameterTypes[0])) {
maxArgs= 0;
}
if (maxArgs < funcArgCount) {
iterator.remove();
result.add(binding);
continue;
}
}
} catch (DOMException e) {
// Ignore problem bindings.
continue;
}
}
}

View file

@ -389,13 +389,10 @@ public class CSourceHover extends AbstractCEditorTextHover {
} else {
final boolean expectClosingBrace;
IType type= null;
try {
if (binding instanceof ITypedef) {
type= ((ITypedef)binding).getType();
} else if (binding instanceof IVariable) {
type= ((IVariable)binding).getType();
}
} catch (DOMException exc) {
if (binding instanceof ITypedef) {
type= ((ITypedef)binding).getType();
} else if (binding instanceof IVariable) {
type= ((IVariable)binding).getType();
}
expectClosingBrace= type instanceof ICompositeType || type instanceof IEnumeration;
final int nameLine= doc.getLineOfOffset(nameOffset);

View file

@ -373,47 +373,44 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
StringBuilder idargs = new StringBuilder(); // for the idargString
boolean hasArgs = true;
String returnTypeStr = null;
try {
IParameter[] params = function.getParameters();
if (params != null) {
for (int i = 0; i < params.length; ++i) {
IType paramType = params[i].getType();
if (i > 0) {
dispargs.append(',');
idargs.append(',');
}
IParameter[] params = function.getParameters();
if (params != null) {
for (int i = 0; i < params.length; ++i) {
IType paramType = params[i].getType();
if (i > 0) {
dispargs.append(',');
idargs.append(',');
}
dispargs.append(ASTTypeUtil.getType(paramType, false));
idargs.append(ASTTypeUtil.getType(paramType, false));
String paramName = params[i].getName();
if (paramName != null && paramName.length() > 0) {
dispargs.append(' ');
dispargs.append(paramName);
}
}
if (function.takesVarArgs()) {
if (params.length > 0) {
dispargs.append(',');
idargs.append(',');
}
dispargs.append("..."); //$NON-NLS-1$
idargs.append("..."); //$NON-NLS-1$
} else if (params.length == 0) { // force the void in
dispargs.append("void"); //$NON-NLS-1$
idargs.append("void"); //$NON-NLS-1$
dispargs.append(ASTTypeUtil.getType(paramType, false));
idargs.append(ASTTypeUtil.getType(paramType, false));
String paramName = params[i].getName();
if (paramName != null && paramName.length() > 0) {
dispargs.append(' ');
dispargs.append(paramName);
}
}
IFunctionType functionType = function.getType();
if (functionType != null) {
IType returnType = functionType.getReturnType();
if (returnType != null)
returnTypeStr = ASTTypeUtil.getType(returnType, false);
if (function.takesVarArgs()) {
if (params.length > 0) {
dispargs.append(',');
idargs.append(',');
}
dispargs.append("..."); //$NON-NLS-1$
idargs.append("..."); //$NON-NLS-1$
} else if (params.length == 0) { // force the void in
dispargs.append("void"); //$NON-NLS-1$
idargs.append("void"); //$NON-NLS-1$
}
hasArgs = ASTTypeUtil.functionTakesParameters(function);
} catch (DOMException e) {
}
IFunctionType functionType = function.getType();
if (functionType != null) {
IType returnType = functionType.getReturnType();
if (returnType != null)
returnTypeStr = ASTTypeUtil.getType(returnType, false);
}
hasArgs = ASTTypeUtil.functionTakesParameters(function);
String dispargString = dispargs.toString();
String idargString = idargs.toString();
@ -457,18 +454,14 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
private void handleVariable(IVariable variable, CContentAssistInvocationContext context,
int baseRelevance, List<ICompletionProposal> proposals) {
if (context.isContextInformationStyle()) {
// Handle the case where a variable is initialized with a constructor
try {
IType t = variable.getType();
t= unwindTypedefs(t);
if (t instanceof ICPPClassType) {
ICPPClassType classType= (ICPPClassType) t;
ICPPConstructor[] constructors = classType.getConstructors();
for (ICPPConstructor constructor : constructors) {
handleFunction(constructor, context, baseRelevance, proposals);
}
IType t = variable.getType();
t= unwindTypedefs(t);
if (t instanceof ICPPClassType) {
ICPPClassType classType= (ICPPClassType) t;
ICPPConstructor[] constructors = classType.getConstructors();
for (ICPPConstructor constructor : constructors) {
handleFunction(constructor, context, baseRelevance, proposals);
}
} catch (DOMException e) {
}
return;
}
@ -477,12 +470,9 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
repStringBuff.append(variable.getName());
String returnTypeStr = "<unknown>"; //$NON-NLS-1$
try {
IType varType = variable.getType();
if (varType != null)
returnTypeStr = ASTTypeUtil.getType(varType, false);
} catch (DOMException e) {
}
IType varType = variable.getType();
if (varType != null)
returnTypeStr = ASTTypeUtil.getType(varType, false);
StringBuilder dispStringBuff = new StringBuilder(repStringBuff.toString());
if (returnTypeStr != null) {