mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-10 12:03:16 +02:00
More parsing and cleanup
This commit is contained in:
parent
98d3530766
commit
7a4f1833a5
5 changed files with 45 additions and 79 deletions
|
@ -5,12 +5,9 @@
|
|||
|
||||
package org.eclipse.cdt.debug.mi.core.cdi.model.type;
|
||||
|
||||
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIArrayType;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIType;
|
||||
import org.eclipse.cdt.debug.mi.core.cdi.Session;
|
||||
import org.eclipse.cdt.debug.mi.core.cdi.SourceManager;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
@ -35,27 +32,14 @@ public class ArrayType extends DerivedType implements ICDIArrayType {
|
|||
int lbracket = orig.lastIndexOf('[');
|
||||
int rbracket = orig.lastIndexOf(']');
|
||||
if (lbracket != -1 && rbracket != -1 && (rbracket > lbracket)) {
|
||||
String dim = name.substring(lbracket + 1, rbracket).trim();
|
||||
try {
|
||||
String dim = name.substring(lbracket + 1, rbracket).trim();
|
||||
dimension = Integer.parseInt(dim);
|
||||
name = orig.substring(0, lbracket).trim();
|
||||
Session session = (Session)(getTarget().getSession());
|
||||
SourceManager sourceMgr = (SourceManager)session.getSourceManager();
|
||||
derivedType = sourceMgr.getType(getTarget(), name);
|
||||
} catch (CDIException e) {
|
||||
// // Try after ptype.
|
||||
// String ptype = sourceMgr.getDetailTypeName(type);
|
||||
// try {
|
||||
// type = sourceMgr.getType(ptype);
|
||||
// } catch (CDIException ex) {
|
||||
// type = new IncompleteType(typename);
|
||||
// }
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
name = orig.substring(0, lbracket).trim();
|
||||
}
|
||||
if (derivedType == null) {
|
||||
derivedType = new IncompleteType(getTarget(), name);
|
||||
}
|
||||
setDerivedType(name);
|
||||
}
|
||||
return derivedType;
|
||||
}
|
||||
|
@ -64,6 +48,10 @@ public class ArrayType extends DerivedType implements ICDIArrayType {
|
|||
* @see org.eclipse.cdt.debug.core.cdi.model.type.ICDIArrayType#getDimension()
|
||||
*/
|
||||
public int getDimension() {
|
||||
// Need to initialize.
|
||||
if (derivedType == null) {
|
||||
getComponentType();
|
||||
}
|
||||
return dimension;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,9 +5,12 @@
|
|||
|
||||
package org.eclipse.cdt.debug.mi.core.cdi.model.type;
|
||||
|
||||
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIDerivedType;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIType;
|
||||
import org.eclipse.cdt.debug.mi.core.cdi.Session;
|
||||
import org.eclipse.cdt.debug.mi.core.cdi.SourceManager;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
@ -19,4 +22,24 @@ public abstract class DerivedType extends Type implements ICDIDerivedType {
|
|||
super(target, typename);
|
||||
}
|
||||
|
||||
|
||||
void setDerivedType(String name) {
|
||||
ICDITarget target = getTarget();
|
||||
Session session = (Session)(target.getSession());
|
||||
SourceManager sourceMgr = (SourceManager)session.getSourceManager();
|
||||
try {
|
||||
derivedType = sourceMgr.getType(target, name);
|
||||
} catch (CDIException e) {
|
||||
// Try after ptype.
|
||||
try {
|
||||
String ptype = sourceMgr.getDetailTypeName(name);
|
||||
derivedType = sourceMgr.getType(target, ptype);
|
||||
} catch (CDIException ex) {
|
||||
}
|
||||
}
|
||||
if (derivedType == null) {
|
||||
derivedType = new IncompleteType(getTarget(), name);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,20 +5,20 @@
|
|||
|
||||
package org.eclipse.cdt.debug.mi.core.cdi.model.type;
|
||||
|
||||
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIFunctionType;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIType;
|
||||
import org.eclipse.cdt.debug.mi.core.cdi.Session;
|
||||
import org.eclipse.cdt.debug.mi.core.cdi.SourceManager;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class FunctionType extends DerivedType implements ICDIFunctionType {
|
||||
|
||||
String params = "";
|
||||
|
||||
public FunctionType(ICDITarget target, String typename) {
|
||||
super(target, typename);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.cdi.model.type.ICDIDerivedType#getComponentType()
|
||||
*/
|
||||
|
@ -29,27 +29,18 @@ public class FunctionType extends DerivedType implements ICDIFunctionType {
|
|||
int lparen = orig.lastIndexOf('(');
|
||||
int rparen = orig.lastIndexOf(')');
|
||||
if (lparen != -1 && rparen != -1 && (rparen > lparen)) {
|
||||
String dim = name.substring(lparen + 1, rparen).trim();
|
||||
try {
|
||||
name = orig.substring(0, lparen).trim();
|
||||
Session session = (Session)(getTarget().getSession());
|
||||
SourceManager sourceMgr = (SourceManager)session.getSourceManager();
|
||||
derivedType = sourceMgr.getType(getTarget(), name);
|
||||
} catch (CDIException e) {
|
||||
// // Try after ptype.
|
||||
// String ptype = sourceMgr.getDetailTypeName(type);
|
||||
// try {
|
||||
// type = sourceMgr.getType(ptype);
|
||||
// } catch (CDIException ex) {
|
||||
// type = new IncompleteType(typename);
|
||||
// }
|
||||
}
|
||||
}
|
||||
if (derivedType == null) {
|
||||
derivedType = new IncompleteType(getTarget(), name);
|
||||
params = name.substring(lparen + 1, rparen).trim();
|
||||
name = orig.substring(0, lparen).trim();
|
||||
}
|
||||
setDerivedType(name);
|
||||
}
|
||||
return derivedType;
|
||||
}
|
||||
|
||||
public String getArguments() {
|
||||
if (derivedType != null) {
|
||||
getComponentType();
|
||||
}
|
||||
return params;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,12 +5,9 @@
|
|||
|
||||
package org.eclipse.cdt.debug.mi.core.cdi.model.type;
|
||||
|
||||
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIPointerType;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIType;
|
||||
import org.eclipse.cdt.debug.mi.core.cdi.Session;
|
||||
import org.eclipse.cdt.debug.mi.core.cdi.SourceManager;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
@ -32,23 +29,8 @@ public class PointerType extends DerivedType implements ICDIPointerType {
|
|||
// remove last '*'
|
||||
if (star != -1) {
|
||||
name = orig.substring(0, star).trim();
|
||||
Session session = (Session)(getTarget().getSession());
|
||||
SourceManager sourceMgr = (SourceManager)session.getSourceManager();
|
||||
try {
|
||||
derivedType = sourceMgr.getType(getTarget(), name);
|
||||
} catch (CDIException e) {
|
||||
// // Try after ptype.
|
||||
// String ptype = sourceMgr.getDetailTypeName(type);
|
||||
// try {
|
||||
// type = sourceMgr.getType(ptype);
|
||||
// } catch (CDIException ex) {
|
||||
// type = new IncompleteType(typename);
|
||||
// }
|
||||
}
|
||||
}
|
||||
if (derivedType == null) {
|
||||
derivedType = new IncompleteType(getTarget(), name);
|
||||
}
|
||||
setDerivedType(name);
|
||||
}
|
||||
return derivedType;
|
||||
}
|
||||
|
|
|
@ -5,12 +5,9 @@
|
|||
|
||||
package org.eclipse.cdt.debug.mi.core.cdi.model.type;
|
||||
|
||||
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIReferenceType;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIType;
|
||||
import org.eclipse.cdt.debug.mi.core.cdi.Session;
|
||||
import org.eclipse.cdt.debug.mi.core.cdi.SourceManager;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
@ -31,26 +28,11 @@ public class ReferenceType extends DerivedType implements ICDIReferenceType {
|
|||
String orig = getTypeName();
|
||||
String name = orig;
|
||||
int amp = orig.lastIndexOf('&');
|
||||
// remove last '*'
|
||||
// remove last '&'
|
||||
if (amp != -1) {
|
||||
name = orig.substring(0, amp).trim();
|
||||
Session session = (Session)(getTarget().getSession());
|
||||
SourceManager sourceMgr = (SourceManager)session.getSourceManager();
|
||||
try {
|
||||
derivedType = sourceMgr.getType(getTarget(), name);
|
||||
} catch (CDIException e) {
|
||||
// // Try after ptype.
|
||||
// String ptype = sourceMgr.getDetailTypeName(type);
|
||||
// try {
|
||||
// type = sourceMgr.getType(ptype);
|
||||
// } catch (CDIException ex) {
|
||||
// type = new IncompleteType(typename);
|
||||
// }
|
||||
}
|
||||
}
|
||||
if (derivedType == null) {
|
||||
derivedType = new IncompleteType(getTarget(), name);
|
||||
}
|
||||
setDerivedType(name);
|
||||
}
|
||||
return derivedType;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue