Package org.eclipse.ease.ui.completion
Class CompletionContext
java.lang.Object
org.eclipse.ease.ui.completion.CompletionContext
- All Implemented Interfaces:
ICompletionContext
- Direct Known Subclasses:
JavaScriptCompletionContext
,PythonCompletionContext
public abstract class CompletionContext extends Object implements ICompletionContext
The context evaluates and stores information on the code fragment at a given cursor position.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CompletionContext.Bracket
Nested classes/interfaces inherited from interface org.eclipse.ease.ICompletionContext
ICompletionContext.Type
-
Constructor Summary
Constructors Constructor Description CompletionContext(IScriptEngine scriptEngine, ScriptType scriptType)
Context constructor. -
Method Summary
Modifier and Type Method Description void
calculateContext(Object resource, String code, int offset, int selectionRange)
Calculate a context over a given code fragment.String
getCaller()
Get the caller method for string literals.String
getFilter()
Map<Object,String>
getIncludedResources()
Get a list of included resource.Collection<ModuleDefinition>
getLoadedModules()
Get a list of loaded modules.int
getOffset()
String
getOriginalCode()
String
getPackage()
Returns the package for PACKAGE types.int
getParameterOffset()
Get the index of the parameter for string literals.String
getProcessedCode()
Class<? extends Object>
getReferredClazz()
Object
getResource()
Get the base resource of the context.IScriptEngine
getScriptEngine()
Get the running script engine.ScriptType
getScriptType()
int
getSelectionRange()
ICompletionContext.Type
getType()
String
replaceStringLiterals(String code)
Remove all string literal content and keep empty literals.
-
Constructor Details
-
CompletionContext
Context constructor. A context is bound to a given script engine or script type.- Parameters:
scriptEngine
- script engine to evaluatescriptType
- script type to evaluate
-
-
Method Details
-
getType
- Specified by:
getType
in interfaceICompletionContext
-
getReferredClazz
- Specified by:
getReferredClazz
in interfaceICompletionContext
-
calculateContext
Calculate a context over a given code fragment.- Parameters:
resource
- base resource (eg. edited file)code
- code fragment to evaluateoffset
- the offset within the provided document (usually code.length())selectionRange
- amount of selected characters
-
replaceStringLiterals
Remove all string literal content and keep empty literals.- Parameters:
code
- code fragment to parse- Returns:
- code fragment with empty string literals
-
getOriginalCode
- Specified by:
getOriginalCode
in interfaceICompletionContext
-
getProcessedCode
- Specified by:
getProcessedCode
in interfaceICompletionContext
-
getResource
Description copied from interface:ICompletionContext
Get the base resource of the context. Typically holds a reference to the file open in an editor- Specified by:
getResource
in interfaceICompletionContext
- Returns:
- base resource or
null
-
getScriptEngine
Description copied from interface:ICompletionContext
Get the running script engine. Only works for live engines like a shell.- Specified by:
getScriptEngine
in interfaceICompletionContext
- Returns:
- script engine or
null
-
getScriptType
- Specified by:
getScriptType
in interfaceICompletionContext
-
getLoadedModules
Description copied from interface:ICompletionContext
Get a list of loaded modules.- Specified by:
getLoadedModules
in interfaceICompletionContext
- Returns:
- loaded modules
-
getIncludedResources
Description copied from interface:ICompletionContext
Get a list of included resource. Returns a map of resource objects -> resource content.- Specified by:
getIncludedResources
in interfaceICompletionContext
- Returns:
- map of included resources
-
getFilter
- Specified by:
getFilter
in interfaceICompletionContext
-
getOffset
public int getOffset()- Specified by:
getOffset
in interfaceICompletionContext
-
getSelectionRange
public int getSelectionRange()- Specified by:
getSelectionRange
in interfaceICompletionContext
-
getPackage
Description copied from interface:ICompletionContext
Returns the package for PACKAGE types.- Specified by:
getPackage
in interfaceICompletionContext
- Returns:
- package name
-
getCaller
Description copied from interface:ICompletionContext
Get the caller method for string literals. On STRING_LITERAL types this value denotes the calling method. The whole context of the caller is passed as a value. Eg. "new java.lang.String". May not returnnull
.- Specified by:
getCaller
in interfaceICompletionContext
- Returns:
- calling method or empty string
-
getParameterOffset
public int getParameterOffset()Description copied from interface:ICompletionContext
Get the index of the parameter for string literals. On STRING_LITERAL types this value indicates which parameter we are looking at: 0 for the first, 1 for the second, ...- Specified by:
getParameterOffset
in interfaceICompletionContext
- Returns:
- parameter offset for string literals
-