Klasse EvaluationContextWrapper
- Alle implementierten Schnittstellen:
IEvaluationContext
-
Feldübersicht
-
Konstruktorübersicht
KonstruktorBeschreibungEvaluationContextWrapper
(EvaluationContext context, JavaProject project) Creates a new wrapper around the given infrastructure evaluation context and project. -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungReturns the global variables declared in this evaluation context.protected void
Checks to ensure that there is a previously built state.void
codeComplete
(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
(String codeSnippet, int position, CompletionRequestor requestor, WorkingCopyOwner owner) Performs a code completion at the given position in the given code snippet, reporting results to the given completion requestor.void
codeComplete
(String codeSnippet, int position, CompletionRequestor requestor, WorkingCopyOwner owner, org.eclipse.core.runtime.IProgressMonitor monitor) Performs a code completion at the given position in the given code snippet, reporting results to the given completion requestor.void
codeComplete
(String codeSnippet, int position, CompletionRequestor requestor, org.eclipse.core.runtime.IProgressMonitor monitor) Performs a code completion at the given position in the given code snippet, reporting results to the given completion requestor.void
codeComplete
(String codeSnippet, int position, ICodeCompletionRequestor requestor) Veraltet.- use codeComplete(String, int, ICompletionRequestor) insteadvoid
codeComplete
(String codeSnippet, int position, ICompletionRequestor requestor) Veraltet.void
codeComplete
(String codeSnippet, int position, ICompletionRequestor requestor, WorkingCopyOwner owner) Veraltet.codeSelect
(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.codeSelect
(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
(String codeSnippet, String[] localVariableTypeNames, String[] localVariableNames, int[] localVariableModifiers, IType declaringType, boolean isStatic, boolean isConstructorCall, ICodeSnippetRequestor requestor, org.eclipse.core.runtime.IProgressMonitor progressMonitor) Evaluates the given code snippet in the context of a suspended thread.void
evaluateCodeSnippet
(String codeSnippet, ICodeSnippetRequestor requestor, org.eclipse.core.runtime.IProgressMonitor progressMonitor) Evaluates the given code snippet.void
evaluateVariable
(IGlobalVariable variable, ICodeSnippetRequestor requestor, org.eclipse.core.runtime.IProgressMonitor progressMonitor) Evaluates the given global variable.protected INameEnvironment
Returns a name environment for the last built state.String[]
Returns the import declarations for this evaluation context.Returns the infrastructure evaluation context.protected IRequestor
Returns a new infrastructure evaluation requestor instance.Returns the name of the package in which code snippets are to be compiled and run.protected IProblemFactory
Returns the problem factory to be used during evaluation.Returns the Java project this evaluation context was created for.char[]
protected void
Handles an install exception by throwing a Java Model exception.newVariable
(String typeName, String name, String initializer) Creates a new global variable with the given name, type, and initializer.void
setImports
(String[] imports) Sets the import declarations for this evaluation context.void
setPackageName
(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.
-
Felddetails
-
context
-
project
-
-
Konstruktordetails
-
EvaluationContextWrapper
Creates a new wrapper around the given infrastructure evaluation context and project.
-
-
Methodendetails
-
allVariables
Beschreibung aus Schnittstelle kopiert:IEvaluationContext
Returns the global variables declared in this evaluation context. The variables are maintained in the order they are created in.- Angegeben von:
allVariables
in SchnittstelleIEvaluationContext
- Gibt zurück:
- the list of global variables
- Siehe auch:
-
checkBuilderState
protected void checkBuilderState()Checks to ensure that there is a previously built state. -
codeComplete
public void codeComplete(String codeSnippet, int position, ICompletionRequestor requestor) throws JavaModelException Veraltet.Beschreibung aus Schnittstelle kopiert:IEvaluationContext
Performs a code completion at the given position in the given code snippet, reporting results to the given completion requestor.Note that code completion does not involve evaluation.
- Angegeben von:
codeComplete
in SchnittstelleIEvaluationContext
- Parameter:
codeSnippet
- 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- Löst aus:
JavaModelException
- if code completion could not be performed. Reasons include:- The position specified is less than -1 or is greater than the snippet's length (INDEX_OUT_OF_BOUNDS)
- Siehe auch:
-
codeComplete
public void codeComplete(String codeSnippet, int position, ICompletionRequestor requestor, WorkingCopyOwner owner) throws JavaModelException Veraltet.Beschreibung aus Schnittstelle kopiert:IEvaluationContext
Performs a code completion at the given position in the given code snippet, reporting results to the given completion requestor. It considers types in the working copies with the given owner first. In other words, the owner's working copies will take precedence over their original compilation units in the workspace.Note 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.
- Angegeben von:
codeComplete
in SchnittstelleIEvaluationContext
- Parameter:
codeSnippet
- 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- Löst aus:
JavaModelException
- if code completion could not be performed. Reasons include:- The position specified is less than -1 or is greater than the snippet's length (INDEX_OUT_OF_BOUNDS)
- Siehe auch:
-
codeComplete
public void codeComplete(String codeSnippet, int position, CompletionRequestor requestor) throws JavaModelException Beschreibung aus Schnittstelle kopiert:IEvaluationContext
Performs a code completion at the given position in the given code snippet, reporting results to the given completion requestor.Note that code completion does not involve evaluation.
- Angegeben von:
codeComplete
in SchnittstelleIEvaluationContext
- Parameter:
codeSnippet
- 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- Löst aus:
JavaModelException
- if code completion could not be performed. Reasons include:- The position specified is less than -1 or is greater than the snippet's length (INDEX_OUT_OF_BOUNDS)
- Siehe auch:
-
codeComplete
public void codeComplete(String codeSnippet, int position, CompletionRequestor requestor, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException Beschreibung aus Schnittstelle kopiert:IEvaluationContext
Performs a code completion at the given position in the given code snippet, reporting results to the given completion requestor.Note that code completion does not involve evaluation.
If
IProgressMonitor
is notnull
then some proposals which can be very long to compute are proposed. To avoid that the code assist operation take too much time aIProgressMonitor
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 Ungültige Eingabe: "<"= System.currentTimeMillis(); } ... };
- Angegeben von:
codeComplete
in SchnittstelleIEvaluationContext
- Parameter:
codeSnippet
- 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- Löst aus:
JavaModelException
- if code completion could not be performed. Reasons include:- The position specified is less than -1 or is greater than the snippet's length (INDEX_OUT_OF_BOUNDS)
- Siehe auch:
-
codeComplete
public void codeComplete(String codeSnippet, int position, CompletionRequestor requestor, WorkingCopyOwner owner) throws JavaModelException Beschreibung aus Schnittstelle kopiert:IEvaluationContext
Performs a code completion at the given position in the given code snippet, reporting results to the given completion requestor. It considers types in the working copies with the given owner first. In other words, the owner's working copies will take precedence over their original compilation units in the workspace.Note 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.
- Angegeben von:
codeComplete
in SchnittstelleIEvaluationContext
- Parameter:
codeSnippet
- 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- Löst aus:
JavaModelException
- if code completion could not be performed. Reasons include:- The position specified is less than -1 or is greater than the snippet's length (INDEX_OUT_OF_BOUNDS)
- Siehe auch:
-
codeComplete
public void codeComplete(String codeSnippet, int position, CompletionRequestor requestor, WorkingCopyOwner owner, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException Beschreibung aus Schnittstelle kopiert:IEvaluationContext
Performs a code completion at the given position in the given code snippet, reporting results to the given completion requestor. It considers types in the working copies with the given owner first. In other words, the owner's working copies will take precedence over their original compilation units in the workspace.Note 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 notnull
then some proposals which can be very long to compute are proposed. To avoid that the code assist operation take too much time aIProgressMonitor
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 Ungültige Eingabe: "<"= System.currentTimeMillis(); } ... };
- Angegeben von:
codeComplete
in SchnittstelleIEvaluationContext
- Parameter:
codeSnippet
- 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- Löst aus:
JavaModelException
- if code completion could not be performed. Reasons include:- The position specified is less than -1 or is greater than the snippet's length (INDEX_OUT_OF_BOUNDS)
- Siehe auch:
-
codeSelect
public IJavaElement[] codeSelect(String codeSnippet, int offset, int length) throws JavaModelException Beschreibung aus Schnittstelle kopiert:IEvaluationContext
Resolves and returns a collection of Java elements corresponding to the source code at the given positions in the given code snippet.Note that code select does not involve evaluation, and problems are never reported.
- Angegeben von:
codeSelect
in SchnittstelleIEvaluationContext
- Parameter:
codeSnippet
- 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- Gibt zurück:
- the (possibly empty) list of selection Java elements
- Löst aus:
JavaModelException
- if code resolve could not be performed. Reasons include:- The position specified is less than -1 or is greater than the snippet's length (INDEX_OUT_OF_BOUNDS)
- Siehe auch:
-
codeSelect
public IJavaElement[] codeSelect(String codeSnippet, int offset, int length, WorkingCopyOwner owner) throws JavaModelException Beschreibung aus Schnittstelle kopiert:IEvaluationContext
Resolves and returns a collection of Java elements corresponding to the source code at the given positions in the given code snippet. It considers types in the working copies with the given owner first. In other words, the owner's working copies will take precedence over their original compilation units in the workspace.Note 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.
- Angegeben von:
codeSelect
in SchnittstelleIEvaluationContext
- Parameter:
codeSnippet
- 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- Gibt zurück:
- the (possibly empty) list of selection Java elements
- Löst aus:
JavaModelException
- if code resolve could not be performed. Reasons include:- The position specified is less than -1 or is greater than the snippet's length (INDEX_OUT_OF_BOUNDS)
- Siehe auch:
-
deleteVariable
Beschreibung aus Schnittstelle kopiert:IEvaluationContext
Deletes the given variable from this evaluation context. Does nothing if the given variable has already been deleted.- Angegeben von:
deleteVariable
in SchnittstelleIEvaluationContext
- Parameter:
variable
- the global variable- Siehe auch:
-
evaluateCodeSnippet
public void evaluateCodeSnippet(String codeSnippet, String[] localVariableTypeNames, String[] localVariableNames, int[] localVariableModifiers, IType declaringType, boolean isStatic, boolean isConstructorCall, ICodeSnippetRequestor requestor, org.eclipse.core.runtime.IProgressMonitor progressMonitor) throws JavaModelException Beschreibung aus Schnittstelle kopiert:IEvaluationContext
Evaluates the given code snippet in the context of a suspended thread. The code snippet is compiled along with this context's package declaration, imports, and global variables. The given requestor'sacceptProblem
method is called for each compilation problem that is detected. Then the resulting class files are handed to the given requestor'sacceptClassFiles
method to deploy and run.The requestor is expected to:
- send the class files to the target VM,
- load them (starting with the code snippet class),
- create a new instance of the code snippet class,
- run the method
run()
of the code snippet, - retrieve the values of the local variables,
- retrieve the returned value of the code snippet
This method is long-running; progress and cancellation are provided by the given progress monitor.
- Angegeben von:
evaluateCodeSnippet
in SchnittstelleIEvaluationContext
- Parameter:
codeSnippet
- 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- Löst aus:
JavaModelException
- if a runtime problem occurred or if this context's project has no build state- Siehe auch:
-
evaluateCodeSnippet
public void evaluateCodeSnippet(String codeSnippet, ICodeSnippetRequestor requestor, org.eclipse.core.runtime.IProgressMonitor progressMonitor) throws JavaModelException Beschreibung aus Schnittstelle kopiert:IEvaluationContext
Evaluates the given code snippet. The code snippet is compiled along with this context's package declaration, imports, and global variables. The given requestor'sacceptProblem
method is called for each compilation problem that is detected. Then the resulting class files are handed to the given requestor'sacceptClassFiles
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.
- Angegeben von:
evaluateCodeSnippet
in SchnittstelleIEvaluationContext
- Parameter:
codeSnippet
- the code snippetrequestor
- the code snippet requestorprogressMonitor
- a progress monitor- Löst aus:
JavaModelException
- if a runtime problem occurred or if this context's project has no build state- Siehe auch:
-
evaluateVariable
public void evaluateVariable(IGlobalVariable variable, ICodeSnippetRequestor requestor, org.eclipse.core.runtime.IProgressMonitor progressMonitor) throws JavaModelException Beschreibung aus Schnittstelle kopiert:IEvaluationContext
Evaluates the given global variable. During this operation, this context's package declaration, imports, and all its declared variables are verified. The given requestor'sacceptProblem
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.
- Angegeben von:
evaluateVariable
in SchnittstelleIEvaluationContext
- Parameter:
variable
- the global variablerequestor
- the code snippet requestorprogressMonitor
- a progress monitor- Löst aus:
JavaModelException
- if a runtime problem occurred or if this context's project has no build state- Siehe auch:
-
getBuildNameEnvironment
Returns a name environment for the last built state. -
getVarClassName
public char[] getVarClassName() -
getImports
Beschreibung aus Schnittstelle kopiert:IEvaluationContext
Returns the import declarations for this evaluation context. Returns and empty list if there are no imports (the default if the imports have never been set). The syntax for the import corresponds to a fully qualified type name, or to an on-demand package name as defined by ImportDeclaration (JLS2 7.5). For example,"java.util.Hashtable"
or"java.util.*"
.- Angegeben von:
getImports
in SchnittstelleIEvaluationContext
- Gibt zurück:
- the list of import names
- Siehe auch:
-
getInfrastructureEvaluationContext
Returns the infrastructure evaluation context. -
getInfrastructureEvaluationRequestor
Returns a new infrastructure evaluation requestor instance. -
getPackageName
Beschreibung aus Schnittstelle kopiert:IEvaluationContext
Returns the name of the package in which code snippets are to be compiled and run. Returns an empty string for the default package (the default if the package name has never been set). For example,"com.example.myapp"
.- Angegeben von:
getPackageName
in SchnittstelleIEvaluationContext
- Gibt zurück:
- the dot-separated package name, or the empty string indicating the default package
- Siehe auch:
-
getProblemFactory
Returns the problem factory to be used during evaluation. -
getProject
Beschreibung aus Schnittstelle kopiert:IEvaluationContext
Returns the Java project this evaluation context was created for.- Angegeben von:
getProject
in SchnittstelleIEvaluationContext
- Gibt zurück:
- the Java project
- Siehe auch:
-
handleInstallException
Handles an install exception by throwing a Java Model exception.- Löst aus:
JavaModelException
-
newVariable
Beschreibung aus Schnittstelle kopiert:IEvaluationContext
Creates a new global variable with the given name, type, and initializer.The
typeName
andinitializer
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).
- Angegeben von:
newVariable
in SchnittstelleIEvaluationContext
- Parameter:
typeName
- the type namename
- the name of the global variableinitializer
- the initializer expression, ornull
if the variable is not initialized- Gibt zurück:
- a new global variable with the given name, type, and initializer
- Siehe auch:
-
setImports
Beschreibung aus Schnittstelle kopiert:IEvaluationContext
Sets the import declarations for this evaluation context. An empty list indicates there are no imports. The syntax for the import corresponds to a fully qualified type name, or to an on-demand package name as defined by ImportDeclaration (JLS2 7.5). For example,"java.util.Hashtable"
or"java.util.*"
.- Angegeben von:
setImports
in SchnittstelleIEvaluationContext
- Parameter:
imports
- the list of import names- Siehe auch:
-
setPackageName
Beschreibung aus Schnittstelle kopiert:IEvaluationContext
Sets the dot-separated name of the package in which code snippets are to be compiled and run. For example,"com.example.myapp"
.- Angegeben von:
setPackageName
in SchnittstelleIEvaluationContext
- Parameter:
packageName
- the dot-separated package name, or the empty string indicating the default package- Siehe auch:
-
validateImports
Beschreibung aus Schnittstelle kopiert:IEvaluationContext
Validates this evaluation context's import declarations. The given requestor'sacceptProblem
method is called for each problem that is detected.- Angegeben von:
validateImports
in SchnittstelleIEvaluationContext
- Parameter:
requestor
- the code snippet requestor- Siehe auch:
-
codeComplete
public void codeComplete(String codeSnippet, int position, ICodeCompletionRequestor requestor) throws JavaModelException Veraltet.- use codeComplete(String, int, ICompletionRequestor) insteadBeschreibung aus Schnittstelle kopiert:IEvaluationContext
Performs a code completion at the given position in the given code snippet, reporting results to the given completion requestor.Note that code completion does not involve evaluation.
- Angegeben von:
codeComplete
in SchnittstelleIEvaluationContext
- Parameter:
codeSnippet
- 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- Löst aus:
JavaModelException
- if code completion could not be performed. Reasons include:- The position specified is less than -1 or is greater than the snippet's length (INDEX_OUT_OF_BOUNDS)
- Siehe auch:
-