umbrello 2.34.70-5524f40e1
Umbrello UML Modeller is a Unified Modelling Language (UML) diagram program based on KDE Technology
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
NativeImportBase Class Referenceabstract

Base class for native implementations of language import. More...

#include <nativeimportbase.h>

Inheritance diagram for NativeImportBase:
Collaboration diagram for NativeImportBase:

Public Member Functions

 NativeImportBase (const QString &singleLineCommentIntro, CodeImpThread *thread=0)
 
virtual ~NativeImportBase ()
 
- Public Member Functions inherited from ClassImport
 ClassImport (CodeImpThread *thread=0)
 
virtual ~ClassImport ()
 
bool importFiles (const QStringList &fileNames)
 
bool importFile (const QString &fileName)
 
void setRootPath (const QString &path)
 
bool enabled () const
 

Protected Member Functions

void initialize ()
 
void setMultiLineComment (const QString &intro, const QString &end)
 
void setMultiLineAltComment (const QString &intro, const QString &end)
 
virtual bool parseFile (const QString &filename)
 
virtual void initVars ()
 
void scan (const QString &line)
 
virtual bool preprocess (QString &line)
 
virtual QStringList split (const QString &line)
 
virtual void fillSource (const QString &word)=0
 
virtual bool parseStmt ()=0
 
void skipStmt (const QString &until=QLatin1String(";"))
 
bool skipToClosing (QChar opener)
 
QString current ()
 
QString lookAhead ()
 
virtual QString advance ()
 
void pushScope (UMLPackage *p)
 
UMLPackagepopScope ()
 
UMLPackagecurrentScope ()
 
int scopeIndex ()
 
- Protected Member Functions inherited from ClassImport
virtual void initPerFile ()
 
void log (const QString &file, const QString &text)
 
void log (const QString &text)
 

Protected Attributes

QString m_singleLineCommentIntro
 start token of a single line comment More...
 
QStringList m_source
 the scanned lexemes More...
 
int m_srcIndex
 used for indexing m_source More...
 
QList< UMLPackage * > m_scope
 stack of scopes for use by the specific importer More...
 
UMLClassifierm_klass
 class currently being processed More...
 
Uml::Visibility::Enum m_currentAccess
 current access (public/protected/private) More...
 
QString m_comment
 intermediate accumulator for comment text More...
 
bool m_inComment
 
bool m_isAbstract
 accumulator for abstractness More...
 
QString m_multiLineCommentIntro
 multi line comment delimiter intro More...
 
QString m_multiLineCommentEnd
 multi line comment delimiter end More...
 
QString m_multiLineAltCommentIntro
 
QString m_multiLineAltCommentEnd
 
- Protected Attributes inherited from ClassImport
CodeImpThreadm_thread
 thread in which the work of importing is done More...
 
bool m_enabled
 state of importer More...
 
QString m_rootPath
 root path of import More...
 

Static Protected Attributes

static QStringList m_parsedFiles
 

Additional Inherited Members

- Static Public Member Functions inherited from ClassImport
static ClassImportcreateImporterByFileExt (const QString &fileName, CodeImpThread *thread=0)
 

Detailed Description

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

Constructor & Destructor Documentation

◆ NativeImportBase()

NativeImportBase::NativeImportBase ( const QString &  singleLineCommentIntro,
CodeImpThread thread = 0 
)
explicit

Constructor

Parameters
singleLineCommentIntro"//" for IDL and Java, "--" for Ada
threadthread in which the code import runs

◆ ~NativeImportBase()

NativeImportBase::~NativeImportBase ( )
virtual

Destructor.

Member Function Documentation

◆ 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()

UMLPackage * NativeImportBase::currentScope ( )
protected

Return current scope. If the scope stack is empty then return nullptr.

Returns
scope

◆ fillSource()

virtual void NativeImportBase::fillSource ( const QString &  word)
protectedpure virtual

Analyze the given word and fill `m_source'. A "word" is a whitespace delimited item from the input line. To be provided by the specific importer class.

Implemented in PythonImport, AdaImport, CSharpImport, CsValaImportBase, IDLImport, JavaImport, PascalImport, and SQLImport.

◆ initialize()

void NativeImportBase::initialize ( )
protectedvirtual

Implement abstract operation from ClassImport.

Implements ClassImport.

◆ initVars()

void NativeImportBase::initVars ( )
protectedvirtual

Initialize auxiliary variables. This is called by the default implementation of parseFile() after scanning (before parsing the QStringList m_source.) The default implementation is empty.

Reimplemented in AdaImport, CsValaImportBase, JavaImport, PascalImport, and PythonImport.

◆ 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
filenameThe file to import.
Returns
state of parsing - false means errors

Implements ClassImport.

Reimplemented in IDLImport, CsValaImportBase, and JavaImport.

Here is the call graph for this function:

◆ parseStmt()

virtual bool NativeImportBase::parseStmt ( )
protectedpure virtual

Parse the statement which starts at m_source[m_srcIndex] leaving m_srcIndex pointing to the end of the recognized statement. To be provided by the concrete importer.

Returns
True if the statement was recognized.

Implemented in AdaImport, CsValaImportBase, IDLImport, JavaImport, PascalImport, PythonImport, and SQLImport.

◆ popScope()

UMLPackage * NativeImportBase::popScope ( )
protected

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
lineThe 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
pUML 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
lineThe line to scan.
Here is the call graph for this function:

◆ 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
introthe start comment string
endthe end comment string

◆ setMultiLineComment()

void NativeImportBase::setMultiLineComment ( const QString &  intro,
const QString &  end 
)
protected

Set the delimiter strings for a multi line comment.

Parameters
introIn languages with a C style multiline comment this is slash-star.
endIn 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
untilthe target string

◆ 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
openerthe opener string
Returns
True for success, false for misuse (invalid opener) or if no matching closing character is found in m_source.
Here is the call graph for this function:

◆ 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
linethe line to split
Returns
the parts of the line

Reimplemented in AdaImport, and PascalImport.

Member Data Documentation

◆ m_comment

QString NativeImportBase::m_comment
protected

intermediate accumulator for comment text

◆ m_currentAccess

Uml::Visibility::Enum NativeImportBase::m_currentAccess
protected

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

UMLClassifier* NativeImportBase::m_klass
protected

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

QList<UMLPackage *> NativeImportBase::m_scope
protected

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

the scanned lexemes

◆ m_srcIndex

int NativeImportBase::m_srcIndex
protected

used for indexing m_source


The documentation for this class was generated from the following files: