1 /******************************************************************************* 2 * Copyright (c) 2000, 2005 IBM Corporation and others. 3 * All rights reserved. This program and the accompanying materials 4 * are made available under the terms of the Eclipse Public License v1.0 5 * which accompanies this distribution, and is available at 6 * http://www.eclipse.org/legal/epl-v10.html 7 * 8 * Contributors: 9 * IBM Corporation - initial API and implementation 10 *******************************************************************************/ 11 package org.eclipse.jdt.internal.debug.eval.ast.engine; 12 13 14 import org.eclipse.core.runtime.CoreException; 15 import org.eclipse.jdt.core.IJavaProject; 16 import org.eclipse.jdt.debug.core.IJavaClassObject; 17 import org.eclipse.jdt.debug.core.IJavaDebugTarget; 18 import org.eclipse.jdt.debug.core.IJavaObject; 19 import org.eclipse.jdt.debug.core.IJavaReferenceType; 20 import org.eclipse.jdt.debug.core.IJavaThread; 21 import org.eclipse.jdt.debug.core.IJavaVariable; 22 23 /** 24 * The context in which an evaluation is to be performed. An 25 * evaluation is performed in the context of an object or class. 26 * The evaluation may be in the context of a method, in which case 27 * there could be local variables. 28 * <p> 29 * Clients are not intended to implement this interface. 30 */ 31 32 public interface IRuntimeContext { 33 34 /** 35 * Returns the virtual machine in which to perform the 36 * evaluation. 37 * 38 * @return virtual machine 39 */ 40 IJavaDebugTarget getVM(); 41 42 /** 43 * Returns the receiving object context in which to perform 44 * the evaluation - equivalent to 'this'. Returns <code>null</code> 45 * if the context of an evaluation is in a class rather than 46 * an object. 47 * 48 * @return 'this', or <code>null</code> 49 * @exception EvaluationException if this method fails. Reasons include: 50 * <ul><li>Failure communicating with the VM. The exception's 51 * status code contains the underlying exception responsible for 52 * the failure.</li></ul> 53 */ 54 IJavaObject getThis() throws CoreException; 55 56 /** 57 * Returns the receiving type context in which to perform 58 * the evaluation. The type of 'this', or in the case of a 59 * static context, the class or interface in which the evaluation is being 60 * performed. 61 * 62 * @return receiving class 63 * @exception EvaluationException if this method fails. Reasons include: 64 * <ul><li>Failure communicating with the VM. The exception's 65 * status code contains the underlying exception responsible for 66 * the failure.</li></ul> 67 */ 68 IJavaReferenceType getReceivingType() throws CoreException; 69 70 /** 71 * Returns the local variables visible for the evaluation. 72 * This includes method arguments, if any. Does not return 73 * <code>null</code> returns an empty collection if there 74 * are no locals. 75 * 76 * @return local variables 77 * @exception EvaluationException if this method fails. Reasons include: 78 * <ul><li>Failure communicating with the VM. The exception's 79 * status code contains the underlying exception responsible for 80 * the failure.</li></ul> 81 */ 82 IJavaVariable[] getLocals() throws CoreException; 83 84 /** 85 * Returns the Java project context in which this expression 86 * should be compiled. 87 * 88 * @return project 89 */ 90 IJavaProject getProject(); 91 92 /** 93 * Returns the thread in which message sends may be performed. 94 * 95 * @return thread 96 */ 97 IJavaThread getThread(); 98 99 /** 100 * Returns whether the context of this evaluation is within 101 * a constructor. 102 * 103 * @return whether the context of this evaluation is within 104 * a constructor 105 * @exception EvaluationException if this method fails. Reasons include: 106 * <ul><li>Failure communicating with the VM. The exception's 107 * status code contains the underlying exception responsible for 108 * the failure.</li></ul> 109 */ 110 public boolean isConstructor() throws CoreException; 111 112 /** 113 * Loads, prepares and returns the class with the given name in this runtime 114 * context's receiving type's class loader. If the class is already loaded, 115 * it is simply returned. 116 * 117 * @param name fully qualified class name 118 * @return class object 119 * @throws CoreException if unable to load the class 120 * @since 3.2 121 */ 122 public IJavaClassObject classForName(String name) throws CoreException; 123 124 } 125 126