forked from qt-creator/qt-creator
Cleanup
Done with: Erik Verbruggen
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include <QTextDocument>
|
||||
#include <QTextCursor>
|
||||
#include <QTextBlock>
|
||||
#include <QDir>
|
||||
#include <QDebug>
|
||||
|
||||
#include <Control.h>
|
||||
@@ -163,32 +164,24 @@ private:
|
||||
Overview oo;
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
void generateAST_H(const Snapshot &snapshot, const QDir &cplusplusDir)
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
QStringList files = app.arguments();
|
||||
files.removeFirst();
|
||||
QFileInfo fileAST_h(cplusplusDir, QLatin1String("AST.h"));
|
||||
Q_ASSERT(fileAST_h.exists());
|
||||
|
||||
if (files.isEmpty()) {
|
||||
std::cerr << "Usage: cplusplus AST.h" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
const QString fileName = fileAST_h.absoluteFilePath();
|
||||
|
||||
Snapshot snapshot;
|
||||
|
||||
//const QString configuration = QLatin1String("#define CPLUSPLUS_EXPORT\n");
|
||||
|
||||
foreach (const QString &fileName, files) {
|
||||
QFile file(fileName);
|
||||
if (! file.open(QFile::ReadOnly))
|
||||
continue;
|
||||
return;
|
||||
|
||||
const QString source = QTextStream(&file).readAll();
|
||||
file.close();
|
||||
|
||||
QTextDocument document;
|
||||
document.setPlainText(source);
|
||||
|
||||
Document::Ptr doc = Document::create(fileName);
|
||||
//doc->control()->setDiagnosticClient(0);
|
||||
const QByteArray preprocessedCode = snapshot.preprocessedCode(source, fileName);
|
||||
doc->setSource(preprocessedCode);
|
||||
doc->check();
|
||||
@@ -210,7 +203,7 @@ int main(int argc, char *argv[])
|
||||
const QString className = oo(classAST->symbol->name());
|
||||
const QString methodName = QLatin1String("as") + className.mid(0, className.length() - 3);
|
||||
replacementCastMethods[classAST] = QString(" virtual %1 *%2() { return this; }\n").arg(className, methodName);
|
||||
castMethods.append(QString(" virtual %1 *%2() { return 0; }").arg(className, methodName));
|
||||
castMethods.append(QString(" virtual %1 *%2() { return 0; }\n").arg(className, methodName));
|
||||
}
|
||||
|
||||
if (! baseCastMethodCursors.isEmpty()) {
|
||||
@@ -219,7 +212,7 @@ int main(int argc, char *argv[])
|
||||
baseCastMethodCursors[i].removeSelectedText();
|
||||
}
|
||||
|
||||
baseCastMethodCursors.first().insertText(castMethods.join(QLatin1String("\n")));
|
||||
baseCastMethodCursors.first().insertText(castMethods.join(QLatin1String("")));
|
||||
}
|
||||
|
||||
for (int classIndex = 0; classIndex < astNodes.deriveds.size(); ++classIndex) {
|
||||
@@ -234,6 +227,25 @@ int main(int argc, char *argv[])
|
||||
astNodes.endOfPublicClassSpecifiers[classIndex].insertText(replacementCastMethods.value(classAST));
|
||||
}
|
||||
|
||||
std::cout << qPrintable(document.toPlainText());
|
||||
if (file.open(QFile::WriteOnly)) {
|
||||
QTextStream out(&file);
|
||||
out << document.toPlainText();
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
QStringList files = app.arguments();
|
||||
files.removeFirst();
|
||||
|
||||
if (files.isEmpty()) {
|
||||
std::cerr << "Usage: cplusplus [path to C++ front-end]" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
QDir cplusplusDir(files.first());
|
||||
Snapshot snapshot;
|
||||
|
||||
generateAST_H(snapshot, cplusplusDir);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user