Updated Doxygen warning system
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13598 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
771c61f9f1
commit
3eed72b659
4 changed files with 36 additions and 25 deletions
|
|
@ -174,7 +174,7 @@ std::string DoxygenParser::getStringTilEndCommand(std::string theCommand, TokenL
|
|||
|
||||
tokList.next();
|
||||
}
|
||||
tokList.printListError(theCommand + " command expected");
|
||||
tokList.printListError(WARN_DOXYGEN_COMMAND_EXPECTED, theCommand + " command expected");
|
||||
return description;
|
||||
}
|
||||
|
||||
|
|
@ -263,7 +263,7 @@ int DoxygenParser::addCommandWord(std::string theCommand, TokenList & tokList, s
|
|||
doxyList.push_back(DoxygenEntity(theCommand, aNewList));
|
||||
return 1;
|
||||
} else
|
||||
tokList.printListError("No word followed " + theCommand + " command. Not added");
|
||||
tokList.printListError(WARN_DOXYGEN_COMMAND_ERROR, "No word followed " + theCommand + " command. Not added");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -291,7 +291,7 @@ int DoxygenParser::addCommandEndCommand(std::string theCommand, TokenList & tokL
|
|||
cout << "Parsing " << theCommand << endl;
|
||||
std::list < Token >::iterator endCommand = getEndCommand("end" + theCommand, tokList);
|
||||
if (endCommand == tokList.end()) {
|
||||
tokList.printListError("Expected end" + theCommand);
|
||||
tokList.printListError(WARN_DOXYGEN_COMMAND_EXPECTED, "Expected end" + theCommand);
|
||||
return 0;
|
||||
}
|
||||
std::list < DoxygenEntity > aNewList;
|
||||
|
|
@ -306,7 +306,7 @@ int DoxygenParser::addCommandWordParagraph(std::string theCommand, TokenList & t
|
|||
cout << "Parsing " << theCommand << endl;
|
||||
std::string name = getNextWord(tokList);
|
||||
if (name.empty()) {
|
||||
tokList.printListError("No word followed " + theCommand + " command. Not added");
|
||||
tokList.printListError(WARN_DOXYGEN_COMMAND_ERROR, "No word followed " + theCommand + " command. Not added");
|
||||
return 0;
|
||||
}
|
||||
std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList);
|
||||
|
|
@ -322,7 +322,7 @@ int DoxygenParser::addCommandWordLine(std::string theCommand, TokenList & tokLis
|
|||
cout << "Parsing " << theCommand << endl;
|
||||
std::string name = getNextWord(tokList);
|
||||
if (name.empty()) {
|
||||
tokList.printListError("No word followed " + theCommand + " command. Not added");
|
||||
tokList.printListError(WARN_DOXYGEN_COMMAND_ERROR, "No word followed " + theCommand + " command. Not added");
|
||||
return 0;
|
||||
}
|
||||
std::list < Token >::iterator endOfLine = getOneLine(tokList);
|
||||
|
|
@ -339,7 +339,7 @@ int DoxygenParser::addCommandWordOWordOWord(std::string theCommand, TokenList &
|
|||
cout << "Parsing " << theCommand << endl;
|
||||
std::string name = getNextWord(tokList);
|
||||
if (name.empty()) {
|
||||
tokList.printListError("No word followed " + theCommand + " command. Not added");
|
||||
tokList.printListError(WARN_DOXYGEN_COMMAND_ERROR, "No word followed " + theCommand + " command. Not added");
|
||||
return 0;
|
||||
}
|
||||
std::string headerfile = getNextWord(tokList);
|
||||
|
|
@ -365,7 +365,7 @@ int DoxygenParser::addCommandOWord(std::string theCommand, TokenList & tokList,
|
|||
}
|
||||
|
||||
int DoxygenParser::addCommandErrorThrow(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &) {
|
||||
tokList.printListError("Encountered: " + theCommand +
|
||||
tokList.printListError(WARN_DOXYGEN_COMMAND_ERROR, "Encountered: " + theCommand +
|
||||
"\nThis command should not have been encountered. Behaviour past this may be unpredictable");
|
||||
std::list < Token >::iterator endOfLine = getOneLine(tokList);
|
||||
tokList.setIterator(endOfLine);
|
||||
|
|
@ -387,17 +387,17 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList,
|
|||
cout << "Parsing " << theCommand << endl;
|
||||
std::string key = getNextWord(tokList);
|
||||
if (key.empty()) {
|
||||
tokList.printListError("No key followed " + theCommand + " command. Not added");
|
||||
tokList.printListError(WARN_DOXYGEN_COMMAND_ERROR, "No key followed " + theCommand + " command. Not added");
|
||||
return 0;
|
||||
}
|
||||
std::string heading = getNextWord(tokList);
|
||||
if (key.empty()) {
|
||||
tokList.printListError("No heading followed " + theCommand + " command. Not added");
|
||||
tokList.printListError(WARN_DOXYGEN_COMMAND_ERROR, "No heading followed " + theCommand + " command. Not added");
|
||||
return 0;
|
||||
}
|
||||
std::string title = getNextWord(tokList);
|
||||
if (title.empty()) {
|
||||
tokList.printListError("No title followed " + theCommand + " command. Not added");
|
||||
tokList.printListError(WARN_DOXYGEN_COMMAND_ERROR, "No title followed " + theCommand + " command. Not added");
|
||||
return 0;
|
||||
}
|
||||
std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList);
|
||||
|
|
@ -460,7 +460,7 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList,
|
|||
cout << "Parsing " << theCommand << endl;
|
||||
std::string name = getNextWord(tokList);
|
||||
if (name.empty()) {
|
||||
tokList.printListError("No word followed " + theCommand + " command. Not added");
|
||||
tokList.printListError(WARN_DOXYGEN_COMMAND_ERROR, "No word followed " + theCommand + " command. Not added");
|
||||
return 0;
|
||||
}
|
||||
std::list < DoxygenEntity > aNewList;
|
||||
|
|
@ -477,7 +477,7 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList,
|
|||
cout << "Parsing " << theCommand << endl;
|
||||
std::string name = getNextWord(tokList);
|
||||
if (name.empty()) {
|
||||
tokList.printListError("No key followed " + theCommand + " command. Not added");
|
||||
tokList.printListError(WARN_DOXYGEN_COMMAND_ERROR, "No key followed " + theCommand + " command. Not added");
|
||||
return 0;
|
||||
}
|
||||
std::string text = getNextWord(tokList);
|
||||
|
|
@ -492,7 +492,7 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList,
|
|||
cout << "Parsing " << theCommand << endl;
|
||||
std::string name = getNextWord(tokList);
|
||||
if (name.empty()) {
|
||||
tokList.printListError("No name followed " + theCommand + " command. Not added");
|
||||
tokList.printListError(WARN_DOXYGEN_COMMAND_ERROR, "No name followed " + theCommand + " command. Not added");
|
||||
return 0;
|
||||
}
|
||||
std::string text = getNextWord(tokList);
|
||||
|
|
@ -541,7 +541,7 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList,
|
|||
cout << "Parsing " << theCommand << endl;
|
||||
std::string file = getNextWord(tokList);
|
||||
if (file.empty()) {
|
||||
tokList.printListError("No file followed " + theCommand + " command. Not added");
|
||||
tokList.printListError(WARN_DOXYGEN_COMMAND_ERROR, "No file followed " + theCommand + " command. Not added");
|
||||
return 0;
|
||||
}
|
||||
std::string caption = getNextWord(tokList);
|
||||
|
|
@ -556,12 +556,12 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList,
|
|||
cout << "Parsing " << theCommand << endl;
|
||||
std::string format = getNextWord(tokList);
|
||||
if (format.empty()) {
|
||||
tokList.printListError("No format followed " + theCommand + " command. Not added");
|
||||
tokList.printListError(WARN_DOXYGEN_COMMAND_ERROR, "No format followed " + theCommand + " command. Not added");
|
||||
return 0;
|
||||
}
|
||||
std::string file = getNextWord(tokList);
|
||||
if (file.empty()) {
|
||||
tokList.printListError("No name followed " + theCommand + " command. Not added");
|
||||
tokList.printListError(WARN_DOXYGEN_COMMAND_ERROR, "No name followed " + theCommand + " command. Not added");
|
||||
return 0;
|
||||
}
|
||||
std::string caption = getNextWord(tokList);
|
||||
|
|
@ -582,7 +582,7 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList,
|
|||
cout << "Parsing " << theCommand << endl;
|
||||
std::string name = getNextWord(tokList);
|
||||
if (name.empty()) {
|
||||
tokList.printListError("No word followed " + theCommand + " command. Not added");
|
||||
tokList.printListError(WARN_DOXYGEN_COMMAND_ERROR, "No word followed " + theCommand + " command. Not added");
|
||||
return 0;
|
||||
}
|
||||
std::list < DoxygenEntity > aNewList;
|
||||
|
|
@ -605,7 +605,7 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList,
|
|||
if (needsCond) {
|
||||
cond = getNextWord(tokList);
|
||||
if (cond.empty()) {
|
||||
tokList.printListError("No word followed " + theCommand + " command. Not added");
|
||||
tokList.printListError(WARN_DOXYGEN_COMMAND_ERROR, "No word followed " + theCommand + " command. Not added");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -633,7 +633,7 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList,
|
|||
}
|
||||
|
||||
if (endCommand == tokList.end()) {
|
||||
tokList.printListError("No corresponding endif found");
|
||||
tokList.printListError(WARN_DOXYGEN_COMMAND_EXPECTED, "No corresponding endif found");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -701,7 +701,7 @@ std::list < DoxygenEntity > DoxygenParser::parse(std::list < Token >::iterator e
|
|||
if (currCommand < 0) {
|
||||
if (noisy)
|
||||
cout << "Unidentified Command " << currToken.tokenString << endl;
|
||||
tokList.printListError("Unsupported command: " + currToken.tokenString + ". Ignored");
|
||||
tokList.printListError(WARN_DOXYGEN_UNKNOWN_COMMAND, "Unsupported command: '" + currToken.tokenString + "'. Ignored");
|
||||
tokList.current()->tokenType = PLAINSTRING; // little hack to add the command as plaintext
|
||||
addCommand(currPlainstringCommandType, tokList, aNewList);
|
||||
} else {
|
||||
|
|
@ -714,7 +714,7 @@ std::list < DoxygenEntity > DoxygenParser::parse(std::list < Token >::iterator e
|
|||
|
||||
if (endParsingIndex != tokList.end() && tokList.current() == tokList.end()) {
|
||||
// this could happen if we cant reach the original endParsingIndex
|
||||
tokList.printListError("Unexpected end of comment encountered");
|
||||
tokList.printListError(WARN_DOXYGEN_UNEXPECTED_END_OF_COMMENT, "Unexpected end of comment encountered");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,8 +42,10 @@ TokenList TokenList::tokenizeDoxygenComment(const std::string &doxygenComment, c
|
|||
else if (prevChar == '\\' || prevChar == '@') {
|
||||
// it's a doxygen command
|
||||
// hack to get commands like \\ or \@ or @\ or @@
|
||||
if (doxygenComment[pos] == '@' || doxygenComment[pos] == '\\')
|
||||
if (doxygenComment[pos] == '@' || doxygenComment[pos] == '\\') {
|
||||
currentWord += doxygenComment[pos];
|
||||
pos++;
|
||||
}
|
||||
tokList.m_tokenList.push_back(Token(COMMAND, currentWord));
|
||||
}
|
||||
else if (currentWord.size() && (currentWord[0] == '!' || currentWord[0] == '*' || currentWord[0] == '/')) {
|
||||
|
|
@ -133,10 +135,10 @@ void TokenList::printList() {
|
|||
}
|
||||
}
|
||||
|
||||
void TokenList::printListError(std::string message) {
|
||||
void TokenList::printListError(int warningType, std::string message) {
|
||||
int curLine = fileLine;
|
||||
for (list< Token >::iterator it = m_tokenList.begin(); it != current(); it++)
|
||||
if (it->tokenType == END_LINE)
|
||||
curLine++;
|
||||
Swig_error(fileName.c_str(), curLine, "Doxygen parser error: %s. \n", message.c_str());
|
||||
Swig_warning(warningType, fileName.c_str(), curLine, "Doxygen parser warning: %s. \n", message.c_str());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
#include <string>
|
||||
#include <list>
|
||||
#include "Token.h"
|
||||
#include "swigwarn.h"
|
||||
|
||||
/* a small class used to represent the sequence of tokens
|
||||
* that can be derived from a formatted doxygen string
|
||||
|
|
@ -43,7 +44,7 @@ public:
|
|||
void setIterator(list < Token >::iterator newPosition); /*moves up the iterator */
|
||||
|
||||
void printList(); /* prints out the sequence of tokens */
|
||||
void printListError(std::string message); /* prints properly formatted error message */
|
||||
void printListError(int warningType, std::string message); /* prints properly formatted error message */
|
||||
|
||||
/*
|
||||
* Create TokenList and populate it with tokens from
|
||||
|
|
|
|||
|
|
@ -221,6 +221,14 @@
|
|||
|
||||
/* please leave 700-719 free for D */
|
||||
|
||||
#define WARN_DOXYGEN_UNKNOWN_COMMAND 720
|
||||
#define WARN_DOXYGEN_UNEXPECTED_END_OF_COMMENT 721
|
||||
#define WARN_DOXYGEN_COMMAND_EXPECTED 722
|
||||
#define WARN_DOXYGEN_UNTERMINATED_STRING 723
|
||||
#define WARN_DOXYGEN_COMMAND_ERROR 724
|
||||
|
||||
/* please leave 720-729 free for Doxygen */
|
||||
|
||||
#define WARN_RUBY_WRONG_NAME 801
|
||||
#define WARN_RUBY_MULTIPLE_INHERITANCE 802
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue