[Uml-devel] KDE/kdesdk/umbrello
Andi Fischer
andi.fischer at hispeed.ch
Wed Aug 3 20:47:35 UTC 2011
SVN commit 1244714 by fischer:
Code import wizard - small improvements.
M +21 -1 test/ATP.txt
M +26 -1 umbrello/codeimport/classimport.cpp
M +3 -0 umbrello/codeimport/classimport.h
M +6 -3 umbrello/codeimport/javaimport.cpp
M +1 -1 umbrello/codeimport/javaimport.h
M +3 -14 umbrello/codeimport/nativeimportbase.cpp
M +2 -6 umbrello/codeimport/pythonimport.cpp
M +9 -5 umbrello/codeimpwizard/codeimpstatuspage.cpp
--- trunk/KDE/kdesdk/umbrello/test/ATP.txt #1244713:1244714
@@ -1,5 +1,5 @@
============================
-| Application Test Procedure | (last updated: 2011-07-30 by Andi Fischer)
+| Application Test Procedure | (last updated: 2011-07-31 by Andi Fischer)
============================
===============================================================================
@@ -341,6 +341,16 @@
-------------------------------------------------------------------------------
COI08 - Code import Java: OK[ ] NOK[ ]
-------------------------------------------------------------------------------
+Testprocedure:
+ 1) Download a java project, e.g. LAoE
+ information at http://www.oli4.ch/laoe/home.html
+ source code at http://sourceforge.net/projects/laoe/
+ 2) Import all or only some single files.
+Testresult:
+ 1) The code is parsed and imported as expected.
+ 2) All classes are found.
+ 3) All methods are found with the right parameters.
+ 4) All attributes are found.
-------------------------------------------------------------------------------
COI09 - Code import JavaScript: OK[ ] NOK[ ]
@@ -373,6 +383,16 @@
-------------------------------------------------------------------------------
COI16 - Code import Python: OK[ ] NOK[ ]
-------------------------------------------------------------------------------
+Testprocedure:
+ 1) Download a python project, e.g. eric5
+ information at http://eric-ide.python-projects.org/
+ source code at http://sourceforge.net/projects/eric-ide/files/eric5/stable/
+ 2) Import all or only some single files.
+Testresult:
+ 1) The code is parsed and imported as expected.
+ 2) All classes are found.
+ 3) All methods are found with the right parameters.
+ 4) All attributes are found.
-------------------------------------------------------------------------------
COI17 - Code import Ruby: OK[ ] NOK[ ]
--- trunk/KDE/kdesdk/umbrello/umbrello/codeimport/classimport.cpp #1244713:1244714
@@ -16,6 +16,7 @@
#include <klocale.h>
// app includes
+#include "debug_utils.h"
#include "umldoc.h"
#include "uml.h"
#include "idlimport.h"
@@ -41,7 +42,7 @@
else if (fileName.contains(QRegExp("\\.pyw?$")))
classImporter = new PythonImport(thread);
else if (fileName.endsWith(QLatin1String(".java")))
- classImporter = new JavaImport();
+ classImporter = new JavaImport(thread);
else if (fileName.contains(QRegExp("\\.ad[sba]$")))
classImporter = new AdaImport();
else if (fileName.endsWith(QLatin1String(".pas")))
@@ -83,3 +84,27 @@
initialize();
parseFile(fileName);
}
+
+/**
+ * Write info to a logger or to the debug output.
+ * @param file the name of the parsed file
+ * @param text the text to write
+ */
+void ClassImport::log(const QString& file, const QString& text)
+{
+ if (m_thread) {
+ m_thread->emitMessageToLog(file, text);
+ }
+ else {
+ uDebug() << file << " - " << text;
+ }
+}
+
+/**
+ * Write info to a logger or to the debug output.
+ * @param text the text to write
+ */
+void ClassImport::log(const QString& text)
+{
+ log("", text);
+}
--- trunk/KDE/kdesdk/umbrello/umbrello/codeimport/classimport.h #1244713:1244714
@@ -51,6 +51,9 @@
*/
virtual void parseFile(const QString& fileName) = 0;
+ void log(const QString& file, const QString& text);
+ void log(const QString& text);
+
CodeImpThread* m_thread; ///< thread in which the work of importing is done
};
--- trunk/KDE/kdesdk/umbrello/umbrello/codeimport/javaimport.cpp #1244713:1244714
@@ -14,6 +14,7 @@
// app includes
#include "attribute.h"
#include "classifier.h"
+#include "codeimpthread.h"
#include "debug_utils.h"
#include "enum.h"
#include "import_utils.h"
@@ -35,7 +36,8 @@
/**
* Constructor.
*/
-JavaImport::JavaImport() : NativeImportBase("//")
+JavaImport::JavaImport(CodeImpThread* thread)
+ : NativeImportBase("//", thread)
{
setMultiLineComment("/*", "*/");
initVars();
@@ -273,6 +275,7 @@
const QStringList names = qualifiedName.split('.');
for (QStringList::ConstIterator it = names.begin(); it != names.end(); ++it) {
QString name = (*it);
+ log(keyword + " " + name);
UMLObject *ns = Import_Utils::createUMLObject(UMLObject::ot_Package,
name, m_scope[m_scopeIndex], m_comment);
m_scope[++m_scopeIndex] = static_cast<UMLPackage*>(ns);
@@ -286,6 +289,7 @@
if (keyword == "class" || keyword == "interface") {
const QString& name = advance();
const UMLObject::ObjectType t = (keyword == "class" ? UMLObject::ot_Class : UMLObject::ot_Interface);
+ log(keyword + " " + name);
UMLObject *ns = Import_Utils::createUMLObject(t, name, m_scope[m_scopeIndex], m_comment);
m_scope[++m_scopeIndex] = m_klass = static_cast<UMLClassifier*>(ns);
m_klass->setAbstract(m_isAbstract);
@@ -370,6 +374,7 @@
}
if (keyword == "enum") {
const QString& name = advance();
+ log(keyword + " " + name);
UMLObject *ns = Import_Utils::createUMLObject(UMLObject::ot_Enum,
name, m_scope[m_scopeIndex], m_comment);
UMLEnum *enumType = static_cast<UMLEnum*>(ns);
@@ -597,5 +602,3 @@
}
return true;
}
-
-
--- trunk/KDE/kdesdk/umbrello/umbrello/codeimport/javaimport.h #1244713:1244714
@@ -24,7 +24,7 @@
class JavaImport : public NativeImportBase
{
public:
- JavaImport();
+ JavaImport(CodeImpThread* thread = 0);
virtual ~JavaImport();
protected:
--- trunk/KDE/kdesdk/umbrello/umbrello/codeimport/nativeimportbase.cpp #1244713:1244714
@@ -357,7 +357,7 @@
return;
m_parsedFiles.append(nameWithoutPath);
QString fname = filename;
- const QString msgPrefix = "NativeImportBase::parseFile(" + filename + "): ";
+ const QString msgPrefix = filename + ": ";
if (filename.contains('/')) {
QString path = filename;
path.remove( QRegExp("/[^/]+$") );
@@ -393,12 +393,7 @@
uError() << msgPrefix << "cannot open file";
return;
}
- if (m_thread) {
- m_thread->emitMessageToLog(nameWithoutPath, "parsing...");
- }
- else {
- uDebug() << msgPrefix << "parsing.";
- }
+ log("parsing...");
// Scan the input file into the QStringList m_source.
m_source.clear();
m_srcIndex = 0;
@@ -426,13 +421,8 @@
skipStmt();
m_comment.clear();
}
- if (m_thread) {
- m_thread->emitMessageToLog(nameWithoutPath, "...end of parse");
+ log("...end of parse");
}
- else {
- uDebug() << msgPrefix << "...end of parse";
- }
-}
/**
* Implement abstract operation from ClassImport.
@@ -441,4 +431,3 @@
{
m_parsedFiles.clear();
}
-
--- trunk/KDE/kdesdk/umbrello/umbrello/codeimport/pythonimport.cpp #1244713:1244714
@@ -224,9 +224,7 @@
if (m_source[m_srcIndex] != "{") {
skipStmt("{");
}
- if (m_thread) {
- m_thread->emitMessageToLog("", "class " + name);
- }
+ log("class " + name);
return true;
}
if (keyword == "def") {
@@ -253,9 +251,7 @@
false /*isStatic*/, false /*isAbstract*/, false /*isFriend*/,
false /*isConstructor*/, m_comment);
op->setSourceCode(skipBody());
- if (m_thread) {
- m_thread->emitMessageToLog("", "def " + name);
- }
+ log("def " + name);
return true;
}
--- trunk/KDE/kdesdk/umbrello/umbrello/codeimpwizard/codeimpstatuspage.cpp #1244713:1244714
@@ -114,11 +114,10 @@
UMLDoc* doc = UMLApp::app()->document();
- ui_textEditLogger->setHtml(i18n("<b>Code import of %1 files:</b>", m_files.size()));
+ ui_textEditLogger->setHtml(i18n("<b>Code import of %1 files:</b><br>", m_files.size()));
foreach (const QFileInfo& file, m_files) {
messageToLog(file.fileName(), i18n("importing file ..."));
-uDebug() << "****** preparing task for " << file.fileName();
CodeImpThread* worker = new CodeImpThread(file);
connect(worker, SIGNAL(messageToWiz(QString,QString)), this, SLOT(updateStatus(QString,QString)));
connect(worker, SIGNAL(messageToLog(QString,QString)), this, SLOT(messageToLog(QString,QString)));
@@ -136,7 +135,7 @@
delete classImporter;
}
#endif
- messageToLog(file.fileName(), i18n("importing file ... DONE"));
+ messageToLog(file.fileName(), i18n("importing file ... DONE<br>"));
updateStatus(file.fileName(), i18n("Import Done"));
}
doc->setLoading(false);
@@ -184,9 +183,14 @@
*/
void CodeImpStatusPage::messageToLog(const QString& file, const QString& text)
{
- uDebug() << file << ">> " << text;
QString oldText = ui_textEditLogger->toHtml();
- QString newText = "\n<b>" + file + ":</b> " + text;
+ QString newText('\n');
+ if (file.isEmpty()) {
+ newText.append(" " + text);
+ }
+ else {
+ newText.append("<b>" + file + ":</b> " + text);
+ }
oldText.append(newText);
ui_textEditLogger->setHtml(oldText);
}
More information about the umbrello-devel
mailing list