Package org.eclipse.cdt.core.dom.parser

## Class AbstractCLikeLanguage

- java.lang.Object
- - org.eclipse.core.runtime.PlatformObject
  - - org.eclipse.cdt.core.model.AbstractLanguage
    - - org.eclipse.cdt.core.dom.parser.AbstractCLikeLanguage

All Implemented Interfaces:
  `ICLanguageKeywords`, `ILanguage`, `org.eclipse.core.runtime.IAdaptable`

Direct Known Subclasses:
  `GCCLanguage`, `GPPLanguage`

    public abstract class AbstractCLikeLanguage
    extends AbstractLanguage
    implements ICLanguageKeywords

This class provides a skeletal implementation of the ILanguage interface for the DOM parser framework. This class uses the template method pattern, derived classes need only implement `getScannerExtensionConfiguration(IScannerInfo info)`, `getParserLanguage()` and `createParser(IScanner scanner, ParserMode parserMode, IParserLogService logService, IIndex index)`.

Since:
  5.0
See Also:
  `AbstractScannerExtensionConfiguration`

### Field Summary

### Fields inherited from interface org.eclipse.cdt.core.model.ILanguage

`OPTION_ADD_COMMENTS, OPTION_IS_SOURCE_UNIT, OPTION_NO_IMAGE_LOCATIONS, OPTION_PARSE_INACTIVE_CODE, OPTION_SKIP_FUNCTION_BODIES, OPTION_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS`

### Constructor Summary

Constructors
`AbstractCLikeLanguage()`

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods
`IContributedModelBuilder` `createModelBuilder​(ITranslationUnit tu)` Used to override the default model building behavior for a translation unit.
`protected ISourceCodeParser` `createParser​(IScanner scanner, IParserLogService log, IIndex index, boolean forCompletion, int options)` Creates the parser.
`protected ISourceCodeParser` `createParser​(IScanner scanner, IParserLogService log, IIndex index, boolean forCompletion, int options, IParserSettings settings)` Create the parser with additional settings.
`protected abstract ISourceCodeParser` `createParser​(IScanner scanner, ParserMode parserMode, IParserLogService logService, IIndex index)`
`protected ISourceCodeParser` `createParser​(IScanner scanner, ParserMode parserMode, IParserLogService logService, IIndex index, int options, IParserSettings settings)`
`protected IScanner` `createScanner​(CodeReader reader, IScannerInfo scanInfo, ICodeReaderFactory fileCreator, IParserLogService log)` Deprecated. Replaced by `createScanner(FileContent, IScannerInfo, IncludeFileContentProvider, IParserLogService)`
`protected IScanner` `createScanner​(FileContent content, IScannerInfo scanInfo, IncludeFileContentProvider fcp, IParserLogService log)` Create the scanner to be used with the parser.
`<T> T` `getAdapter​(Class<T> adapter)`
`IASTTranslationUnit` `getASTTranslationUnit​(CodeReader reader, IScannerInfo scanInfo, ICodeReaderFactory codeReaderFactory, IIndex index, int options, IParserLogService log)` Deprecated.
`IASTTranslationUnit` `getASTTranslationUnit​(CodeReader reader, IScannerInfo scanInfo, ICodeReaderFactory fileCreator, IIndex index, IParserLogService log)` Deprecated.
`IASTTranslationUnit` `getASTTranslationUnit​(FileContent reader, IScannerInfo scanInfo, IncludeFileContentProvider fileCreator, IIndex index, int options, IParserLogService log)` Constructs an AST for the source code provided by `reader`.
`String[]` `getBuiltinTypes()` Returns the built-in type names defined for this language.
`IASTCompletionNode` `getCompletionNode​(CodeReader reader, IScannerInfo scanInfo, ICodeReaderFactory fileCreator, IIndex index, IParserLogService log, int offset)` Deprecated.
`IASTCompletionNode` `getCompletionNode​(FileContent reader, IScannerInfo scanInfo, IncludeFileContentProvider fileCreator, IIndex index, IParserLogService log, int offset)` Returns the AST completion node for the given offset.
`String[]` `getKeywords()` Returns the keywords defined for this language, excluding built-in types.
`protected abstract ParserLanguage` `getParserLanguage()`
`String[]` `getPreprocessorKeywords()` Returns the preprocessor keywords (directives) defined for this language.
`protected IScannerExtensionConfiguration` `getScannerExtensionConfiguration()` Deprecated. Do not override this method.
`protected IScannerExtensionConfiguration` `getScannerExtensionConfiguration​(IScannerInfo info)`
`IASTName[]` `getSelectedNames​(IASTTranslationUnit ast, int start, int length)` Deprecated.

### Methods inherited from class org.eclipse.cdt.core.model.AbstractLanguage

`getName`

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

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

### Methods inherited from interface org.eclipse.cdt.core.model.ILanguage

`getId, getLinkageID`

### Constructor Detail

#### AbstractCLikeLanguage

    public AbstractCLikeLanguage()

### Method Detail

#### getScannerExtensionConfiguration

    @Deprecated
    protected IScannerExtensionConfiguration getScannerExtensionConfiguration()

Deprecated.
Do not override this method. Override `getScannerExtensionConfiguration(IScannerInfo)` instead.

Restriction:
  This method is not intended to be re-implemented or extended by clients.

#### getScannerExtensionConfiguration

    protected IScannerExtensionConfiguration getScannerExtensionConfiguration​(IScannerInfo info)

Returns:
  the scanner extension configuration for this language. May not return `null`.
Since:
  5.4

#### createParser

    protected abstract ISourceCodeParser createParser​(IScanner scanner,
                                                      ParserMode parserMode,
                                                      IParserLogService logService,
                                                      IIndex index)

Returns:
  the actual parser object.

#### createParser

    protected ISourceCodeParser createParser​(IScanner scanner,
                                             ParserMode parserMode,
                                             IParserLogService logService,
                                             IIndex index,
                                             int options,
                                             IParserSettings settings)

Returns:
  the actual parser object, configured with additional settings.
Since:
  5.6

#### getParserLanguage

    protected abstract ParserLanguage getParserLanguage()

Returns:
  The ParserLanguage value corresponding to the language supported.

#### getASTTranslationUnit

    @Deprecated
    public IASTTranslationUnit getASTTranslationUnit​(CodeReader reader,
                                                     IScannerInfo scanInfo,
                                                     ICodeReaderFactory fileCreator,
                                                     IIndex index,
                                                     IParserLogService log)
                                              throws org.eclipse.core.runtime.CoreException

Deprecated.

Specified by:
  `getASTTranslationUnit` in interface `ILanguage`
Throws:
  `org.eclipse.core.runtime.CoreException`

#### getASTTranslationUnit

    @Deprecated
    public IASTTranslationUnit getASTTranslationUnit​(CodeReader reader,
                                                     IScannerInfo scanInfo,
                                                     ICodeReaderFactory codeReaderFactory,
                                                     IIndex index,
                                                     int options,
                                                     IParserLogService log)
                                              throws org.eclipse.core.runtime.CoreException

Deprecated.

Specified by:
  `getASTTranslationUnit` in interface `ILanguage`
Overrides:
  `getASTTranslationUnit` in class `AbstractLanguage`
Throws:
  `org.eclipse.core.runtime.CoreException`

#### getASTTranslationUnit

    public IASTTranslationUnit getASTTranslationUnit​(FileContent reader,
                                                     IScannerInfo scanInfo,
                                                     IncludeFileContentProvider fileCreator,
                                                     IIndex index,
                                                     int options,
                                                     IParserLogService log)
                                              throws org.eclipse.core.runtime.CoreException

Description copied from interface: `ILanguage`
Constructs an AST for the source code provided by `reader`.

Specified by:
  `getASTTranslationUnit` in interface `ILanguage`
Overrides:
  `getASTTranslationUnit` in class `AbstractLanguage`
Parameters:
  `reader` - source code to be parsed.
  `scanInfo` - provides include paths and defined symbols.
  `fileCreator` - factory that provides file content for files included
  `index` - (optional) index to use to lookup symbols external to the translation unit.
  `options` - A combination of `ILanguage.OPTION_SKIP_FUNCTION_BODIES`, `ILanguage.OPTION_NO_IMAGE_LOCATIONS`, or `0`.
  `log` - logger
Returns:
  an AST for the source code provided by reader.
Throws:
  `org.eclipse.core.runtime.CoreException`

#### getCompletionNode

    @Deprecated
    public IASTCompletionNode getCompletionNode​(CodeReader reader,
                                                IScannerInfo scanInfo,
                                                ICodeReaderFactory fileCreator,
                                                IIndex index,
                                                IParserLogService log,
                                                int offset)
                                         throws org.eclipse.core.runtime.CoreException

Deprecated.

Specified by:
  `getCompletionNode` in interface `ILanguage`
Throws:
  `org.eclipse.core.runtime.CoreException`

