make simple functions inline
This commit is contained in:
parent
2c4b692033
commit
e80a92c30a
|
@ -145,29 +145,6 @@ QList<PStatement> CppParser::getListOfFunctions(const QString &fileName, const Q
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
PStatement CppParser::findAndScanBlockAt(const QString &filename, int line)
|
|
||||||
{
|
|
||||||
QMutexLocker locker(&mMutex);
|
|
||||||
if (mParsing) {
|
|
||||||
return PStatement();
|
|
||||||
}
|
|
||||||
PFileIncludes fileIncludes = mPreprocessor.includesList().value(filename);
|
|
||||||
if (!fileIncludes)
|
|
||||||
return PStatement();
|
|
||||||
|
|
||||||
PStatement statement = fileIncludes->scopes.findScopeAtLine(line);
|
|
||||||
return statement;
|
|
||||||
}
|
|
||||||
|
|
||||||
PFileIncludes CppParser::findFileIncludes(const QString &filename, bool deleteIt)
|
|
||||||
{
|
|
||||||
QMutexLocker locker(&mMutex);
|
|
||||||
PFileIncludes fileIncludes = mPreprocessor.includesList().value(filename,PFileIncludes());
|
|
||||||
if (deleteIt && fileIncludes)
|
|
||||||
mPreprocessor.includesList().remove(filename);
|
|
||||||
return fileIncludes;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString CppParser::findFirstTemplateParamOf(const QString &fileName, const QString &phrase, const PStatement& currentScope)
|
QString CppParser::findFirstTemplateParamOf(const QString &fileName, const QString &phrase, const PStatement& currentScope)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&mMutex);
|
QMutexLocker locker(&mMutex);
|
||||||
|
@ -862,17 +839,9 @@ void CppParser::parseHardDefines()
|
||||||
mIsSystemHeader=oldIsSystemHeader;
|
mIsSystemHeader=oldIsSystemHeader;
|
||||||
});
|
});
|
||||||
for (const PDefine& define:mPreprocessor.hardDefines()) {
|
for (const PDefine& define:mPreprocessor.hardDefines()) {
|
||||||
QString hintText = "#define";
|
|
||||||
if (define->name != "")
|
|
||||||
hintText += ' ' + define->name;
|
|
||||||
if (define->args != "")
|
|
||||||
hintText += ' ' + define->args;
|
|
||||||
if (define->value != "")
|
|
||||||
hintText += ' ' + define->value;
|
|
||||||
addStatement(
|
addStatement(
|
||||||
PStatement(), // defines don't belong to any scope
|
PStatement(), // defines don't belong to any scope
|
||||||
"",
|
"",
|
||||||
hintText, // override hint
|
|
||||||
"", // define has no type
|
"", // define has no type
|
||||||
define->name,
|
define->name,
|
||||||
define->value,
|
define->value,
|
||||||
|
@ -973,51 +942,73 @@ QString CppParser::getScopePrefix(const PStatement& statement){
|
||||||
QString CppParser::prettyPrintStatement(const PStatement& statement, const QString& filename, int line)
|
QString CppParser::prettyPrintStatement(const PStatement& statement, const QString& filename, int line)
|
||||||
{
|
{
|
||||||
QString result;
|
QString result;
|
||||||
if (!statement->hintText.isEmpty()) {
|
switch(statement->kind) {
|
||||||
if (statement->kind != StatementKind::skPreprocessor)
|
case StatementKind::skPreprocessor:
|
||||||
result = statement->hintText;
|
if (statement->command == "__FILE__")
|
||||||
else if (statement->command == "__FILE__")
|
result = '"'+filename+'"';
|
||||||
result = '"'+filename+'"';
|
else if (statement->command == "__LINE__")
|
||||||
else if (statement->command == "__LINE__")
|
result = QString("\"%1\"").arg(line);
|
||||||
result = QString("\"%1\"").arg(line);
|
else if (statement->command == "__DATE__")
|
||||||
else if (statement->command == "__DATE__")
|
result = QString("\"%1\"").arg(QDate::currentDate().toString(Qt::ISODate));
|
||||||
result = QString("\"%1\"").arg(QDate::currentDate().toString(Qt::ISODate));
|
else if (statement->command == "__TIME__")
|
||||||
else if (statement->command == "__TIME__")
|
result = QString("\"%1\"").arg(QTime::currentTime().toString(Qt::ISODate));
|
||||||
result = QString("\"%1\"").arg(QTime::currentTime().toString(Qt::ISODate));
|
else {
|
||||||
else
|
QString hintText = "#define";
|
||||||
result = statement->hintText;
|
if (statement->command != "")
|
||||||
} else {
|
hintText += ' ' + statement->command;
|
||||||
switch(statement->kind) {
|
if (statement->args != "")
|
||||||
case StatementKind::skFunction:
|
hintText += ' ' + statement->args;
|
||||||
case StatementKind::skVariable:
|
if (statement->value != "")
|
||||||
case StatementKind::skParameter:
|
hintText += ' ' + statement->value;
|
||||||
case StatementKind::skClass:
|
result = hintText;
|
||||||
if (statement->scope!= StatementScope::ssLocal)
|
|
||||||
result = getScopePrefix(statement)+ ' '; // public
|
|
||||||
result += statement->type + ' '; // void
|
|
||||||
result += statement->fullName; // A::B::C::Bar
|
|
||||||
result += statement->args; // (int a)
|
|
||||||
break;
|
|
||||||
case StatementKind::skNamespace:
|
|
||||||
result = statement->fullName; // Bar
|
|
||||||
break;
|
|
||||||
case StatementKind::skConstructor:
|
|
||||||
result = getScopePrefix(statement); // public
|
|
||||||
result += QObject::tr("constructor") + ' '; // constructor
|
|
||||||
result += statement->type + ' '; // void
|
|
||||||
result += statement->fullName; // A::B::C::Bar
|
|
||||||
result += statement->args; // (int a)
|
|
||||||
break;
|
|
||||||
case StatementKind::skDestructor:
|
|
||||||
result = getScopePrefix(statement); // public
|
|
||||||
result += QObject::tr("destructor") + ' '; // constructor
|
|
||||||
result += statement->type + ' '; // void
|
|
||||||
result += statement->fullName; // A::B::C::Bar
|
|
||||||
result += statement->args; // (int a)
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case StatementKind::skEnumClassType:
|
||||||
|
result = "enum class "+statement->command;
|
||||||
|
break;
|
||||||
|
case StatementKind::skEnumType:
|
||||||
|
result = "enum "+statement->command;
|
||||||
|
break;
|
||||||
|
case StatementKind::skEnum:
|
||||||
|
result = statement->type + "::" + statement->command;
|
||||||
|
break;
|
||||||
|
case StatementKind::skTypedef:
|
||||||
|
result = "typedef "+statement->type+" "+statement->command;
|
||||||
|
if (!statement->args.isEmpty())
|
||||||
|
result += " "+statement->args;
|
||||||
|
break;
|
||||||
|
case StatementKind::skAlias:
|
||||||
|
result = "using "+statement->type;
|
||||||
|
break;
|
||||||
|
case StatementKind::skFunction:
|
||||||
|
case StatementKind::skVariable:
|
||||||
|
case StatementKind::skParameter:
|
||||||
|
case StatementKind::skClass:
|
||||||
|
if (statement->scope!= StatementScope::ssLocal)
|
||||||
|
result = getScopePrefix(statement)+ ' '; // public
|
||||||
|
result += statement->type + ' '; // void
|
||||||
|
result += statement->fullName; // A::B::C::Bar
|
||||||
|
result += statement->args; // (int a)
|
||||||
|
break;
|
||||||
|
case StatementKind::skNamespace:
|
||||||
|
result = statement->fullName; // Bar
|
||||||
|
break;
|
||||||
|
case StatementKind::skConstructor:
|
||||||
|
result = getScopePrefix(statement); // public
|
||||||
|
result += QObject::tr("constructor") + ' '; // constructor
|
||||||
|
result += statement->type + ' '; // void
|
||||||
|
result += statement->fullName; // A::B::C::Bar
|
||||||
|
result += statement->args; // (int a)
|
||||||
|
break;
|
||||||
|
case StatementKind::skDestructor:
|
||||||
|
result = getScopePrefix(statement); // public
|
||||||
|
result += QObject::tr("destructor") + ' '; // constructor
|
||||||
|
result += statement->type + ' '; // void
|
||||||
|
result += statement->fullName; // A::B::C::Bar
|
||||||
|
result += statement->args; // (int a)
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -1081,7 +1072,6 @@ PStatement CppParser::addInheritedStatement(const PStatement& derived, const PSt
|
||||||
PStatement statement = addStatement(
|
PStatement statement = addStatement(
|
||||||
derived,
|
derived,
|
||||||
inherit->fileName,
|
inherit->fileName,
|
||||||
inherit->hintText,
|
|
||||||
inherit->type, // "Type" is already in use
|
inherit->type, // "Type" is already in use
|
||||||
inherit->command,
|
inherit->command,
|
||||||
inherit->args,
|
inherit->args,
|
||||||
|
@ -1098,7 +1088,7 @@ PStatement CppParser::addInheritedStatement(const PStatement& derived, const PSt
|
||||||
}
|
}
|
||||||
|
|
||||||
PStatement CppParser::addChildStatement(const PStatement& parent, const QString &fileName,
|
PStatement CppParser::addChildStatement(const PStatement& parent, const QString &fileName,
|
||||||
const QString &hintText, const QString &aType,
|
const QString &aType,
|
||||||
const QString &command, const QString &args,
|
const QString &command, const QString &args,
|
||||||
const QString &value, int line, StatementKind kind,
|
const QString &value, int line, StatementKind kind,
|
||||||
const StatementScope& scope, const StatementClassScope& classScope,
|
const StatementScope& scope, const StatementClassScope& classScope,
|
||||||
|
@ -1107,7 +1097,6 @@ PStatement CppParser::addChildStatement(const PStatement& parent, const QString
|
||||||
return addStatement(
|
return addStatement(
|
||||||
parent,
|
parent,
|
||||||
fileName,
|
fileName,
|
||||||
hintText,
|
|
||||||
aType,
|
aType,
|
||||||
command,
|
command,
|
||||||
args,
|
args,
|
||||||
|
@ -1122,7 +1111,6 @@ PStatement CppParser::addChildStatement(const PStatement& parent, const QString
|
||||||
|
|
||||||
PStatement CppParser::addStatement(const PStatement& parent,
|
PStatement CppParser::addStatement(const PStatement& parent,
|
||||||
const QString &fileName,
|
const QString &fileName,
|
||||||
const QString &hintText,
|
|
||||||
const QString &aType,
|
const QString &aType,
|
||||||
const QString &command,
|
const QString &command,
|
||||||
const QString &args,
|
const QString &args,
|
||||||
|
@ -1168,7 +1156,6 @@ PStatement CppParser::addStatement(const PStatement& parent,
|
||||||
}
|
}
|
||||||
PStatement result = std::make_shared<Statement>();
|
PStatement result = std::make_shared<Statement>();
|
||||||
result->parentScope = parent;
|
result->parentScope = parent;
|
||||||
result->hintText = hintText;
|
|
||||||
result->type = newType;
|
result->type = newType;
|
||||||
if (!newCommand.isEmpty())
|
if (!newCommand.isEmpty())
|
||||||
result->command = newCommand;
|
result->command = newCommand;
|
||||||
|
@ -1872,7 +1859,6 @@ void CppParser::handleCatchBlock()
|
||||||
PStatement block = addStatement(
|
PStatement block = addStatement(
|
||||||
getCurrentScope(),
|
getCurrentScope(),
|
||||||
mCurrentFile,
|
mCurrentFile,
|
||||||
"", // override hint
|
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
@ -1939,7 +1925,6 @@ void CppParser::handleEnum()
|
||||||
enumStatement=addStatement(
|
enumStatement=addStatement(
|
||||||
getCurrentScope(),
|
getCurrentScope(),
|
||||||
mCurrentFile,
|
mCurrentFile,
|
||||||
"enum class "+enumName,
|
|
||||||
"enum class",
|
"enum class",
|
||||||
enumName,
|
enumName,
|
||||||
"",
|
"",
|
||||||
|
@ -1954,7 +1939,6 @@ void CppParser::handleEnum()
|
||||||
enumStatement=addStatement(
|
enumStatement=addStatement(
|
||||||
getCurrentScope(),
|
getCurrentScope(),
|
||||||
mCurrentFile,
|
mCurrentFile,
|
||||||
"enum "+enumName,
|
|
||||||
"enum",
|
"enum",
|
||||||
enumName,
|
enumName,
|
||||||
"",
|
"",
|
||||||
|
@ -1996,7 +1980,6 @@ void CppParser::handleEnum()
|
||||||
addStatement(
|
addStatement(
|
||||||
enumStatement,
|
enumStatement,
|
||||||
mCurrentFile,
|
mCurrentFile,
|
||||||
lastType + "::" + mTokenizer[mIndex]->text, // override hint
|
|
||||||
lastType,
|
lastType,
|
||||||
cmd,
|
cmd,
|
||||||
args,
|
args,
|
||||||
|
@ -2013,7 +1996,6 @@ void CppParser::handleEnum()
|
||||||
addStatement(
|
addStatement(
|
||||||
enumStatement,
|
enumStatement,
|
||||||
mCurrentFile,
|
mCurrentFile,
|
||||||
lastType + "::" + mTokenizer[mIndex]->text, // override hint
|
|
||||||
lastType,
|
lastType,
|
||||||
cmd,
|
cmd,
|
||||||
args,
|
args,
|
||||||
|
@ -2028,7 +2010,6 @@ void CppParser::handleEnum()
|
||||||
addStatement(
|
addStatement(
|
||||||
getCurrentScope(),
|
getCurrentScope(),
|
||||||
mCurrentFile,
|
mCurrentFile,
|
||||||
lastType + "::" + mTokenizer[mIndex]->text, // override hint
|
|
||||||
lastType,
|
lastType,
|
||||||
cmd,
|
cmd,
|
||||||
args,
|
args,
|
||||||
|
@ -2080,7 +2061,6 @@ void CppParser::handleForBlock()
|
||||||
PStatement block = addStatement(
|
PStatement block = addStatement(
|
||||||
getCurrentScope(),
|
getCurrentScope(),
|
||||||
mCurrentFile,
|
mCurrentFile,
|
||||||
"", // override hint
|
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
@ -2212,7 +2192,6 @@ void CppParser::handleMethod(const QString &sType, const QString &sName, const Q
|
||||||
functionStatement=addStatement(
|
functionStatement=addStatement(
|
||||||
functionClass,
|
functionClass,
|
||||||
mCurrentFile,
|
mCurrentFile,
|
||||||
"", // do not override hint
|
|
||||||
sType,
|
sType,
|
||||||
scopelessName,
|
scopelessName,
|
||||||
sArgs,
|
sArgs,
|
||||||
|
@ -2232,7 +2211,6 @@ void CppParser::handleMethod(const QString &sType, const QString &sName, const Q
|
||||||
addStatement(
|
addStatement(
|
||||||
functionStatement,
|
functionStatement,
|
||||||
mCurrentFile,
|
mCurrentFile,
|
||||||
"", // do not override hint
|
|
||||||
functionClass->command,
|
functionClass->command,
|
||||||
"this",
|
"this",
|
||||||
"",
|
"",
|
||||||
|
@ -2248,7 +2226,6 @@ void CppParser::handleMethod(const QString &sType, const QString &sName, const Q
|
||||||
addStatement(
|
addStatement(
|
||||||
functionStatement,
|
functionStatement,
|
||||||
mCurrentFile,
|
mCurrentFile,
|
||||||
"", //dont override hint
|
|
||||||
"static const char ",
|
"static const char ",
|
||||||
"__func__",
|
"__func__",
|
||||||
"[]",
|
"[]",
|
||||||
|
@ -2263,7 +2240,6 @@ void CppParser::handleMethod(const QString &sType, const QString &sName, const Q
|
||||||
functionStatement = addStatement(
|
functionStatement = addStatement(
|
||||||
functionClass,
|
functionClass,
|
||||||
mCurrentFile,
|
mCurrentFile,
|
||||||
"", // do not override hint
|
|
||||||
sType,
|
sType,
|
||||||
scopelessName,
|
scopelessName,
|
||||||
sArgs,
|
sArgs,
|
||||||
|
@ -2334,7 +2310,6 @@ void CppParser::handleNamespace()
|
||||||
addStatement(
|
addStatement(
|
||||||
getCurrentScope(),
|
getCurrentScope(),
|
||||||
mCurrentFile,
|
mCurrentFile,
|
||||||
"", // do not override hint
|
|
||||||
aliasName, // name of the alias namespace
|
aliasName, // name of the alias namespace
|
||||||
command, // command
|
command, // command
|
||||||
"", // args
|
"", // args
|
||||||
|
@ -2364,7 +2339,6 @@ void CppParser::handleNamespace()
|
||||||
PStatement namespaceStatement = addStatement(
|
PStatement namespaceStatement = addStatement(
|
||||||
getCurrentScope(),
|
getCurrentScope(),
|
||||||
mCurrentFile,
|
mCurrentFile,
|
||||||
"", // do not override hint
|
|
||||||
"", // type
|
"", // type
|
||||||
command, // command
|
command, // command
|
||||||
"", // args
|
"", // args
|
||||||
|
@ -2412,7 +2386,6 @@ void CppParser::handleOtherTypedefs()
|
||||||
addStatement(
|
addStatement(
|
||||||
getCurrentScope(),
|
getCurrentScope(),
|
||||||
mCurrentFile,
|
mCurrentFile,
|
||||||
"typedef " + newType, // override hint
|
|
||||||
"",
|
"",
|
||||||
newType,
|
newType,
|
||||||
"",
|
"",
|
||||||
|
@ -2464,8 +2437,6 @@ void CppParser::handleOtherTypedefs()
|
||||||
addStatement(
|
addStatement(
|
||||||
getCurrentScope(),
|
getCurrentScope(),
|
||||||
mCurrentFile,
|
mCurrentFile,
|
||||||
"typedef " + oldType + " " + mTokenizer[mIndex]->text + " " +
|
|
||||||
mTokenizer[mIndex + 1]->text, // do not override hint
|
|
||||||
oldType,
|
oldType,
|
||||||
newType,
|
newType,
|
||||||
mTokenizer[mIndex + 1]->text,
|
mTokenizer[mIndex + 1]->text,
|
||||||
|
@ -2487,7 +2458,6 @@ void CppParser::handleOtherTypedefs()
|
||||||
addStatement(
|
addStatement(
|
||||||
getCurrentScope(),
|
getCurrentScope(),
|
||||||
mCurrentFile,
|
mCurrentFile,
|
||||||
"typedef " + oldType + " " + newType, // override hint
|
|
||||||
oldType,
|
oldType,
|
||||||
newType,
|
newType,
|
||||||
"",
|
"",
|
||||||
|
@ -2547,19 +2517,9 @@ void CppParser::handlePreprocessor()
|
||||||
QString name,args,value;
|
QString name,args,value;
|
||||||
mPreprocessor.getDefineParts(s,name,args,value);
|
mPreprocessor.getDefineParts(s,name,args,value);
|
||||||
|
|
||||||
// Generate custom hint
|
|
||||||
QString hintText = "#define";
|
|
||||||
if (!name.isEmpty())
|
|
||||||
hintText += ' ' + name;
|
|
||||||
if (!args.isEmpty())
|
|
||||||
hintText += ' ' + args;
|
|
||||||
if (!value.isEmpty())
|
|
||||||
hintText += ' ' + value;
|
|
||||||
|
|
||||||
addStatement(
|
addStatement(
|
||||||
nullptr, // defines don't belong to any scope
|
nullptr, // defines don't belong to any scope
|
||||||
mCurrentFile,
|
mCurrentFile,
|
||||||
hintText, // override hint
|
|
||||||
"", // define has no type
|
"", // define has no type
|
||||||
name,
|
name,
|
||||||
args,
|
args,
|
||||||
|
@ -2621,7 +2581,6 @@ bool CppParser::handleStatement()
|
||||||
PStatement block = addStatement(
|
PStatement block = addStatement(
|
||||||
getCurrentScope(),
|
getCurrentScope(),
|
||||||
mCurrentFile,
|
mCurrentFile,
|
||||||
"", // override hint
|
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
@ -2722,7 +2681,6 @@ void CppParser::handleStructs(bool isTypedef)
|
||||||
addStatement(
|
addStatement(
|
||||||
getCurrentScope(),
|
getCurrentScope(),
|
||||||
mCurrentFile,
|
mCurrentFile,
|
||||||
"typedef " + prefix + " " + oldType + ' ' + newType, // override hint
|
|
||||||
oldType,
|
oldType,
|
||||||
newType,
|
newType,
|
||||||
"",
|
"",
|
||||||
|
@ -2769,7 +2727,6 @@ void CppParser::handleStructs(bool isTypedef)
|
||||||
firstSynonym = addStatement(
|
firstSynonym = addStatement(
|
||||||
getCurrentScope(),
|
getCurrentScope(),
|
||||||
mCurrentFile,
|
mCurrentFile,
|
||||||
"", // do not override hint
|
|
||||||
prefix, // type
|
prefix, // type
|
||||||
command, // command
|
command, // command
|
||||||
"", // args
|
"", // args
|
||||||
|
@ -2792,7 +2749,6 @@ void CppParser::handleStructs(bool isTypedef)
|
||||||
firstSynonym = addStatement(
|
firstSynonym = addStatement(
|
||||||
getCurrentScope(),
|
getCurrentScope(),
|
||||||
mCurrentFile,
|
mCurrentFile,
|
||||||
"", // do not override hint
|
|
||||||
prefix, // type
|
prefix, // type
|
||||||
command, // command
|
command, // command
|
||||||
"", // args
|
"", // args
|
||||||
|
@ -2875,7 +2831,6 @@ void CppParser::handleStructs(bool isTypedef)
|
||||||
firstSynonym = addStatement(
|
firstSynonym = addStatement(
|
||||||
getCurrentScope(),
|
getCurrentScope(),
|
||||||
mCurrentFile,
|
mCurrentFile,
|
||||||
"", // do not override hint
|
|
||||||
prefix,
|
prefix,
|
||||||
"__"+command,
|
"__"+command,
|
||||||
"",
|
"",
|
||||||
|
@ -2892,7 +2847,6 @@ void CppParser::handleStructs(bool isTypedef)
|
||||||
addStatement(
|
addStatement(
|
||||||
getCurrentScope(),
|
getCurrentScope(),
|
||||||
mCurrentFile,
|
mCurrentFile,
|
||||||
"typedef " + firstSynonym->command + ' ' + command, // override hint
|
|
||||||
firstSynonym->command,
|
firstSynonym->command,
|
||||||
command,
|
command,
|
||||||
"",
|
"",
|
||||||
|
@ -2908,7 +2862,6 @@ void CppParser::handleStructs(bool isTypedef)
|
||||||
addStatement(
|
addStatement(
|
||||||
getCurrentScope(),
|
getCurrentScope(),
|
||||||
mCurrentFile,
|
mCurrentFile,
|
||||||
"", // do not override hint
|
|
||||||
firstSynonym->command,
|
firstSynonym->command,
|
||||||
command,
|
command,
|
||||||
args,
|
args,
|
||||||
|
@ -2939,7 +2892,6 @@ void CppParser::handleStructs(bool isTypedef)
|
||||||
firstSynonym=addStatement(
|
firstSynonym=addStatement(
|
||||||
getCurrentScope(),
|
getCurrentScope(),
|
||||||
mCurrentFile,
|
mCurrentFile,
|
||||||
"", // override hint
|
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
@ -2986,7 +2938,6 @@ void CppParser::handleUsing()
|
||||||
addStatement(
|
addStatement(
|
||||||
getCurrentScope(),
|
getCurrentScope(),
|
||||||
mCurrentFile,
|
mCurrentFile,
|
||||||
"using "+fullName+" = " + aliasName, //hint text
|
|
||||||
aliasName, // name of the alias (type)
|
aliasName, // name of the alias (type)
|
||||||
fullName, // command
|
fullName, // command
|
||||||
"", // args
|
"", // args
|
||||||
|
@ -3011,7 +2962,6 @@ void CppParser::handleUsing()
|
||||||
addStatement(
|
addStatement(
|
||||||
getCurrentScope(),
|
getCurrentScope(),
|
||||||
mCurrentFile,
|
mCurrentFile,
|
||||||
"using "+fullName, //hint text
|
|
||||||
fullName, // name of the alias (type)
|
fullName, // name of the alias (type)
|
||||||
usingName, // command
|
usingName, // command
|
||||||
"", // args
|
"", // args
|
||||||
|
@ -3177,7 +3127,6 @@ void CppParser::handleVar()
|
||||||
addChildStatement(
|
addChildStatement(
|
||||||
getCurrentScope(),
|
getCurrentScope(),
|
||||||
mCurrentFile,
|
mCurrentFile,
|
||||||
"", // do not override hint
|
|
||||||
lastType,
|
lastType,
|
||||||
cmd,
|
cmd,
|
||||||
args,
|
args,
|
||||||
|
@ -3431,16 +3380,6 @@ PStatement CppParser::findStatementInScope(const QString &name, const QString &n
|
||||||
return PStatement();
|
return PStatement();
|
||||||
}
|
}
|
||||||
|
|
||||||
PStatement CppParser::findStatementInScope(const QString &name, const PStatement& scope)
|
|
||||||
{
|
|
||||||
if (!scope)
|
|
||||||
return findMemberOfStatement(name,scope);
|
|
||||||
if (scope->kind == StatementKind::skNamespace) {
|
|
||||||
return findStatementInNamespace(name, scope->fullName);
|
|
||||||
} else {
|
|
||||||
return findMemberOfStatement(name,scope);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PStatement CppParser::findStatementInNamespace(const QString &name, const QString &namespaceName)
|
PStatement CppParser::findStatementInNamespace(const QString &name, const QString &namespaceName)
|
||||||
{
|
{
|
||||||
|
@ -4130,42 +4069,6 @@ void CppParser::doSkipInExpression(const QStringList &expression, int &pos, cons
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CppParser::isIdentifier(const QString &token) const
|
|
||||||
{
|
|
||||||
return (!token.isEmpty() && isLetterChar(token.front())
|
|
||||||
&& !token.contains('\"'));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CppParser::isIntegerLiteral(const QString &token) const
|
|
||||||
{
|
|
||||||
if (token.isEmpty())
|
|
||||||
return false;
|
|
||||||
QChar ch = token.front();
|
|
||||||
return (ch>='0' && ch<='9' && !token.contains(".") && !token.contains("e"));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CppParser::isFloatLiteral(const QString &token) const
|
|
||||||
{
|
|
||||||
if (token.isEmpty())
|
|
||||||
return false;
|
|
||||||
QChar ch = token.front();
|
|
||||||
return (ch>='0' && ch<='9' && (token.contains(".") || token.contains("e")));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CppParser::isStringLiteral(const QString &token) const
|
|
||||||
{
|
|
||||||
if (token.isEmpty())
|
|
||||||
return false;
|
|
||||||
return (!token.startsWith('\'') && token.contains('"'));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CppParser::isCharLiteral(const QString &token) const
|
|
||||||
{
|
|
||||||
if (token.isEmpty())
|
|
||||||
return false;
|
|
||||||
return (token.startsWith('\''));
|
|
||||||
}
|
|
||||||
|
|
||||||
PStatement CppParser::doParseEvalTypeInfo(
|
PStatement CppParser::doParseEvalTypeInfo(
|
||||||
const QString &fileName,
|
const QString &fileName,
|
||||||
const PStatement &scope,
|
const PStatement &scope,
|
||||||
|
@ -4409,7 +4312,6 @@ void CppParser::scanMethodArgs(const PStatement& functionStatement, const QStrin
|
||||||
addStatement(
|
addStatement(
|
||||||
functionStatement,
|
functionStatement,
|
||||||
mCurrentFile,
|
mCurrentFile,
|
||||||
"", // do not override hint
|
|
||||||
s.mid(0,varStartPos), // 'int*'
|
s.mid(0,varStartPos), // 'int*'
|
||||||
s.mid(varStartPos,varEndPos-varStartPos+1), // a
|
s.mid(varStartPos,varEndPos-varStartPos+1), // a
|
||||||
args,
|
args,
|
||||||
|
@ -4577,91 +4479,6 @@ QString CppParser::removeArgNames(const QString &args)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CppParser::isSpaceChar(const QChar &ch) const
|
|
||||||
{
|
|
||||||
return ch==' ' || ch =='\t';
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CppParser::isWordChar(const QChar &ch) const
|
|
||||||
{
|
|
||||||
// return (ch>= 'A' && ch<='Z')
|
|
||||||
// || (ch>='a' && ch<='z')
|
|
||||||
return ch.isLetter()
|
|
||||||
|| ch == '_'
|
|
||||||
|| ch == '*'
|
|
||||||
|| ch == '&';
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CppParser::isLetterChar(const QChar &ch) const
|
|
||||||
{
|
|
||||||
// return (ch>= 'A' && ch<='Z')
|
|
||||||
// || (ch>='a' && ch<='z')
|
|
||||||
return ch.isLetter()
|
|
||||||
|| ch == '_';
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CppParser::isDigitChar(const QChar &ch) const
|
|
||||||
{
|
|
||||||
return (ch>='0' && ch<='9');
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CppParser::isSeperator(const QChar &ch) const {
|
|
||||||
switch(ch.unicode()){
|
|
||||||
case '(':
|
|
||||||
case ';':
|
|
||||||
case ':':
|
|
||||||
case '{':
|
|
||||||
case '}':
|
|
||||||
case '#':
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CppParser::isblockChar(const QChar &ch) const
|
|
||||||
{
|
|
||||||
switch(ch.unicode()){
|
|
||||||
case ';':
|
|
||||||
case '{':
|
|
||||||
case '}':
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CppParser::isInvalidVarPrefixChar(const QChar &ch) const
|
|
||||||
{
|
|
||||||
switch (ch.unicode()) {
|
|
||||||
case '#':
|
|
||||||
case ',':
|
|
||||||
case ';':
|
|
||||||
case ':':
|
|
||||||
case '{':
|
|
||||||
case '}':
|
|
||||||
case '!':
|
|
||||||
case '/':
|
|
||||||
case '+':
|
|
||||||
case '-':
|
|
||||||
case '<':
|
|
||||||
case '>':
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CppParser::isBraceChar(const QChar &ch) const
|
|
||||||
{
|
|
||||||
return ch == '{' || ch =='}';
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CppParser::isLineChar(const QChar &ch) const
|
|
||||||
{
|
|
||||||
return ch=='\n' || ch=='\r';
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CppParser::isNotFuncArgs(const QString &args)
|
bool CppParser::isNotFuncArgs(const QString &args)
|
||||||
{
|
{
|
||||||
int i=1; //skip '('
|
int i=1; //skip '('
|
||||||
|
|
|
@ -44,8 +44,25 @@ public:
|
||||||
QList<PStatement> getListOfFunctions(const QString& fileName,
|
QList<PStatement> getListOfFunctions(const QString& fileName,
|
||||||
const QString& phrase,
|
const QString& phrase,
|
||||||
int line);
|
int line);
|
||||||
PStatement findAndScanBlockAt(const QString& filename, int line);
|
PStatement findAndScanBlockAt(const QString& filename, int line) {
|
||||||
PFileIncludes findFileIncludes(const QString &filename, bool deleteIt = false);
|
QMutexLocker locker(&mMutex);
|
||||||
|
if (mParsing) {
|
||||||
|
return PStatement();
|
||||||
|
}
|
||||||
|
PFileIncludes fileIncludes = mPreprocessor.includesList().value(filename);
|
||||||
|
if (!fileIncludes)
|
||||||
|
return PStatement();
|
||||||
|
|
||||||
|
PStatement statement = fileIncludes->scopes.findScopeAtLine(line);
|
||||||
|
return statement;
|
||||||
|
}
|
||||||
|
PFileIncludes findFileIncludes(const QString &filename, bool deleteIt = false) {
|
||||||
|
QMutexLocker locker(&mMutex);
|
||||||
|
PFileIncludes fileIncludes = mPreprocessor.includesList().value(filename,PFileIncludes());
|
||||||
|
if (deleteIt && fileIncludes)
|
||||||
|
mPreprocessor.includesList().remove(filename);
|
||||||
|
return fileIncludes;
|
||||||
|
}
|
||||||
QString findFirstTemplateParamOf(const QString& fileName,
|
QString findFirstTemplateParamOf(const QString& fileName,
|
||||||
const QString& phrase,
|
const QString& phrase,
|
||||||
const PStatement& currentScope);
|
const PStatement& currentScope);
|
||||||
|
@ -152,7 +169,6 @@ private:
|
||||||
// support for multiple parents (only typedef struct/union use multiple parents)
|
// support for multiple parents (only typedef struct/union use multiple parents)
|
||||||
const PStatement& parent,
|
const PStatement& parent,
|
||||||
const QString& fileName,
|
const QString& fileName,
|
||||||
const QString& hintText,
|
|
||||||
const QString& aType, // "Type" is already in use
|
const QString& aType, // "Type" is already in use
|
||||||
const QString& command,
|
const QString& command,
|
||||||
const QString& args,
|
const QString& args,
|
||||||
|
@ -166,7 +182,6 @@ private:
|
||||||
PStatement addStatement(
|
PStatement addStatement(
|
||||||
const PStatement& parent,
|
const PStatement& parent,
|
||||||
const QString &fileName,
|
const QString &fileName,
|
||||||
const QString &hintText,
|
|
||||||
const QString &aType, // "Type" is already in use
|
const QString &aType, // "Type" is already in use
|
||||||
const QString &command,
|
const QString &command,
|
||||||
const QString &args,
|
const QString &args,
|
||||||
|
@ -222,7 +237,15 @@ private:
|
||||||
const PStatement& scope);
|
const PStatement& scope);
|
||||||
PStatement findStatementInScope(
|
PStatement findStatementInScope(
|
||||||
const QString& name,
|
const QString& name,
|
||||||
const PStatement& scope);
|
const PStatement& scope) {
|
||||||
|
if (!scope)
|
||||||
|
return findMemberOfStatement(name,scope);
|
||||||
|
if (scope->kind == StatementKind::skNamespace) {
|
||||||
|
return findStatementInNamespace(name, scope->fullName);
|
||||||
|
} else {
|
||||||
|
return findMemberOfStatement(name,scope);
|
||||||
|
}
|
||||||
|
}
|
||||||
PStatement findStatementInNamespace(
|
PStatement findStatementInNamespace(
|
||||||
const QString& name,
|
const QString& name,
|
||||||
const QString& namespaceName);
|
const QString& namespaceName);
|
||||||
|
@ -302,11 +325,35 @@ private:
|
||||||
PEvalStatement doCreateEvalFunction(const QString& fileName, PStatement funcStatement);
|
PEvalStatement doCreateEvalFunction(const QString& fileName, PStatement funcStatement);
|
||||||
PEvalStatement doCreateEvalLiteral(const QString& type);
|
PEvalStatement doCreateEvalLiteral(const QString& type);
|
||||||
void doSkipInExpression(const QStringList& expression, int&pos, const QString& startSymbol, const QString& endSymbol);
|
void doSkipInExpression(const QStringList& expression, int&pos, const QString& startSymbol, const QString& endSymbol);
|
||||||
bool isIdentifier(const QString& token) const;
|
|
||||||
bool isIntegerLiteral(const QString& token) const;
|
bool isIdentifier(const QString& token) const {
|
||||||
bool isFloatLiteral(const QString& token) const;
|
return (!token.isEmpty() && isLetterChar(token.front())
|
||||||
bool isStringLiteral(const QString& token) const;
|
&& !token.contains('\"'));
|
||||||
bool isCharLiteral(const QString& token) const;
|
}
|
||||||
|
|
||||||
|
bool isIntegerLiteral(const QString& token) const {
|
||||||
|
if (token.isEmpty())
|
||||||
|
return false;
|
||||||
|
QChar ch = token.front();
|
||||||
|
return (ch>='0' && ch<='9' && !token.contains(".") && !token.contains("e"));
|
||||||
|
}
|
||||||
|
bool isFloatLiteral(const QString& token) const {
|
||||||
|
if (token.isEmpty())
|
||||||
|
return false;
|
||||||
|
QChar ch = token.front();
|
||||||
|
return (ch>='0' && ch<='9' && (token.contains(".") || token.contains("e")));
|
||||||
|
}
|
||||||
|
bool isStringLiteral(const QString& token) const {
|
||||||
|
if (token.isEmpty())
|
||||||
|
return false;
|
||||||
|
return (!token.startsWith('\'') && token.contains('"'));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isCharLiteral(const QString& token) const{
|
||||||
|
if (token.isEmpty())
|
||||||
|
return false;
|
||||||
|
return (token.startsWith('\''));
|
||||||
|
}
|
||||||
PStatement doParseEvalTypeInfo(
|
PStatement doParseEvalTypeInfo(
|
||||||
const QString& fileName,
|
const QString& fileName,
|
||||||
const PStatement& scope,
|
const PStatement& scope,
|
||||||
|
@ -388,27 +435,82 @@ private:
|
||||||
|
|
||||||
QString removeArgNames(const QString& args);
|
QString removeArgNames(const QString& args);
|
||||||
|
|
||||||
bool isSpaceChar(const QChar& ch) const;
|
bool isSpaceChar(const QChar& ch) const {
|
||||||
|
return ch==' ' || ch =='\t';
|
||||||
|
}
|
||||||
|
|
||||||
bool isWordChar(const QChar& ch) const;
|
bool isWordChar(const QChar& ch) const {
|
||||||
|
return ch.isLetter()
|
||||||
|
|| ch == '_'
|
||||||
|
|| ch == '*'
|
||||||
|
|| ch == '&';
|
||||||
|
}
|
||||||
|
|
||||||
bool isLetterChar(const QChar& ch) const;
|
bool isLetterChar(const QChar& ch) const {
|
||||||
|
return ch.isLetter()
|
||||||
|
|| ch == '_';
|
||||||
|
}
|
||||||
|
|
||||||
bool isDigitChar(const QChar& ch) const;
|
bool isDigitChar(const QChar& ch) const {
|
||||||
|
return (ch>='0' && ch<='9');
|
||||||
|
}
|
||||||
|
|
||||||
/*'(', ';', ':', '{', '}', '#' */
|
/*'(', ';', ':', '{', '}', '#' */
|
||||||
bool isSeperator(const QChar& ch) const;
|
bool isSeperator(const QChar& ch) const {
|
||||||
|
switch(ch.unicode()){
|
||||||
|
case '(':
|
||||||
|
case ';':
|
||||||
|
case ':':
|
||||||
|
case '{':
|
||||||
|
case '}':
|
||||||
|
case '#':
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*';', '{', '}'*/
|
/*';', '{', '}'*/
|
||||||
bool isblockChar(const QChar& ch) const;
|
bool isblockChar(const QChar& ch) const {
|
||||||
|
switch(ch.unicode()){
|
||||||
|
case ';':
|
||||||
|
case '{':
|
||||||
|
case '}':
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* '#', ',', ';', ':', '{', '}', '!', '/', '+', '-', '<', '>' */
|
/* '#', ',', ';', ':', '{', '}', '!', '/', '+', '-', '<', '>' */
|
||||||
bool isInvalidVarPrefixChar(const QChar& ch) const;
|
bool isInvalidVarPrefixChar(const QChar& ch) const {
|
||||||
|
switch (ch.unicode()) {
|
||||||
|
case '#':
|
||||||
|
case ',':
|
||||||
|
case ';':
|
||||||
|
case ':':
|
||||||
|
case '{':
|
||||||
|
case '}':
|
||||||
|
case '!':
|
||||||
|
case '/':
|
||||||
|
case '+':
|
||||||
|
case '-':
|
||||||
|
case '<':
|
||||||
|
case '>':
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*'{', '}' */
|
/*'{', '}' */
|
||||||
bool isBraceChar(const QChar& ch) const;
|
bool isBraceChar(const QChar& ch) const {
|
||||||
|
return ch == '{' || ch =='}';
|
||||||
|
}
|
||||||
|
|
||||||
bool isLineChar(const QChar& ch) const;
|
bool isLineChar(const QChar& ch) const {
|
||||||
|
return ch=='\n' || ch=='\r';
|
||||||
|
}
|
||||||
|
|
||||||
bool isNotFuncArgs(const QString& args);
|
bool isNotFuncArgs(const QString& args);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue