mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-29 20:05:35 +02:00
Bug 326372: Enhancing CElementHandles by Patrick Hofer.
This commit is contained in:
parent
bbf5a39ad8
commit
d68ed8353d
5 changed files with 45 additions and 5 deletions
|
@ -213,10 +213,6 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
|
||||||
return ""; //$NON-NLS-1$
|
return ""; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getReturnType() {
|
|
||||||
return ""; //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isConst() {
|
public boolean isConst() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,9 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.model.ext;
|
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.dom.ast.IField;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
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 {
|
public class FieldHandle extends CElementHandle implements org.eclipse.cdt.core.model.IField {
|
||||||
|
|
||||||
private ASTAccessVisibility fVisibility;
|
private ASTAccessVisibility fVisibility;
|
||||||
|
private String fTypeName;
|
||||||
private boolean fIsStatic;
|
private boolean fIsStatic;
|
||||||
|
|
||||||
public FieldHandle(ICElement parent, IField field) {
|
public FieldHandle(ICElement parent, IField field) {
|
||||||
super(parent, ICElement.C_FIELD, field.getName());
|
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);
|
fVisibility= getVisibility(field);
|
||||||
fIsStatic= field.isStatic();
|
fIsStatic= field.isStatic();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTypeName() {
|
||||||
|
return fTypeName;
|
||||||
|
}
|
||||||
|
|
||||||
public ASTAccessVisibility getVisibility() throws CModelException {
|
public ASTAccessVisibility getVisibility() throws CModelException {
|
||||||
return fVisibility;
|
return fVisibility;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.model.ext;
|
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.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IFunction;
|
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
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.core.model.IFunctionDeclaration;
|
||||||
import org.eclipse.cdt.internal.core.model.FunctionDeclaration;
|
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[] fParameterTypes;
|
||||||
|
private String fReturnType;
|
||||||
private boolean fIsStatic;
|
private boolean fIsStatic;
|
||||||
|
|
||||||
public FunctionDeclarationHandle(ICElement parent, IFunction func) throws DOMException {
|
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 {
|
protected FunctionDeclarationHandle(ICElement parent, int type, IFunction func) throws DOMException {
|
||||||
super(parent, type, func.getName());
|
super(parent, type, func.getName());
|
||||||
fParameterTypes= extractParameterTypes(func);
|
fParameterTypes= extractParameterTypes(func);
|
||||||
|
fReturnType= ASTTypeUtil.getType(func.getType().getReturnType(), false);
|
||||||
fIsStatic= func.isStatic();
|
fIsStatic= func.isStatic();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,6 +52,10 @@ public class FunctionDeclarationHandle extends CElementHandle implements org.ecl
|
||||||
return fParameterTypes;
|
return fParameterTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getReturnType() {
|
||||||
|
return fReturnType;
|
||||||
|
}
|
||||||
|
|
||||||
public String getSignature() throws CModelException {
|
public String getSignature() throws CModelException {
|
||||||
return FunctionDeclaration.getSignature(this);
|
return FunctionDeclaration.getSignature(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.model.ext;
|
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.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
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 {
|
public class MethodDeclarationHandle extends CElementHandle implements IMethodDeclaration {
|
||||||
private String[] fParameterTypes;
|
private String[] fParameterTypes;
|
||||||
|
private String fReturnType;
|
||||||
private ASTAccessVisibility fVisibility;
|
private ASTAccessVisibility fVisibility;
|
||||||
private boolean fIsStatic;
|
private boolean fIsStatic;
|
||||||
private boolean fIsConstructor;
|
private boolean fIsConstructor;
|
||||||
|
@ -34,6 +36,7 @@ public class MethodDeclarationHandle extends CElementHandle implements IMethodDe
|
||||||
protected MethodDeclarationHandle(ICElement parent, int type, ICPPMethod method) throws DOMException {
|
protected MethodDeclarationHandle(ICElement parent, int type, ICPPMethod method) throws DOMException {
|
||||||
super(parent, type, method.getName());
|
super(parent, type, method.getName());
|
||||||
fParameterTypes= extractParameterTypes(method);
|
fParameterTypes= extractParameterTypes(method);
|
||||||
|
fReturnType= ASTTypeUtil.getType(method.getType().getReturnType(), false);
|
||||||
fVisibility= getVisibility(method);
|
fVisibility= getVisibility(method);
|
||||||
fIsStatic= method.isStatic();
|
fIsStatic= method.isStatic();
|
||||||
fIsConstructor= method instanceof ICPPConstructor;
|
fIsConstructor= method instanceof ICPPConstructor;
|
||||||
|
@ -58,6 +61,10 @@ public class MethodDeclarationHandle extends CElementHandle implements IMethodDe
|
||||||
return fParameterTypes;
|
return fParameterTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getReturnType() {
|
||||||
|
return fReturnType;
|
||||||
|
}
|
||||||
|
|
||||||
public String getSignature() throws CModelException {
|
public String getSignature() throws CModelException {
|
||||||
return FunctionDeclaration.getSignature(this);
|
return FunctionDeclaration.getSignature(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,18 +10,33 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.model.ext;
|
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.dom.ast.IVariable;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
|
||||||
public class VariableHandle extends CElementHandle implements org.eclipse.cdt.core.model.IVariable {
|
public class VariableHandle extends CElementHandle implements org.eclipse.cdt.core.model.IVariable {
|
||||||
|
private String fTypeName;
|
||||||
private boolean fIsStatic;
|
private boolean fIsStatic;
|
||||||
|
|
||||||
public VariableHandle(ICElement parent, IVariable var) {
|
public VariableHandle(ICElement parent, IVariable var) {
|
||||||
super(parent, ICElement.C_VARIABLE, var.getName());
|
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();
|
fIsStatic= var.isStatic();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTypeName() {
|
||||||
|
return fTypeName;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isStatic() throws CModelException {
|
public boolean isStatic() throws CModelException {
|
||||||
return fIsStatic;
|
return fIsStatic;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue