|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.aspectj.org.eclipse.jdt.internal.core.eval.EvaluationContextWrapper
public class EvaluationContextWrapper
A wrapper around the infrastructure evaluation context.
| Field Summary | |
|---|---|
protected EvaluationContext |
context
|
protected JavaProject |
project
|
| Constructor Summary | |
|---|---|
EvaluationContextWrapper(EvaluationContext context,
JavaProject project)
Creates a new wrapper around the given infrastructure evaluation context and project. |
|
| Method Summary | |
|---|---|
IGlobalVariable[] |
allVariables()
Returns the global variables declared in this evaluation context. |
protected void |
checkBuilderState()
Checks to ensure that there is a previously built state. |
void |
codeComplete(java.lang.String codeSnippet,
int position,
CompletionRequestor requestor)
Performs a code completion at the given position in the given code snippet, reporting results to the given completion requestor. |
void |
codeComplete(java.lang.String codeSnippet,
int position,
CompletionRequestor requestor,
IProgressMonitor monitor)
Performs a code completion at the given position in the given code snippet, reporting results to the given completion requestor. |
void |
codeComplete(java.lang.String codeSnippet,
int position,
CompletionRequestor requestor,
WorkingCopyOwner owner,
IProgressMonitor monitor)
Performs a code completion at the given position in the given code snippet, reporting results to the given completion requestor. |
void |
codeComplete(java.lang.String codeSnippet,
int position,
ICodeCompletionRequestor requestor)
Deprecated. - use codeComplete(String, int, ICompletionRequestor) instead |
void |
codeComplete(java.lang.String codeSnippet,
int position,
ICompletionRequestor requestor)
Deprecated. |
void |
codeComplete(java.lang.String codeSnippet,
int position,
ICompletionRequestor requestor,
WorkingCopyOwner owner)
Deprecated. |
IJavaElement[] |
codeSelect(java.lang.String codeSnippet,
int offset,
int length)
Resolves and returns a collection of Java elements corresponding to the source code at the given positions in the given code snippet. |
IJavaElement[] |
codeSelect(java.lang.String codeSnippet,
int offset,
int length,
WorkingCopyOwner owner)
Resolves and returns a collection of Java elements corresponding to the source code at the given positions in the given code snippet. |
void |
deleteVariable(IGlobalVariable variable)
Deletes the given variable from this evaluation context. |
void |
evaluateCodeSnippet(java.lang.String codeSnippet,
ICodeSnippetRequestor requestor,
IProgressMonitor progressMonitor)
Evaluates the given code snippet. |
void |
evaluateCodeSnippet(java.lang.String codeSnippet,
java.lang.String[] localVariableTypeNames,
java.lang.String[] localVariableNames,
int[] localVariableModifiers,
IType declaringType,
boolean isStatic,
boolean isConstructorCall,
ICodeSnippetRequestor requestor,
IProgressMonitor progressMonitor)
Evaluates the given code snippet in the context of a suspended thread. |
void |
evaluateVariable(IGlobalVariable variable,
ICodeSnippetRequestor requestor,
IProgressMonitor progressMonitor)
Evaluates the given global variable. |
protected INameEnvironment |
getBuildNameEnvironment()
Returns a name environment for the last built state. |
java.lang.String[] |
getImports()
Returns the import declarations for this evaluation context. |
EvaluationContext |
getInfrastructureEvaluationContext()
Returns the infrastructure evaluation context. |
protected IRequestor |
getInfrastructureEvaluationRequestor(ICodeSnippetRequestor requestor)
Returns a new infrastructure evaluation requestor instance. |
java.lang.String |
getPackageName()
Returns the name of the package in which code snippets are to be compiled and run. |
protected IProblemFactory |
getProblemFactory()
Returns the problem factory to be used during evaluation. |
IJavaProject |
getProject()
Returns the Java project this evaluation context was created for. |
char[] |
getVarClassName()
|
protected void |
handleInstallException(InstallException e)
Handles an install exception by throwing a Java Model exception. |
IGlobalVariable |
newVariable(java.lang.String typeName,
java.lang.String name,
java.lang.String initializer)
Creates a new global variable with the given name, type, and initializer. |
void |
setImports(java.lang.String[] imports)
Sets the import declarations for this evaluation context. |
void |
setPackageName(java.lang.String packageName)
Sets the dot-separated name of the package in which code snippets are to be compiled and run. |
void |
validateImports(ICodeSnippetRequestor requestor)
Validates this evaluation context's import declarations. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected EvaluationContext context
protected JavaProject project
| Constructor Detail |
|---|
public EvaluationContextWrapper(EvaluationContext context,
JavaProject project)
| Method Detail |
|---|
public IGlobalVariable[] allVariables()
IEvaluationContext
allVariables in interface IEvaluationContextIEvaluationContext.allVariables()protected void checkBuilderState()
public void codeComplete(java.lang.String codeSnippet,
int position,
ICompletionRequestor requestor)
throws JavaModelException
IEvaluationContextNote that code completion does not involve evaluation.
codeComplete in interface IEvaluationContextcodeSnippet - the code snippet to complete inposition - the character position in the code snippet to complete at,
or -1 indicating the beginning of the snippetrequestor - the code completion requestor capable of accepting all
possible types of completions
JavaModelException - if code completion could not be performed. Reasons include:
IEvaluationContext.codeComplete(String, int, ICompletionRequestor)
public void codeComplete(java.lang.String codeSnippet,
int position,
ICompletionRequestor requestor,
WorkingCopyOwner owner)
throws JavaModelException
IEvaluationContextNote that if a working copy is empty, it will be as if the original compilation unit had been deleted.
Note that code completion does not involve evaluation.
codeComplete in interface IEvaluationContextcodeSnippet - the code snippet to complete inposition - the character position in the code snippet to complete at,
or -1 indicating the beginning of the snippetrequestor - the code completion requestor capable of accepting all
possible types of completionsowner - the owner of working copies that take precedence over their original compilation units
JavaModelException - if code completion could not be performed. Reasons include:
IEvaluationContext.codeComplete(String, int, ICompletionRequestor, WorkingCopyOwner)
public void codeComplete(java.lang.String codeSnippet,
int position,
CompletionRequestor requestor)
throws JavaModelException
IEvaluationContextNote that code completion does not involve evaluation.
codeComplete in interface IEvaluationContextcodeSnippet - the code snippet to complete inposition - the character position in the code snippet to complete at,
or -1 indicating the beginning of the snippetrequestor - the code completion requestor capable of accepting all
possible types of completions
JavaModelException - if code completion could not be performed. Reasons include:
IEvaluationContext.codeComplete(String, int, CompletionRequestor)
public void codeComplete(java.lang.String codeSnippet,
int position,
CompletionRequestor requestor,
IProgressMonitor monitor)
throws JavaModelException
IEvaluationContextNote that code completion does not involve evaluation.
If IProgressMonitor is not null then some proposals which
can be very long to compute are proposed. To avoid that the code assist operation
take too much time a IProgressMonitor which automatically cancel the code
assist operation when a specified amount of time is reached could be used.
new IProgressMonitor() {
private final static int TIMEOUT = 500; //ms
private long endTime;
public void beginTask(String name, int totalWork) {
fEndTime= System.currentTimeMillis() + TIMEOUT;
}
public boolean isCanceled() {
return endTime <= System.currentTimeMillis();
}
...
};
codeComplete in interface IEvaluationContextcodeSnippet - the code snippet to complete inposition - the character position in the code snippet to complete at,
or -1 indicating the beginning of the snippetrequestor - the code completion requestor capable of accepting all
possible types of completionsmonitor - the progress monitor used to report progress
JavaModelException - if code completion could not be performed. Reasons include:
IEvaluationContext.codeComplete(String, int, CompletionRequestor, IProgressMonitor)
public void codeComplete(java.lang.String codeSnippet,
int position,
CompletionRequestor requestor,
WorkingCopyOwner owner,
IProgressMonitor monitor)
throws JavaModelException
IEvaluationContextNote that if a working copy is empty, it will be as if the original compilation unit had been deleted.
Note that code completion does not involve evaluation.
If IProgressMonitor is not null then some proposals which
can be very long to compute are proposed. To avoid that the code assist operation
take too much time a IProgressMonitor which automatically cancel the code
assist operation when a specified amount of time is reached could be used.
new IProgressMonitor() {
private final static int TIMEOUT = 500; //ms
private long endTime;
public void beginTask(String name, int totalWork) {
fEndTime= System.currentTimeMillis() + TIMEOUT;
}
public boolean isCanceled() {
return endTime <= System.currentTimeMillis();
}
...
};
codeComplete in interface IEvaluationContextcodeSnippet - the code snippet to complete inposition - the character position in the code snippet to complete at,
or -1 indicating the beginning of the snippetrequestor - the code completion requestor capable of accepting all
possible types of completionsowner - the owner of working copies that take precedence over their original compilation unitsmonitor - the progress monitor used to report progress
JavaModelException - if code completion could not be performed. Reasons include:
IEvaluationContext.codeComplete(String, int, CompletionRequestor, WorkingCopyOwner, IProgressMonitor)
public IJavaElement[] codeSelect(java.lang.String codeSnippet,
int offset,
int length)
throws JavaModelException
IEvaluationContextNote that code select does not involve evaluation, and problems are never reported.
codeSelect in interface IEvaluationContextcodeSnippet - the code snippet to resolve inoffset - the position in the code snippet of the first character
of the code to resolvelength - the length of the selected code to resolve
JavaModelException - if code resolve could not be performed.
Reasons include:
IEvaluationContext.codeSelect(String, int, int)
public IJavaElement[] codeSelect(java.lang.String codeSnippet,
int offset,
int length,
WorkingCopyOwner owner)
throws JavaModelException
IEvaluationContextNote that if a working copy is empty, it will be as if the original compilation unit had been deleted.
Note that code select does not involve evaluation, and problems are never reported.
codeSelect in interface IEvaluationContextcodeSnippet - the code snippet to resolve inoffset - the position in the code snippet of the first character
of the code to resolvelength - the length of the selected code to resolveowner - the owner of working copies that take precedence over their original compilation units
JavaModelException - if code resolve could not be performed.
Reasons include:
IEvaluationContext.codeSelect(String, int, int, WorkingCopyOwner)public void deleteVariable(IGlobalVariable variable)
IEvaluationContext
deleteVariable in interface IEvaluationContextvariable - the global variableIEvaluationContext.deleteVariable(IGlobalVariable)
public void evaluateCodeSnippet(java.lang.String codeSnippet,
java.lang.String[] localVariableTypeNames,
java.lang.String[] localVariableNames,
int[] localVariableModifiers,
IType declaringType,
boolean isStatic,
boolean isConstructorCall,
ICodeSnippetRequestor requestor,
IProgressMonitor progressMonitor)
throws JavaModelException
IEvaluationContextacceptProblem method is called for each compilation problem that
is detected. Then the resulting class files are handed to the given
requestor's acceptClassFiles method to deploy and run.
The requestor is expected to:
run() of the code snippet,
This method is long-running; progress and cancellation are provided by the given progress monitor.
evaluateCodeSnippet in interface IEvaluationContextcodeSnippet - the code snippetlocalVariableTypeNames - the dot-separated fully qualified names of the types of the local variables.localVariableNames - the names of the local variables as they are declared in the user's code.localVariableModifiers - the modifiers of the local variables (default modifier or final modifier).declaringType - the type in which the code snippet is evaluated.isStatic - whether the code snippet is evaluated in a static member of the declaring type.isConstructorCall - whether the code snippet is evaluated in a constructor of the declaring type.requestor - the code snippet requestorprogressMonitor - a progress monitor
JavaModelException - if a runtime problem occurred or if this
context's project has no build stateIEvaluationContext.evaluateCodeSnippet(String, String[], String[], int[], IType, boolean, boolean, ICodeSnippetRequestor, IProgressMonitor)
public void evaluateCodeSnippet(java.lang.String codeSnippet,
ICodeSnippetRequestor requestor,
IProgressMonitor progressMonitor)
throws JavaModelException
IEvaluationContextacceptProblem method
is called for each compilation problem that is detected. Then the resulting
class files are handed to the given requestor's acceptClassFiles
method to deploy and run. The requestor is also responsible for getting the
result back.
This method is long-running; progress and cancellation are provided by the given progress monitor.
evaluateCodeSnippet in interface IEvaluationContextcodeSnippet - the code snippetrequestor - the code snippet requestorprogressMonitor - a progress monitor
JavaModelException - if a runtime problem occurred or if this
context's project has no build stateIEvaluationContext.evaluateCodeSnippet(String, ICodeSnippetRequestor, IProgressMonitor)
public void evaluateVariable(IGlobalVariable variable,
ICodeSnippetRequestor requestor,
IProgressMonitor progressMonitor)
throws JavaModelException
IEvaluationContextacceptProblem
method will be called for each problem that is detected.
This method is long-running; progress and cancellation are provided by the given progress monitor.
evaluateVariable in interface IEvaluationContextvariable - the global variablerequestor - the code snippet requestorprogressMonitor - a progress monitor
JavaModelException - if a runtime problem occurred or if this
context's project has no build stateIEvaluationContext.evaluateVariable(IGlobalVariable, ICodeSnippetRequestor, IProgressMonitor)protected INameEnvironment getBuildNameEnvironment()
public char[] getVarClassName()
public java.lang.String[] getImports()
IEvaluationContext"java.util.Hashtable" or "java.util.*".
getImports in interface IEvaluationContextIEvaluationContext.getImports()public EvaluationContext getInfrastructureEvaluationContext()
protected IRequestor getInfrastructureEvaluationRequestor(ICodeSnippetRequestor requestor)
public java.lang.String getPackageName()
IEvaluationContext"com.example.myapp".
getPackageName in interface IEvaluationContextIEvaluationContext.getPackageName()protected IProblemFactory getProblemFactory()
public IJavaProject getProject()
IEvaluationContext
getProject in interface IEvaluationContextIEvaluationContext.getProject()
protected void handleInstallException(InstallException e)
throws JavaModelException
JavaModelException
public IGlobalVariable newVariable(java.lang.String typeName,
java.lang.String name,
java.lang.String initializer)
IEvaluationContext
The typeName and initializer are interpreted in
the context of this context's package and import declarations.
The syntax for a type name corresponds to Type in Field Declaration (JLS2 8.3).
newVariable in interface IEvaluationContexttypeName - the type namename - the name of the global variableinitializer - the initializer expression, or null if the
variable is not initialized
IEvaluationContext.newVariable(String, String, String)public void setImports(java.lang.String[] imports)
IEvaluationContext"java.util.Hashtable"
or "java.util.*".
setImports in interface IEvaluationContextimports - the list of import namesIEvaluationContext.setImports(String[])public void setPackageName(java.lang.String packageName)
IEvaluationContext"com.example.myapp".
setPackageName in interface IEvaluationContextpackageName - the dot-separated package name, or the empty string
indicating the default packageIEvaluationContext.setPackageName(String)public void validateImports(ICodeSnippetRequestor requestor)
IEvaluationContextacceptProblem method is called for each problem that is detected.
validateImports in interface IEvaluationContextrequestor - the code snippet requestorIEvaluationContext.validateImports(ICodeSnippetRequestor)
public void codeComplete(java.lang.String codeSnippet,
int position,
ICodeCompletionRequestor requestor)
throws JavaModelException
IEvaluationContextNote that code completion does not involve evaluation.
codeComplete in interface IEvaluationContextcodeSnippet - the code snippet to complete inposition - the character position in the code snippet to complete at,
or -1 indicating the beginning of the snippetrequestor - the code completion requestor capable of accepting all
possible types of completions
JavaModelException - if code completion could not be performed. Reasons include:
IEvaluationContext.codeComplete(String, int, ICodeCompletionRequestor)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||