[Uml-devel] branches/work/soc-umbrello/umbrello

Andi Fischer andi.fischer at hispeed.ch
Tue Jul 3 11:30:58 UTC 2012


SVN commit 1303799 by fischer:

New codeimport fixes from trunk applied.

 M  +2 -1      codeimport/cppimport.cpp  
 M  +6 -4      codeimport/kdevcppparser/driver.cpp  
 M  +1 -1      codeimport/kdevcppparser/driver.h  
 M  +18 -4     codeimport/kdevcppparser/lexer.cpp  
 M  +2 -2      codeimport/kdevcppparser/lexer.h  
 M  +1 -1      codeimport/kdevcppparser/parser.cpp  
 M  +11 -0     codeimport/kdevcppparser/position.h  
 M  +8 -1      codeimport/kdevcppparser/preprocesslexer.cpp  
 M  +1 -1      codeimport/kdevcppparser/preprocesslexer.h  
 M  +14 -10    codeimpwizard/codeimpstatuspage.cpp  
 M  +1 -1      codeimpwizard/codeimpstatuspage.h  
 M  +3 -3      codeimpwizard/codeimpthread.cpp  
 M  +2 -1      codeimpwizard/codeimpthread.h  


--- branches/work/soc-umbrello/umbrello/codeimport/cppimport.cpp #1303798:1303799
@@ -133,7 +133,8 @@
 {
     if (ms_seenFiles.indexOf(fileName) != -1)
         return true;
-    ms_driver->parseFile( fileName );
+    if (!ms_driver->parseFile( fileName ))
+        return false;
     feedTheModel(fileName);
     return true;
 }
--- branches/work/soc-umbrello/umbrello/codeimport/kdevcppparser/driver.cpp #1303798:1303799
@@ -211,7 +211,7 @@
     return QList<Problem>();
 }
 
-void Driver::parseFile( const QString& fileName, bool onlyPreProcess, bool force )
+bool Driver::parseFile( const QString& fileName, bool onlyPreProcess, bool force )
 {
     QFileInfo fileInfo( fileName );
     QString absoluteFilePath = fileInfo.absoluteFilePath();
@@ -222,7 +222,7 @@
         takeTranslationUnit( absoluteFilePath );
     } else if( it != m_parsedUnits.end() && *it != 0 ){
         // file already processed
-        return;
+        return true;
     }
 
     m_dependences.remove( fileName );
@@ -234,8 +234,9 @@
     lexer = &lex;
     setupLexer( &lex );
 
-    lex.setSource( sourceProvider()->contents(fileName),
-                   QString2PositionFilename( fileName));
+    if (!lex.setSource( sourceProvider()->contents(fileName),
+                   QString2PositionFilename( fileName)))
+        return false;
 
     if( !onlyPreProcess ){
         Parser parser( this, &lex );
@@ -249,6 +250,7 @@
 
     m_currentFileName.clear();
     lexer = 0;
+    return true;
 }
 
 void Driver::setupLexer( Lexer * lexer )
--- branches/work/soc-umbrello/umbrello/codeimport/kdevcppparser/driver.h #1303798:1303799
@@ -170,7 +170,7 @@
 
     virtual void reset();
 
-    virtual void parseFile( const QString& fileName, bool onlyPreProcesss=false, bool force=false );
+    virtual bool parseFile( const QString& fileName, bool onlyPreProcesss=false, bool force=false );
     virtual void fileParsed( const QString& fileName );
     virtual void addDependence( const QString& fileName, const Dependence& dep );
     virtual void addMacro( const Macro& macro) {m_macroManager.addMacro( macro);}
--- branches/work/soc-umbrello/umbrello/codeimport/kdevcppparser/lexer.cpp #1303798:1303799
@@ -245,6 +245,17 @@
     return *this;
 }
 
+QDebug operator<<(QDebug out, const Token &t)
+{
+    out << "Token("
+    << "type:" << t.type()
+    << "text:" << t.text()
+    << "start:" << t.getStartPosition()
+    << "end:" << t.getEndPosition()
+    << ")";
+    return out;
+}
+
 Token Lexer::Source::createToken(int type, CharIterator start,
                                  CharIterator end) const
 {
@@ -313,13 +324,14 @@
 {
 }
 
-void Lexer::setSource(const QString& source,
+bool Lexer::setSource(const QString& source,
                       PositionFilename const& p_filename)
 {
     reset();
     m_preprocessLexer.setSource(source, p_filename);
     m_source.set_filename(p_filename);
-    tokenize();
+    return tokenize();
+
 }
 
 void Lexer::reset()
@@ -386,9 +398,10 @@
         m_source.set_startLine(false);
 }
 
-void Lexer::tokenize()
+bool Lexer::tokenize()
 {
-    m_preprocessLexer.preprocess();
+    if (!m_preprocessLexer.preprocess())
+        return false;
 #if 0
     QByteArray l_tmp = m_preprocessLexer.preprocessedString().toAscii();
     for (int i = 0; i < l_tmp.size(); ++i)
@@ -410,6 +423,7 @@
 
     Token tk = m_source.createToken(Token_eof, m_source.get_ptr());
     m_tokens.push_back(tk);
+    return true;
 }
 
 void Lexer::handleDirective(const QString& directive)
--- branches/work/soc-umbrello/umbrello/codeimport/kdevcppparser/lexer.h #1303798:1303799
@@ -71,7 +71,7 @@
                      const QString& str = QString())
     { m_preprocessLexer.addSkipWord( word, skipType, str); }
 
-    void setSource( const QString& source, PositionFilename const& p_filename);
+    bool setSource( const QString& source, PositionFilename const& p_filename);
     void setRecordComments( bool record );
     Position currentPosition() const { return m_source.get_currentPosition(); }
 
@@ -83,7 +83,7 @@
     Position const& getTokenPosition(const Token& token) const;
     TokenIterator tokenBegin() const {return m_tokens.begin();}
 private:
-    void tokenize();
+    bool tokenize();
     void nextToken(Token& token);
     bool recordComments() const;
     void reset();
--- branches/work/soc-umbrello/umbrello/codeimport/kdevcppparser/parser.cpp #1303798:1303799
@@ -433,7 +433,7 @@
             ast->setComment(comment);
             ++m_tokenIt;
         }
-        uDebug() << m_driver->currentFileName() << comment;
+        //uDebug() << m_driver->currentFileName() << comment;
         node = ast;
         return true;
     }
--- branches/work/soc-umbrello/umbrello/codeimport/kdevcppparser/position.h #1303798:1303799
@@ -41,6 +41,7 @@
 #include <boost/spirit/include/classic.hpp>
 #include <QString>
 #include <QChar>
+#include <QDebug>
 
 typedef boost::spirit::classic::file_position_base<std::basic_string<QChar> > Position;
 typedef std::basic_string<QChar> PositionFilename;
@@ -50,6 +51,16 @@
     return p.data();
 }
 
+inline QDebug operator<<(QDebug out, Position const &p)
+{
+    out << "Position("
+        //<< "file" << p.file
+        << "line:" << p.line
+        << "column:" << p.column
+        << ")";
+    return out;
+}
+
 inline bool operator<( Position const& p1, Position const& p2)
 {
     assert( p1.file == p2.file);
--- branches/work/soc-umbrello/umbrello/codeimport/kdevcppparser/preprocesslexer.cpp #1303798:1303799
@@ -579,16 +579,23 @@
         m_preprocessedString += *p_first;
 }
 
-void PreprocessLexer::preprocess()
+bool PreprocessLexer::preprocess()
 {
     for (;;) {
+        Position start = currentPosition();
         nextLine();
+        if (currentPosition() == start) {
+            uError() << "failed to preprocess file" << start;
+            return false;
+        }
+
         if (m_source.currentChar().isNull())
             break;
     }
 
     Token tk = m_source.createToken(Token_eof, m_source.get_ptr());
     m_preprocessedString += tk.text();
+    return true;
 }
 
 void PreprocessLexer::addSkipWord(const QString& word, SkipType skipType, const QString& str)
--- branches/work/soc-umbrello/umbrello/codeimport/kdevcppparser/preprocesslexer.h #1303798:1303799
@@ -201,7 +201,7 @@
 
     void addSkipWord( const QString& word, SkipType skipType = SkipWord,
                       const QString& str = QString() );
-    void preprocess();
+    bool preprocess();
     void setSource( const QString& source, PositionFilename const& p_filename);
     void setRecordComments( bool record );
     QString const& preprocessedString() const {return m_preprocessedString;}
