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

added more exception handling in model

This commit is contained in:
David Inglis 2004-04-20 16:13:11 +00:00
parent 0b7e5958f2
commit a16487b5bd
44 changed files with 432 additions and 305 deletions

View file

@ -1,3 +1,6 @@
2004-04-20 David Inglis
The CoreModel interfaces throw much more exception, we need to log them for errors.
2004-04-19 Alain Magloire 2004-04-19 Alain Magloire
The CoreModel interfaces throw much more exception, we need to log them for errors. The CoreModel interfaces throw much more exception, we need to log them for errors.

View file

@ -502,7 +502,7 @@ public class CModelElementsTests extends TestCase {
assertEquals(startLine, element.getStartLine()); assertEquals(startLine, element.getStartLine());
assertEquals(endLine, element.getEndLine()); assertEquals(endLine, element.getEndLine());
} }
private void checkElementOffset(CElement element){ private void checkElementOffset(CElement element) throws CModelException{
if(element.getElementName().length() > 0 ){ if(element.getElementName().length() > 0 ){
assertTrue (element.getStartPos() <= element.getIdStartPos()); assertTrue (element.getStartPos() <= element.getIdStartPos());
assertEquals (element.getIdLength(), element.getElementName().length()); assertEquals (element.getIdLength(), element.getElementName().length());

View file

@ -208,7 +208,7 @@ public class IStructureTests extends IntegratedCModelTest {
} }
} }
public void testIsUnion() { public void testIsUnion() throws CModelException {
ITranslationUnit tu = getTU(); ITranslationUnit tu = getTU();
ICElement myElementUnion = null; ICElement myElementUnion = null;
ICElement myElementNonUnion = null; ICElement myElementNonUnion = null;
@ -232,7 +232,7 @@ public class IStructureTests extends IntegratedCModelTest {
assertNotNull( myStructNonUnion ); assertNotNull( myStructNonUnion );
assertFalse( myStructNonUnion.isUnion() ); assertFalse( myStructNonUnion.isUnion() );
} }
public void testIsStruct() { public void testIsStruct() throws CModelException {
ITranslationUnit tu = getTU(); ITranslationUnit tu = getTU();
ICElement myElementStruct = null; ICElement myElementStruct = null;
ICElement myElementNonStruct = null; ICElement myElementNonStruct = null;
@ -257,7 +257,7 @@ public class IStructureTests extends IntegratedCModelTest {
assertFalse( myStructNonStruct.isStruct() ); assertFalse( myStructNonStruct.isStruct() );
} }
public void testIsClass() { public void testIsClass() throws CModelException {
ITranslationUnit tu = getTU(); ITranslationUnit tu = getTU();
ICElement myElementClass = null; ICElement myElementClass = null;
ICElement myElementNonClass = null; ICElement myElementNonClass = null;

View file

@ -1,3 +1,10 @@
2004-04-20 David Inglis
Added more CModelException throwing in model essentially if the model fails to create
a info an exception is thrown, it we *not* return null.
to many files changes to list here.....
2004-04-20 Alain Magloire 2004-04-20 Alain Magloire
Fix for PR 59081 Fix for PR 59081

View file

@ -35,13 +35,17 @@ public interface ICProject extends IParent, IOpenable, ICElement {
/** /**
* Return the ArchiveContainer of this Project. * Return the ArchiveContainer of this Project.
* @return
* @throws CModelException
*/ */
IArchiveContainer getArchiveContainer(); IArchiveContainer getArchiveContainer() throws CModelException;
/** /**
* Return the BinaryContainer of this Project. * Return the BinaryContainer of this Project.
* @return
* @throws CModelException
*/ */
IBinaryContainer getBinaryContainer(); IBinaryContainer getBinaryContainer() throws CModelException;
/** /**
* Returns the source root folders of the project. * Returns the source root folders of the project.

View file

@ -12,7 +12,25 @@ package org.eclipse.cdt.core.model;
***********************************************************************/ ***********************************************************************/
public interface IDeclaration extends ICElement, ISourceManipulation, ISourceReference { public interface IDeclaration extends ICElement, ISourceManipulation, ISourceReference {
boolean isStatic();
boolean isConst(); /**
boolean isVolatile(); *
* @return
* @throws CModelException
*/
boolean isStatic() throws CModelException;
/**
*
* @return
* @throws CModelException
*/
boolean isConst() throws CModelException;
/**
*
* @return
* @throws CModelException
*/
boolean isVolatile() throws CModelException;
} }

View file

@ -16,5 +16,5 @@ public interface IField extends IMember, IVariableDeclaration {
* @exception CModelException if this element does not exist or if an * @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource. * exception occurs while accessing its corresponding resource.
*/ */
public boolean isMutable(); public boolean isMutable() throws CModelException;
} }

View file

@ -62,5 +62,5 @@ public interface IFunctionDeclaration extends IDeclaration {
/** /**
* Returns the signature of the method. * Returns the signature of the method.
*/ */
String getSignature(); String getSignature() throws CModelException;
} }

View file

@ -19,6 +19,6 @@ public interface IMember extends IDeclaration {
* V_PRIVATE = 0 V_PROTECTED = 1 V_PUBLIC = 2 * V_PRIVATE = 0 V_PROTECTED = 1 V_PUBLIC = 2
* @return int * @return int
*/ */
public ASTAccessVisibility getVisibility(); public ASTAccessVisibility getVisibility() throws CModelException;
} }

View file

@ -16,7 +16,7 @@ public interface IMethodDeclaration extends IMember, IFunctionDeclaration {
* @exception CModelException if this element does not exist or if an * @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource. * exception occurs while accessing its corresponding resource.
*/ */
boolean isConstructor(); boolean isConstructor() throws CModelException;
/** /**
* Returns whether this method is a destructor. * Returns whether this method is a destructor.
@ -24,7 +24,7 @@ public interface IMethodDeclaration extends IMember, IFunctionDeclaration {
* @exception CModelException if this element does not exist or if an * @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource. * exception occurs while accessing its corresponding resource.
*/ */
boolean isDestructor(); boolean isDestructor() throws CModelException;
/** /**
* Returns whether this method is an operator method. * Returns whether this method is an operator method.
@ -32,7 +32,7 @@ public interface IMethodDeclaration extends IMember, IFunctionDeclaration {
* @exception CModelException if this element does not exist or if an * @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource. * exception occurs while accessing its corresponding resource.
*/ */
boolean isOperator(); boolean isOperator() throws CModelException;
/** /**
* Returns whether this method is declared pure virtual. * Returns whether this method is declared pure virtual.
@ -42,19 +42,19 @@ public interface IMethodDeclaration extends IMember, IFunctionDeclaration {
* @exception CModelException if this element does not exist or if an * @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource. * exception occurs while accessing its corresponding resource.
*/ */
boolean isPureVirtual(); boolean isPureVirtual() throws CModelException;
/** /**
* Returns if this method is static or not * Returns if this method is static or not
* @return boolean * @return boolean
*/ */
public boolean isStatic(); public boolean isStatic() throws CModelException;
/** /**
* Returns if this method is inline or not * Returns if this method is inline or not
* @return boolean * @return boolean
*/ */
public boolean isInline(); public boolean isInline() throws CModelException;
/** /**
* Returns whether this method is declared virtual. * Returns whether this method is declared virtual.
@ -62,11 +62,11 @@ public interface IMethodDeclaration extends IMember, IFunctionDeclaration {
* @exception CModelException if this element does not exist or if an * @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource. * exception occurs while accessing its corresponding resource.
*/ */
boolean isVirtual(); boolean isVirtual() throws CModelException;
/** /**
* return true if the member is a friend. * return true if the member is a friend.
*/ */
public boolean isFriend(); public boolean isFriend() throws CModelException;
} }

View file

@ -46,6 +46,8 @@ public interface ISourceReference {
/** /**
* Returns the translation unit in which this member is declared, or <code>null</code> * Returns the translation unit in which this member is declared, or <code>null</code>
* if this member is not declared in a translation unit (for example, a binary type). * if this member is not declared in a translation unit (for example, a binary type).
* @return
* @throws CModelException
*/ */
ITranslationUnit getTranslationUnit(); ITranslationUnit getTranslationUnit();
} }

View file

@ -28,11 +28,26 @@ public interface IStructure extends IInheritance, IParent, IVariableDeclaration
*/ */
public IMethodDeclaration [] getMethods() throws CModelException; public IMethodDeclaration [] getMethods() throws CModelException;
public boolean isUnion(); /**
*
* @return
* @throws CModelException
*/
public boolean isUnion() throws CModelException;
public boolean isClass(); /**
*
* @return
* @throws CModelException
*/
public boolean isClass() throws CModelException;
public boolean isStruct(); /**
*
* @return
* @throws CModelException
*/
public boolean isStruct() throws CModelException;
/** /**
* *
@ -40,5 +55,4 @@ public interface IStructure extends IInheritance, IParent, IVariableDeclaration
* @throws CModelException * @throws CModelException
*/ */
public boolean isAbstract() throws CModelException; public boolean isAbstract() throws CModelException;
} }

