# Using Context Resolvers

### Overview

Context resolvers are an abstraction used by the JSF EL framework to decouple sources of context information from the way that information is created. Common examples of such contexts are:
- a dynamic web project in an Eclipse workspace
- a JSP file in a dynamic web project
- a particular absolute offset into an IDocument
Context resolvers allow us to derive interesting information from these contexts such as:
- what is the current IProject?
- where are we in an IRegion or DOM tree?
- what JSF EL symbols are available at the current IDocument position?

### IStructuredDocumentContext

A particularly useful context is one in an IStructuredDocument. An IStructuredDocument represents an SSE document that can be manipulated in a number of different ways including as a regular IDocument or as a DOM. The IStructuredDocumentContext points to a specific absolute offset into such a document. The context can then be passed to various resolvers to determine information about this position in the document.

### Context Resolvers

The following is a list of context resolvers that are available as provisional APIs:

Resolver Type | Purpose
ITaglibContextResolver | Resolves taglib information for the current context such as retrieving the tag library information for the current tag.
IWorkspaceContextResolver | Resolves workspace information for the current document context such as IFile and IProject.
IDOMContextResolver | Resolves DOM information for the current context such as current element and attribute.
IMetadataContextResolver | Resolves meta-data framework information for a given context. For example, if the current context resolves to an XML attribute, retrieves meta-data associate with that attribute/element/uri.
ISymbolContextResolver | Determines what symbols are available or valid within the current context. For example, if context is an EL expression, what bean names are available?

### Factories

Factories exist to create both contexts and context resolvers. These are:

Factory Name | What it does
org.eclipse.jst.jsf.context.structureddocument.internal.provisional.IStructuredDocumentContextFactory | Creates new IStructuredDocumentContext objects based on a document and offset.
org.eclipse.jst.jsf.context.resolver.structureddocument.internal.provisional.IStructuredDocumentContextResolverFactory | Creates a new instances of context resolvers for an IStructuredDocumentContext.

### Adding Factory Delegates

The existing factories can be extended using factory delegates. A delegate for IStructuredDocumentContextFactory allows you to extend the existing factory to create IStructuredDocumentContext's for document contexts other than an IStructuredDocumentContext and offset. Similarly, adding factory delegates to IStructuredDocumentContextResolverFactory allows you to create context resolvers for structured documents other than those already supported.
Factory delegates are added programmatically be calling addFactoryDelegate on the appropriate factory. See the JavaDoc for IDelegatingFactory for more details.