mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
C/C++ Problems & Exceptions
- semantic problems result in IProblemBindings - attempting to do too much with an IProblemBinding results in a DOMException - All IBinding, IType & IScope interface functions throw DOMException
This commit is contained in:
parent
6a104cdd5b
commit
2852b6fafd
63 changed files with 827 additions and 349 deletions
|
@ -15,16 +15,12 @@
|
|||
package org.eclipse.cdt.core.parser.tests;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.parser.CodeReader;
|
||||
|
@ -32,7 +28,6 @@ import org.eclipse.cdt.core.parser.IParser;
|
|||
import org.eclipse.cdt.core.parser.IProblem;
|
||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.NullLogService;
|
||||
import org.eclipse.cdt.core.parser.NullSourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
|
@ -74,9 +69,7 @@ import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTVariableReference;
|
||||
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
||||
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
||||
import org.eclipse.cdt.core.testplugin.FileManager;
|
||||
|
||||
import org.eclipse.cdt.internal.core.parser.Parser;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
|
||||
|
@ -86,11 +79,7 @@ import org.eclipse.core.resources.IResource;
|
|||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.dialogs.SaveAsDialog;
|
||||
|
||||
/**
|
||||
* @author dsteffle
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
***********************************************************************/
|
||||
package org.eclipse.cdt.core.parser.tests.ast2;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
|
||||
|
@ -457,9 +455,9 @@ public class AST2KnRTests extends AST2BaseTest {
|
|||
assertEquals( A_struct_name1.toString(), "A_struct" ); //$NON-NLS-1$
|
||||
ICompositeType A_struct_type1 = (ICompositeType)A_struct_name1.resolveBinding();
|
||||
assertEquals( ((ICBinding)A_struct_type1).getPhysicalNode(), A_struct.getDeclSpecifier() );
|
||||
List fields = A_struct_type1.getFields();
|
||||
IField a1 = (IField)fields.get(0);
|
||||
IField c1 = (IField)fields.get(1);
|
||||
IField[] fields = A_struct_type1.getFields();
|
||||
IField a1 = fields[0];
|
||||
IField c1 = fields[1];
|
||||
assertEquals( a1.getName().toString(), "a" ); //$NON-NLS-1$
|
||||
assertEquals( c1.getName().toString(), "c" ); //$NON-NLS-1$
|
||||
IBasicType a1_t = (IBasicType)a1.getType();
|
||||
|
|
|
@ -83,7 +83,7 @@ import org.eclipse.cdt.internal.core.parser.ParserException;
|
|||
*/
|
||||
public class AST2Tests extends AST2BaseTest {
|
||||
|
||||
public void testBasicFunction() throws ParserException {
|
||||
public void testBasicFunction() throws Exception {
|
||||
StringBuffer buff = new StringBuffer();
|
||||
buff.append("int x;\n"); //$NON-NLS-1$
|
||||
buff.append("void f(int y) {\n"); //$NON-NLS-1$
|
||||
|
@ -216,7 +216,7 @@ public class AST2Tests extends AST2BaseTest {
|
|||
ICScope.NAMESPACE_TYPE_OTHER, new String("y").toCharArray())); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void testSimpleStruct() throws ParserException {
|
||||
public void testSimpleStruct() throws Exception {
|
||||
StringBuffer buff = new StringBuffer();
|
||||
buff.append("typedef struct {\n"); //$NON-NLS-1$
|
||||
buff.append(" int x;\n"); //$NON-NLS-1$
|
||||
|
|
|
@ -35,6 +35,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
|||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||
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.ILabel;
|
||||
|
@ -370,9 +371,9 @@ public class CompleteParser2Tests extends TestCase {
|
|||
ICPPField x = (ICPPField) col.getName(1).resolveBinding();
|
||||
|
||||
assertSame( x.getScope(), A.getCompositeScope() );
|
||||
List fields = A.getFields();
|
||||
assertEquals( fields.size(), 1 );
|
||||
assertSame( fields.get(0), x );
|
||||
IField [] fields = A.getFields();
|
||||
assertEquals( fields.length, 1 );
|
||||
assertSame( fields[0], x );
|
||||
}
|
||||
|
||||
public void testUsingClauses() throws Exception
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
/*
|
||||
* Created on Jan 31, 2005
|
||||
*/
|
||||
package org.eclipse.cdt.core.dom.ast;
|
||||
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class DOMException extends Exception {
|
||||
IProblemBinding problemBinding;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public DOMException( IProblemBinding problem ) {
|
||||
super( problem != null ? problem.getMessage() : CPPSemantics.EMPTY_NAME );
|
||||
problemBinding = problem;
|
||||
}
|
||||
|
||||
public IProblemBinding getProblem(){
|
||||
return problemBinding;
|
||||
}
|
||||
}
|
|
@ -19,5 +19,5 @@ package org.eclipse.cdt.core.dom.ast;
|
|||
*/
|
||||
public interface IArrayType extends IType {
|
||||
|
||||
IType getType();
|
||||
IType getType() throws DOMException;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ public interface IBasicType extends IType {
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
public int getType();
|
||||
public int getType() throws DOMException;
|
||||
|
||||
public static final int t_unspecified = IASTSimpleDeclSpecifier.t_unspecified;
|
||||
public static final int t_void = IASTSimpleDeclSpecifier.t_void;
|
||||
|
@ -35,8 +35,8 @@ public interface IBasicType extends IType {
|
|||
public static final int t_float = IASTSimpleDeclSpecifier.t_float;
|
||||
public static final int t_double = IASTSimpleDeclSpecifier.t_double;
|
||||
|
||||
public boolean isSigned();
|
||||
public boolean isUnsigned();
|
||||
public boolean isShort();
|
||||
public boolean isLong();
|
||||
public boolean isSigned() throws DOMException;
|
||||
public boolean isUnsigned() throws DOMException;
|
||||
public boolean isShort() throws DOMException;
|
||||
public boolean isLong() throws DOMException;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,6 @@ public interface IBinding {
|
|||
*
|
||||
* @return the scope of this name
|
||||
*/
|
||||
public IScope getScope();
|
||||
public IScope getScope() throws DOMException;
|
||||
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
**********************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
|
@ -23,14 +22,14 @@ public interface ICompositeType extends IBinding, IType {
|
|||
* what kind of composite type is this?
|
||||
* @return
|
||||
*/
|
||||
public int getKey();
|
||||
public int getKey() throws DOMException;
|
||||
|
||||
/**
|
||||
* Returns the fields for this type.
|
||||
*
|
||||
* @return List of IField
|
||||
*/
|
||||
public List getFields();
|
||||
public IField[] getFields() throws DOMException;
|
||||
|
||||
/**
|
||||
* returns the field that matches name,
|
||||
|
@ -39,7 +38,7 @@ public interface ICompositeType extends IBinding, IType {
|
|||
* @param name
|
||||
* @return
|
||||
*/
|
||||
public IField findField( String name );
|
||||
public IField findField( String name ) throws DOMException;
|
||||
|
||||
public IScope getCompositeScope();
|
||||
public IScope getCompositeScope() throws DOMException;
|
||||
}
|
||||
|
|
|
@ -18,5 +18,5 @@ package org.eclipse.cdt.core.dom.ast;
|
|||
* @author aniefer
|
||||
*/
|
||||
public interface IEnumeration extends IBinding, IType {
|
||||
|
||||
IEnumerator [] getEnumerators() throws DOMException;
|
||||
}
|
||||
|
|
|
@ -21,5 +21,5 @@ public interface IEnumerator extends IBinding {
|
|||
/**
|
||||
* @return the type of the variable
|
||||
*/
|
||||
public IType getType();
|
||||
public IType getType() throws DOMException;
|
||||
}
|
||||
|
|
|
@ -23,16 +23,23 @@ public interface IFunction extends IBinding {
|
|||
* This gets the parameters to the function which are IVariables.
|
||||
*
|
||||
* @return List of IParameter
|
||||
* @throws DOMException if this is a problem binding
|
||||
*/
|
||||
public IParameter [] getParameters();
|
||||
public IParameter [] getParameters() throws DOMException;
|
||||
|
||||
/**
|
||||
* Get the function scope
|
||||
*
|
||||
* @return
|
||||
* @throws DOMException if this is a problem binding
|
||||
*/
|
||||
public IScope getFunctionScope();
|
||||
public IScope getFunctionScope() throws DOMException;
|
||||
|
||||
public IFunctionType getType();
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws DOMException if this is a problem binding
|
||||
*/
|
||||
public IFunctionType getType() throws DOMException;
|
||||
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ package org.eclipse.cdt.core.dom.ast;
|
|||
* @author aniefer
|
||||
*/
|
||||
public interface IFunctionType extends IType {
|
||||
public IType getReturnType();
|
||||
public IType getReturnType() throws DOMException;
|
||||
|
||||
public IType [] getParameterTypes();
|
||||
public IType [] getParameterTypes() throws DOMException;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,6 @@ public interface ILabel extends IBinding {
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
public IASTLabelStatement getLabelStatement();
|
||||
public IASTLabelStatement getLabelStatement() throws DOMException;
|
||||
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ package org.eclipse.cdt.core.dom.ast;
|
|||
* @author aniefer
|
||||
*/
|
||||
public interface IPointerType extends IType {
|
||||
public IType getType();
|
||||
public boolean isConst();
|
||||
public boolean isVolatile();
|
||||
public IType getType() throws DOMException;
|
||||
public boolean isConst() throws DOMException;
|
||||
public boolean isVolatile() throws DOMException;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ package org.eclipse.cdt.core.dom.ast;
|
|||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public interface IProblemBinding extends IBinding {
|
||||
public interface IProblemBinding extends IBinding, IScope, IType {
|
||||
|
||||
/**
|
||||
* Returns the problem id
|
||||
|
@ -106,5 +106,9 @@ public interface IProblemBinding extends IBinding {
|
|||
public static final int SEMANTIC_ILLFORMED_FRIEND = 0x011;
|
||||
|
||||
public static final int SEMANTIC_RECURSIVE_TEMPLATE_INSTANTIATION = 0x012;
|
||||
public static final int LAST_PROBLEM = SEMANTIC_RECURSIVE_TEMPLATE_INSTANTIATION;
|
||||
|
||||
public static final int SEMANTIC_DEFINITION_NOT_FOUND = 0x013;
|
||||
public static final int SEMANTIC_KNR_PARAMETER_DECLARATION_NOT_FOUND = 0x014;
|
||||
public static final int SEMANTIC_LABEL_STATEMENT_NOT_FOUND = 0x015;
|
||||
public static final int LAST_PROBLEM = SEMANTIC_LABEL_STATEMENT_NOT_FOUND;
|
||||
}
|
||||
|
|
|
@ -18,8 +18,8 @@ package org.eclipse.cdt.core.dom.ast;
|
|||
* @author aniefer
|
||||
*/
|
||||
public interface IQualifierType extends IType {
|
||||
public boolean isConst();
|
||||
public boolean isVolatile();
|
||||
public boolean isConst() throws DOMException;
|
||||
public boolean isVolatile() throws DOMException;
|
||||
|
||||
public IType getType();
|
||||
public IType getType() throws DOMException;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ public interface IScope {
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
public IScope getParent();
|
||||
public IScope getParent() throws DOMException;
|
||||
|
||||
/**
|
||||
* This is the general lookup entry point. It returns the list of
|
||||
|
@ -33,5 +33,5 @@ public interface IScope {
|
|||
* @param searchString
|
||||
* @return List of IBinding
|
||||
*/
|
||||
public List find(String name);
|
||||
public List find(String name) throws DOMException;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,6 @@ public interface ITypedef extends IBinding, IType {
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
public IType getType();
|
||||
public IType getType() throws DOMException;
|
||||
|
||||
}
|
||||
|
|
|
@ -18,5 +18,5 @@ public interface IVariable extends IBinding {
|
|||
/**
|
||||
* @return the type of the variable
|
||||
*/
|
||||
public IType getType();
|
||||
public IType getType() throws DOMException;
|
||||
}
|
||||
|
|
|
@ -10,15 +10,16 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.c;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IArrayType;
|
||||
|
||||
/**
|
||||
* @author dsteffle
|
||||
*/
|
||||
public interface ICArrayType extends IArrayType {
|
||||
public boolean isConst();
|
||||
public boolean isRestrict();
|
||||
public boolean isVolatile();
|
||||
public boolean isStatic();
|
||||
public boolean isVariableLength();
|
||||
public boolean isConst() throws DOMException;
|
||||
public boolean isRestrict() throws DOMException;
|
||||
public boolean isVolatile() throws DOMException;
|
||||
public boolean isStatic() throws DOMException;
|
||||
public boolean isVariableLength() throws DOMException;
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
*/
|
||||
package org.eclipse.cdt.core.dom.ast.c;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
||||
|
||||
/**
|
||||
|
@ -24,5 +25,5 @@ public interface ICBasicType extends IBasicType {
|
|||
public static final int t_Complex = ICASTSimpleDeclSpecifier.t_Complex;
|
||||
public static final int t_Imaginary = ICASTSimpleDeclSpecifier.t_Imaginary;
|
||||
|
||||
public boolean isLongLong();
|
||||
public boolean isLongLong() throws DOMException;
|
||||
}
|
||||
|
|
|
@ -14,11 +14,12 @@
|
|||
*/
|
||||
package org.eclipse.cdt.core.dom.ast.c;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public interface ICCompositeTypeScope extends ICScope {
|
||||
public IBinding getBinding( char[] name );
|
||||
public IBinding getBinding( char[] name ) throws DOMException;
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
*/
|
||||
package org.eclipse.cdt.core.dom.ast.c;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
|
||||
|
@ -21,7 +22,7 @@ import org.eclipse.cdt.core.dom.ast.IScope;
|
|||
* @author aniefer
|
||||
*/
|
||||
public interface ICFunctionScope extends ICScope {
|
||||
public IScope getBodyScope();
|
||||
public IBinding getBinding( char[] name );
|
||||
public IScope getBodyScope() throws DOMException;
|
||||
public IBinding getBinding( char[] name ) throws DOMException;
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
*/
|
||||
package org.eclipse.cdt.core.dom.ast.c;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
|
||||
|
@ -24,7 +25,7 @@ public interface ICScope extends IScope {
|
|||
public static final int NAMESPACE_TYPE_TAG = 0;
|
||||
public static final int NAMESPACE_TYPE_OTHER = 1;
|
||||
|
||||
void addBinding( IBinding binding );
|
||||
void removeBinding( IBinding binding );
|
||||
public IBinding getBinding( int namespaceType, char [] name );
|
||||
void addBinding( IBinding binding ) throws DOMException;
|
||||
void removeBinding( IBinding binding ) throws DOMException;
|
||||
public IBinding getBinding( int namespaceType, char [] name ) throws DOMException;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,9 @@ package org.eclipse.cdt.core.dom.ast.cpp;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||
import org.eclipse.cdt.core.dom.ast.IField;
|
||||
|
||||
/**
|
||||
* Represents a C++ class.
|
||||
|
@ -28,13 +30,13 @@ public interface ICPPClassType extends ICompositeType {
|
|||
*
|
||||
* @return List of ICPPBase
|
||||
*/
|
||||
public ICPPBase [] getBases();
|
||||
public ICPPBase [] getBases() throws DOMException;
|
||||
|
||||
/**
|
||||
* Get fields is restated here just to point out that this method returns
|
||||
* a list of ICPPField objects representing all fields, declared or inherited.
|
||||
*/
|
||||
public List getFields();
|
||||
public IField[] getFields() throws DOMException;
|
||||
|
||||
/**
|
||||
* Returns a list of ICPPField objects representing fields declared in this
|
||||
|
@ -42,7 +44,7 @@ public interface ICPPClassType extends ICompositeType {
|
|||
*
|
||||
* @return List of ICPPField
|
||||
*/
|
||||
public List getDeclaredFields();
|
||||
public List getDeclaredFields() throws DOMException;
|
||||
|
||||
/**
|
||||
* Returns a list of ICPPMethod objects representing all methods defined for
|
||||
|
@ -51,7 +53,7 @@ public interface ICPPClassType extends ICompositeType {
|
|||
*
|
||||
* @return List of ICPPMethod
|
||||
*/
|
||||
public List getMethods();
|
||||
public List getMethods() throws DOMException;
|
||||
|
||||
/**
|
||||
* Returns a list of ICPPMethod objects representing all method explicitly
|
||||
|
@ -60,7 +62,7 @@ public interface ICPPClassType extends ICompositeType {
|
|||
*
|
||||
* @return List of ICPPMethod
|
||||
*/
|
||||
public List getAllDeclaredMethods();
|
||||
public List getAllDeclaredMethods() throws DOMException;
|
||||
|
||||
/**
|
||||
* Returns a list of ICPPMethod objects representing all methods explicitly
|
||||
|
@ -69,11 +71,11 @@ public interface ICPPClassType extends ICompositeType {
|
|||
*
|
||||
* @return List of ICPPMethod
|
||||
*/
|
||||
public List getDeclaredMethods();
|
||||
public List getDeclaredMethods() throws DOMException;
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public ICPPConstructor[] getConstructors();
|
||||
public ICPPConstructor[] getConstructors() throws DOMException;
|
||||
|
||||
}
|
||||
|
|
|
@ -13,11 +13,12 @@
|
|||
*/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public interface ICPPCompositeBinding extends IBinding {
|
||||
IBinding [] getBindings();
|
||||
IBinding [] getBindings() throws DOMException;
|
||||
}
|
||||
|
|
|
@ -13,14 +13,18 @@
|
|||
*/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public interface ICPPConstructor extends ICPPMethod {
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws DOMException
|
||||
*/
|
||||
boolean isExplicit();
|
||||
boolean isExplicit() throws DOMException;
|
||||
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
**********************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
|
||||
/**
|
||||
* Represents a member of a class. Adds in the visibility attribute.
|
||||
*
|
||||
|
@ -22,7 +24,7 @@ public interface ICPPMember {
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
public int getVisibility();
|
||||
public int getVisibility() throws DOMException;
|
||||
|
||||
public static final int v_private = ICPPASTVisiblityLabel.v_private;
|
||||
public static final int v_protected = ICPPASTVisiblityLabel.v_protected;
|
||||
|
|
|
@ -13,11 +13,12 @@
|
|||
*/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public interface ICPPNamespace extends IBinding {
|
||||
public ICPPNamespaceScope getNamespaceScope();
|
||||
public ICPPNamespaceScope getNamespaceScope() throws DOMException;
|
||||
}
|
||||
|
|
|
@ -14,11 +14,12 @@
|
|||
*/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public interface ICPPReferenceType extends IType {
|
||||
public IType getType();
|
||||
public IType getType() throws DOMException;
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
*/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
|
@ -22,7 +23,7 @@ import org.eclipse.cdt.core.dom.ast.IScope;
|
|||
* @author aniefer
|
||||
*/
|
||||
public interface ICPPScope extends IScope {
|
||||
public IASTNode getPhysicalNode();
|
||||
public void addBinding( IBinding binding );
|
||||
public IBinding getBinding( IASTName name );
|
||||
public IASTNode getPhysicalNode() throws DOMException;
|
||||
public void addBinding( IBinding binding ) throws DOMException;
|
||||
public IBinding getBinding( IASTName name ) throws DOMException;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
**********************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
|
||||
/**
|
||||
|
@ -22,6 +23,6 @@ public interface ICPPTemplateTypeParameter extends ICPPTemplateParameter, IType
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
public IType getDefault();
|
||||
public IType getDefault() throws DOMException;
|
||||
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
*/
|
||||
package org.eclipse.cdt.core.dom.ast.gnu.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
|
||||
|
||||
|
@ -25,7 +26,7 @@ public interface IGPPBasicType extends ICPPBasicType {
|
|||
public static final int t_Imaginary = IGPPASTSimpleDeclSpecifier.t_Imaginary;
|
||||
public static final int t_typeof = IGPPASTSimpleDeclSpecifier.t_typeof;
|
||||
|
||||
public boolean isLongLong();
|
||||
public boolean isLongLong() throws DOMException;
|
||||
|
||||
public IType getTypeofType();
|
||||
public IType getTypeofType() throws DOMException;
|
||||
}
|
||||
|
|
|
@ -14,12 +14,13 @@
|
|||
*/
|
||||
package org.eclipse.cdt.internal.core.dom.parser;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public interface ITypeContainer extends IType{
|
||||
IType getType();
|
||||
IType getType() throws DOMException;
|
||||
void setType( IType type );
|
||||
}
|
||||
|
|
|
@ -15,7 +15,9 @@
|
|||
package org.eclipse.cdt.internal.core.dom.parser;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
|
@ -26,7 +28,7 @@ import org.eclipse.cdt.internal.core.parser.ParserMessages;
|
|||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class ProblemBinding implements IProblemBinding, IType {
|
||||
public class ProblemBinding implements IProblemBinding, IType, IScope {
|
||||
private final int id;
|
||||
private final char [] arg;
|
||||
|
||||
|
@ -101,19 +103,35 @@ public class ProblemBinding implements IProblemBinding, IType {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
|
||||
*/
|
||||
public IScope getScope() {
|
||||
return null;
|
||||
public IScope getScope() throws DOMException {
|
||||
throw new DOMException( this );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getPhysicalNode()
|
||||
*/
|
||||
public IASTNode getPhysicalNode() {
|
||||
return null;
|
||||
public IASTNode getPhysicalNode() throws DOMException {
|
||||
throw new DOMException( this );
|
||||
}
|
||||
|
||||
public Object clone(){
|
||||
//don't clone problems
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IScope#getParent()
|
||||
*/
|
||||
public IScope getParent() throws DOMException {
|
||||
throw new DOMException( this );
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
|
||||
*/
|
||||
public List find( String name ) throws DOMException {
|
||||
throw new DOMException( this );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,8 +14,10 @@
|
|||
*/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTEnumerationSpecifier;
|
||||
|
@ -64,4 +66,17 @@ public class CEnumeration implements IEnumeration {
|
|||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IEnumeration#getEnumerators()
|
||||
*/
|
||||
public IEnumerator[] getEnumerators() {
|
||||
IASTEnumerationSpecifier.IASTEnumerator[] enums = enumSpec.getEnumerators();
|
||||
IEnumerator [] bindings = new IEnumerator [ enums.length ];
|
||||
|
||||
for( int i = 0; i < enums.length; i++ ){
|
||||
bindings[i] = (IEnumerator) enums[i].getName().resolveBinding();
|
||||
}
|
||||
return bindings;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,11 @@ import org.eclipse.cdt.core.dom.ast.IField;
|
|||
* @author aniefer
|
||||
*/
|
||||
public class CField extends CVariable implements IField {
|
||||
|
||||
public static class CFieldProblem extends CVariable.CVariableProblem implements IField {
|
||||
public CFieldProblem( int id, char[] arg ) {
|
||||
super( id, arg );
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param name
|
||||
*/
|
||||
|
|
|
@ -23,6 +23,7 @@ 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.IProblemBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
|
||||
|
@ -88,21 +89,17 @@ public class CFunction implements IFunction, ICBinding {
|
|||
}
|
||||
}
|
||||
} else if (dtor instanceof ICASTKnRFunctionDeclarator) {
|
||||
IASTDeclaration[] params = ((ICASTKnRFunctionDeclarator)dtor).getParameterDeclarations();
|
||||
IASTName[] names = ((ICASTKnRFunctionDeclarator)dtor).getParameterNames();
|
||||
result = new IParameter[ names.length ];
|
||||
if( names.length > 0 ){
|
||||
// ensures that the List of parameters is created in the same order as the K&R C parameter names
|
||||
for( int i=0; i<names.length; i++ ) {
|
||||
for( int j=0; j<params.length; j++) {
|
||||
if ( params[j] instanceof IASTSimpleDeclaration ) {
|
||||
IASTDeclarator[] decltors = ((IASTSimpleDeclaration)params[j]).getDeclarators();
|
||||
for (int k=0; k<decltors.length; k++) {
|
||||
if ( CharArrayUtils.equals(names[i].toCharArray(), decltors[k].getName().toCharArray()) ) {
|
||||
result[i] = (IParameter) decltors[k].getName().resolveBinding();
|
||||
}
|
||||
} }
|
||||
}
|
||||
IASTDeclarator decl = getKnRParameterDeclarator( (ICASTKnRFunctionDeclarator) dtor, names[i] );
|
||||
if( decl != null ) {
|
||||
result[i] = (IParameter) decl.getName().resolveBinding();
|
||||
} else {
|
||||
result[i] = new CParameter.CParameterProblem( IProblemBinding.SEMANTIC_KNR_PARAMETER_DECLARATION_NOT_FOUND, names[i].toCharArray() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
|
||||
|
@ -32,12 +33,20 @@ public class CFunctionType implements IFunctionType {
|
|||
public boolean equals( Object o ){
|
||||
if( o instanceof IFunctionType ){
|
||||
IFunctionType ft = (IFunctionType) o;
|
||||
IType [] fps = ft.getParameterTypes();
|
||||
|
||||
IType [] fps;
|
||||
try {
|
||||
fps = ft.getParameterTypes();
|
||||
} catch ( DOMException e ) {
|
||||
return false;
|
||||
}
|
||||
if( fps.length != parameters.length )
|
||||
return false;
|
||||
if( ! returnType.equals( ft.getReturnType() ) )
|
||||
try {
|
||||
if( ! returnType.equals( ft.getReturnType() ) )
|
||||
return false;
|
||||
} catch ( DOMException e1 ) {
|
||||
return false;
|
||||
}
|
||||
for( int i = 0; i < parameters.length; i++ )
|
||||
if( ! parameters[i].equals( fps[i] ) )
|
||||
return false;
|
||||
|
|
|
@ -14,16 +14,28 @@
|
|||
*/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTLabelStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.ILabel;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CLabel implements ILabel {
|
||||
|
||||
public static class CLabelProblem extends ProblemBinding implements ILabel {
|
||||
public CLabelProblem( int id, char[] arg ) {
|
||||
super( id, arg );
|
||||
}
|
||||
|
||||
public IASTLabelStatement getLabelStatement() throws DOMException{
|
||||
throw new DOMException( this );
|
||||
}
|
||||
}
|
||||
|
||||
private final IASTLabelStatement labelStatement;
|
||||
|
||||
public CLabel( IASTLabelStatement statement ){
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
**********************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
||||
|
@ -20,12 +21,23 @@ 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.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||
|
||||
/**
|
||||
* Created on Nov 5, 2004
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CParameter implements IParameter {
|
||||
public static class CParameterProblem extends ProblemBinding implements IParameter {
|
||||
public CParameterProblem( int id, char[] arg ) {
|
||||
super( id, arg );
|
||||
}
|
||||
|
||||
public IType getType() throws DOMException {
|
||||
throw new DOMException( this );
|
||||
}
|
||||
}
|
||||
|
||||
private IASTName [] declarations;
|
||||
|
||||
public CParameter( IASTName parameterName ){
|
||||
|
|
|
@ -11,9 +11,6 @@
|
|||
**********************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||
|
@ -24,6 +21,7 @@ import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
|||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||
import org.eclipse.cdt.core.dom.ast.IField;
|
||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTCompositeTypeSpecifier;
|
||||
|
@ -36,7 +34,6 @@ import org.eclipse.cdt.core.dom.ast.c.ICASTElaboratedTypeSpecifier;
|
|||
public class CStructure implements ICompositeType, ICBinding {
|
||||
private IASTElaboratedTypeSpecifier[] declarations = null;
|
||||
private ICASTCompositeTypeSpecifier definition;
|
||||
//final private IASTDeclSpecifier declSpecifier;
|
||||
|
||||
public CStructure( IASTDeclSpecifier declSpec ){
|
||||
if( declSpec instanceof IASTCompositeTypeSpecifier )
|
||||
|
@ -86,17 +83,17 @@ public class CStructure implements ICompositeType, ICBinding {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getFields()
|
||||
*/
|
||||
public List getFields() {
|
||||
public IField[] getFields() {
|
||||
if( definition == null ){
|
||||
ICASTCompositeTypeSpecifier temp = checkForDefinition( declarations[0] );
|
||||
if( temp == null )
|
||||
return null;
|
||||
return new IField [] { new CField.CFieldProblem( IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, getNameCharArray() ) };
|
||||
definition = temp;
|
||||
}
|
||||
|
||||
IASTDeclaration[] members = definition.getMembers();
|
||||
int size = members.length;
|
||||
List fields = new ArrayList( size );
|
||||
IField[] fields = new IField[ size ];
|
||||
if( size > 0 ){
|
||||
|
||||
for( int i = 0; i < size; i++ ){
|
||||
|
@ -107,7 +104,7 @@ public class CStructure implements ICompositeType, ICBinding {
|
|||
IASTDeclarator declarator = declarators[j];
|
||||
IBinding binding = declarator.getName().resolveBinding();
|
||||
if( binding != null )
|
||||
fields.add( binding );
|
||||
fields[i] = (IField) binding;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -123,7 +120,7 @@ public class CStructure implements ICompositeType, ICBinding {
|
|||
if( definition == null ){
|
||||
ICASTCompositeTypeSpecifier temp = checkForDefinition( declarations[0] );
|
||||
if( temp == null )
|
||||
return null;
|
||||
return new CField.CFieldProblem( IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, getNameCharArray() );
|
||||
definition = temp;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
**********************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
|
@ -18,42 +19,33 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
|||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||
|
||||
/**
|
||||
* Created on Nov 5, 2004
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CVariable implements IVariable, ICBinding {
|
||||
public static class CVariableProblem extends ProblemBinding implements IVariable {
|
||||
public CVariableProblem( int id, char[] arg ) {
|
||||
super( id, arg );
|
||||
}
|
||||
|
||||
public IType getType() throws DOMException {
|
||||
throw new DOMException( this );
|
||||
}
|
||||
|
||||
}
|
||||
final IASTName name;
|
||||
private IType type = null;
|
||||
|
||||
public CVariable( IASTName name ){
|
||||
// name = checkForDefinition( name );
|
||||
this.name = name;
|
||||
}
|
||||
public IASTNode getPhysicalNode(){
|
||||
return name;
|
||||
}
|
||||
// private IASTName checkForDefinition( IASTName nm ){
|
||||
// IASTDeclarator dtor = (IASTDeclarator) nm.getParent();
|
||||
// IASTSimpleDeclaration dcl = (IASTSimpleDeclaration) dtor.getParent();
|
||||
// IASTDeclSpecifier declSpec = dcl.getDeclSpecifier();
|
||||
// if( declSpec.getStorageClass() == IASTDeclSpecifier.sc_extern ){
|
||||
// IASTDeclarator prev = dtor, tmp = CVisitor.findDefinition( dtor, CVisitor.AT_BEGINNING );
|
||||
// while( tmp != null && tmp != prev ){
|
||||
// CASTName n = (CASTName) tmp.getName();
|
||||
// IASTDeclSpecifier spec = ((IASTSimpleDeclaration)tmp.getParent()).getDeclSpecifier();
|
||||
// if( spec.getStorageClass() != IASTDeclSpecifier.sc_extern ){
|
||||
// nm = n;
|
||||
// }
|
||||
// n.setBinding( this );
|
||||
// prev = tmp;
|
||||
// tmp = CVisitor.findDefinition( tmp, CVisitor.AT_NEXT );
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return nm;
|
||||
// }
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IVariable#getType()
|
||||
*/
|
||||
|
|
|
@ -14,6 +14,7 @@ package org.eclipse.cdt.internal.core.dom.parser.c;
|
|||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression;
|
||||
|
@ -71,6 +72,7 @@ import org.eclipse.cdt.core.dom.ast.IFunction;
|
|||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.ILabel;
|
||||
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
|
@ -142,9 +144,13 @@ public class CVisitor {
|
|||
}
|
||||
public int processName(IASTName name) {
|
||||
if ( ((CASTName)name).hasBinding() ) {
|
||||
ICScope scope = (ICScope)name.resolveBinding().getScope();
|
||||
if ( scope != null )
|
||||
scope.removeBinding(name.resolveBinding());
|
||||
ICScope scope;
|
||||
try {
|
||||
scope = (ICScope)name.resolveBinding().getScope();
|
||||
if ( scope != null )
|
||||
scope.removeBinding(name.resolveBinding());
|
||||
} catch ( DOMException e ) {
|
||||
}
|
||||
((CASTName) name ).setBinding( null );
|
||||
}
|
||||
|
||||
|
@ -490,30 +496,42 @@ public class CVisitor {
|
|||
|
||||
private static IBinding createBinding( ICASTEnumerationSpecifier enumeration ){
|
||||
IEnumeration binding = new CEnumeration( enumeration );
|
||||
((ICScope)binding.getScope()).addBinding( binding );
|
||||
return binding;
|
||||
try {
|
||||
((ICScope)binding.getScope()).addBinding( binding );
|
||||
} catch ( DOMException e ) {
|
||||
}
|
||||
return binding;
|
||||
}
|
||||
private static IBinding createBinding( IASTEnumerator enumerator ){
|
||||
IEnumerator binding = new CEnumerator( enumerator );
|
||||
((ICScope)binding.getScope()).addBinding( binding );
|
||||
try {
|
||||
((ICScope)binding.getScope()).addBinding( binding );
|
||||
} catch ( DOMException e ) {
|
||||
}
|
||||
return binding;
|
||||
}
|
||||
private static IBinding createBinding( IASTStatement statement ){
|
||||
if( statement instanceof IASTGotoStatement ){
|
||||
char [] gotoName = ((IASTGotoStatement)statement).getName().toCharArray();
|
||||
IScope scope = getContainingScope( statement );
|
||||
if( scope != null && scope instanceof ICFunctionScope ){
|
||||
CFunctionScope functionScope = (CFunctionScope) scope;
|
||||
List labels = functionScope.getLabels();
|
||||
for( int i = 0; i < labels.size(); i++ ){
|
||||
ILabel label = (ILabel) labels.get(i);
|
||||
if( label.getName().equals( ((IASTGotoStatement)statement).getName().toString() ) ){
|
||||
if( CharArrayUtils.equals( label.getNameCharArray(), gotoName) ){
|
||||
return label;
|
||||
}
|
||||
}
|
||||
//label not found
|
||||
return new CLabel.CLabelProblem( IProblemBinding.SEMANTIC_LABEL_STATEMENT_NOT_FOUND, gotoName );
|
||||
}
|
||||
} else if( statement instanceof IASTLabelStatement ){
|
||||
IBinding binding = new CLabel( (IASTLabelStatement) statement );
|
||||
((ICFunctionScope) binding.getScope()).addBinding( binding );
|
||||
try {
|
||||
((ICFunctionScope) binding.getScope()).addBinding( binding );
|
||||
} catch ( DOMException e ) {
|
||||
}
|
||||
return binding;
|
||||
}
|
||||
return null;
|
||||
|
@ -527,7 +545,10 @@ public class CVisitor {
|
|||
IBinding binding = resolveBinding( elabTypeSpec, CURRENT_SCOPE | TAGS );
|
||||
if( binding == null ){
|
||||
binding = new CStructure( elabTypeSpec );
|
||||
((ICScope) binding.getScope()).addBinding( binding );
|
||||
try {
|
||||
((ICScope) binding.getScope()).addBinding( binding );
|
||||
} catch ( DOMException e ) {
|
||||
}
|
||||
}
|
||||
return binding;
|
||||
}
|
||||
|
@ -547,38 +568,50 @@ public class CVisitor {
|
|||
type = getExpressionType( fieldOwner );
|
||||
}
|
||||
while( type != null && type instanceof ITypeContainer) {
|
||||
type = ((ITypeContainer)type).getType();
|
||||
try {
|
||||
type = ((ITypeContainer)type).getType();
|
||||
} catch ( DOMException e ) {
|
||||
return e.getProblem();
|
||||
}
|
||||
}
|
||||
|
||||
if( type != null && type instanceof ICompositeType ){
|
||||
return ((ICompositeType) type).findField( fieldReference.getFieldName().toString() );
|
||||
try {
|
||||
return ((ICompositeType) type).findField( fieldReference.getFieldName().toString() );
|
||||
} catch ( DOMException e ) {
|
||||
return e.getProblem();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static IType getExpressionType( IASTExpression expression ) {
|
||||
if( expression instanceof IASTIdExpression ){
|
||||
IBinding binding = resolveBinding( expression );
|
||||
if( binding instanceof IVariable ){
|
||||
return ((IVariable)binding).getType();
|
||||
}
|
||||
} else if( expression instanceof IASTCastExpression ){
|
||||
IASTTypeId id = ((IASTCastExpression)expression).getTypeId();
|
||||
IBinding binding = resolveBinding( id );
|
||||
if( binding != null && binding instanceof IType ){
|
||||
return (IType) binding;
|
||||
}
|
||||
} else if( expression instanceof IASTFieldReference ){
|
||||
IBinding binding = ((IASTFieldReference)expression).getFieldName().resolveBinding();
|
||||
|
||||
if( binding instanceof IVariable ){
|
||||
return ((IVariable)binding).getType();
|
||||
}
|
||||
}
|
||||
else if( expression instanceof IASTUnaryExpression )
|
||||
{
|
||||
if( ((IASTUnaryExpression)expression).getOperator() == IASTUnaryExpression.op_bracketedPrimary )
|
||||
return getExpressionType(((IASTUnaryExpression)expression).getOperand() );
|
||||
try{
|
||||
if( expression instanceof IASTIdExpression ){
|
||||
IBinding binding = resolveBinding( expression );
|
||||
if( binding instanceof IVariable ){
|
||||
return ((IVariable)binding).getType();
|
||||
}
|
||||
} else if( expression instanceof IASTCastExpression ){
|
||||
IASTTypeId id = ((IASTCastExpression)expression).getTypeId();
|
||||
IBinding binding = resolveBinding( id );
|
||||
if( binding != null && binding instanceof IType ){
|
||||
return (IType) binding;
|
||||
}
|
||||
} else if( expression instanceof IASTFieldReference ){
|
||||
IBinding binding = ((IASTFieldReference)expression).getFieldName().resolveBinding();
|
||||
|
||||
if( binding instanceof IVariable ){
|
||||
return ((IVariable)binding).getType();
|
||||
}
|
||||
}
|
||||
else if( expression instanceof IASTUnaryExpression )
|
||||
{
|
||||
if( ((IASTUnaryExpression)expression).getOperator() == IASTUnaryExpression.op_bracketedPrimary )
|
||||
return getExpressionType(((IASTUnaryExpression)expression).getOperand() );
|
||||
}
|
||||
} catch( DOMException e ){
|
||||
return e.getProblem();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -613,7 +646,10 @@ public class CVisitor {
|
|||
if ( declarator.getParent() instanceof IASTFunctionDefinition ) {
|
||||
ICScope scope = (ICScope) ((IASTCompoundStatement)((IASTFunctionDefinition)declarator.getParent()).getBody()).getScope();
|
||||
if ( scope != null && binding != null )
|
||||
scope.addBinding(binding);
|
||||
try {
|
||||
scope.addBinding(binding);
|
||||
} catch ( DOMException e ) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if( parent instanceof IASTSimpleDeclaration ){
|
||||
|
@ -628,7 +664,10 @@ public class CVisitor {
|
|||
if( parent instanceof IASTFunctionDefinition ){
|
||||
ICScope scope = (ICScope) ((IASTCompoundStatement)((IASTFunctionDefinition)parent).getBody()).getScope();
|
||||
if ( scope != null && binding != null )
|
||||
scope.addBinding(binding);
|
||||
try {
|
||||
scope.addBinding(binding);
|
||||
} catch ( DOMException e ) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if ( parent instanceof IASTFunctionDeclarator ) {
|
||||
|
@ -650,18 +689,25 @@ public class CVisitor {
|
|||
|
||||
ICScope scope = (ICScope) getContainingScope( parent );
|
||||
IBinding binding = null;
|
||||
binding = ( scope != null ) ? scope.getBinding( ICScope.NAMESPACE_TYPE_OTHER, declarator.getName().toCharArray() ) : null;
|
||||
try {
|
||||
binding = ( scope != null ) ? scope.getBinding( ICScope.NAMESPACE_TYPE_OTHER, declarator.getName().toCharArray() ) : null;
|
||||
} catch ( DOMException e1 ) {
|
||||
binding = null;
|
||||
}
|
||||
|
||||
if( declarator instanceof IASTFunctionDeclarator ){
|
||||
if( binding != null && binding instanceof IFunction ){
|
||||
IFunction function = (IFunction) binding;
|
||||
IFunctionType ftype = function.getType();
|
||||
IType type = createType( declarator.getName() );
|
||||
if( ftype.equals( type ) ){
|
||||
if( parent instanceof IASTSimpleDeclaration )
|
||||
((CFunction)function).addDeclarator( (IASTFunctionDeclarator) declarator );
|
||||
|
||||
return function;
|
||||
try{
|
||||
IFunction function = (IFunction) binding;
|
||||
IFunctionType ftype = function.getType();
|
||||
IType type = createType( declarator.getName() );
|
||||
if( ftype.equals( type ) ){
|
||||
if( parent instanceof IASTSimpleDeclaration )
|
||||
((CFunction)function).addDeclarator( (IASTFunctionDeclarator) declarator );
|
||||
|
||||
return function;
|
||||
}
|
||||
} catch( DOMException e ){
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -681,15 +727,23 @@ public class CVisitor {
|
|||
}
|
||||
|
||||
if( scope != null && binding != null )
|
||||
scope.addBinding( binding );
|
||||
try {
|
||||
scope.addBinding( binding );
|
||||
} catch ( DOMException e ) {
|
||||
}
|
||||
return binding;
|
||||
}
|
||||
|
||||
|
||||
private static IBinding createBinding( ICASTCompositeTypeSpecifier compositeTypeSpec ){
|
||||
ICompositeType binding = new CStructure( compositeTypeSpec );
|
||||
ICScope scope = (ICScope) binding.getScope();
|
||||
scope.addBinding( binding );
|
||||
ICScope scope;
|
||||
try {
|
||||
scope = (ICScope) binding.getScope();
|
||||
scope.addBinding( binding );
|
||||
} catch ( DOMException e ) {
|
||||
}
|
||||
|
||||
return binding;
|
||||
}
|
||||
|
||||
|
@ -702,10 +756,16 @@ public class CVisitor {
|
|||
IBinding binding = null;
|
||||
if( simpleDeclaration.getDeclSpecifier().getStorageClass() == IASTDeclSpecifier.sc_typedef ){
|
||||
binding = new CTypeDef( name );
|
||||
((ICScope) binding.getScope()).addBinding( binding );
|
||||
try {
|
||||
((ICScope) binding.getScope()).addBinding( binding );
|
||||
} catch ( DOMException e ) {
|
||||
}
|
||||
} else if( simpleDeclaration.getParent() instanceof ICASTCompositeTypeSpecifier ){
|
||||
binding = new CField( name );
|
||||
((ICScope) binding.getScope()).addBinding( binding );
|
||||
try {
|
||||
((ICScope) binding.getScope()).addBinding( binding );
|
||||
} catch ( DOMException e ) {
|
||||
}
|
||||
} else {
|
||||
CScope scope = (CScope) CVisitor.getContainingScope( simpleDeclaration );
|
||||
binding = scope.getBinding( ICScope.NAMESPACE_TYPE_OTHER, name.toCharArray() );
|
||||
|
@ -787,10 +847,16 @@ public class CVisitor {
|
|||
if ( struct instanceof CStructure ) {
|
||||
return ((CStructure)struct).findField(((ICASTFieldDesignator)node).getName().toString());
|
||||
} else if ( struct instanceof ITypeContainer ) {
|
||||
IType type = ((ITypeContainer)struct).getType();
|
||||
while ( type instanceof ITypeContainer && !(type instanceof CStructure) ) {
|
||||
type = ((ITypeContainer)type).getType();
|
||||
}
|
||||
IType type;
|
||||
try {
|
||||
type = ((ITypeContainer)struct).getType();
|
||||
while ( type instanceof ITypeContainer && !(type instanceof CStructure) ) {
|
||||
type = ((ITypeContainer)type).getType();
|
||||
}
|
||||
} catch ( DOMException e ) {
|
||||
return e.getProblem();
|
||||
}
|
||||
|
||||
|
||||
if ( type instanceof CStructure )
|
||||
return ((CStructure)type).findField(((ICASTFieldDesignator)node).getName().toString());
|
||||
|
@ -855,13 +921,21 @@ public class CVisitor {
|
|||
} else if( parent instanceof IASTFunctionDefinition ){
|
||||
IASTFunctionDeclarator fnDeclarator = ((IASTFunctionDefinition) parent ).getDeclarator();
|
||||
IFunction function = (IFunction) fnDeclarator.getName().resolveBinding();
|
||||
scope = function.getFunctionScope();
|
||||
try {
|
||||
scope = function.getFunctionScope();
|
||||
} catch ( DOMException e ) {
|
||||
return e.getProblem();
|
||||
}
|
||||
}
|
||||
|
||||
if( statement instanceof IASTGotoStatement || statement instanceof IASTLabelStatement ){
|
||||
//labels have function scope
|
||||
while( scope != null && !(scope instanceof ICFunctionScope) ){
|
||||
scope = scope.getParent();
|
||||
try {
|
||||
scope = scope.getParent();
|
||||
} catch ( DOMException e ) {
|
||||
scope = e.getProblem();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -928,7 +1002,11 @@ public class CVisitor {
|
|||
if( scope != null ){
|
||||
int namespaceType = (bits & TAGS) != 0 ? ICScope.NAMESPACE_TYPE_TAG
|
||||
: ICScope.NAMESPACE_TYPE_OTHER;
|
||||
binding = scope.getBinding( namespaceType, name.toCharArray() );
|
||||
try {
|
||||
binding = scope.getBinding( namespaceType, name.toCharArray() );
|
||||
} catch ( DOMException e ) {
|
||||
binding = null;
|
||||
}
|
||||
if( binding != null )
|
||||
return binding;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
**********************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
|
@ -88,7 +89,11 @@ public class CPPASTNamespaceDefinition extends CPPASTNode implements
|
|||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition#getScope()
|
||||
*/
|
||||
public IScope getScope() {
|
||||
return ((ICPPNamespace) name.resolveBinding()).getNamespaceScope();
|
||||
try {
|
||||
return ((ICPPNamespace) name.resolveBinding()).getNamespaceScope();
|
||||
} catch ( DOMException e ) {
|
||||
return e.getProblem();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
*/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IArrayType;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||
|
@ -38,7 +39,11 @@ public class CPPArrayType implements IArrayType, ITypeContainer {
|
|||
|
||||
public boolean equals(Object obj) {
|
||||
if( obj instanceof IArrayType ){
|
||||
return ((IArrayType) obj).getType().equals( type );
|
||||
try {
|
||||
return ((IArrayType) obj).getType().equals( type );
|
||||
} catch ( DOMException e ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
|
@ -53,9 +54,14 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
|
|||
private void createImplicitMembers(){
|
||||
//create bindings for the implicit members, if the user declared them then those declarations
|
||||
//will resolve to these bindings.
|
||||
ICPPASTCompositeTypeSpecifier compTypeSpec = (ICPPASTCompositeTypeSpecifier) getPhysicalNode();
|
||||
|
||||
//default constructor: A()
|
||||
ICPPASTCompositeTypeSpecifier compTypeSpec;
|
||||
try {
|
||||
compTypeSpec = (ICPPASTCompositeTypeSpecifier) getPhysicalNode();
|
||||
} catch ( DOMException e ) {
|
||||
return;
|
||||
}
|
||||
|
||||
//default constructor: A()
|
||||
addBinding( new CPPImplicitConstructor( this, IParameter.EMPTY_PARAMETER_ARRAY ) );
|
||||
|
||||
ICPPClassType clsType = (ICPPClassType) compTypeSpec.getName().resolveBinding();
|
||||
|
@ -119,7 +125,7 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#getBinding(int, char[])
|
||||
*/
|
||||
public IBinding getBinding( IASTName name ) {
|
||||
public IBinding getBinding( IASTName name ) throws DOMException {
|
||||
char [] c = name.toCharArray();
|
||||
|
||||
ICPPASTCompositeTypeSpecifier compType = (ICPPASTCompositeTypeSpecifier) getPhysicalNode();
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
*/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
||||
|
@ -28,6 +27,7 @@ import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IField;
|
||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||
|
@ -131,16 +131,16 @@ public class CPPClassType implements ICPPClassType, ICPPBinding {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getFields()
|
||||
*/
|
||||
public List getFields() {
|
||||
public IField[] getFields() {
|
||||
if( definition == null ){
|
||||
checkForDefinition();
|
||||
if( definition == null )
|
||||
return null; //TODO IProblem
|
||||
return new IField [] { new CPPField.CPPFieldProblem( IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, getNameCharArray() ) };
|
||||
}
|
||||
|
||||
IASTDeclaration[] members = definition.getMembers();
|
||||
int size = members.length;
|
||||
List fields = new ArrayList( size );
|
||||
IField[] fields = new IField[ size ];
|
||||
if( size > 0 ){
|
||||
|
||||
for( int i = 0; i < size; i++ ){
|
||||
|
@ -151,7 +151,7 @@ public class CPPClassType implements ICPPClassType, ICPPBinding {
|
|||
IASTDeclarator declarator = declarators[i];
|
||||
IBinding binding = declarator.getName().resolveBinding();
|
||||
if( binding != null && binding instanceof IField )
|
||||
fields.add( binding );
|
||||
fields[i] = (IField) binding;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -303,7 +303,7 @@ public class CPPClassType implements ICPPClassType, ICPPBinding {
|
|||
if( definition == null ){
|
||||
checkForDefinition();
|
||||
if( definition == null ){
|
||||
return null; //TODO problem
|
||||
return new ICPPConstructor [] { new CPPConstructor.CPPConstructorProblem( IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, getNameCharArray() ) };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
|
@ -49,7 +50,7 @@ public class CPPCompositeBinding implements ICPPCompositeBinding {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
|
||||
*/
|
||||
public IScope getScope() {
|
||||
public IScope getScope() throws DOMException {
|
||||
return bindings[0].getScope();
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
*/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||
|
||||
|
@ -21,6 +22,15 @@ 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( int id, char[] arg ) {
|
||||
super( id, arg );
|
||||
}
|
||||
|
||||
public boolean isExplicit() throws DOMException{
|
||||
throw new DOMException( this );
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param declarator
|
||||
*/
|
||||
|
|
|
@ -17,6 +17,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
|
||||
|
@ -84,4 +85,17 @@ public class CPPEnumeration implements IEnumeration, ICPPBinding {
|
|||
return t;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IEnumeration#getEnumerators()
|
||||
*/
|
||||
public IEnumerator[] getEnumerators() {
|
||||
IASTEnumerationSpecifier.IASTEnumerator[] enums = enumSpecifier.getEnumerators();
|
||||
IEnumerator [] bindings = new IEnumerator [ enums.length ];
|
||||
|
||||
for( int i = 0; i < enums.length; i++ ){
|
||||
bindings[i] = (IEnumerator) enums[i].getName().resolveBinding();
|
||||
}
|
||||
return bindings;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
*/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||
|
||||
|
@ -20,6 +21,23 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
|||
* @author aniefer
|
||||
*/
|
||||
public class CPPField extends CPPVariable implements ICPPField, ICPPBinding {
|
||||
public static class CPPFieldProblem extends CPPVariable.CPPVariableProblem implements ICPPField {
|
||||
/**
|
||||
* @param id
|
||||
* @param arg
|
||||
*/
|
||||
public CPPFieldProblem( int id, char[] arg ) {
|
||||
super( id, arg );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMember#getVisibility()
|
||||
*/
|
||||
public int getVisibility() throws DOMException {
|
||||
throw new DOMException( this );
|
||||
}
|
||||
}
|
||||
|
||||
public CPPField( IASTDeclarator declarator ){
|
||||
super( declarator );
|
||||
}
|
||||
|
|
|
@ -13,22 +13,48 @@
|
|||
*/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
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.IASTParameterDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
|
||||
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.cpp.ICPPASTFunctionDeclarator;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPFunction implements IFunction, ICPPBinding {
|
||||
|
||||
public static class CPPFunctionProblem extends ProblemBinding implements IFunction {
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @param arg
|
||||
*/
|
||||
public CPPFunctionProblem( int id, char[] arg ) {
|
||||
super( id, arg );
|
||||
}
|
||||
|
||||
public IParameter[] getParameters() throws DOMException {
|
||||
throw new DOMException( this );
|
||||
}
|
||||
|
||||
public IScope getFunctionScope() throws DOMException {
|
||||
throw new DOMException( this );
|
||||
}
|
||||
|
||||
public IFunctionType getType() throws DOMException {
|
||||
throw new DOMException( this );
|
||||
}
|
||||
}
|
||||
|
||||
protected ICPPASTFunctionDeclarator [] declarations;
|
||||
protected ICPPASTFunctionDeclarator definition;
|
||||
protected IFunctionType type = null;
|
||||
|
|
|
@ -15,6 +15,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
|
@ -69,7 +70,7 @@ public class CPPFunctionScope extends CPPScope implements ICPPFunctionScope {
|
|||
return null;
|
||||
}
|
||||
|
||||
public IScope getParent() {
|
||||
public IScope getParent() throws DOMException {
|
||||
IASTFunctionDefinition fn = (IASTFunctionDefinition) getPhysicalNode();
|
||||
IFunction function = (IFunction) fn.getDeclarator().getName().resolveBinding();
|
||||
if( function instanceof ICPPMethod ){
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
*/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
|
||||
|
@ -36,16 +37,24 @@ public class CPPFunctionType implements IFunctionType {
|
|||
public boolean equals( Object o ){
|
||||
if( o instanceof IFunctionType ){
|
||||
IFunctionType ft = (IFunctionType) o;
|
||||
IType [] fps = ft.getParameterTypes();
|
||||
|
||||
IType [] fps;
|
||||
try {
|
||||
fps = ft.getParameterTypes();
|
||||
} catch ( DOMException e ) {
|
||||
return false;
|
||||
}
|
||||
if( fps.length != parameters.length )
|
||||
return false;
|
||||
|
||||
//constructors & destructors have null return type
|
||||
if( ( returnType == null ) ^ ( ft.getReturnType() == null ) )
|
||||
return false;
|
||||
else if( returnType != null && ! returnType.equals( ft.getReturnType() ) )
|
||||
try {
|
||||
//constructors & destructors have null return type
|
||||
if( ( returnType == null ) ^ ( ft.getReturnType() == null ) )
|
||||
return false;
|
||||
else if( returnType != null && ! returnType.equals( ft.getReturnType() ) )
|
||||
return false;
|
||||
} catch ( DOMException e1 ) {
|
||||
return false;
|
||||
}
|
||||
for( int i = 0; i < parameters.length; i++ )
|
||||
if( ! parameters[i].equals( fps[i] ) )
|
||||
return false;
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
*/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||
|
@ -32,11 +33,25 @@ import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
|||
*/
|
||||
public class CPPMethod extends CPPFunction implements ICPPMethod {
|
||||
|
||||
public static class CPPMethodProblem extends CPPFunctionProblem implements ICPPMethod {
|
||||
/**
|
||||
* @param id
|
||||
* @param arg
|
||||
*/
|
||||
public CPPMethodProblem( int id, char[] arg ) {
|
||||
super( id, arg );
|
||||
}
|
||||
|
||||
public int getVisibility() throws DOMException {
|
||||
throw new DOMException( this );
|
||||
}
|
||||
}
|
||||
|
||||
public CPPMethod( ICPPASTFunctionDeclarator declarator ){
|
||||
super( declarator );
|
||||
}
|
||||
|
||||
public IASTDeclaration getPrimaryDeclaration(){
|
||||
public IASTDeclaration getPrimaryDeclaration() throws DOMException{
|
||||
//first check if we already know it
|
||||
if( declarations != null ){
|
||||
for( int i = 0; i < declarations.length; i++ ){
|
||||
|
@ -76,7 +91,7 @@ public class CPPMethod extends CPPFunction implements ICPPMethod {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMember#getVisibility()
|
||||
*/
|
||||
public int getVisibility() {
|
||||
public int getVisibility() throws DOMException {
|
||||
IASTDeclaration decl = getPrimaryDeclaration();
|
||||
IASTCompositeTypeSpecifier cls = (IASTCompositeTypeSpecifier) decl.getParent();
|
||||
IASTDeclaration [] members = cls.getMembers();
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
*/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||
|
@ -47,7 +48,11 @@ public class CPPReferenceType implements ICPPReferenceType, ITypeContainer {
|
|||
return (obj == null);
|
||||
|
||||
if( obj instanceof ICPPReferenceType ){
|
||||
return type.equals( ((ICPPReferenceType) obj).getType() );
|
||||
try {
|
||||
return type.equals( ((ICPPReferenceType) obj).getType() );
|
||||
} catch ( DOMException e ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -13,14 +13,42 @@
|
|||
*/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
abstract public class CPPScope implements ICPPScope{
|
||||
public static class CPPScopeProblem extends ProblemBinding implements ICPPScope {
|
||||
public CPPScopeProblem( int id, char[] arg ) {
|
||||
super( id, arg );
|
||||
}
|
||||
public void addBinding( IBinding binding ) throws DOMException {
|
||||
throw new DOMException( this );
|
||||
}
|
||||
|
||||
public IBinding getBinding( IASTName name ) throws DOMException {
|
||||
throw new DOMException( this );
|
||||
}
|
||||
|
||||
public IScope getParent() throws DOMException {
|
||||
throw new DOMException( this );
|
||||
}
|
||||
|
||||
public List find( String name ) throws DOMException {
|
||||
throw new DOMException( this );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private IASTNode physicalNode;
|
||||
public CPPScope( IASTNode physicalNode ) {
|
||||
this.physicalNode = physicalNode;
|
||||
|
@ -29,11 +57,11 @@ abstract public class CPPScope implements ICPPScope{
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IScope#getParent()
|
||||
*/
|
||||
public IScope getParent() {
|
||||
public IScope getParent() throws DOMException {
|
||||
return CPPVisitor.getContainingScope( physicalNode );
|
||||
}
|
||||
|
||||
public IASTNode getPhysicalNode(){
|
||||
public IASTNode getPhysicalNode() throws DOMException{
|
||||
return physicalNode;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||
|
@ -199,7 +200,7 @@ public class CPPSemantics {
|
|||
public static final int USERDEFINED_CONVERSION_RANK = 4;
|
||||
public static final int ELLIPSIS_CONVERSION = 5;
|
||||
|
||||
public int compare( Cost cost ){
|
||||
public int compare( Cost cost ) throws DOMException{
|
||||
int result = 0;
|
||||
|
||||
if( rank != cost.rank ){
|
||||
|
@ -243,18 +244,26 @@ public class CPPSemantics {
|
|||
op1 = null;
|
||||
op2 = null;
|
||||
while( true ){
|
||||
if( t1 instanceof ITypedef )
|
||||
t1 = ((ITypedef)t1).getType();
|
||||
else {
|
||||
if( t1 instanceof ITypedef )
|
||||
try {
|
||||
t1 = ((ITypedef)t1).getType();
|
||||
} catch ( DOMException e ) {
|
||||
t1 = e.getProblem();
|
||||
}
|
||||
else {
|
||||
if( t1 instanceof IPointerType )
|
||||
op1 = (IPointerType) t1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
while( true ){
|
||||
if( t2 instanceof ITypedef )
|
||||
t2 = ((ITypedef)t2).getType();
|
||||
else {
|
||||
if( t2 instanceof ITypedef )
|
||||
try {
|
||||
t2 = ((ITypedef)t2).getType();
|
||||
} catch ( DOMException e ) {
|
||||
t2 = e.getProblem();
|
||||
}
|
||||
else {
|
||||
if( t2 instanceof IPointerType )
|
||||
op1 = (IPointerType) t2;
|
||||
break;
|
||||
|
@ -305,22 +314,35 @@ public class CPPSemantics {
|
|||
//1: get some context info off of the name to figure out what kind of lookup we want
|
||||
LookupData data = createLookupData( name );
|
||||
|
||||
//2: lookup
|
||||
lookup( data, name );
|
||||
try {
|
||||
//2: lookup
|
||||
lookup( data, name );
|
||||
} catch ( DOMException e1 ) {
|
||||
data.problem = (ProblemBinding) e1.getProblem();
|
||||
}
|
||||
|
||||
if( data.problem != null )
|
||||
return data.problem;
|
||||
|
||||
//3: resolve ambiguities
|
||||
IBinding binding = resolveAmbiguities( data, name );
|
||||
|
||||
//4: post processing
|
||||
IBinding binding;
|
||||
try {
|
||||
binding = resolveAmbiguities( data, name );
|
||||
} catch ( DOMException e2 ) {
|
||||
binding = e2.getProblem();
|
||||
}
|
||||
//4: post processing
|
||||
if( binding instanceof ICPPClassType && data.considerConstructors() ){
|
||||
ICPPClassType cls = (ICPPClassType) binding;
|
||||
//force resolution of constructor bindings
|
||||
cls.getConstructors();
|
||||
//then use the class scope to resolve which one.
|
||||
binding = ((ICPPClassScope)cls.getCompositeScope()).getBinding( name );
|
||||
try {
|
||||
//force resolution of constructor bindings
|
||||
cls.getConstructors();
|
||||
//then use the class scope to resolve which one.
|
||||
binding = ((ICPPClassScope)cls.getCompositeScope()).getBinding( name );
|
||||
} catch ( DOMException e ) {
|
||||
binding = e.getProblem();
|
||||
}
|
||||
|
||||
}
|
||||
if( binding != null && data.forDefinition() && !( binding instanceof IProblemBinding ) ){
|
||||
addDefinition( binding, name );
|
||||
|
@ -380,7 +402,7 @@ public class CPPSemantics {
|
|||
return data;
|
||||
}
|
||||
|
||||
static private ICPPScope getLookupScope( IASTName name ){
|
||||
static private ICPPScope getLookupScope( IASTName name ) throws DOMException{
|
||||
IASTNode parent = name.getParent();
|
||||
|
||||
if( parent instanceof ICPPASTBaseSpecifier ) {
|
||||
|
@ -395,7 +417,7 @@ public class CPPSemantics {
|
|||
return (ICPPScope) CPPVisitor.getContainingScope( name );
|
||||
}
|
||||
|
||||
static private void lookup( CPPSemantics.LookupData data, IASTName name ){
|
||||
static private void lookup( CPPSemantics.LookupData data, IASTName name ) throws DOMException{
|
||||
IASTNode node = name;
|
||||
|
||||
ICPPScope scope = getLookupScope( name );
|
||||
|
@ -458,7 +480,7 @@ public class CPPSemantics {
|
|||
}
|
||||
}
|
||||
|
||||
private static List lookupInParents( CPPSemantics.LookupData data, ICPPClassScope lookIn ){
|
||||
private static List lookupInParents( CPPSemantics.LookupData data, ICPPClassScope lookIn ) throws DOMException{
|
||||
ICPPASTCompositeTypeSpecifier compositeTypeSpec = (ICPPASTCompositeTypeSpecifier) lookIn.getPhysicalNode();
|
||||
ICPPASTBaseSpecifier [] bases = compositeTypeSpec.getBaseSpecifiers();
|
||||
|
||||
|
@ -559,7 +581,7 @@ public class CPPSemantics {
|
|||
return false;
|
||||
}
|
||||
|
||||
static private void processDirectives( CPPSemantics.LookupData data, IScope scope, List directives ){
|
||||
static private void processDirectives( CPPSemantics.LookupData data, IScope scope, List directives ) throws DOMException{
|
||||
if( directives == null || directives.size() == 0 )
|
||||
return;
|
||||
|
||||
|
@ -596,7 +618,7 @@ public class CPPSemantics {
|
|||
|
||||
}
|
||||
|
||||
static private ICPPScope getClosestEnclosingScope( IScope scope1, IScope scope2 ){
|
||||
static private ICPPScope getClosestEnclosingScope( IScope scope1, IScope scope2 ) throws DOMException{
|
||||
ObjectSet set = new ObjectSet( 2 );
|
||||
IScope parent = scope1;
|
||||
while( parent != null ){
|
||||
|
@ -614,8 +636,9 @@ public class CPPSemantics {
|
|||
*
|
||||
* @param scope
|
||||
* @return List of encountered using directives
|
||||
* @throws DOMException
|
||||
*/
|
||||
static private List lookupInScope( CPPSemantics.LookupData data, ICPPScope scope, IASTNode blockItem, List usingDirectives ) {
|
||||
static private List lookupInScope( CPPSemantics.LookupData data, ICPPScope scope, IASTNode blockItem, List usingDirectives ) throws DOMException {
|
||||
IASTName possible = null;
|
||||
IASTNode [] nodes = null;
|
||||
IASTNode parent = scope.getPhysicalNode();
|
||||
|
@ -691,7 +714,7 @@ public class CPPSemantics {
|
|||
return found;
|
||||
}
|
||||
|
||||
static private List lookupInNominated( CPPSemantics.LookupData data, ICPPScope scope, List transitives ){
|
||||
static private List lookupInNominated( CPPSemantics.LookupData data, ICPPScope scope, List transitives ) throws DOMException{
|
||||
if( data.usingDirectives.isEmpty() )
|
||||
return transitives;
|
||||
|
||||
|
@ -859,7 +882,11 @@ public class CPPSemantics {
|
|||
|
||||
LookupData data = createLookupData( name );
|
||||
data.foundItems = bindings;
|
||||
return resolveAmbiguities( data, name );
|
||||
try {
|
||||
return resolveAmbiguities( data, name );
|
||||
} catch ( DOMException e ) {
|
||||
return e.getProblem();
|
||||
}
|
||||
}
|
||||
|
||||
static private boolean declaredBefore( IBinding binding, IASTNode node ){
|
||||
|
@ -876,7 +903,7 @@ public class CPPSemantics {
|
|||
return false;
|
||||
}
|
||||
|
||||
static private IBinding resolveAmbiguities( CPPSemantics.LookupData data, IASTName name ) {
|
||||
static private IBinding resolveAmbiguities( CPPSemantics.LookupData data, IASTName name ) throws DOMException {
|
||||
if( data.foundItems == null || data.foundItems.size() == 0 )
|
||||
return null;
|
||||
|
||||
|
@ -942,7 +969,7 @@ public class CPPSemantics {
|
|||
return obj;
|
||||
}
|
||||
|
||||
static private boolean functionHasParameters( IFunction function, IASTParameterDeclaration [] params ){
|
||||
static private boolean functionHasParameters( IFunction function, IASTParameterDeclaration [] params ) throws DOMException{
|
||||
IFunctionType ftype = function.getType();
|
||||
if( params.length == 0 ){
|
||||
return ftype.getParameterTypes().length == 0;
|
||||
|
@ -956,7 +983,7 @@ public class CPPSemantics {
|
|||
return false;
|
||||
}
|
||||
|
||||
static private void reduceToViable( LookupData data, List functions ){
|
||||
static private void reduceToViable( LookupData data, List functions ) throws DOMException{
|
||||
Object [] fParams = data.functionParameters;
|
||||
int numParameters = ( fParams != null ) ? fParams.length : 0;
|
||||
int num;
|
||||
|
@ -1047,7 +1074,7 @@ public class CPPSemantics {
|
|||
return VOID_TYPE;
|
||||
return null;
|
||||
}
|
||||
static private IBinding resolveFunction( CPPSemantics.LookupData data, List fns ){
|
||||
static private IBinding resolveFunction( CPPSemantics.LookupData data, List fns ) throws DOMException{
|
||||
if( data.forUsingDeclaration() ){
|
||||
if( fns.size() == 1 )
|
||||
return (IBinding) fns.get( 0 );
|
||||
|
@ -1209,7 +1236,7 @@ public class CPPSemantics {
|
|||
return bestFn;
|
||||
}
|
||||
|
||||
static private Cost checkStandardConversionSequence( IType source, IType target ) {
|
||||
static private Cost checkStandardConversionSequence( IType source, IType target ) throws DOMException {
|
||||
Cost cost = lvalue_to_rvalue( source, target );
|
||||
|
||||
if( cost.source == null || cost.target == null ){
|
||||
|
@ -1250,7 +1277,7 @@ public class CPPSemantics {
|
|||
return cost;
|
||||
}
|
||||
|
||||
static private Cost checkUserDefinedConversionSequence( IType source, IType target ) {
|
||||
static private Cost checkUserDefinedConversionSequence( IType source, IType target ) throws DOMException {
|
||||
Cost cost = null;
|
||||
Cost constructorCost = null;
|
||||
Cost conversionCost = null;
|
||||
|
@ -1320,18 +1347,22 @@ public class CPPSemantics {
|
|||
}
|
||||
|
||||
static protected IType getUltimateType( IType type ){
|
||||
while( true ){
|
||||
if( type instanceof ITypedef )
|
||||
type = ((ITypedef)type).getType();
|
||||
else if( type instanceof IQualifierType )
|
||||
type = ((IQualifierType)type).getType();
|
||||
else if( type instanceof IPointerType )
|
||||
type = ((IPointerType) type).getType();
|
||||
else if( type instanceof ICPPReferenceType )
|
||||
type = ((ICPPReferenceType)type).getType();
|
||||
else
|
||||
return type;
|
||||
}
|
||||
try {
|
||||
while( true ){
|
||||
if( type instanceof ITypedef )
|
||||
type = ((ITypedef)type).getType();
|
||||
else if( type instanceof IQualifierType )
|
||||
type = ((IQualifierType)type).getType();
|
||||
else if( type instanceof IPointerType )
|
||||
type = ((IPointerType) type).getType();
|
||||
else if( type instanceof ICPPReferenceType )
|
||||
type = ((ICPPReferenceType)type).getType();
|
||||
else
|
||||
return type;
|
||||
}
|
||||
} catch ( DOMException e ) {
|
||||
return e.getProblem();
|
||||
}
|
||||
}
|
||||
|
||||
static private boolean isCompleteType( IType type ){
|
||||
|
@ -1341,7 +1372,7 @@ public class CPPSemantics {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
static private Cost lvalue_to_rvalue( IType source, IType target ){
|
||||
static private Cost lvalue_to_rvalue( IType source, IType target ) throws DOMException{
|
||||
Cost cost = new Cost( source, target );
|
||||
|
||||
if( ! isCompleteType( source ) ){
|
||||
|
@ -1363,7 +1394,7 @@ public class CPPSemantics {
|
|||
return cost;
|
||||
}
|
||||
|
||||
static private void qualificationConversion( Cost cost ){
|
||||
static private void qualificationConversion( Cost cost ) throws DOMException{
|
||||
boolean canConvert = true;
|
||||
|
||||
IPointerType op1, op2;
|
||||
|
@ -1441,8 +1472,9 @@ public class CPPSemantics {
|
|||
* following that can hold it: int, unsigned int, long unsigned long.
|
||||
* 4.5-4 bool can be promoted to int
|
||||
* 4.6 float can be promoted to double
|
||||
* @throws DOMException
|
||||
*/
|
||||
static private void promotion( Cost cost ){
|
||||
static private void promotion( Cost cost ) throws DOMException{
|
||||
IType src = getUltimateType( cost.source );
|
||||
IType trg = getUltimateType( cost.target );
|
||||
|
||||
|
@ -1467,7 +1499,7 @@ public class CPPSemantics {
|
|||
|
||||
cost.rank = (cost.promotion > 0 ) ? Cost.PROMOTION_RANK : Cost.NO_MATCH_RANK;
|
||||
}
|
||||
static private void conversion( Cost cost ){
|
||||
static private void conversion( Cost cost ) throws DOMException{
|
||||
IType src = cost.source;
|
||||
IType trg = cost.target;
|
||||
|
||||
|
@ -1530,7 +1562,7 @@ public class CPPSemantics {
|
|||
|
||||
}
|
||||
|
||||
static private void derivedToBaseConversion( Cost cost ) {
|
||||
static private void derivedToBaseConversion( Cost cost ) throws DOMException {
|
||||
IType s = getUltimateType( cost.source );
|
||||
IType t = getUltimateType( cost.target );
|
||||
|
||||
|
@ -1544,7 +1576,7 @@ public class CPPSemantics {
|
|||
}
|
||||
}
|
||||
|
||||
static private int hasBaseClass( ICPPClassType symbol, ICPPClassType base, boolean needVisibility ) {
|
||||
static private int hasBaseClass( ICPPClassType symbol, ICPPClassType base, boolean needVisibility ) throws DOMException {
|
||||
if( symbol == base ){
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
*/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
|
@ -52,7 +53,11 @@ public class CPPTypedef implements ITypedef, ITypeContainer, ICPPBinding {
|
|||
|
||||
public boolean equals( Object o ){
|
||||
if( o instanceof ITypedef )
|
||||
return getType().equals( ((ITypedef)o).getType());
|
||||
try {
|
||||
return getType().equals( ((ITypedef)o).getType());
|
||||
} catch ( DOMException e ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !( o instanceof IType ) )
|
||||
return false;
|
||||
|
|
|
@ -13,16 +13,28 @@
|
|||
*/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPVariable implements IVariable, ICPPBinding {
|
||||
public static class CPPVariableProblem extends ProblemBinding implements IVariable{
|
||||
public CPPVariableProblem( int id, char[] arg ) {
|
||||
super( id, arg );
|
||||
}
|
||||
|
||||
public IType getType() throws DOMException {
|
||||
throw new DOMException( this );
|
||||
}
|
||||
|
||||
}
|
||||
private IASTDeclarator declarator = null;
|
||||
private IType type = null;
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression;
|
||||
|
@ -171,45 +172,69 @@ public class CPPVisitor {
|
|||
private static IBinding createBinding( IASTGotoStatement gotoStatement ) {
|
||||
ICPPFunctionScope functionScope = (ICPPFunctionScope) getContainingScope( gotoStatement );
|
||||
IASTName name = gotoStatement.getName();
|
||||
IBinding binding = functionScope.getBinding( name );
|
||||
if( binding == null ){
|
||||
binding = new CPPLabel( gotoStatement );
|
||||
functionScope.addBinding( binding );
|
||||
}
|
||||
IBinding binding;
|
||||
try {
|
||||
binding = functionScope.getBinding( name );
|
||||
if( binding == null ){
|
||||
binding = new CPPLabel( gotoStatement );
|
||||
functionScope.addBinding( binding );
|
||||
}
|
||||
} catch ( DOMException e ) {
|
||||
binding = e.getProblem();
|
||||
}
|
||||
|
||||
return binding;
|
||||
}
|
||||
|
||||
private static IBinding createBinding( IASTLabelStatement labelStatement ) {
|
||||
ICPPFunctionScope functionScope = (ICPPFunctionScope) getContainingScope( labelStatement );
|
||||
IASTName name = labelStatement.getName();
|
||||
IBinding binding = functionScope.getBinding( name );
|
||||
if( binding == null ){
|
||||
binding = new CPPLabel( labelStatement );
|
||||
functionScope.addBinding( binding );
|
||||
} else {
|
||||
((CPPLabel)binding).setLabelStatement( labelStatement );
|
||||
}
|
||||
IBinding binding;
|
||||
try {
|
||||
binding = functionScope.getBinding( name );
|
||||
if( binding == null ){
|
||||
binding = new CPPLabel( labelStatement );
|
||||
functionScope.addBinding( binding );
|
||||
} else {
|
||||
((CPPLabel)binding).setLabelStatement( labelStatement );
|
||||
}
|
||||
} catch ( DOMException e ) {
|
||||
binding = e.getProblem();
|
||||
}
|
||||
|
||||
return binding;
|
||||
}
|
||||
|
||||
private static IBinding createBinding( IASTEnumerator enumerator ) {
|
||||
ICPPScope scope = (ICPPScope) getContainingScope( enumerator );
|
||||
IBinding enumtor = scope.getBinding( enumerator.getName() );
|
||||
if( enumtor == null ){
|
||||
enumtor = new CPPEnumerator( enumerator );
|
||||
scope.addBinding( enumtor );
|
||||
IBinding enumtor;
|
||||
try {
|
||||
enumtor = scope.getBinding( enumerator.getName() );
|
||||
if( enumtor == null ){
|
||||
enumtor = new CPPEnumerator( enumerator );
|
||||
scope.addBinding( enumtor );
|
||||
}
|
||||
} catch ( DOMException e ) {
|
||||
enumtor = e.getProblem();
|
||||
}
|
||||
|
||||
return enumtor;
|
||||
}
|
||||
|
||||
|
||||
private static IBinding createBinding( IASTEnumerationSpecifier specifier ) {
|
||||
ICPPScope scope = (ICPPScope) getContainingScope( specifier );
|
||||
IBinding enumeration = scope.getBinding( specifier.getName() );
|
||||
if( enumeration == null ){
|
||||
enumeration = new CPPEnumeration( specifier );
|
||||
scope.addBinding( enumeration );
|
||||
IBinding enumeration;
|
||||
try {
|
||||
enumeration = scope.getBinding( specifier.getName() );
|
||||
if( enumeration == null ){
|
||||
enumeration = new CPPEnumeration( specifier );
|
||||
scope.addBinding( enumeration );
|
||||
}
|
||||
} catch ( DOMException e ) {
|
||||
enumeration = e.getProblem();
|
||||
}
|
||||
|
||||
return enumeration;
|
||||
}
|
||||
|
||||
|
@ -227,14 +252,20 @@ public class CPPVisitor {
|
|||
}
|
||||
|
||||
ICPPScope scope = (ICPPScope) getContainingScope( elabType );
|
||||
CPPClassType binding = (CPPClassType) scope.getBinding( elabType.getName() );
|
||||
if( binding == null ){
|
||||
if( elabType.getKind() != IASTElaboratedTypeSpecifier.k_enum )
|
||||
binding = new CPPClassType( elabType );
|
||||
scope.addBinding( binding );
|
||||
} else {
|
||||
binding.addDeclaration( elabType );
|
||||
}
|
||||
IBinding binding;
|
||||
try {
|
||||
binding = scope.getBinding( elabType.getName() );
|
||||
if( binding == null ){
|
||||
if( elabType.getKind() != IASTElaboratedTypeSpecifier.k_enum )
|
||||
binding = new CPPClassType( elabType );
|
||||
scope.addBinding( binding );
|
||||
} else {
|
||||
((CPPClassType)binding).addDeclaration( elabType );
|
||||
}
|
||||
} catch ( DOMException e ) {
|
||||
binding = e.getProblem();
|
||||
}
|
||||
|
||||
return binding;
|
||||
}
|
||||
private static IBinding createBinding( ICPPASTCompositeTypeSpecifier compType ){
|
||||
|
@ -244,24 +275,35 @@ public class CPPVisitor {
|
|||
name = ns[ ns.length - 1 ];
|
||||
}
|
||||
ICPPScope scope = (ICPPScope) getContainingScope( name );
|
||||
IBinding binding = scope.getBinding( compType.getName() );
|
||||
if( binding == null || !(binding instanceof ICPPClassType) ){
|
||||
binding = new CPPClassType( compType );
|
||||
scope.addBinding( binding );
|
||||
} else {
|
||||
((CPPClassType)binding).addDefinition( compType );
|
||||
}
|
||||
IBinding binding;
|
||||
try {
|
||||
binding = scope.getBinding( compType.getName() );
|
||||
if( binding == null || !(binding instanceof ICPPClassType) ){
|
||||
binding = new CPPClassType( compType );
|
||||
scope.addBinding( binding );
|
||||
} else {
|
||||
((CPPClassType)binding).addDefinition( compType );
|
||||
}
|
||||
} catch ( DOMException e ) {
|
||||
binding = e.getProblem();
|
||||
}
|
||||
|
||||
return binding;
|
||||
}
|
||||
private static IBinding createBinding( IASTDeclaration declaration ){
|
||||
if( declaration instanceof ICPPASTNamespaceDefinition ){
|
||||
ICPPASTNamespaceDefinition namespaceDef = (ICPPASTNamespaceDefinition) declaration;
|
||||
ICPPScope scope = (ICPPScope) getContainingScope( namespaceDef );
|
||||
CPPNamespace binding = (CPPNamespace) scope.getBinding( namespaceDef.getName() );
|
||||
if( binding == null ){
|
||||
binding = new CPPNamespace( namespaceDef.getName() );
|
||||
scope.addBinding( binding );
|
||||
}
|
||||
IBinding binding;
|
||||
try {
|
||||
binding = scope.getBinding( namespaceDef.getName() );
|
||||
if( binding == null ){
|
||||
binding = new CPPNamespace( namespaceDef.getName() );
|
||||
scope.addBinding( binding );
|
||||
}
|
||||
} catch ( DOMException e ) {
|
||||
binding = e.getProblem();
|
||||
}
|
||||
return binding;
|
||||
} else if( declaration instanceof ICPPASTUsingDirective ){
|
||||
return CPPSemantics.resolveBinding( ((ICPPASTUsingDirective) declaration).getQualifiedName() );
|
||||
|
@ -288,21 +330,30 @@ public class CPPVisitor {
|
|||
}
|
||||
|
||||
ICPPScope scope = (ICPPScope) getContainingScope( parent );
|
||||
IBinding binding = ( scope != null ) ? scope.getBinding( declarator.getName() ) : null;
|
||||
|
||||
if( declarator instanceof ICPPASTFunctionDeclarator ){
|
||||
IBinding binding;
|
||||
try {
|
||||
binding = ( scope != null ) ? scope.getBinding( declarator.getName() ) : null;
|
||||
} catch ( DOMException e ) {
|
||||
binding = null;
|
||||
}
|
||||
|
||||
if( declarator instanceof ICPPASTFunctionDeclarator ){
|
||||
if( binding != null && binding instanceof IFunction ){
|
||||
IFunction function = (IFunction) binding;
|
||||
IFunctionType ftype = function.getType();
|
||||
IType type = createType( declarator );
|
||||
if( ftype.equals( type ) ){
|
||||
if( parent instanceof IASTSimpleDeclaration )
|
||||
((CPPFunction)function).addDeclaration( (ICPPASTFunctionDeclarator) declarator );
|
||||
else
|
||||
((CPPFunction)function).addDefinition( (ICPPASTFunctionDeclarator) declarator );
|
||||
|
||||
return function;
|
||||
}
|
||||
IFunctionType ftype;
|
||||
try {
|
||||
ftype = function.getType();
|
||||
IType type = createType( declarator );
|
||||
if( ftype.equals( type ) ){
|
||||
if( parent instanceof IASTSimpleDeclaration )
|
||||
((CPPFunction)function).addDeclaration( (ICPPASTFunctionDeclarator) declarator );
|
||||
else
|
||||
((CPPFunction)function).addDefinition( (ICPPASTFunctionDeclarator) declarator );
|
||||
|
||||
return function;
|
||||
}
|
||||
} catch ( DOMException e1 ) {
|
||||
}
|
||||
}
|
||||
if( scope instanceof ICPPClassScope ){
|
||||
if( isConstructor( scope, declarator) )
|
||||
|
@ -328,8 +379,13 @@ public class CPPVisitor {
|
|||
}
|
||||
}
|
||||
|
||||
if( scope != null && binding != null )
|
||||
scope.addBinding( binding );
|
||||
if( scope != null && binding != null ){
|
||||
try {
|
||||
scope.addBinding( binding );
|
||||
} catch ( DOMException e1 ) {
|
||||
}
|
||||
}
|
||||
|
||||
return binding;
|
||||
}
|
||||
|
||||
|
@ -337,8 +393,13 @@ public class CPPVisitor {
|
|||
if( containingScope == null || !(containingScope instanceof ICPPClassScope) )
|
||||
return false;
|
||||
|
||||
ICPPASTCompositeTypeSpecifier clsTypeSpec = (ICPPASTCompositeTypeSpecifier) ((ICPPClassScope)containingScope).getPhysicalNode();
|
||||
return isConstructor( clsTypeSpec.getName(), declarator );
|
||||
ICPPASTCompositeTypeSpecifier clsTypeSpec;
|
||||
try {
|
||||
clsTypeSpec = (ICPPASTCompositeTypeSpecifier) ((ICPPClassScope)containingScope).getPhysicalNode();
|
||||
} catch ( DOMException e ) {
|
||||
return false;
|
||||
}
|
||||
return isConstructor( clsTypeSpec.getName(), declarator );
|
||||
}
|
||||
public static boolean isConstructor( IASTName parentName, IASTDeclarator declarator ){
|
||||
if( declarator == null || !(declarator instanceof IASTFunctionDeclarator) )
|
||||
|
@ -407,26 +468,30 @@ public class CPPVisitor {
|
|||
}
|
||||
public static IScope getContainingScope( IASTName name ){
|
||||
IASTNode parent = name.getParent();
|
||||
if( parent instanceof ICPPASTQualifiedName ){
|
||||
IASTName [] names = ((ICPPASTQualifiedName) parent).getNames();
|
||||
int i = 0;
|
||||
for( ; i < names.length; i++ ){
|
||||
if( names[i] == name ) break;
|
||||
}
|
||||
if( i > 0 ){
|
||||
IBinding binding = names[i - 1].resolveBinding();
|
||||
if( binding instanceof ICPPClassType ){
|
||||
return ((ICPPClassType)binding).getCompositeScope();
|
||||
} else if( binding instanceof ICPPNamespace ){
|
||||
return ((ICPPNamespace)binding).getNamespaceScope();
|
||||
try {
|
||||
if( parent instanceof ICPPASTQualifiedName ){
|
||||
IASTName [] names = ((ICPPASTQualifiedName) parent).getNames();
|
||||
int i = 0;
|
||||
for( ; i < names.length; i++ ){
|
||||
if( names[i] == name ) break;
|
||||
}
|
||||
if( i > 0 ){
|
||||
IBinding binding = names[i - 1].resolveBinding();
|
||||
if( binding instanceof ICPPClassType ){
|
||||
return ((ICPPClassType)binding).getCompositeScope();
|
||||
} else if( binding instanceof ICPPNamespace ){
|
||||
return ((ICPPNamespace)binding).getNamespaceScope();
|
||||
}
|
||||
}
|
||||
} else if( parent instanceof ICPPASTFieldReference ){
|
||||
IASTExpression owner = ((ICPPASTFieldReference)parent).getFieldOwner();
|
||||
IType type = CPPSemantics.getUltimateType( getExpressionType( owner ) );
|
||||
if( type instanceof ICPPClassType ){
|
||||
return ((ICPPClassType) type).getCompositeScope();
|
||||
}
|
||||
}
|
||||
} else if( parent instanceof ICPPASTFieldReference ){
|
||||
IASTExpression owner = ((ICPPASTFieldReference)parent).getFieldOwner();
|
||||
IType type = CPPSemantics.getUltimateType( getExpressionType( owner ) );
|
||||
if( type instanceof ICPPClassType ){
|
||||
return ((ICPPClassType) type).getCompositeScope();
|
||||
}
|
||||
} catch( DOMException e ){
|
||||
return e.getProblem();
|
||||
}
|
||||
return getContainingScope( parent );
|
||||
}
|
||||
|
@ -462,13 +527,21 @@ public class CPPVisitor {
|
|||
} else if( parent instanceof IASTFunctionDefinition ){
|
||||
IASTFunctionDeclarator fnDeclarator = ((IASTFunctionDefinition) parent ).getDeclarator();
|
||||
IFunction function = (IFunction) fnDeclarator.getName().resolveBinding();
|
||||
scope = function.getFunctionScope();
|
||||
try {
|
||||
scope = function.getFunctionScope();
|
||||
} catch ( DOMException e ) {
|
||||
return e.getProblem();
|
||||
}
|
||||
}
|
||||
|
||||
if( statement instanceof IASTGotoStatement || statement instanceof IASTLabelStatement ){
|
||||
//labels have function scope
|
||||
while( scope != null && !(scope instanceof ICPPFunctionScope) ){
|
||||
scope = scope.getParent();
|
||||
try {
|
||||
scope = scope.getParent();
|
||||
} catch ( DOMException e ) {
|
||||
return e.getProblem();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1127,11 +1200,19 @@ public class CPPVisitor {
|
|||
|
||||
ArrayList temp = new ArrayList();
|
||||
for( int i = 0; i < parameters.length; i++ ){
|
||||
pt = parameters[i].getType();
|
||||
try {
|
||||
pt = parameters[i].getType();
|
||||
} catch ( DOMException e ) {
|
||||
pt = e.getProblem();
|
||||
}
|
||||
|
||||
temp.add( pt.clone() );
|
||||
while( pt instanceof ITypeContainer){
|
||||
pt = ((ITypeContainer)pt).getType();
|
||||
try {
|
||||
pt = ((ITypeContainer)pt).getType();
|
||||
} catch ( DOMException e1 ) {
|
||||
pt = e1.getProblem();
|
||||
}
|
||||
if( pt instanceof ITypeContainer && !(pt instanceof ITypedef) ){
|
||||
IType t = (IType) pt.clone();
|
||||
((ITypeContainer) temp.get( temp.size() - 1 )).setType( t );
|
||||
|
@ -1152,7 +1233,11 @@ public class CPPVisitor {
|
|||
|
||||
IType lastType = (IType) temp.get( lastIdx );
|
||||
if( lastType instanceof IArrayType ){
|
||||
lastType = new CPPPointerType( ((IArrayType) lastType).getType() );
|
||||
try {
|
||||
lastType = new CPPPointerType( ((IArrayType) lastType).getType() );
|
||||
} catch ( DOMException e1 ) {
|
||||
lastType = e1.getProblem();
|
||||
}
|
||||
} else if( lastType instanceof IFunctionType ){
|
||||
lastType = new CPPPointerType( lastType );
|
||||
}
|
||||
|
@ -1181,7 +1266,11 @@ public class CPPVisitor {
|
|||
//any parameter of type array of T is adjusted to be pointer to T
|
||||
if( pt instanceof IArrayType ){
|
||||
IArrayType at = (IArrayType) pt;
|
||||
pt = new CPPPointerType( at.getType() );
|
||||
try {
|
||||
pt = new CPPPointerType( at.getType() );
|
||||
} catch ( DOMException e ) {
|
||||
pt = e.getProblem();
|
||||
}
|
||||
}
|
||||
|
||||
//any parameter to type function returning T is adjusted to be pointer to function
|
||||
|
@ -1316,7 +1405,11 @@ public class CPPVisitor {
|
|||
if( expression instanceof IASTIdExpression ){
|
||||
IBinding binding = resolveBinding( expression );
|
||||
if( binding instanceof IVariable ){
|
||||
return ((IVariable)binding).getType();
|
||||
try {
|
||||
return ((IVariable)binding).getType();
|
||||
} catch ( DOMException e ) {
|
||||
return e.getProblem();
|
||||
}
|
||||
}
|
||||
} else if( expression instanceof IASTCastExpression ){
|
||||
IASTTypeId id = ((IASTCastExpression)expression).getTypeId();
|
||||
|
@ -1342,9 +1435,15 @@ public class CPPVisitor {
|
|||
} else if( expression instanceof IASTFunctionCallExpression ){
|
||||
IBinding binding = resolveBinding( expression );
|
||||
if( binding instanceof IFunction ){
|
||||
IFunctionType fType = ((IFunction)binding).getType();
|
||||
if( fType != null )
|
||||
return fType.getReturnType();
|
||||
IFunctionType fType;
|
||||
try {
|
||||
fType = ((IFunction)binding).getType();
|
||||
if( fType != null )
|
||||
return fType.getReturnType();
|
||||
} catch ( DOMException e ) {
|
||||
return e.getProblem();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else if( expression instanceof IASTUnaryExpression )
|
||||
|
|
Loading…
Add table
Reference in a new issue