[Uml-devel] KDE/kdesdk/umbrello/umbrello/codeimport
Ralf Habacker
ralf.habacker at gmail.com
Wed Nov 30 12:48:53 UTC 2011
SVN commit 1266703 by habacker:
let parseFile() return a value to make callers able to react in case of errors
M +1 -1 classimport.h
M +3 -2 cppimport.cpp
M +1 -1 cppimport.h
M +4 -3 idlimport.cpp
M +1 -1 idlimport.h
M +2 -1 javaimport.cpp
M +1 -1 javaimport.h
M +7 -5 nativeimportbase.cpp
M +1 -1 nativeimportbase.h
--- trunk/KDE/kdesdk/umbrello/umbrello/codeimport/classimport.h #1266702:1266703
@@ -49,7 +49,7 @@
*
* @param fileName The file to import.
*/
- virtual void parseFile(const QString& fileName) = 0;
+ virtual bool parseFile(const QString& fileName) = 0;
void log(const QString& file, const QString& text);
void log(const QString& text);
--- trunk/KDE/kdesdk/umbrello/umbrello/codeimport/cppimport.cpp #1266702:1266703
@@ -128,10 +128,11 @@
* Import a single file.
* @param fileName The file to import.
*/
-void CppImport::parseFile(const QString& fileName)
+bool CppImport::parseFile(const QString& fileName)
{
if (ms_seenFiles.indexOf(fileName) != -1)
- return;
+ return true;
ms_driver->parseFile( fileName );
feedTheModel(fileName);
+ return true;
}
--- trunk/KDE/kdesdk/umbrello/umbrello/codeimport/cppimport.h #1266702:1266703
@@ -31,7 +31,7 @@
void initialize();
- void parseFile(const QString& fileName);
+ bool parseFile(const QString& fileName);
private:
--- trunk/KDE/kdesdk/umbrello/umbrello/codeimport/idlimport.cpp #1266702:1266703
@@ -103,7 +103,7 @@
* Reimplement operation from NativeImportBase.
* Need to do this because we use the external C preprocessor.
*/
-void IDLImport::parseFile(const QString& filename)
+bool IDLImport::parseFile(const QString& filename)
{
if (filename.contains('/')) {
QString path = filename;
@@ -128,12 +128,12 @@
p.start(executable, arguments);
if (!p.waitForStarted()) {
uError() << "could not run preprocessor";
- return;
+ return false;
}
if (!p.waitForFinished()) {
uError() << "could not run preprocessor";
- return;
+ return false;
}
QByteArray out = p.readAllStandardOutput();
@@ -161,6 +161,7 @@
m_currentAccess = Uml::Visibility::Public;
m_comment.clear();
}
+ return true;
}
/**
--- trunk/KDE/kdesdk/umbrello/umbrello/codeimport/idlimport.h #1266702:1266703
@@ -25,7 +25,7 @@
bool parseStmt();
- void parseFile(const QString& file);
+ bool parseFile(const QString& file);
bool preprocess(QString& line);
--- trunk/KDE/kdesdk/umbrello/umbrello/codeimport/javaimport.cpp #1266702:1266703
@@ -243,7 +243,7 @@
* Keep track of the current file being parsed and reset the list of imports.
* @param filename the name of the file being parsed
*/
-void JavaImport::parseFile(const QString& filename)
+bool JavaImport::parseFile(const QString& filename)
{
m_currentFileName = filename;
m_imports.clear();
@@ -263,6 +263,7 @@
s_filesAlreadyParsed.clear();
s_parseDepth = 0;
}
+ return true;
}
/**
--- trunk/KDE/kdesdk/umbrello/umbrello/codeimport/javaimport.h #1266702:1266703
@@ -34,7 +34,7 @@
void fillSource(const QString& word);
- void parseFile(const QString& filename);
+ bool parseFile(const QString& filename);
UMLObject* resolveClass (const QString& className);
--- trunk/KDE/kdesdk/umbrello/umbrello/codeimport/nativeimportbase.cpp #1266702:1266703
@@ -348,13 +348,14 @@
* The default implementation should be feasible for languages that
* don't depend on an external preprocessor.
* @param filename The file to import.
+ * @return state of parsing - false means errors
*/
-void NativeImportBase::parseFile(const QString& filename)
+bool NativeImportBase::parseFile(const QString& filename)
{
QString nameWithoutPath = filename;
nameWithoutPath.remove(QRegExp("^.*/"));
if (m_parsedFiles.contains(nameWithoutPath))
- return;
+ return true;
m_parsedFiles.append(nameWithoutPath);
QString fname = filename;
const QString msgPrefix = filename + ": ";
@@ -367,7 +368,7 @@
if (! QFile::exists(filename)) {
if (filename.startsWith('/')) {
uError() << msgPrefix << "cannot find file";
- return;
+ return false;
}
bool found = false;
const QStringList includePaths = Import_Utils::includePathList();
@@ -385,13 +386,13 @@
}
if (! found) {
uError() << msgPrefix << "cannot find file";
- return;
+ return false;
}
}
QFile file(fname);
if (! file.open(QIODevice::ReadOnly)) {
uError() << msgPrefix << "cannot open file";
- return;
+ return false;
}
log("parsing...");
// Scan the input file into the QStringList m_source.
@@ -422,6 +423,7 @@
m_comment.clear();
}
log("...end of parse");
+ return true;
}
/**
--- trunk/KDE/kdesdk/umbrello/umbrello/codeimport/nativeimportbase.h #1266702:1266703
@@ -53,7 +53,7 @@
void setMultiLineComment(const QString &intro, const QString &end);
void setMultiLineAltComment(const QString &intro, const QString &end);
- virtual void parseFile(const QString& filename);
+ virtual bool parseFile(const QString& filename);
virtual void initVars();
More information about the umbrello-devel
mailing list