#### getCompletionNode

    public IASTCompletionNode getCompletionNode​(FileContent reader,
                                                IScannerInfo scanInfo,
                                                IncludeFileContentProvider fileCreator,
                                                IIndex index,
                                                IParserLogService log,
                                                int offset)
                                         throws org.eclipse.core.runtime.CoreException

Description copied from interface: `ILanguage`
Returns the AST completion node for the given offset.

Specified by:
  `getCompletionNode` in interface `ILanguage`
Overrides:
  `getCompletionNode` in class `AbstractLanguage`
Throws:
  `org.eclipse.core.runtime.CoreException`

#### createParser

    protected ISourceCodeParser createParser​(IScanner scanner,
                                             IParserLogService log,
                                             IIndex index,
                                             boolean forCompletion,
                                             int options)

Creates the parser.

Parameters:
  `scanner` - the IScanner to get tokens from
  `log` - the parser log service
  `index` - the index to help resolve bindings
  `forCompletion` - whether the parser is used for code completion
  `options` - for valid options see `AbstractLanguage.getASTTranslationUnit(FileContent, IScannerInfo, IncludeFileContentProvider, IIndex, int, IParserLogService)`
Returns:
  an instance of ISourceCodeParser

#### createParser

    protected ISourceCodeParser createParser​(IScanner scanner,
                                             IParserLogService log,
                                             IIndex index,
                                             boolean forCompletion,
                                             int options,
                                             IParserSettings settings)

Create the parser with additional settings.

Parameters:
  `scanner` - the IScanner to get tokens from
  `log` - the parser log service
  `index` - the index to help resolve bindings
  `forCompletion` - whether the parser is used for code completion
  `options` - for valid options see `AbstractLanguage.getASTTranslationUnit(FileContent, IScannerInfo, IncludeFileContentProvider, IIndex, int, IParserLogService)`
  `settings` - for the parser
Returns:
  an instance of ISourceCodeParser
Since:
  5.6

#### createScanner

    @Deprecated
    protected IScanner createScanner​(CodeReader reader,
                                     IScannerInfo scanInfo,
                                     ICodeReaderFactory fileCreator,
                                     IParserLogService log)

Deprecated.
Replaced by `createScanner(FileContent, IScannerInfo, IncludeFileContentProvider, IParserLogService)`

#### createScanner

    protected IScanner createScanner​(FileContent content,
                                     IScannerInfo scanInfo,
                                     IncludeFileContentProvider fcp,
                                     IParserLogService log)

Create the scanner to be used with the parser.

Since:
  5.2

#### getSelectedNames

    @Deprecated
    public IASTName[] getSelectedNames​(IASTTranslationUnit ast,
                                       int start,
                                       int length)

Deprecated.

Specified by:
  `getSelectedNames` in interface `ILanguage`

#### createModelBuilder

    public IContributedModelBuilder createModelBuilder​(ITranslationUnit tu)

Description copied from interface: `ILanguage`
Used to override the default model building behavior for a translation unit.

Specified by:
  `createModelBuilder` in interface `ILanguage`
Parameters:
  `tu` - the `ITranslationUnit` to be parsed (non-`null`)
Returns:
  an `IModelBuilder`, which parses the given translation unit and returns the `ICElement`s of its model, or `null` to parse using the default CDT model builder

#### getAdapter

    public <T> T getAdapter​(Class<T> adapter)

Specified by:
  `getAdapter` in interface `org.eclipse.core.runtime.IAdaptable`
Overrides:
  `getAdapter` in class `org.eclipse.core.runtime.PlatformObject`

#### getBuiltinTypes

    public String[] getBuiltinTypes()

Description copied from interface: `ICLanguageKeywords`
Returns the built-in type names defined for this language.

Specified by:
  `getBuiltinTypes` in interface `ICLanguageKeywords`
Returns:
  an array of names, never `null`

#### getKeywords

    public String[] getKeywords()

Description copied from interface: `ICLanguageKeywords`
Returns the keywords defined for this language, excluding built-in types.

Specified by:
  `getKeywords` in interface `ICLanguageKeywords`
Returns:
  an array of keywords, never `null`

#### getPreprocessorKeywords

    public String[] getPreprocessorKeywords()

Description copied from interface: `ICLanguageKeywords`
Returns the preprocessor keywords (directives) defined for this language.

Specified by:
  `getPreprocessorKeywords` in interface `ICLanguageKeywords`
Returns:
  an array of keywords, never `null`