/** * Returns whether the given field variable has the same name as any variables */ protected boolean isDuplicateName(IJavaFieldVariable variable) { IJavaReferenceType javaType= variable.getReceivingType(); try { String[] names = javaType.getAllFieldNames(); boolean found= false; for (int i = 0; i < names.length; i++) { if (variable.getName().equals(names[i])) { if (found) { return true; } found= true; } } return false; } catch (DebugException e) { } return false; }
private IJavaObject getObject(IJavaObject object, String field, boolean superfield) throws DebugException { IJavaFieldVariable variable = object.getField(field, superfield); if (variable != null) { IValue value = variable.getValue(); if (value instanceof IJavaObject) return (IJavaObject) value; } return null; }
/** * Determines if the selection is a field or not * @param selection the current selection * @return true if the selection is a field false otherwise */ private boolean isFields(IStructuredSelection selection) { if (!selection.isEmpty()) { try { Iterator iterator = selection.iterator(); while (iterator.hasNext()) { Object thing = iterator.next(); if (thing instanceof IField) { int flags = ((IField)thing).getFlags(); return !Flags.isFinal(flags) & !(Flags.isFinal(flags) & Flags.isStatic(flags)); } else if(thing instanceof IJavaFieldVariable) { IJavaFieldVariable fv = (IJavaFieldVariable)thing; return !fv.isFinal() & !(fv.isFinal() & fv.isStatic()); } } } catch(JavaModelException e) {return false;} catch(DebugException de) {return false;} } return false; }
typeName = var.getDeclaringType().getName(); fieldName = var.getName(); boolean fin = var.isFinal(); allowed = !(fin) & !(var.isStatic() & fin);
/** * Return the associated IField (Java model) for the given * IJavaFieldVariable (JDI model) */ private IField getField(IJavaFieldVariable variable) throws CoreException { String varName = null; try { varName = variable.getName(); } catch (DebugException x) { JDIDebugUIPlugin.log(x); return null; } IField field; IJavaType declaringType = variable.getDeclaringType(); IType type = JavaDebugUtils.resolveType(declaringType); if (type != null) { field = type.getField(varName); if (field.exists()) { return field; } } return null; }
if (isDuplicateName(field)) { try { String decl = field.getDeclaringType().getName(); buff.append(MessageFormat.format(" ({0})", new String[]{getQualifiedName(decl)})); //$NON-NLS-1$ } catch (DebugException e) {
IJavaWatchpoint wp = (IJavaWatchpoint)jbp; IJavaFieldVariable fv = (IJavaFieldVariable)variable; if (variable.getName().equals(wp.getFieldName()) && fv.getDeclaringType().getName().equals(wp.getTypeName())) { valid = wp;
IType type = JavaDebugUtils.resolveType(var.getDeclaringType()); return type != null && type.isInterface();
private String getValue(IJavaObject object, String variable) throws DebugException { IJavaFieldVariable var = object.getField(variable, false); return var == null ? null : var.getValue().getValueString(); }