--- branches/work/soc-umbrello/umbrello/codeimpwizard/codeimpstatuspage.cpp #1303798:1303799
@@ -131,26 +131,30 @@
 #ifdef ENABLE_IMPORT_THREAD
     m_thread = new QThread;
     //connect(thread, SIGNAL(started()), this, SLOT(importCodeFile()));
-    connect(m_thread, SIGNAL(finished()), this, SLOT(importCodeFile()));
+    connect(m_thread, SIGNAL(finished(bool)), this, SLOT(importCodeFile(bool)));
     connect(m_thread, SIGNAL(terminated()), this, SLOT(importCodeStop()));
 #endif
     importCodeFile();
 }
 
-void CodeImpStatusPage::importCodeFile()
+void CodeImpStatusPage::importCodeFile(bool noError)
 {
+    if (m_index > 0) {
+        if (noError) {
+            messageToLog(m_file.fileName(), i18n("importing file ... DONE<br>"));
+            updateStatus(m_file.fileName(), i18n("Import Done"));
+        }
+        else {
+            messageToLog(m_file.fileName(), i18n("importing file ... FAILED<br>"));
+            updateStatus(m_file.fileName(), i18n("Import Failed"));
+        }
+    }
+
     // all files done
     if (m_index >= m_files.size()) {
-        messageToLog(m_file.fileName(), i18n("importing file ... DONE<br>"));
-        updateStatus(m_file.fileName(), i18n("Import Done"));
         importCodeFinish();
         return;
     }
-    // at least one file done
-    else if (m_index > 0) {
-        messageToLog(m_file.fileName(), i18n("importing file ... DONE<br>"));
-        updateStatus(m_file.fileName(), i18n("Import Done"));
-    }
 
     m_file = m_files.at(m_index++);
     messageToLog(m_file.fileName(), i18n("importing file ..."));
@@ -159,7 +163,7 @@
     connect(worker, SIGNAL(messageToLog(QString,QString)), this, SLOT(messageToLog(QString,QString)));
     connect(worker, SIGNAL(messageToApp(QString)), this, SLOT(messageToApp(QString)));
 #ifndef ENABLE_IMPORT_THREAD
-    connect(worker, SIGNAL(finished()), this, SLOT(importCodeFile()));
+    connect(worker, SIGNAL(finished(bool)), this, SLOT(importCodeFile(bool)));
     connect(worker, SIGNAL(aborted()), this, SLOT(importCodeStop()));
     worker->run();
     worker->deleteLater();
--- branches/work/soc-umbrello/umbrello/codeimpwizard/codeimpstatuspage.h #1303798:1303799
@@ -61,7 +61,7 @@
 
 protected slots:
     void importCode(); ///< start importing
-    void importCodeFile(); ///< import single file
+    void importCodeFile(bool noError=true); ///< import single file
     void importCodeFinish(); ///< finish importing
     void importCodeStop(); ///< cancel importing
     void updateStatus(const QString& file, const QString& text);
--- branches/work/soc-umbrello/umbrello/codeimpwizard/codeimpthread.cpp #1303798:1303799
@@ -61,15 +61,15 @@
 
         if (!classImporter->importFile(fileName)) {
             emit messageToApp(i18nc("show failed on status bar", "Failed."));
-            emit messageToWiz(m_file.fileName(), "failed");
+            emit messageToWiz(m_file.fileName(), "");
             emit messageToLog(m_file.fileName(), "...import failed");
-            emit aborted();
+            emit finished(false);
         }
         else {
             emit messageToApp(i18nc("show Ready on status bar", "Ready."));
             emit messageToWiz(m_file.fileName(), "finished");
             emit messageToLog(m_file.fileName(), "...import finished");
-            emit finished();
+            emit finished(true);
         }
         delete classImporter;
     }
--- branches/work/soc-umbrello/umbrello/codeimpwizard/codeimpthread.h #1303798:1303799
@@ -50,8 +50,9 @@
     void messageToWiz(const QString& file, const QString& text);
     void messageToLog(const QString& file, const QString& text);
     void messageToApp(const QString& text);
-    void finished();
     void aborted();
+    void failed();
+    void finished(bool noError);
 
 private slots:
     void questionAsked(const QString& question, int& answer);




More information about the umbrello-devel mailing list