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];
|
return mIncludes[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppPreprocessor::openInclude(const QString &fileName, QTextStream stream)
|
void CppPreprocessor::openInclude(const QString &fileName, QStringList bufferedText)
|
||||||
{
|
{
|
||||||
if (mIncludes.size()>0) {
|
if (mIncludes.size()>0) {
|
||||||
PParsedFile topFile = mIncludes.front();
|
PParsedFile topFile = mIncludes.front();
|
||||||
|
@ -328,7 +328,7 @@ void CppPreprocessor::openInclude(const QString &fileName, QTextStream stream)
|
||||||
parsedFile->fileIncludes = mCurrentIncludes;
|
parsedFile->fileIncludes = mCurrentIncludes;
|
||||||
|
|
||||||
// Don't parse stuff we have already parsed
|
// Don't parse stuff we have already parsed
|
||||||
if ((stream.device()!=nullptr) || !mScannedFiles.contains(fileName)) {
|
if ((!bufferedText.isEmpty()) || !mScannedFiles.contains(fileName)) {
|
||||||
// Parse ONCE
|
// Parse ONCE
|
||||||
//if not Assigned(Stream) then
|
//if not Assigned(Stream) then
|
||||||
mScannedFiles.insert(fileName);
|
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
|
// Only load up the file if we are allowed to parse it
|
||||||
bool isSystemFile = isSystemHeaderFile(fileName, mIncludePaths);
|
bool isSystemFile = isSystemHeaderFile(fileName, mIncludePaths);
|
||||||
if ((mParseSystem && isSystemFile) || (mParseLocal && !isSystemFile)) {
|
if ((mParseSystem && isSystemFile) || (mParseLocal && !isSystemFile)) {
|
||||||
if (stream.device()!=nullptr) {
|
if (!bufferedText.isEmpty()) {
|
||||||
stream.seek(0); // start scanning from here
|
parsedFile->buffer = bufferedText;
|
||||||
parsedFile->buffer = ReadStreamToLines(&stream);
|
|
||||||
} else {
|
} else {
|
||||||
parsedFile->buffer = ReadFileToLines(fileName);
|
parsedFile->buffer = ReadFileToLines(fileName);
|
||||||
}
|
}
|
||||||
|
@ -417,14 +416,9 @@ void CppPreprocessor::removeCurrentBranch()
|
||||||
mBranchResults.pop_back();
|
mBranchResults.pop_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CppPreprocessor::getResult()
|
QStringList CppPreprocessor::getResult()
|
||||||
{
|
{
|
||||||
QString s;
|
return mResult;
|
||||||
for (QString line:mResult) {
|
|
||||||
s.append(line);
|
|
||||||
s.append(lineBreak());
|
|
||||||
}
|
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PFileIncludes CppPreprocessor::getFileIncludesEntry(const QString &fileName)
|
PFileIncludes CppPreprocessor::getFileIncludesEntry(const QString &fileName)
|
||||||
|
|
|
@ -70,7 +70,7 @@ private:
|
||||||
QString removeSuffixes(const QString& input);
|
QString removeSuffixes(const QString& input);
|
||||||
// current file stuff
|
// current file stuff
|
||||||
PParsedFile getInclude(int index);
|
PParsedFile getInclude(int index);
|
||||||
void openInclude(const QString& fileName, QTextStream stream = QTextStream());
|
void openInclude(const QString& fileName, QStringList bufferedText=QStringList());
|
||||||
void closeInclude();
|
void closeInclude();
|
||||||
|
|
||||||
// branch stuff
|
// branch stuff
|
||||||
|
|
Loading…
Reference in New Issue