[Uml-devel] KDE/kdesdk/umbrello/umbrello/codeimport/kdevcppparser
Ralf Habacker
ralf.habacker at gmail.com
Mon Dec 26 10:03:24 UTC 2011
SVN commit 1270602 by habacker:
make sure that only the first comment is taken as file comment
M +19 -11 parser.cpp
--- trunk/KDE/kdesdk/umbrello/umbrello/codeimport/kdevcppparser/parser.cpp #1270601:1270602
@@ -69,7 +69,6 @@
lex(lexer)
{
d = new ParserPrivateData();
-
m_maxProblems = 5;
objcp = false;
}
@@ -421,25 +420,34 @@
bool Parser::parseDeclaration(DeclarationAST::Node& node)
{
//uDebug() << "--- tok = " << (*m_tokenIt).text() << " -- " << "Parser::parseDeclaration()";
- bool firstToken = m_tokenIt == lex->tokenBegin();
- QString comment;
- while ((*m_tokenIt) == Token_comment) {
- comment += (*m_tokenIt).text();
- ++m_tokenIt;
- }
-
- if (firstToken)
+ // catch first comment
+ Position ps = m_tokenIt->getStartPosition();
+ if (ps.line == 1 && ps.column == 1)
{
FileAST::Node ast = CreateNode<FileAST>();
+ ast->setFileName(m_driver->currentFileName());
+ QString comment = (*m_tokenIt).text();
+
+ if ((*m_tokenIt) == Token_comment) {
ast->setComment(comment);
- ast->setFileName(m_driver->currentFileName());
+ ++m_tokenIt;
+ }
+ uDebug() << m_driver->currentFileName() << comment;
node = ast;
return true;
}
- if ((*m_tokenIt).isNull())
+ QString comment;
+ while ((*m_tokenIt) == Token_comment) {
+ comment += (*m_tokenIt).text();
+ ++m_tokenIt;
+ }
+
+ if ((*m_tokenIt).isNull()) {
+ // FIXME: add fetched comment to FileAST
return false;
+ }
TokenIterator start = m_tokenIt;
bool success = false;
More information about the umbrello-devel
mailing list