View file

@ -23,8 +23,9 @@ public interface ITemplate extends IDeclaration {
/** /**
* Returns the template signature * Returns the template signature
* @return String * @return String
* @throws CModelException
*/ */
String getTemplateSignature(); String getTemplateSignature() throws CModelException;
/** /**
* Returns the number of template parameters * Returns the number of template parameters
* @return int * @return int

View file

@ -9,6 +9,17 @@ package org.eclipse.cdt.core.model;
* Represents the declaration of a variable. * Represents the declaration of a variable.
*/ */
public interface IVariableDeclaration extends IDeclaration { public interface IVariableDeclaration extends IDeclaration {
public String getTypeName(); /**
public void setTypeName(String type); *
* @return
* @throws CModelException
*/
public String getTypeName() throws CModelException;
/**
*
* @param type
* @throws CModelException
*/
public void setTypeName(String type) throws CModelException;
} }

View file

@ -50,7 +50,7 @@ public class Archive extends Openable implements IArchive {
return new ArchiveInfo(this); return new ArchiveInfo(this);
} }
protected ArchiveInfo getArchiveInfo() { protected ArchiveInfo getArchiveInfo() throws CModelException {
return (ArchiveInfo)getElementInfo(); return (ArchiveInfo)getElementInfo();
} }
/* (non-Javadoc) /* (non-Javadoc)

View file

@ -219,7 +219,7 @@ public class Binary extends Openable implements IBinary {
} }
boolean computeChildren(OpenableInfo info, IResource res) { boolean computeChildren(OpenableInfo info, IResource res) throws CModelException {
boolean ok = false; boolean ok = false;
if (isObject() || isExecutable() || isSharedLib()) { if (isObject() || isExecutable() || isSharedLib()) {
Map hash = new HashMap(); Map hash = new HashMap();
@ -243,7 +243,7 @@ public class Binary extends Openable implements IBinary {
return ok; return ok;
} }
private void addFunction(OpenableInfo info, ISymbol symbol, Map hash) { private void addFunction(OpenableInfo info, ISymbol symbol, Map hash) throws CModelException {
IPath filename = filename = symbol.getFilename(); IPath filename = filename = symbol.getFilename();
BinaryFunction function = null; BinaryFunction function = null;
@ -273,7 +273,7 @@ public class Binary extends Openable implements IBinary {
// } // }
} }
private void addVariable(OpenableInfo info, ISymbol symbol, Map hash) { private void addVariable(OpenableInfo info, ISymbol symbol, Map hash) throws CModelException {
IPath filename = filename = symbol.getFilename(); IPath filename = filename = symbol.getFilename();
BinaryVariable variable = null; BinaryVariable variable = null;
if (filename != null) { if (filename != null) {

View file

@ -43,17 +43,18 @@ public class BinaryRunner {
if (cproject == null || monitor.isCanceled()) { if (cproject == null || monitor.isCanceled()) {
return Status.CANCEL_STATUS; return Status.CANCEL_STATUS;
} }
try {
BinaryContainer vbin = (BinaryContainer) cproject.getBinaryContainer(); BinaryContainer vbin = (BinaryContainer) cproject.getBinaryContainer();
ArchiveContainer vlib = (ArchiveContainer) cproject.getArchiveContainer(); ArchiveContainer vlib = (ArchiveContainer) cproject.getArchiveContainer();
vlib.removeChildren(); vlib.removeChildren();
vbin.removeChildren(); vbin.removeChildren();
try {
cproject.getProject().accept(new Visitor(BinaryRunner.this, monitor)); cproject.getProject().accept(new Visitor(BinaryRunner.this, monitor));
fireEvents(cproject, vbin);
fireEvents(cproject, vlib);
} catch (CoreException e) { } catch (CoreException e) {
return e.getStatus(); return e.getStatus();
} }
fireEvents(cproject, vbin);
fireEvents(cproject, vlib);
return Status.OK_STATUS; return Status.OK_STATUS;
} }
}; };

View file

@ -220,7 +220,7 @@ public class CContainer extends Openable implements ICContainer {
return true; return true;
} }
protected ICElement computeChild(IResource resource, ICProject cproject) { protected ICElement computeChild(IResource resource, ICProject cproject) throws CModelException {
ICElement celement = null; ICElement celement = null;
switch (resource.getType()) { switch (resource.getType()) {
case IResource.FILE : case IResource.FILE :

View file

@ -78,7 +78,11 @@ public abstract class CElement extends PlatformObject implements ICElement {
} }
public boolean exists() { public boolean exists() {
try {
return getElementInfo() != null; return getElementInfo() != null;
} catch (CModelException e) {
return false;
}
} }
/** /**
@ -143,7 +147,7 @@ public abstract class CElement extends PlatformObject implements ICElement {
return null; return null;
} }
protected void addChild(ICElement e) { protected void addChild(ICElement e) throws CModelException {
} }
public void setPos(int startPos, int length) { public void setPos(int startPos, int length) {
@ -225,8 +229,7 @@ public abstract class CElement extends PlatformObject implements ICElement {
return false; return false;
} }
public CElementInfo getElementInfo () { public CElementInfo getElementInfo () throws CModelException {
try {
CModelManager manager; CModelManager manager;
synchronized(manager = CModelManager.getDefault()){ synchronized(manager = CModelManager.getDefault()){
Object info = manager.getInfo(this); Object info = manager.getInfo(this);
@ -239,9 +242,6 @@ public abstract class CElement extends PlatformObject implements ICElement {
} }
return (CElementInfo)info; return (CElementInfo)info;
} }
} catch(CModelException e) {
return null;
}
} }
public String toString() { public String toString() {

View file

@ -15,6 +15,7 @@ import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICElementDelta; import org.eclipse.cdt.core.model.ICElementDelta;
import org.eclipse.cdt.core.model.IParent; import org.eclipse.cdt.core.model.IParent;
@ -125,7 +126,7 @@ private void added(ICElement element) {
* Builds the C element deltas between the old content of the translation unit * Builds the C element deltas between the old content of the translation unit
* and its new content. * and its new content.
*/ */
public void buildDeltas() { public void buildDeltas() throws CModelException {
this.recordNewPositions(this.cElement, 0); this.recordNewPositions(this.cElement, 0);
this.findAdditions(this.cElement, 0); this.findAdditions(this.cElement, 0);
this.findDeletions(); this.findDeletions();
@ -135,7 +136,7 @@ public void buildDeltas() {
/** /**
* Finds elements which have been added or changed. * Finds elements which have been added or changed.
*/ */
private void findAdditions(ICElement newElement, int depth) { private void findAdditions(ICElement newElement, int depth) throws CModelException {
CElementInfo oldInfo = this.getElementInfo(newElement); CElementInfo oldInfo = this.getElementInfo(newElement);
if (oldInfo == null && depth < this.maxDepth) { if (oldInfo == null && depth < this.maxDepth) {
this.delta.added(newElement); this.delta.added(newElement);
@ -169,7 +170,7 @@ private void findAdditions(ICElement newElement, int depth) {
/** /**
* Looks for changed positioning of elements. * Looks for changed positioning of elements.
*/ */
private void findChangesInPositioning(ICElement element, int depth) { private void findChangesInPositioning(ICElement element, int depth) throws CModelException {
if (depth >= this.maxDepth || this.added.contains(element) || this.removed.contains(element)) if (depth >= this.maxDepth || this.added.contains(element) || this.removed.contains(element))
return; return;
@ -340,7 +341,7 @@ private void recordElementInfo(ICElement element, int depth) {
/** /**
* Fills the newPositions hashtable with the new position information * Fills the newPositions hashtable with the new position information
*/ */
private void recordNewPositions(ICElement newElement, int depth) { private void recordNewPositions(ICElement newElement, int depth) throws CModelException {
if (depth < this.maxDepth && newElement instanceof IParent) { if (depth < this.maxDepth && newElement instanceof IParent) {
CElementInfo info = null; CElementInfo info = null;
info = ((CElement)newElement).getElementInfo(); info = ((CElement)newElement).getElementInfo();

View file

@ -183,7 +183,7 @@ public class CModelBuilder {
} }
private void generateModelElements(){ private void generateModelElements() throws CModelException{
Iterator i = quickParseCallback.iterateOffsetableElements(); Iterator i = quickParseCallback.iterateOffsetableElements();
while (i.hasNext()){ while (i.hasNext()){
IASTOffsetableElement offsetable = (IASTOffsetableElement)i.next(); IASTOffsetableElement offsetable = (IASTOffsetableElement)i.next();
@ -201,7 +201,7 @@ public class CModelBuilder {
} }
} }
private void generateModelElements (Parent parent, IASTDeclaration declaration) throws ASTNotImplementedException private void generateModelElements (Parent parent, IASTDeclaration declaration) throws CModelException, ASTNotImplementedException
{ {
if(declaration instanceof IASTNamespaceDefinition ) { if(declaration instanceof IASTNamespaceDefinition ) {
generateModelElements(parent, (IASTNamespaceDefinition) declaration); generateModelElements(parent, (IASTNamespaceDefinition) declaration);
@ -222,7 +222,7 @@ public class CModelBuilder {
createSimpleElement(parent, declaration, false); createSimpleElement(parent, declaration, false);
} }
private void generateModelElements (Parent parent, IASTNamespaceDefinition declaration) throws ASTNotImplementedException{ private void generateModelElements (Parent parent, IASTNamespaceDefinition declaration) throws CModelException, ASTNotImplementedException{
// IASTNamespaceDefinition // IASTNamespaceDefinition
IParent namespace = createNamespace(parent, declaration); IParent namespace = createNamespace(parent, declaration);
Iterator nsDecls = declaration.getDeclarations(); Iterator nsDecls = declaration.getDeclarations();
@ -232,13 +232,13 @@ public class CModelBuilder {
} }
} }
private void generateModelElements (Parent parent, IASTAbstractTypeSpecifierDeclaration abstractDeclaration) throws ASTNotImplementedException private void generateModelElements (Parent parent, IASTAbstractTypeSpecifierDeclaration abstractDeclaration) throws CModelException, ASTNotImplementedException
{ {
// IASTAbstractTypeSpecifierDeclaration // IASTAbstractTypeSpecifierDeclaration
CElement element = createAbstractElement(parent, abstractDeclaration, false); CElement element = createAbstractElement(parent, abstractDeclaration, false);
} }
private void generateModelElements (Parent parent, IASTTemplateDeclaration templateDeclaration) throws ASTNotImplementedException private void generateModelElements (Parent parent, IASTTemplateDeclaration templateDeclaration) throws CModelException, ASTNotImplementedException
{ {
// Template Declaration // Template Declaration
IASTDeclaration declaration = (IASTDeclaration)templateDeclaration.getOwnedDeclaration(); IASTDeclaration declaration = (IASTDeclaration)templateDeclaration.getOwnedDeclaration();
@ -269,14 +269,14 @@ public class CModelBuilder {
} }
} }
private void generateModelElements (Parent parent, IASTTypedefDeclaration declaration) throws ASTNotImplementedException private void generateModelElements (Parent parent, IASTTypedefDeclaration declaration) throws CModelException, ASTNotImplementedException
{ {
TypeDef typeDef = createTypeDef(parent, declaration); TypeDef typeDef = createTypeDef(parent, declaration);
IASTAbstractDeclaration abstractDeclaration = declaration.getAbstractDeclarator(); IASTAbstractDeclaration abstractDeclaration = declaration.getAbstractDeclarator();
CElement element = createAbstractElement(parent, abstractDeclaration, false); CElement element = createAbstractElement(parent, abstractDeclaration, false);
} }
private CElement createAbstractElement(Parent parent, IASTTypeSpecifierOwner abstractDeclaration, boolean isTemplate)throws ASTNotImplementedException{ private CElement createAbstractElement(Parent parent, IASTTypeSpecifierOwner abstractDeclaration, boolean isTemplate)throws ASTNotImplementedException, CModelException{
CElement element = null; CElement element = null;
if(abstractDeclaration != null){ if(abstractDeclaration != null){
IASTTypeSpecifier typeSpec = abstractDeclaration.getTypeSpecifier(); IASTTypeSpecifier typeSpec = abstractDeclaration.getTypeSpecifier();
@ -306,7 +306,7 @@ public class CModelBuilder {
return element; return element;
} }
private CElement createSimpleElement(Parent parent, IASTDeclaration declaration, boolean isTemplate)throws ASTNotImplementedException{ private CElement createSimpleElement(Parent parent, IASTDeclaration declaration, boolean isTemplate)throws CModelException, ASTNotImplementedException{
CElement element = null; CElement element = null;
if (declaration instanceof IASTVariable) if (declaration instanceof IASTVariable)
@ -321,7 +321,7 @@ public class CModelBuilder {
return element; return element;
} }
private Include createInclusion(Parent parent, IASTInclusion inclusion){ private Include createInclusion(Parent parent, IASTInclusion inclusion) throws CModelException{
// create element // create element
Include element = new Include((CElement)parent, inclusion.getName(), !inclusion.isLocal()); Include element = new Include((CElement)parent, inclusion.getName(), !inclusion.isLocal());
element.setFullPathName(inclusion.getFullFileName()); element.setFullPathName(inclusion.getFullFileName());
@ -335,7 +335,7 @@ public class CModelBuilder {
return element; return element;
} }
private Macro createMacro(Parent parent, IASTMacro macro){ private Macro createMacro(Parent parent, IASTMacro macro) throws CModelException{
// create element // create element
org.eclipse.cdt.internal.core.model.Macro element = new Macro(parent, macro.getName()); org.eclipse.cdt.internal.core.model.Macro element = new Macro(parent, macro.getName());
// add to parent // add to parent
@ -349,7 +349,7 @@ public class CModelBuilder {
} }
private Namespace createNamespace(Parent parent, IASTNamespaceDefinition nsDef){ private Namespace createNamespace(Parent parent, IASTNamespaceDefinition nsDef) throws CModelException{
// create element // create element
String type = "namespace"; //$NON-NLS-1$ String type = "namespace"; //$NON-NLS-1$
String nsName = (nsDef.getName() == null ) String nsName = (nsDef.getName() == null )
@ -368,7 +368,7 @@ public class CModelBuilder {
return element; return element;
} }
private Enumeration createEnumeration(Parent parent, IASTEnumerationSpecifier enumSpecifier){ private Enumeration createEnumeration(Parent parent, IASTEnumerationSpecifier enumSpecifier) throws CModelException{
// create element // create element
String type = "enum"; //$NON-NLS-1$ String type = "enum"; //$NON-NLS-1$
String enumName = (enumSpecifier.getName() == null ) String enumName = (enumSpecifier.getName() == null )
@ -394,7 +394,7 @@ public class CModelBuilder {
return element; return element;
} }
private Enumerator createEnumerator(Parent enum, IASTEnumerator enumDef){ private Enumerator createEnumerator(Parent enum, IASTEnumerator enumDef) throws CModelException{
Enumerator element = new Enumerator (enum, enumDef.getName().toString()); Enumerator element = new Enumerator (enum, enumDef.getName().toString());
IASTExpression initialValue = enumDef.getInitialValue(); IASTExpression initialValue = enumDef.getInitialValue();
if(initialValue != null){ if(initialValue != null){
@ -413,7 +413,7 @@ public class CModelBuilder {
return element; return element;
} }
private Structure createClass(Parent parent, IASTClassSpecifier classSpecifier, boolean isTemplate){ private Structure createClass(Parent parent, IASTClassSpecifier classSpecifier, boolean isTemplate) throws CModelException{
// create element // create element
String className = ""; //$NON-NLS-1$ String className = ""; //$NON-NLS-1$
String type = ""; //$NON-NLS-1$ String type = ""; //$NON-NLS-1$
@ -482,7 +482,7 @@ public class CModelBuilder {
return element; return element;
} }
private TypeDef createTypeDef(Parent parent, IASTTypedefDeclaration typeDefDeclaration){ private TypeDef createTypeDef(Parent parent, IASTTypedefDeclaration typeDefDeclaration) throws CModelException{
// create the element // create the element
String name = typeDefDeclaration.getName(); String name = typeDefDeclaration.getName();
@ -502,7 +502,7 @@ public class CModelBuilder {
return element; return element;
} }
private VariableDeclaration createVariableSpecification(Parent parent, IASTVariable varDeclaration, boolean isTemplate)throws ASTNotImplementedException private VariableDeclaration createVariableSpecification(Parent parent, IASTVariable varDeclaration, boolean isTemplate)throws CModelException, ASTNotImplementedException
{ {
String variableName = varDeclaration.getName(); String variableName = varDeclaration.getName();
if((variableName == null) || (variableName.length() <= 0)){ if((variableName == null) || (variableName.length() <= 0)){
@ -558,7 +558,7 @@ public class CModelBuilder {
return element; return element;
} }
private FunctionDeclaration createFunctionSpecification(Parent parent, IASTFunction functionDeclaration, boolean isTemplate) private FunctionDeclaration createFunctionSpecification(Parent parent, IASTFunction functionDeclaration, boolean isTemplate) throws CModelException
{ {
String name = functionDeclaration.getName(); String name = functionDeclaration.getName();
if ((name == null) || (name.length() <= 0)) { if ((name == null) || (name.length() <= 0)) {

View file

@ -53,11 +53,11 @@ public class CProject extends Openable implements ICProject {
super(parent, project, CElement.C_PROJECT); super(parent, project, CElement.C_PROJECT);
} }
public IBinaryContainer getBinaryContainer() { public IBinaryContainer getBinaryContainer() throws CModelException {
return ((CProjectInfo) getElementInfo()).getBinaryContainer(); return ((CProjectInfo) getElementInfo()).getBinaryContainer();
} }
public IArchiveContainer getArchiveContainer() { public IArchiveContainer getArchiveContainer() throws CModelException {
return ((CProjectInfo) getElementInfo()).getArchiveContainer(); return ((CProjectInfo) getElementInfo()).getArchiveContainer();
} }

View file

@ -87,7 +87,7 @@ public class DeltaProcessor {
// BUG 36424: // BUG 36424:
// The Binary may only be visible in the BinaryContainers // The Binary may only be visible in the BinaryContainers
try {
if (celement == null && resource.getType() == IResource.FILE) { if (celement == null && resource.getType() == IResource.FILE) {
ICElement[] children; ICElement[] children;
ICProject cproj = manager.create(resource.getProject()); ICProject cproj = manager.create(resource.getProject());
@ -124,7 +124,6 @@ public class DeltaProcessor {
} }
} }
} }
// It is not a C resource if the parent is a Binary/ArchiveContainer // It is not a C resource if the parent is a Binary/ArchiveContainer
// But we have to release too. // But we have to release too.
if (celement != null && resource.getType() == IResource.FILE) { if (celement != null && resource.getType() == IResource.FILE) {
@ -134,13 +133,16 @@ public class DeltaProcessor {
celement = null; celement = null;
} }
} }
} catch (CModelException e) {
return null;
}
return celement; return celement;
} }
/** /**
* Adds the given child handle to its parent's cache of children. * Adds the given child handle to its parent's cache of children.
*/ */
protected void addToParentInfo(Openable child) { protected void addToParentInfo(Openable child) throws CModelException {
Openable parent = (Openable) child.getParent(); Openable parent = (Openable) child.getParent();
if (parent != null && parent.isOpen()) { if (parent != null && parent.isOpen()) {
CElementInfo info = parent.getElementInfo(); CElementInfo info = parent.getElementInfo();
@ -153,7 +155,7 @@ public class DeltaProcessor {
* element does not have a parent, or the parent is not currently open, * element does not have a parent, or the parent is not currently open,
* this has no effect. * this has no effect.
*/ */
private void removeFromParentInfo(ICElement child) { private void removeFromParentInfo(ICElement child) throws CModelException {
CModelManager factory = CModelManager.getDefault(); CModelManager factory = CModelManager.getDefault();
// Remove the child from the parent list. // Remove the child from the parent list.
@ -166,7 +168,7 @@ public class DeltaProcessor {
/** /**
* Release the Element and cleaning. * Release the Element and cleaning.
*/ */
protected void releaseCElement(ICElement celement) { protected void releaseCElement(ICElement celement) throws CModelException {
CModelManager factory = CModelManager.getDefault(); CModelManager factory = CModelManager.getDefault();
int type = celement.getElementType(); int type = celement.getElementType();
if (type == ICElement.C_ARCHIVE) { if (type == ICElement.C_ARCHIVE) {
@ -184,28 +186,22 @@ public class DeltaProcessor {
CProjectInfo pinfo = (CProjectInfo)factory.peekAtInfo(cproject); CProjectInfo pinfo = (CProjectInfo)factory.peekAtInfo(cproject);
if (pinfo != null && pinfo.vBin != null) { if (pinfo != null && pinfo.vBin != null) {
if (factory.peekAtInfo(pinfo.vBin) != null) { if (factory.peekAtInfo(pinfo.vBin) != null) {
try {
ICElement[] bins = pinfo.vBin.getChildren(); ICElement[] bins = pinfo.vBin.getChildren();
for (int i = 0; i < bins.length; i++) { for (int i = 0; i < bins.length; i++) {
if (celement.getPath().isPrefixOf(bins[i].getPath())) { if (celement.getPath().isPrefixOf(bins[i].getPath())) {
fCurrentDelta.changed(pinfo.vBin, ICElementDelta.CHANGED); fCurrentDelta.changed(pinfo.vBin, ICElementDelta.CHANGED);
} }
} }
} catch (CModelException e) {
}
} }
} }
if (pinfo != null && pinfo.vLib != null) { if (pinfo != null && pinfo.vLib != null) {
if (factory.peekAtInfo(pinfo.vLib) != null) { if (factory.peekAtInfo(pinfo.vLib) != null) {
try {
ICElement[] ars = pinfo.vLib.getChildren(); ICElement[] ars = pinfo.vLib.getChildren();
for (int i = 0; i < ars.length; i++) { for (int i = 0; i < ars.length; i++) {
if (celement.getPath().isPrefixOf(ars[i].getPath())) { if (celement.getPath().isPrefixOf(ars[i].getPath())) {
fCurrentDelta.changed(pinfo.vBin, ICElementDelta.CHANGED); fCurrentDelta.changed(pinfo.vBin, ICElementDelta.CHANGED);
} }
} }
} catch (CModelException e) {
}
} }
} }
} }
@ -230,7 +226,7 @@ public class DeltaProcessor {
* <code>basicElementAdded</code>. * <code>basicElementAdded</code>.
* </ul> * </ul>
*/ */
protected void elementAdded(ICElement element, IResourceDelta delta) { protected void elementAdded(ICElement element, IResourceDelta delta) throws CModelException {
if (element instanceof Openable) { if (element instanceof Openable) {
addToParentInfo((Openable)element); addToParentInfo((Openable)element);
@ -258,7 +254,7 @@ public class DeltaProcessor {
* a resource is closed, the platform reports all children as removed. This * a resource is closed, the platform reports all children as removed. This
* would effectively delete the classpath if we processed children. * would effectively delete the classpath if we processed children.
*/ */
protected void elementClosed(ICElement element, IResourceDelta delta) { protected void elementClosed(ICElement element, IResourceDelta delta) throws CModelException {
if (element.getElementType() == ICElement.C_PROJECT) { if (element.getElementType() == ICElement.C_PROJECT) {
// treat project closing as removal // treat project closing as removal
@ -278,7 +274,7 @@ public class DeltaProcessor {
* as a the element being opened (CHANGED + F_CLOSED). * as a the element being opened (CHANGED + F_CLOSED).
* </ul> * </ul>
*/ */
protected void elementOpened(ICElement element, IResourceDelta delta) { protected void elementOpened(ICElement element, IResourceDelta delta) throws CModelException {
if (element.getElementType() == ICElement.C_PROJECT) { if (element.getElementType() == ICElement.C_PROJECT) {
// treat project opening as addition // treat project opening as addition
@ -325,7 +321,7 @@ public class DeltaProcessor {
* <li>Add a REMOVED entry in the delta * <li>Add a REMOVED entry in the delta
* </ul> * </ul>
*/ */
protected void elementRemoved(ICElement element, IResourceDelta delta) { protected void elementRemoved(ICElement element, IResourceDelta delta) throws CModelException {
if ((delta.getFlags() & IResourceDelta.MOVED_TO) != 0) { if ((delta.getFlags() & IResourceDelta.MOVED_TO) != 0) {
IPath movedToPath = delta.getMovedToPath(); IPath movedToPath = delta.getMovedToPath();
// create the moved to element // create the moved to element
@ -445,7 +441,7 @@ public class DeltaProcessor {
* @param parent * @param parent
* @param delta * @param delta
*/ */
protected void nonCResourcesChanged(ICElement parent, IResourceDelta delta) { protected void nonCResourcesChanged(ICElement parent, IResourceDelta delta) throws CModelException {
if (parent instanceof Openable && ((Openable)parent).isOpen()) { if (parent instanceof Openable && ((Openable)parent).isOpen()) {
CElementInfo info = ((Openable)parent).getElementInfo(); CElementInfo info = ((Openable)parent).getElementInfo();
switch (parent.getElementType()) { switch (parent.getElementType()) {

View file

@ -11,6 +11,7 @@ package org.eclipse.cdt.internal.core.model;
* Rational Software - Initial API and implementation * Rational Software - Initial API and implementation
***********************************************************************/ ***********************************************************************/
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IEnumeration; import org.eclipse.cdt.core.model.IEnumeration;
@ -24,7 +25,7 @@ public class Enumeration extends SourceManipulation implements IEnumeration{
return new EnumerationInfo(this); return new EnumerationInfo(this);
} }
private EnumerationInfo getEnumerationInfo(){ private EnumerationInfo getEnumerationInfo() throws CModelException{
return (EnumerationInfo) getElementInfo(); return (EnumerationInfo) getElementInfo();
} }
/** /**
@ -37,35 +38,35 @@ public class Enumeration extends SourceManipulation implements IEnumeration{
/** /**
* @see org.eclipse.cdt.core.model.IVariableDeclaration#getTypeName() * @see org.eclipse.cdt.core.model.IVariableDeclaration#getTypeName()
*/ */
public String getTypeName() { public String getTypeName() throws CModelException {
return getEnumerationInfo().getTypeName(); return getEnumerationInfo().getTypeName();
} }
/** /**
* @see org.eclipse.cdt.core.model.IVariableDeclaration#setTypeName(java.lang.String) * @see org.eclipse.cdt.core.model.IVariableDeclaration#setTypeName(java.lang.String)
*/ */
public void setTypeName(String type) { public void setTypeName(String type) throws CModelException {
getEnumerationInfo().setTypeName(type); getEnumerationInfo().setTypeName(type);
} }
/** /**
* @see org.eclipse.cdt.core.model.IDeclaration#isConst() * @see org.eclipse.cdt.core.model.IDeclaration#isConst()
*/ */
public boolean isConst() { public boolean isConst() throws CModelException {
return getEnumerationInfo().isConst(); return getEnumerationInfo().isConst();
} }
/** /**
* @see org.eclipse.cdt.core.model.IDeclaration#isStatic() * @see org.eclipse.cdt.core.model.IDeclaration#isStatic()
*/ */
public boolean isStatic() { public boolean isStatic() throws CModelException {
return getEnumerationInfo().isStatic(); return getEnumerationInfo().isStatic();
} }
/** /**
* @see org.eclipse.cdt.core.model.IDeclaration#isVolatile() * @see org.eclipse.cdt.core.model.IDeclaration#isVolatile()
*/ */
public boolean isVolatile() { public boolean isVolatile() throws CModelException {
return getEnumerationInfo().isVolatile(); return getEnumerationInfo().isVolatile();
} }
@ -73,7 +74,7 @@ public class Enumeration extends SourceManipulation implements IEnumeration{
* Sets the isConst. * Sets the isConst.
* @param isConst The isConst to set * @param isConst The isConst to set
*/ */
public void setConst(boolean isConst) { public void setConst(boolean isConst) throws CModelException {
getEnumerationInfo().setConst(isConst); getEnumerationInfo().setConst(isConst);
} }
@ -81,7 +82,7 @@ public class Enumeration extends SourceManipulation implements IEnumeration{
* Sets the isStatic. * Sets the isStatic.
* @param isStatic The isStatic to set * @param isStatic The isStatic to set
*/ */
public void setStatic(boolean isStatic) { public void setStatic(boolean isStatic) throws CModelException {
getEnumerationInfo().setStatic( isStatic); getEnumerationInfo().setStatic( isStatic);
} }
@ -89,7 +90,7 @@ public class Enumeration extends SourceManipulation implements IEnumeration{
* Sets the isVolatile. * Sets the isVolatile.
* @param isVolatile The isVolatile to set * @param isVolatile The isVolatile to set
*/ */
public void setVolatile(boolean isVolatile) { public void setVolatile(boolean isVolatile) throws CModelException {
getEnumerationInfo().setVolatile(isVolatile); getEnumerationInfo().setVolatile(isVolatile);
} }

View file

@ -5,6 +5,7 @@ package org.eclipse.cdt.internal.core.model;
* All Rights Reserved. * All Rights Reserved.
*/ */
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IField; import org.eclipse.cdt.core.model.IField;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility; import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
@ -15,55 +16,55 @@ public class Field extends VariableDeclaration implements IField {
super(parent, name, CElement.C_FIELD); super(parent, name, CElement.C_FIELD);
} }
public boolean isMutable(){ public boolean isMutable() throws CModelException{
return getFieldInfo().isMutable(); return getFieldInfo().isMutable();
} }
public void setMutable(boolean mutable){ public void setMutable(boolean mutable) throws CModelException{
getFieldInfo().setMutable(mutable); getFieldInfo().setMutable(mutable);
} }
public String getTypeName() { public String getTypeName() throws CModelException {
return getFieldInfo().getTypeName(); return getFieldInfo().getTypeName();
} }
public void setTypeName(String type) { public void setTypeName(String type) throws CModelException {
getFieldInfo().setTypeName(type); getFieldInfo().setTypeName(type);
} }
public boolean isConst() { public boolean isConst() throws CModelException {
return getFieldInfo().isConst(); return getFieldInfo().isConst();
} }
public void setConst(boolean isConst) { public void setConst(boolean isConst) throws CModelException {
getFieldInfo().setConst(isConst); getFieldInfo().setConst(isConst);
} }
public boolean isVolatile() { public boolean isVolatile() throws CModelException {
return getFieldInfo().isVolatile(); return getFieldInfo().isVolatile();
} }
public void setVolatile(boolean isVolatile) { public void setVolatile(boolean isVolatile) throws CModelException {
getFieldInfo().setVolatile(isVolatile); getFieldInfo().setVolatile(isVolatile);
} }
public boolean isStatic() { public boolean isStatic() throws CModelException {
return getFieldInfo().isStatic(); return getFieldInfo().isStatic();
} }
public void setStatic(boolean isStatic) { public void setStatic(boolean isStatic) throws CModelException {
getFieldInfo().setStatic(isStatic); getFieldInfo().setStatic(isStatic);
} }
public ASTAccessVisibility getVisibility() { public ASTAccessVisibility getVisibility() throws CModelException {
return getFieldInfo().getVisibility(); return getFieldInfo().getVisibility();
} }
public void setVisibility(ASTAccessVisibility visibility) { public void setVisibility(ASTAccessVisibility visibility) throws CModelException {
getFieldInfo().setVisibility(visibility); getFieldInfo().setVisibility(visibility);
} }
public FieldInfo getFieldInfo(){ public FieldInfo getFieldInfo() throws CModelException{
return (FieldInfo) getElementInfo(); return (FieldInfo) getElementInfo();
} }

View file

@ -5,6 +5,7 @@ package org.eclipse.cdt.internal.core.model;
* All Rights Reserved. * All Rights Reserved.
*/ */
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IFunctionDeclaration; import org.eclipse.cdt.core.model.IFunctionDeclaration;
@ -49,13 +50,14 @@ public class FunctionDeclaration extends SourceManipulation implements IFunction
fParameterTypes = parameterTypes; fParameterTypes = parameterTypes;
} }
public String getSignature(){ public String getSignature() throws CModelException{
StringBuffer sig = new StringBuffer(getElementName()); StringBuffer sig = new StringBuffer(getElementName());
sig.append(getParameterClause()); sig.append(getParameterClause());
if(isConst()) if(isConst())
sig.append(" const"); //$NON-NLS-1$ sig.append(" const"); //$NON-NLS-1$
if(isVolatile()) if(isVolatile()) {
sig.append(" volatile"); //$NON-NLS-1$ sig.append(" volatile"); //$NON-NLS-1$
}
return sig.toString(); return sig.toString();
} }
@ -91,7 +93,7 @@ public class FunctionDeclaration extends SourceManipulation implements IFunction
return new FunctionInfo(this); return new FunctionInfo(this);
} }
protected FunctionInfo getFunctionInfo(){ protected FunctionInfo getFunctionInfo() throws CModelException{
return (FunctionInfo) getElementInfo(); return (FunctionInfo) getElementInfo();
} }
@ -110,11 +112,11 @@ public class FunctionDeclaration extends SourceManipulation implements IFunction
* FunctionDeclarations and Functions can not be constant * FunctionDeclarations and Functions can not be constant
* @see org.eclipse.cdt.core.model.IDeclaration#isConst() * @see org.eclipse.cdt.core.model.IDeclaration#isConst()
*/ */
public boolean isConst(){ public boolean isConst() throws CModelException{
return getFunctionInfo().isConst(); return getFunctionInfo().isConst();
} }
public void setConst(boolean isConst){ public void setConst(boolean isConst) throws CModelException{
getFunctionInfo().setConst(isConst); getFunctionInfo().setConst(isConst);
} }
@ -122,7 +124,7 @@ public class FunctionDeclaration extends SourceManipulation implements IFunction
* Returns the isStatic. * Returns the isStatic.
* @return boolean * @return boolean
*/ */
public boolean isStatic() { public boolean isStatic() throws CModelException {
return getFunctionInfo().isStatic(); return getFunctionInfo().isStatic();
} }
@ -130,7 +132,7 @@ public class FunctionDeclaration extends SourceManipulation implements IFunction
* Returns the isVolatile. * Returns the isVolatile.
* @return boolean * @return boolean
*/ */
public boolean isVolatile() { public boolean isVolatile() throws CModelException {
return getFunctionInfo().isVolatile(); return getFunctionInfo().isVolatile();
} }
@ -138,7 +140,7 @@ public class FunctionDeclaration extends SourceManipulation implements IFunction
* Sets the isStatic. * Sets the isStatic.
* @param isStatic The isStatic to set * @param isStatic The isStatic to set
*/ */
public void setStatic(boolean isStatic) { public void setStatic(boolean isStatic) throws CModelException {
getFunctionInfo().setStatic(isStatic); getFunctionInfo().setStatic(isStatic);
} }
@ -146,7 +148,7 @@ public class FunctionDeclaration extends SourceManipulation implements IFunction
* Sets the isVolatile. * Sets the isVolatile.
* @param isVolatile The isVolatile to set * @param isVolatile The isVolatile to set
*/ */
public void setVolatile(boolean isVolatile) { public void setVolatile(boolean isVolatile) throws CModelException {
getFunctionInfo().setVolatile(isVolatile); getFunctionInfo().setVolatile(isVolatile);
} }

View file

@ -11,6 +11,7 @@ package org.eclipse.cdt.internal.core.model;
* Rational Software - Initial API and implementation * Rational Software - Initial API and implementation
***********************************************************************/ ***********************************************************************/
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ITemplate; import org.eclipse.cdt.core.model.ITemplate;
@ -58,7 +59,7 @@ public class FunctionTemplate extends FunctionDeclaration implements ITemplate{
* normal parameter list, then a colon then the function's * normal parameter list, then a colon then the function's
* return type. * return type.
*/ */
public String getTemplateSignature() { public String getTemplateSignature() throws CModelException {
StringBuffer sig = new StringBuffer(getElementName()); StringBuffer sig = new StringBuffer(getElementName());
if(getNumberOfTemplateParameters() > 0){ if(getNumberOfTemplateParameters() > 0){
sig.append("<"); //$NON-NLS-1$ sig.append("<"); //$NON-NLS-1$

View file

@ -11,6 +11,7 @@ package org.eclipse.cdt.internal.core.model;
* Rational Software - Initial API and implementation * Rational Software - Initial API and implementation
***********************************************************************/ ***********************************************************************/
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IMethodDeclaration; import org.eclipse.cdt.core.model.IMethodDeclaration;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility; import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
@ -53,35 +54,35 @@ public class MethodDeclaration extends FunctionDeclaration implements IMethodDec
return getElementName().startsWith("operator"); //$NON-NLS-1$ return getElementName().startsWith("operator"); //$NON-NLS-1$
} }
public boolean isPureVirtual(){ public boolean isPureVirtual() throws CModelException{
return getMethodInfo().isPureVirtual(); return getMethodInfo().isPureVirtual();
} }
public void setPureVirtual(boolean isPureVirtual){ public void setPureVirtual(boolean isPureVirtual) throws CModelException{
getMethodInfo().setPureVirtual(isPureVirtual); getMethodInfo().setPureVirtual(isPureVirtual);
} }
public boolean isInline(){ public boolean isInline() throws CModelException{
return getMethodInfo().isInline(); return getMethodInfo().isInline();
} }
public void setInline(boolean isInline){ public void setInline(boolean isInline) throws CModelException{
getMethodInfo().setInline(isInline); getMethodInfo().setInline(isInline);
} }
public boolean isVirtual(){ public boolean isVirtual() throws CModelException{
return getMethodInfo().isVirtual(); return getMethodInfo().isVirtual();
} }
public void setVirtual(boolean isVirtual){ public void setVirtual(boolean isVirtual) throws CModelException{
getMethodInfo().setVirtual(isVirtual); getMethodInfo().setVirtual(isVirtual);
} }
public boolean isFriend(){ public boolean isFriend() throws CModelException{
return getMethodInfo().isFriend(); return getMethodInfo().isFriend();
} }
public void setFriend(boolean isFriend){ public void setFriend(boolean isFriend) throws CModelException{
getMethodInfo().setFriend(isFriend); getMethodInfo().setFriend(isFriend);
} }
@ -89,16 +90,16 @@ public class MethodDeclaration extends FunctionDeclaration implements IMethodDec
return isConst; return isConst;
} }
public void setConst(boolean isConst){ public void setConst(boolean isConst) throws CModelException{
this.isConst = isConst; this.isConst = isConst;
getMethodInfo().setConst(isConst); getMethodInfo().setConst(isConst);
} }
public ASTAccessVisibility getVisibility(){ public ASTAccessVisibility getVisibility() throws CModelException{
return getMethodInfo().getVisibility(); return getMethodInfo().getVisibility();
} }
public void setVisibility(ASTAccessVisibility visibility){ public void setVisibility(ASTAccessVisibility visibility) throws CModelException{
getMethodInfo().setVisibility(visibility); getMethodInfo().setVisibility(visibility);
} }
@ -106,7 +107,7 @@ public class MethodDeclaration extends FunctionDeclaration implements IMethodDec
return new MethodInfo(this); return new MethodInfo(this);
} }
private MethodInfo getMethodInfo(){ private MethodInfo getMethodInfo() throws CModelException{
return (MethodInfo) getElementInfo(); return (MethodInfo) getElementInfo();
} }

View file

@ -11,6 +11,7 @@ package org.eclipse.cdt.internal.core.model;
* Rational Software - Initial API and implementation * Rational Software - Initial API and implementation
***********************************************************************/ ***********************************************************************/
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ITemplate; import org.eclipse.cdt.core.model.ITemplate;
@ -59,7 +60,7 @@ public class MethodTemplate extends MethodDeclaration implements ITemplate{
* return type. * return type.
*/ */
public String getTemplateSignature() { public String getTemplateSignature() throws CModelException {
StringBuffer sig = new StringBuffer(getElementName()); StringBuffer sig = new StringBuffer(getElementName());
if(getNumberOfTemplateParameters() > 0){ if(getNumberOfTemplateParameters() > 0){
sig.append("<"); //$NON-NLS-1$ sig.append("<"); //$NON-NLS-1$

View file

@ -23,7 +23,7 @@ public abstract class Parent extends CElement {
* Adds a child to the current element. * Adds a child to the current element.
* Implementations override this method to support children * Implementations override this method to support children
*/ */
public void addChild(ICElement member) { public void addChild(ICElement member) throws CModelException {
getElementInfo().addChild(member); getElementInfo().addChild(member);
} }
@ -31,11 +31,11 @@ public abstract class Parent extends CElement {
* Removes a child to the current element. * Removes a child to the current element.
* Implementations override this method to support children * Implementations override this method to support children
*/ */
public void removeChild(ICElement member) { public void removeChild(ICElement member) throws CModelException {
getElementInfo().removeChild(member); getElementInfo().removeChild(member);
} }
public void removeChildren () { public void removeChildren () throws CModelException {
getElementInfo().removeChildren(); getElementInfo().removeChildren();
} }
@ -71,15 +71,27 @@ public abstract class Parent extends CElement {
} }
public boolean hasChildren () { public boolean hasChildren () {
try {
return getElementInfo().hasChildren(); return getElementInfo().hasChildren();
} catch (CModelException e) {
return false;
}
} }
protected void setChanged () { protected void setChanged () {
try {
getElementInfo().setChanged(); getElementInfo().setChanged();
} catch (CModelException e) {
// ignore
}
} }
protected boolean hasChanged () { protected boolean hasChanged () {
try {
return getElementInfo().hasChanged(); return getElementInfo().hasChanged();
} catch (CModelException e) {
return false;
}
} }
} }

View file

@ -92,7 +92,11 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I
* @see IMember * @see IMember
*/ */
public ITranslationUnit getTranslationUnit() { public ITranslationUnit getTranslationUnit() {
try {
return getSourceManipulationInfo().getTranslationUnit(); return getSourceManipulationInfo().getTranslationUnit();
} catch (CModelException e) {
return null;
}
} }
/** /**
@ -149,11 +153,11 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I
return new SourceManipulationInfo(this); return new SourceManipulationInfo(this);
} }
protected SourceManipulationInfo getSourceManipulationInfo() { protected SourceManipulationInfo getSourceManipulationInfo() throws CModelException {
return (SourceManipulationInfo)getElementInfo(); return (SourceManipulationInfo)getElementInfo();
} }
public boolean isIdentical(SourceManipulation other){ public boolean isIdentical(SourceManipulation other) throws CModelException{
return (this.equals(other) return (this.equals(other)
&& (this.getSourceManipulationInfo().hasSameContentsAs(other.getSourceManipulationInfo()))); && (this.getSourceManipulationInfo().hasSameContentsAs(other.getSourceManipulationInfo())));
} }

View file

@ -66,15 +66,15 @@ public class Structure extends SourceManipulation implements IStructure {
return null; return null;
} }
public boolean isUnion() { public boolean isUnion() throws CModelException {
return getStructureInfo().isUnion(); return getStructureInfo().isUnion();
} }
public boolean isClass() { public boolean isClass() throws CModelException {
return getStructureInfo().isClass(); return getStructureInfo().isClass();
} }
public boolean isStruct() { public boolean isStruct() throws CModelException {
return getStructureInfo().isStruct(); return getStructureInfo().isStruct();
} }
@ -96,39 +96,39 @@ public class Structure extends SourceManipulation implements IStructure {
return (ASTAccessVisibility)superClassesNames.get(name); return (ASTAccessVisibility)superClassesNames.get(name);
} }
public String getTypeName() { public String getTypeName() throws CModelException {
return getStructureInfo().getTypeName(); return getStructureInfo().getTypeName();
} }
public void setTypeName(String type){ public void setTypeName(String type) throws CModelException{
getStructureInfo().setTypeString(type); getStructureInfo().setTypeString(type);
} }
public boolean isConst() { public boolean isConst() throws CModelException {
return getStructureInfo().isConst(); return getStructureInfo().isConst();
} }
public void setConst(boolean isConst) { public void setConst(boolean isConst) throws CModelException {
getStructureInfo().setConst(isConst); getStructureInfo().setConst(isConst);
} }
public boolean isVolatile() { public boolean isVolatile() throws CModelException {
return getStructureInfo().isVolatile(); return getStructureInfo().isVolatile();
} }
public void setVolatile(boolean isVolatile) { public void setVolatile(boolean isVolatile) throws CModelException {
getStructureInfo().setVolatile(isVolatile); getStructureInfo().setVolatile(isVolatile);
} }
public boolean isStatic() { public boolean isStatic() throws CModelException {
return getStructureInfo().isStatic(); return getStructureInfo().isStatic();
} }
public void setStatic(boolean isStatic) { public void setStatic(boolean isStatic) throws CModelException {
getStructureInfo().setStatic(isStatic); getStructureInfo().setStatic(isStatic);
} }
public StructureInfo getStructureInfo(){ public StructureInfo getStructureInfo() throws CModelException{
return (StructureInfo) getElementInfo(); return (StructureInfo) getElementInfo();
} }

View file

@ -212,7 +212,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
return getSourceManipulationInfo().getSourceRange(); return getSourceManipulationInfo().getSourceRange();
} }
protected TranslationUnitInfo getTranslationUnitInfo() { protected TranslationUnitInfo getTranslationUnitInfo() throws CModelException {
return (TranslationUnitInfo)getElementInfo(); return (TranslationUnitInfo)getElementInfo();
} }
@ -296,7 +296,11 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
* @param element * @param element
*/ */
private void getNewElements(Map newElements, CElement element){ private void getNewElements(Map newElements, CElement element){
Object info = element.getElementInfo(); Object info = null;
try {
info = element.getElementInfo();
} catch (CModelException e) {
}
if(info != null){ if(info != null){
if(element instanceof IParent){ if(element instanceof IParent){
ICElement[] children = ((CElementInfo)info).getChildren(); ICElement[] children = ((CElementInfo)info).getChildren();

View file

@ -5,6 +5,7 @@ package org.eclipse.cdt.internal.core.model;
* All Rights Reserved. * All Rights Reserved.
*/ */
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IVariableDeclaration; import org.eclipse.cdt.core.model.IVariableDeclaration;
@ -18,39 +19,39 @@ public class VariableDeclaration extends SourceManipulation implements IVariable
super(parent, name, type); super(parent, name, type);
} }
public String getTypeName() { public String getTypeName() throws CModelException {
return getVariableInfo().getTypeName(); return getVariableInfo().getTypeName();
} }
public void setTypeName(String type) { public void setTypeName(String type) throws CModelException {
getVariableInfo().setTypeString(type); getVariableInfo().setTypeString(type);
} }
public boolean isConst() { public boolean isConst() throws CModelException {
return getVariableInfo().isConst(); return getVariableInfo().isConst();
} }
public void setConst(boolean isConst) { public void setConst(boolean isConst) throws CModelException {
getVariableInfo().setConst(isConst); getVariableInfo().setConst(isConst);
} }
public boolean isVolatile() { public boolean isVolatile() throws CModelException {
return getVariableInfo().isVolatile(); return getVariableInfo().isVolatile();
} }
public void setVolatile(boolean isVolatile) { public void setVolatile(boolean isVolatile) throws CModelException {
getVariableInfo().setVolatile(isVolatile); getVariableInfo().setVolatile(isVolatile);
} }
public boolean isStatic() { public boolean isStatic() throws CModelException {
return getVariableInfo().isStatic(); return getVariableInfo().isStatic();
} }
public void setStatic(boolean isStatic) { public void setStatic(boolean isStatic) throws CModelException {
getVariableInfo().setStatic(isStatic); getVariableInfo().setStatic(isStatic);
} }
public VariableInfo getVariableInfo(){ public VariableInfo getVariableInfo() throws CModelException{
return (VariableInfo) getElementInfo(); return (VariableInfo) getElementInfo();
} }

View file

@ -9,6 +9,7 @@ package org.eclipse.cdt.internal.core.model;
* Contributors: * Contributors:
* Rational Software - Initial API and implementation * Rational Software - Initial API and implementation
***********************************************************************/ ***********************************************************************/
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ITemplate; import org.eclipse.cdt.core.model.ITemplate;
@ -46,7 +47,7 @@ public class VariableTemplate extends Variable implements ITemplate {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ITemplate#getTemplateSignature() * @see org.eclipse.cdt.core.model.ITemplate#getTemplateSignature()
*/ */
public String getTemplateSignature() { public String getTemplateSignature() throws CModelException {
StringBuffer sig = new StringBuffer(getElementName()); StringBuffer sig = new StringBuffer(getElementName());
if(getNumberOfTemplateParameters() > 0){ if(getNumberOfTemplateParameters() > 0){
sig.append("<"); //$NON-NLS-1$ sig.append("<"); //$NON-NLS-1$

View file

@ -208,9 +208,13 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
if (this.useCount == 0) { if (this.useCount == 0) {
return false; return false;
} }
try {
// if resource got deleted, then #getModificationStamp() will answer IResource.NULL_STAMP, which is always different from the cached // if resource got deleted, then #getModificationStamp() will answer IResource.NULL_STAMP, which is always different from the cached
// timestamp // timestamp
return ((TranslationUnitInfo) getElementInfo()).fTimestamp == ((IFile) resource).getModificationStamp(); return ((TranslationUnitInfo) getElementInfo()).fTimestamp == ((IFile) resource).getModificationStamp();
} catch (CModelException e) {
return false;
}
} }
/** /**
* @see org.eclipse.cdt.core.model.ITranslationUnit#isWorkingCopy() * @see org.eclipse.cdt.core.model.ITranslationUnit#isWorkingCopy()

View file

@ -525,6 +525,7 @@ public class CCorePlugin extends Plugin {
} }
} catch (CoreException e) { } catch (CoreException e) {
log(e); log(e);
// ignore
} }
} }
if (configs == null) { if (configs == null) {
@ -584,7 +585,7 @@ public class CCorePlugin extends Plugin {
list.toArray(parsers); list.toArray(parsers);
} }
} catch (CoreException e) { } catch (CoreException e) {
log(e); // ignore since we fall back to a default....
} }
} }
if (parsers == null) { if (parsers == null) {

View file

@ -1,3 +1,14 @@
2004-04-20 David Inglis
More of the model throws CModeLException.
* refactor/org/eclipse/cdt/internal/corext/refactoring/rename/RenameElementProcessor.java
* src/org/eclipse/cdt/internal/ui/CElementImageProvider.java
* src/org/eclipse/cdt/internal/ui/search/CElementLabels.java
* src/org/eclipse/cdt/internal/ui/viewsupport/MemberFilter.java
* src/org/eclipse/cdt/ui/CElementContentProvider.java
* src/org/eclipse/cdt/ui/CElementLabelProvider.java
2004-04-20 Alain Magloire 2004-04-20 Alain Magloire
Fix for PR 59081 Fix for PR 59081

View file

@ -151,7 +151,7 @@ public class RenameElementProcessor extends RenameProcessor implements IReferenc
return ((CElement)fCElement).getIdStartPos(); return ((CElement)fCElement).getIdStartPos();
} }
public String getElementQualifiedName(ICElement element){ public String getElementQualifiedName(ICElement element) throws CModelException{
if(!eligibleForRefactoring(element)){ if(!eligibleForRefactoring(element)){
return ""; return "";
} else { } else {
@ -172,7 +172,7 @@ public class RenameElementProcessor extends RenameProcessor implements IReferenc
return name.toString(); return name.toString();
} }
} }
public RefactoringStatus checkNewElementName(String newName){ public RefactoringStatus checkNewElementName(String newName) throws CModelException{
if (!eligibleForRefactoring(fCElement)) { if (!eligibleForRefactoring(fCElement)) {
return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.getString("RenameTypeRefactoring.wrong_element")); //$NON-NLS-1$ return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.getString("RenameTypeRefactoring.wrong_element")); //$NON-NLS-1$
} }

View file

@ -5,6 +5,7 @@ package org.eclipse.cdt.internal.ui;
* All Rights Reserved. * All Rights Reserved.
*/ */
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.IBinary; import org.eclipse.cdt.core.model.IBinary;
import org.eclipse.cdt.core.model.IBinaryModule; import org.eclipse.cdt.core.model.IBinaryModule;
@ -339,21 +340,25 @@ public class CElementImageProvider {
return getEnumeratorImageDescriptor(); return getEnumeratorImageDescriptor();
case ICElement.C_FIELD: case ICElement.C_FIELD:
{ try {
IField field = (IField)celement; IField field = (IField)celement;
ASTAccessVisibility visibility = field.getVisibility(); ASTAccessVisibility visibility = field.getVisibility();
return getFieldImageDescriptor(visibility); return getFieldImageDescriptor(visibility);
} catch (CModelException e) {
return null;
} }
case ICElement.C_METHOD: case ICElement.C_METHOD:
case ICElement.C_METHOD_DECLARATION: case ICElement.C_METHOD_DECLARATION:
case ICElement.C_TEMPLATE_METHOD: case ICElement.C_TEMPLATE_METHOD:
{ try {
IMethodDeclaration md= (IMethodDeclaration)celement; IMethodDeclaration md= (IMethodDeclaration)celement;
ASTAccessVisibility visibility =md.getVisibility(); ASTAccessVisibility visibility =md.getVisibility();
return getMethodImageDescriptor(visibility); return getMethodImageDescriptor(visibility);
} catch (CModelException e) {
return null;
} }
case ICElement.C_VARIABLE: case ICElement.C_VARIABLE:
case ICElement.C_TEMPLATE_VARIABLE: case ICElement.C_TEMPLATE_VARIABLE:
return getVariableImageDescriptor(); return getVariableImageDescriptor();
@ -388,6 +393,7 @@ public class CElementImageProvider {
int flags= computeBasicAdornmentFlags(element, renderFlags); int flags= computeBasicAdornmentFlags(element, renderFlags);
try {
if (showOverlayIcons(renderFlags) && element instanceof IDeclaration) { if (showOverlayIcons(renderFlags) && element instanceof IDeclaration) {
IDeclaration decl = (IDeclaration) element; IDeclaration decl = (IDeclaration) element;
if(decl.isStatic()){ if(decl.isStatic()){
@ -403,6 +409,8 @@ public class CElementImageProvider {
flags |= CElementImageDescriptor.TEMPLATE; flags |= CElementImageDescriptor.TEMPLATE;
} }
} }
} catch (CModelException e) {
}
return flags; return flags;
} }

View file

@ -13,9 +13,11 @@
*/ */
package org.eclipse.cdt.internal.ui.search; package org.eclipse.cdt.internal.ui.search;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IMethod; import org.eclipse.cdt.core.model.IMethod;
import org.eclipse.cdt.core.model.IStructure; import org.eclipse.cdt.core.model.IStructure;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.ui.model.IWorkbenchAdapter; import org.eclipse.ui.model.IWorkbenchAdapter;
@ -280,6 +282,7 @@ public class CElementLabels {
} }
public static void getMethodLabel( IMethod method, int flags, StringBuffer buf ) { public static void getMethodLabel( IMethod method, int flags, StringBuffer buf ) {
try {
//return type //return type
if( getFlag( flags, M_PRE_RETURNTYPE ) && method.exists() && !method.isConstructor() ) { if( getFlag( flags, M_PRE_RETURNTYPE ) && method.exists() && !method.isConstructor() ) {
buf.append( method.getReturnType() ); buf.append( method.getReturnType() );
@ -347,6 +350,9 @@ public class CElementLabels {
buf.append( CONCAT_STRING ); buf.append( CONCAT_STRING );
getTypeLabel( method.getParent(), T_FULLY_QUALIFIED | (flags & P_COMPRESSED), buf ); getTypeLabel( method.getParent(), T_FULLY_QUALIFIED | (flags & P_COMPRESSED), buf );
} }
} catch (CModelException e) {
CUIPlugin.getDefault().log(e);
}
} }
public static void getTypeLabel(ICElement type, int flags, StringBuffer buf) { public static void getTypeLabel(ICElement type, int flags, StringBuffer buf) {

View file

@ -10,6 +10,7 @@
******************************************************************************/ ******************************************************************************/
package org.eclipse.cdt.internal.ui.viewsupport; package org.eclipse.cdt.internal.ui.viewsupport;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.IDeclaration; import org.eclipse.cdt.core.model.IDeclaration;
import org.eclipse.cdt.core.model.IField; import org.eclipse.cdt.core.model.IField;
import org.eclipse.cdt.core.model.IMember; import org.eclipse.cdt.core.model.IMember;
@ -61,6 +62,7 @@ public class MemberFilter extends ViewerFilter{
*/ */
public boolean select(Viewer viewer, Object parentElement, Object element) { public boolean select(Viewer viewer, Object parentElement, Object element) {
if(element instanceof IDeclaration){ if(element instanceof IDeclaration){
try {
IDeclaration declaration = (IDeclaration) element; IDeclaration declaration = (IDeclaration) element;
if (hasFilter(FILTER_STATIC) && (declaration.isStatic()) ) { if (hasFilter(FILTER_STATIC) && (declaration.isStatic()) ) {
return false; return false;
@ -75,6 +77,9 @@ public class MemberFilter extends ViewerFilter{
return false; return false;
} }
} }
} catch (CModelException e) {
// ignore
}
} }
return true; return true;
} }

View file

@ -206,7 +206,7 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
} }
} }
private boolean updateContainer(ICElement cfile) { private boolean updateContainer(ICElement cfile) throws CModelException {
IParent container = null; IParent container = null;
ICProject cproject = null; ICProject cproject = null;
if (cfile instanceof IBinary) { if (cfile instanceof IBinary) {

View file

@ -5,6 +5,7 @@ package org.eclipse.cdt.ui;
* All Rights Reserved. * All Rights Reserved.
*/ */
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.IBinary; import org.eclipse.cdt.core.model.IBinary;
import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IFunctionDeclaration; import org.eclipse.cdt.core.model.IFunctionDeclaration;
@ -117,6 +118,7 @@ public class CElementLabelProvider extends LabelProvider {
*/ */
public String getText(Object element) { public String getText(Object element) {
if (element instanceof ICElement) { if (element instanceof ICElement) {
try {
ICElement celem= (ICElement)element; ICElement celem= (ICElement)element;
StringBuffer name = new StringBuffer(); StringBuffer name = new StringBuffer();
@ -188,6 +190,9 @@ public class CElementLabelProvider extends LabelProvider {
name.append(" - [" + bin.getCPU() + (bin.isLittleEndian() ? "le" : "be") + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ name.append(" - [" + bin.getCPU() + (bin.isLittleEndian() ? "le" : "be") + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
} }
return name.toString(); return name.toString();
} catch (CModelException e) {
CUIPlugin.getDefault().log(e);
}
} }
return fWorkbenchLabelProvider.getText(element); return fWorkbenchLabelProvider.getText(element);
} }