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 classCompletionContext.BracketNested 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 voidcalculateContext(Object resource, String code, int offset, int selectionRange)Calculate a context over a given code fragment.StringgetCaller()Get the caller method for string literals.StringgetFilter()Map<Object,String>getIncludedResources()Get a list of included resource.Collection<ModuleDefinition>getLoadedModules()Get a list of loaded modules.intgetOffset()StringgetOriginalCode()StringgetPackage()Returns the package for PACKAGE types.intgetParameterOffset()Get the index of the parameter for string literals.StringgetProcessedCode()Class<? extends Object>getReferredClazz()ObjectgetResource()Get the base resource of the context.IScriptEnginegetScriptEngine()Get the running script engine.ScriptTypegetScriptType()intgetSelectionRange()ICompletionContext.TypegetType()StringreplaceStringLiterals(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:
getTypein interfaceICompletionContext
-
getReferredClazz
- Specified by:
getReferredClazzin 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:
getOriginalCodein interfaceICompletionContext
-
getProcessedCode
- Specified by:
getProcessedCodein interfaceICompletionContext
-
getResource
Description copied from interface:ICompletionContextGet the base resource of the context. Typically holds a reference to the file open in an editor- Specified by:
getResourcein interfaceICompletionContext- Returns:
- base resource or
null
-
getScriptEngine
Description copied from interface:ICompletionContextGet the running script engine. Only works for live engines like a shell.- Specified by:
getScriptEnginein interfaceICompletionContext- Returns:
- script engine or
null
-
getScriptType
- Specified by:
getScriptTypein interfaceICompletionContext
-
getLoadedModules
Description copied from interface:ICompletionContextGet a list of loaded modules.- Specified by:
getLoadedModulesin interfaceICompletionContext- Returns:
- loaded modules
-
getIncludedResources
Description copied from interface:ICompletionContextGet a list of included resource. Returns a map of resource objects -> resource content.- Specified by:
getIncludedResourcesin interfaceICompletionContext- Returns:
- map of included resources
-
getFilter
- Specified by:
getFilterin interfaceICompletionContext
-
getOffset
public int getOffset()- Specified by:
getOffsetin interfaceICompletionContext
-
getSelectionRange
public int getSelectionRange()- Specified by:
getSelectionRangein interfaceICompletionContext
-
getPackage
Description copied from interface:ICompletionContextReturns the package for PACKAGE types.- Specified by:
getPackagein interfaceICompletionContext- Returns:
- package name
-
getCaller
Description copied from interface:ICompletionContextGet 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:
getCallerin interfaceICompletionContext- Returns:
- calling method or empty string
-
getParameterOffset
public int getParameterOffset()Description copied from interface:ICompletionContextGet 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:
getParameterOffsetin interfaceICompletionContext- Returns:
- parameter offset for string literals
-