1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

Bug 326372: Enhancing CElementHandles by Patrick Hofer.

This commit is contained in:
Markus Schorn 2010-09-29 12:57:42 +00:00
parent bbf5a39ad8
commit d68ed8353d
5 changed files with 45 additions and 5 deletions

View file

@ -213,10 +213,6 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
return ""; //$NON-NLS-1$
}
public String getReturnType() {
return ""; //$NON-NLS-1$
}
public boolean isConst() {
return false;
}

View file

@ -10,6 +10,9 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.model.ext;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IField;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement;
@ -18,14 +21,26 @@ import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
public class FieldHandle extends CElementHandle implements org.eclipse.cdt.core.model.IField {
private ASTAccessVisibility fVisibility;
private String fTypeName;
private boolean fIsStatic;
public FieldHandle(ICElement parent, IField field) {
super(parent, ICElement.C_FIELD, field.getName());
try {
fTypeName= ASTTypeUtil.getType(field.getType(), false);
} catch (DOMException e) {
CCorePlugin.log(e);
fTypeName= ""; //$NON-NLS-1$
}
fVisibility= getVisibility(field);
fIsStatic= field.isStatic();
}
@Override
public String getTypeName() {
return fTypeName;
}
public ASTAccessVisibility getVisibility() throws CModelException {
return fVisibility;
}

View file

@ -11,6 +11,7 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.model.ext;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IFunction;
import org.eclipse.cdt.core.model.CModelException;
@ -18,9 +19,10 @@ import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IFunctionDeclaration;
import org.eclipse.cdt.internal.core.model.FunctionDeclaration;
public class FunctionDeclarationHandle extends CElementHandle implements org.eclipse.cdt.core.model.IFunctionDeclaration {
public class FunctionDeclarationHandle extends CElementHandle implements IFunctionDeclaration {
private String[] fParameterTypes;
private String fReturnType;
private boolean fIsStatic;
public FunctionDeclarationHandle(ICElement parent, IFunction func) throws DOMException {
@ -30,6 +32,7 @@ public class FunctionDeclarationHandle extends CElementHandle implements org.ecl
protected FunctionDeclarationHandle(ICElement parent, int type, IFunction func) throws DOMException {
super(parent, type, func.getName());
fParameterTypes= extractParameterTypes(func);
fReturnType= ASTTypeUtil.getType(func.getType().getReturnType(), false);
fIsStatic= func.isStatic();
}
@ -49,6 +52,10 @@ public class FunctionDeclarationHandle extends CElementHandle implements org.ecl
return fParameterTypes;
}
public String getReturnType() {
return fReturnType;
}
public String getSignature() throws CModelException {
return FunctionDeclaration.getSignature(this);
}

View file

@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.model.ext;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
@ -22,6 +23,7 @@ import org.eclipse.cdt.internal.core.model.MethodDeclaration;
public class MethodDeclarationHandle extends CElementHandle implements IMethodDeclaration {
private String[] fParameterTypes;
private String fReturnType;
private ASTAccessVisibility fVisibility;
private boolean fIsStatic;
private boolean fIsConstructor;
@ -34,6 +36,7 @@ public class MethodDeclarationHandle extends CElementHandle implements IMethodDe
protected MethodDeclarationHandle(ICElement parent, int type, ICPPMethod method) throws DOMException {
super(parent, type, method.getName());
fParameterTypes= extractParameterTypes(method);
fReturnType= ASTTypeUtil.getType(method.getType().getReturnType(), false);
fVisibility= getVisibility(method);
fIsStatic= method.isStatic();
fIsConstructor= method instanceof ICPPConstructor;
@ -58,6 +61,10 @@ public class MethodDeclarationHandle extends CElementHandle implements IMethodDe
return fParameterTypes;
}
public String getReturnType() {
return fReturnType;
}
public String getSignature() throws CModelException {
return FunctionDeclaration.getSignature(this);
}

View file

@ -10,18 +10,33 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.model.ext;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IVariable;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement;
public class VariableHandle extends CElementHandle implements org.eclipse.cdt.core.model.IVariable {
private String fTypeName;
private boolean fIsStatic;
public VariableHandle(ICElement parent, IVariable var) {
super(parent, ICElement.C_VARIABLE, var.getName());
try {
fTypeName= ASTTypeUtil.getType(var.getType(), false);
} catch (DOMException e) {
CCorePlugin.log(e);
fTypeName= ""; //$NON-NLS-1$
}
fIsStatic= var.isStatic();
}
@Override
public String getTypeName() {
return fTypeName;
}
public boolean isStatic() throws CModelException {
return fIsStatic;
}