Base class for native implementations of language import.
More...
#include <nativeimportbase.h>
Base class for native implementations of language import.
Intermediate base class for native Umbrello implementations of programming language import
The default call sequence is as follows (RealizedLanguageImport is used as a placeholder name for the concrete language importer.) NativeImportBase RealizedLanguageImport –> importFiles() parseFile() ———————————–> initVars() scan() preprocess() (may be reimplemented) ———————————> fillSource() ———————————–> parseStmt() This sequence may be changed by overriding default implementations of virtual methods in NativeImportBase.
- Author
- Oliver Kellogg okell.nosp@m.ogg@.nosp@m.users.nosp@m..sou.nosp@m.rcefo.nosp@m.rge..nosp@m.net Bugs and comments to umbre.nosp@m.llo-.nosp@m.devel.nosp@m.@kde.nosp@m..org or https://bugs.kde.org
◆ NativeImportBase()
NativeImportBase::NativeImportBase |
( |
const QString & |
singleLineCommentIntro, |
|
|
CodeImpThread * |
thread = 0 |
|
) |
| |
|
explicit |
Constructor
- Parameters
-
singleLineCommentIntro | "//" for IDL and Java, "--" for Ada |
thread | thread in which the code import runs |
◆ ~NativeImportBase()
NativeImportBase::~NativeImportBase |
( |
| ) |
|
|
virtual |
◆ advance()
QString NativeImportBase::advance |
( |
| ) |
|
|
protectedvirtual |
Advance m_srcIndex until m_source[m_srcIndex] contains a non-comment. Comments encountered during advancement are accumulated in `m_comment'. If m_srcIndex hits the end of m_source then QString() is returned.
- Returns
- the current lexeme or an empty string
Reimplemented in SQLImport.
◆ current()
QString NativeImportBase::current |
( |
| ) |
|
|
protected |
Get the current lexeme. If the end of parse was reached then return an empty string.
- Returns
- the current lexeme
◆ currentScope()
Return current scope. If the scope stack is empty then return nullptr.
- Returns
- scope
◆ fillSource()
virtual void NativeImportBase::fillSource |
( |
const QString & |
word | ) |
|
|
protectedpure virtual |
◆ initialize()
void NativeImportBase::initialize |
( |
| ) |
|
|
protectedvirtual |
◆ initVars()
void NativeImportBase::initVars |
( |
| ) |
|
|
protectedvirtual |
◆ lookAhead()
QString NativeImportBase::lookAhead |
( |
| ) |
|
|
protected |
Get the next lexeme without advancing.
- Returns
- the next lexeme or an empty string
◆ parseFile()
bool NativeImportBase::parseFile |
( |
const QString & |
filename | ) |
|
|
protectedvirtual |
Import a single file. The default implementation should be feasible for languages that don't depend on an external preprocessor.
- Parameters
-
filename | The file to import. |
- Returns
- state of parsing - false means errors
Implements ClassImport.
Reimplemented in IDLImport, CsValaImportBase, and JavaImport.
◆ parseStmt()
virtual bool NativeImportBase::parseStmt |
( |
| ) |
|
|
protectedpure virtual |
◆ popScope()
Return previously defined scope.
- Returns
- previous scope
◆ preprocess()
bool NativeImportBase::preprocess |
( |
QString & |
line | ) |
|
|
protectedvirtual |
Preprocess a line. May modify the given line to remove items consumed by the preprocessing such as comments or preprocessor directives. The default implementation handles multi-line comments.
- Parameters
-
line | The line to preprocess. |
- Returns
- True if the line was completely consumed, false if there are still items left in the line for further analysis.
Reimplemented in CsValaImportBase, IDLImport, and PythonImport.
◆ pushScope()
void NativeImportBase::pushScope |
( |
UMLPackage * |
p | ) |
|
|
protected |
Set package as current scope.
- Parameters
-
p | UML package to set as current scope |
◆ scan()
void NativeImportBase::scan |
( |
const QString & |
line | ) |
|
|
protected |
Scan a single line. parseFile() calls this for each line read from the input file. This in turn calls other methods such as preprocess() and fillSource(). The lexer. Tokenizes the given string and fills `m_source'. Stores possible comments in `m_comment'.
- Parameters
-
◆ scopeIndex()
int NativeImportBase::scopeIndex |
( |
| ) |
|
|
protected |
Return current scope index.
- Returns
- >= 0 index, -1 empty
◆ setMultiLineAltComment()
void NativeImportBase::setMultiLineAltComment |
( |
const QString & |
intro, |
|
|
const QString & |
end |
|
) |
| |
|
protected |
Set the delimiter strings for an alternative form of multi line comment. See setMultiLineComment().
- Parameters
-
intro | the start comment string |
end | the end comment string |
◆ setMultiLineComment()
void NativeImportBase::setMultiLineComment |
( |
const QString & |
intro, |
|
|
const QString & |
end |
|
) |
| |
|
protected |
Set the delimiter strings for a multi line comment.
- Parameters
-
intro | In languages with a C style multiline comment this is slash-star. |
end | In languages with a C style multiline comment this is star-slash. |
◆ skipStmt()
void NativeImportBase::skipStmt |
( |
const QString & |
until = QLatin1String(";") | ) |
|
|
protected |
Advance m_srcIndex until m_source[m_srcIndex] contains the lexeme given by `until'.
- Parameters
-
◆ skipToClosing()
bool NativeImportBase::skipToClosing |
( |
QChar |
opener | ) |
|
|
protected |
Advance m_srcIndex to the index of the corresponding closing character of the given opening. Nested opening/closing pairs are respected. Valid openers are: '{' '[' '(' '<'
- Parameters
-
- Returns
- True for success, false for misuse (invalid opener) or if no matching closing character is found in m_source.
◆ split()
QStringList NativeImportBase::split |
( |
const QString & |
line | ) |
|
|
protectedvirtual |
Split the line so that a string is returned as a single element of the list. When not in a string then split at white space. The default implementation is suitable for C style strings and char constants.
- Parameters
-
- Returns
- the parts of the line
Reimplemented in AdaImport, and PascalImport.
◆ m_comment
QString NativeImportBase::m_comment |
|
protected |
intermediate accumulator for comment text
◆ m_currentAccess
current access (public/protected/private)
◆ m_inComment
bool NativeImportBase::m_inComment |
|
protected |
True if we are currently in a multi-line comment. Only applies to languages with multi-line comments.
◆ m_isAbstract
bool NativeImportBase::m_isAbstract |
|
protected |
accumulator for abstractness
◆ m_klass
class currently being processed
◆ m_multiLineAltCommentEnd
QString NativeImportBase::m_multiLineAltCommentEnd |
|
protected |
◆ m_multiLineAltCommentIntro
QString NativeImportBase::m_multiLineAltCommentIntro |
|
protected |
Some languages support an alternative set of multi line comment delimiters.
◆ m_multiLineCommentEnd
QString NativeImportBase::m_multiLineCommentEnd |
|
protected |
multi line comment delimiter end
◆ m_multiLineCommentIntro
QString NativeImportBase::m_multiLineCommentIntro |
|
protected |
multi line comment delimiter intro
◆ m_parsedFiles
QStringList NativeImportBase::m_parsedFiles |
|
staticprotected |
List of parsed files. Contains file names without paths. Before actually parsing a given file, NativeImportBase checks whether the name is already present in this list in order to avoid parsing the same file multiple times.
◆ m_scope
stack of scopes for use by the specific importer
◆ m_singleLineCommentIntro
QString NativeImportBase::m_singleLineCommentIntro |
|
protected |
start token of a single line comment
◆ m_source
QStringList NativeImportBase::m_source |
|
protected |
◆ m_srcIndex
int NativeImportBase::m_srcIndex |
|
protected |
used for indexing m_source
The documentation for this class was generated from the following files: