1 11 package org.eclipse.jdt.internal.debug.eval.ast.instructions; 12 13 14 import com.ibm.icu.text.MessageFormat; 15 16 import org.eclipse.core.runtime.CoreException; 17 import org.eclipse.core.runtime.IStatus; 18 import org.eclipse.core.runtime.Status; 19 import org.eclipse.jdt.debug.core.IJavaClassType; 20 import org.eclipse.jdt.debug.core.IJavaInterfaceType; 21 import org.eclipse.jdt.debug.core.IJavaType; 22 import org.eclipse.jdt.debug.core.IJavaVariable; 23 import org.eclipse.jdt.internal.debug.core.JDIDebugPlugin; 24 25 29 public class PushStaticFieldVariable extends CompoundInstruction { 30 31 private String fFieldName; 32 33 private String fQualifiedTypeName; 34 35 public PushStaticFieldVariable(String fieldName, String qualifiedTypeName, int start) { 36 super(start); 37 fFieldName= fieldName; 38 fQualifiedTypeName= qualifiedTypeName; 39 } 40 41 public void execute() throws CoreException { 42 IJavaType receiver= getType(fQualifiedTypeName); 43 44 IJavaVariable field= null; 45 46 if (receiver instanceof IJavaInterfaceType) { 47 field= ((IJavaInterfaceType)receiver).getField(fFieldName); 48 } else if (receiver instanceof IJavaClassType) { 49 field= ((IJavaClassType)receiver).getField(fFieldName); 50 } 51 if (field == null) { 52 String message= MessageFormat.format(InstructionsEvaluationMessages.PushStaticFieldVariable_Cannot_find_the_field__0__in__1__1, new String []{fFieldName, fQualifiedTypeName}); 53 throw new CoreException(new Status(IStatus.ERROR, JDIDebugPlugin.getUniqueIdentifier(), IStatus.OK, message, null)); } 55 push(field); 56 } 57 58 public String toString() { 59 return MessageFormat.format(InstructionsEvaluationMessages.PushStaticFieldVariable_push_static_field__0__2, new String []{fFieldName}); 60 } 61 62 } 63 64 | Popular Tags |