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 java.lang.Object
    implements ICompletionContext

The context evaluates and stores information on the code fragment at a given cursor position.

### Nested Class Summary

Nested Classes
`static class` `CompletionContext.Bracket`

### Nested classes/interfaces inherited from interface org.eclipse.ease.ICompletionContext

`ICompletionContext.Type`

### Constructor Summary

Constructors
Constructor and Description
`CompletionContext(IScriptEngine scriptEngine, ScriptType scriptType)` Context constructor.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `calculateContext(java.lang.Object resource, java.lang.String code, int offset, int selectionRange)` Calculate a context over a given code fragment.
`java.lang.String` `getCaller()` Get the caller method for string literals.
`java.lang.String` `getFilter()`
`java.util.Map<java.lang.Object,java.lang.String>` `getIncludedResources()` Get a list of included resource.
`java.util.Collection<ModuleDefinition>` `getLoadedModules()` Get a list of loaded modules.
`int` `getOffset()`
`java.lang.String` `getOriginalCode()`
`java.lang.String` `getPackage()` Returns the package for PACKAGE types.
`int` `getParameterOffset()` Get the index of the parameter for string literals.
`java.lang.String` `getProcessedCode()`
`java.lang.Class<? extends java.lang.Object>` `getReferredClazz()`
`java.lang.Object` `getResource()` Get the base resource of the context.
`IScriptEngine` `getScriptEngine()` Get the running script engine.
`ScriptType` `getScriptType()`
`int` `getSelectionRange()`
`ICompletionContext.Type` `getType()`
`java.lang.String` `replaceStringLiterals(java.lang.String code)` Remove all string literal content and keep empty literals.

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### CompletionContext

    public CompletionContext(IScriptEngine scriptEngine,
                             ScriptType scriptType)

Context constructor. A context is bound to a given script engine or script type.

Parameters:
  `scriptEngine` - script engine to evaluate
  `scriptType` - script type to evaluate

### Method Detail

#### getType

    public ICompletionContext.Type getType()

Specified by:
  `getType` in interface `ICompletionContext`

#### getReferredClazz

    public java.lang.Class<? extends java.lang.Object> getReferredClazz()

Specified by:
  `getReferredClazz` in interface `ICompletionContext`

#### calculateContext

    public void calculateContext(java.lang.Object resource,
                                 java.lang.String code,
                                 int offset,
                                 int selectionRange)

Calculate a context over a given code fragment.

Parameters:
  `resource` - base resource (eg. edited file)
  `code` - code fragment to evaluate
  `offset` - the offset within the provided document (usually code.length())
  `selectionRange` - amount of selected characters

#### replaceStringLiterals

    public java.lang.String replaceStringLiterals(java.lang.String code)

Remove all string literal content and keep empty literals.

Parameters:
  `code` - code fragment to parse
Returns:
  code fragment with empty string literals

#### getOriginalCode

    public java.lang.String getOriginalCode()

Specified by:
  `getOriginalCode` in interface `ICompletionContext`

#### getProcessedCode

    public java.lang.String getProcessedCode()

Specified by:
  `getProcessedCode` in interface `ICompletionContext`

#### getResource

    public java.lang.Object 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 interface `ICompletionContext`
Returns:
  base resource or `null`

#### getScriptEngine

    public IScriptEngine getScriptEngine()

Description copied from interface: `ICompletionContext`
Get the running script engine. Only works for live engines like a shell.

Specified by:
  `getScriptEngine` in interface `ICompletionContext`
Returns:
  script engine or `null`

#### getScriptType

    public ScriptType getScriptType()

Specified by:
  `getScriptType` in interface `ICompletionContext`

#### getLoadedModules

    public java.util.Collection<ModuleDefinition> getLoadedModules()

Description copied from interface: `ICompletionContext`
Get a list of loaded modules.

Specified by:
  `getLoadedModules` in interface `ICompletionContext`
Returns:
  loaded modules

#### getIncludedResources

    public java.util.Map<java.lang.Object,java.lang.String> getIncludedResources()

Description copied from interface: `ICompletionContext`
Get a list of included resource. Returns a map of resource objects -> resource content.

Specified by:
  `getIncludedResources` in interface `ICompletionContext`
Returns:
  map of included resources

#### getFilter

    public java.lang.String getFilter()

Specified by:
  `getFilter` in interface `ICompletionContext`

#### getOffset

    public int getOffset()

Specified by:
  `getOffset` in interface `ICompletionContext`

#### getSelectionRange

    public int getSelectionRange()

Specified by:
  `getSelectionRange` in interface `ICompletionContext`

#### getPackage

    public java.lang.String getPackage()

Description copied from interface: `ICompletionContext`
Returns the package for PACKAGE types.

Specified by:
  `getPackage` in interface `ICompletionContext`
Returns:
  package name

#### getCaller

    public java.lang.String 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 return `null`.

Specified by:
  `getCaller` in interface `ICompletionContext`
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 interface `ICompletionContext`
Returns:
  parameter offset for string literals