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 implementgetScannerExtensionConfiguration(IScannerInfo info)
,getParserLanguage()
andcreateParser(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 Constructor Description AbstractCLikeLanguage()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description 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.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 byreader
.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
-
-
-
-
Method Detail
-
getScannerExtensionConfiguration
@Deprecated protected IScannerExtensionConfiguration getScannerExtensionConfiguration()
Deprecated.Do not override this method. OverridegetScannerExtensionConfiguration(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 interfaceILanguage
- 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 interfaceILanguage
- Overrides:
getASTTranslationUnit
in classAbstractLanguage
- 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 byreader
.- Specified by:
getASTTranslationUnit
in interfaceILanguage
- Overrides:
getASTTranslationUnit
in classAbstractLanguage
- Parameters:
reader
- source code to be parsed.scanInfo
- provides include paths and defined symbols.fileCreator
- factory that provides file content for files includedindex
- (optional) index to use to lookup symbols external to the translation unit.options
- A combination ofILanguage.OPTION_SKIP_FUNCTION_BODIES
,ILanguage.OPTION_NO_IMAGE_LOCATIONS
, or0
.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 interfaceILanguage
- 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 interfaceILanguage
- Overrides:
getCompletionNode
in classAbstractLanguage
- 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 fromlog
- the parser log serviceindex
- the index to help resolve bindingsforCompletion
- whether the parser is used for code completionoptions
- for valid options seeAbstractLanguage.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 fromlog
- the parser log serviceindex
- the index to help resolve bindingsforCompletion
- whether the parser is used for code completionoptions
- for valid options seeAbstractLanguage.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.
-
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 interfaceILanguage
-
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 interfaceILanguage
- Parameters:
tu
- theITranslationUnit
to be parsed (non-null
)- Returns:
- an
IModelBuilder
, which parses the given translation unit and returns theICElement
s of its model, ornull
to parse using the default CDT model builder
-
getAdapter
public <T> T getAdapter(Class<T> adapter)
- Specified by:
getAdapter
in interfaceorg.eclipse.core.runtime.IAdaptable
- Overrides:
getAdapter
in classorg.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 interfaceICLanguageKeywords
- 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 interfaceICLanguageKeywords
- 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 interfaceICLanguageKeywords
- Returns:
- an array of keywords, never
null
-
-