|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ICodeSnippetRequestor
A code snippet requestor implements a callback interface for installing the class files for a code snippet on the target and running it. In addition, it receives compilation problems detected during code snippet compilation.
Clients may implement this interface to provide a bridge a running JavaScript VM.
IEvaluationContext#evaluateCodeSnippet(String, ICodeSnippetRequestor, org.eclipse.core.runtime.IProgressMonitor)
,
Provisional API: This class/interface is part of an interim API that is still under development and expected to
change significantly before reaching stability. It is being made available at this early stage to solicit feedback
from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
(repeatedly) as the API evolves.
Field Summary | |
---|---|
static int |
CODE_SNIPPET
Indicates a compilation problem related to a code snippet. |
static java.lang.String |
DELEGATE_THIS
The name of the field that represent 'this' in a snippet class instance. |
static int |
IMPORT
Indicates a compilation problem related to an import declaration. |
static int |
INTERNAL
Indicates an internal problem. |
static java.lang.String |
LOCAL_VAR_PREFIX
The prefix of fields that represent the local variables in a snippet class. |
static int |
PACKAGE
Indicates a compilation problem related to a package declaration. |
static java.lang.String |
RESULT_TYPE_FIELD
The field of type java.lang.Class on the code snippet instance that contains the type of the returned value. |
static java.lang.String |
RESULT_VALUE_FIELD
The name of the field (of type java.lang.Object ) on the code
snippet instance that contains the returned value. |
static java.lang.String |
RUN_METHOD
The name of the instance method in the snippet class that runs the code snippet. |
static int |
VARIABLE
Indicates a compilation problem related to a global variable. |
Method Summary | |
---|---|
boolean |
acceptClassFiles(byte[][] classFileBytes,
java.lang.String[][] classFileCompoundNames,
java.lang.String codeSnippetClassName)
Sends the given class files to the target and loads them. |
void |
acceptProblem(IMarker problemMarker,
java.lang.String fragmentSource,
int fragmentKind)
Notifies of an evaluation problem. |
Field Detail |
---|
static final java.lang.String LOCAL_VAR_PREFIX
static final java.lang.String DELEGATE_THIS
static final java.lang.String RUN_METHOD
static final java.lang.String RESULT_VALUE_FIELD
java.lang.Object
) on the code
snippet instance that contains the returned value.
static final java.lang.String RESULT_TYPE_FIELD
java.lang.Class
) on the code
snippet instance that contains the runtime type of the returned value.
static final int VARIABLE
Note: if the problem is on the type of the variable, the marker source line number is -1; if the name of the variable, line number is 0; otherwise, the marker source line number is relative to the initializer code.
acceptProblem(IMarker, String, int)
,
Constant Field Valuesstatic final int CODE_SNIPPET
acceptProblem(IMarker, String, int)
,
Constant Field Valuesstatic final int IMPORT
acceptProblem(IMarker, String, int)
,
Constant Field Valuesstatic final int PACKAGE
acceptProblem(IMarker, String, int)
,
Constant Field Valuesstatic final int INTERNAL
acceptProblem(IMarker, String, int)
,
Constant Field ValuesMethod Detail |
---|
boolean acceptClassFiles(byte[][] classFileBytes, java.lang.String[][] classFileCompoundNames, java.lang.String codeSnippetClassName)
null
, run the code snippet with this class
name. Returns whether the code snippet could be deployed. Note it must
return true
even if running the code snippet threw an exception.
The details of sending and loading the class files are left up to implementations.
To run a code snippet, an implementation should create a new instance of
the given code snippet class and call (directly or using another means) its
RUN_METHOD
.
Also before the call, the implementation should copy the values of the local
variables (if any) into the corresponding fields of the code snippet instance.
A field name is formed of LOCAL_VAR_PREFIX
preceded the name of the local variable. For example, the field name for
local variable "myLocal"
is "val$myLocal"
(assuming the
value of LOCAL_VAR_PREFIX
is "val$"). In the
same way, the implementation should copy the value of the 'this' object into the
field called DELEGATE_THIS
.
After calling the RUN_METHOD
, the values of the local
variables may have been modified. The implementation must copy the
values of the fields back into the local variables.
Finally, the overall value returned by the code snippet can be retrieved
from the special field RESULT_VALUE_FIELD
on the code snippet instance.
The Class
that is the runtime type of the returned value can be
retrieved from the special field RESULT_TYPE_FIELD
.
classFileBytes
- the list of class file bytesclassFileCompoundNames
- the corresponding list of class file type
compound names (example of a compound name: {"java", "lang", "Object"})codeSnippetClassName
- name of the actual class to instantiate and run,
or null
if none
true
if the code snippet was successfully deployedvoid acceptProblem(IMarker problemMarker, java.lang.String fragmentSource, int fragmentKind)
VARIABLE
) - fragment source is name of
variableCODE_SNIPPET
) - fragment source is code
snippetIMPORT
) - fragment source is
importPACKAGE
) - fragment source is
package declarationINTERNAL
) - no fragment source is involved, internal error occurred.
problemMarker
- the problem marker (cannot be null)fragmentSource
- the fragment sourcefragmentKind
- the kind of source fragment; one of:
VARIABLE
, CODE_SNIPPET
, IMPORT
,
PACKAGE
, or INTERNAL
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |