work save: cpp parser preprocessor
- remove comments before preprocess - pass stringlist instead of text stream as buffered content
This commit is contained in:
parent
dcf37eca8a
commit
9c42a11c0b
|
@ -268,7 +268,7 @@ PParsedFile CppPreprocessor::getInclude(int index)
|
|||
return mIncludes[index];
|
||||
}
|
||||
|
||||
void CppPreprocessor::openInclude(const QString &fileName, QTextStream stream)
|
||||
void CppPreprocessor::openInclude(const QString &fileName, QStringList bufferedText)
|
||||
{
|
||||
if (mIncludes.size()>0) {
|
||||
PParsedFile topFile = mIncludes.front();
|
||||
|
@ -328,7 +328,7 @@ void CppPreprocessor::openInclude(const QString &fileName, QTextStream stream)
|
|||
parsedFile->fileIncludes = mCurrentIncludes;
|
||||
|
||||
// Don't parse stuff we have already parsed
|
||||
if ((stream.device()!=nullptr) || !mScannedFiles.contains(fileName)) {
|
||||
if ((!bufferedText.isEmpty()) || !mScannedFiles.contains(fileName)) {
|
||||
// Parse ONCE
|
||||
//if not Assigned(Stream) then
|
||||
mScannedFiles.insert(fileName);
|
||||
|
@ -336,9 +336,8 @@ void CppPreprocessor::openInclude(const QString &fileName, QTextStream stream)
|
|||
// Only load up the file if we are allowed to parse it
|
||||
bool isSystemFile = isSystemHeaderFile(fileName, mIncludePaths);
|
||||
if ((mParseSystem && isSystemFile) || (mParseLocal && !isSystemFile)) {
|
||||
if (stream.device()!=nullptr) {
|
||||
stream.seek(0); // start scanning from here
|
||||
parsedFile->buffer = ReadStreamToLines(&stream);
|
||||
if (!bufferedText.isEmpty()) {
|
||||
parsedFile->buffer = bufferedText;
|
||||
} else {
|
||||
parsedFile->buffer = ReadFileToLines(fileName);
|
||||
}
|
||||
|
@ -417,14 +416,9 @@ void CppPreprocessor::removeCurrentBranch()
|
|||
mBranchResults.pop_back();
|
||||
}
|
||||
|
||||
QString CppPreprocessor::getResult()
|
||||
QStringList CppPreprocessor::getResult()
|
||||
{
|
||||
QString s;
|
||||
for (QString line:mResult) {
|
||||
s.append(line);
|
||||
s.append(lineBreak());
|
||||
}
|
||||
return s;
|
||||
return mResult;
|
||||
}
|
||||
|
||||
PFileIncludes CppPreprocessor::getFileIncludesEntry(const QString &fileName)
|
||||
|
|
|
@ -70,7 +70,7 @@ private:
|
|||
QString removeSuffixes(const QString& input);
|
||||
// current file stuff
|
||||
PParsedFile getInclude(int index);
|
||||
void openInclude(const QString& fileName, QTextStream stream = QTextStream());
|
||||
void openInclude(const QString& fileName, QStringList bufferedText=QStringList());
|
||||
void closeInclude();
|
||||
|
||||
// branch stuff
|
||||
|
|
Loading…
Reference in New Issue