minor refactor
This commit is contained in:
parent
de23833992
commit
3a1bc97ca5
|
@ -173,8 +173,7 @@ PStatement CppParser::findScopeStatement(const QString &filename, int line)
|
||||||
if (!fileIncludes)
|
if (!fileIncludes)
|
||||||
return PStatement();
|
return PStatement();
|
||||||
|
|
||||||
PStatement statement = fileIncludes->scopes.findScopeAtLine(line);
|
return fileIncludes->scopes.findScopeAtLine(line);
|
||||||
return statement;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PFileIncludes CppParser::findFileIncludes(const QString &filename, bool deleteIt)
|
PFileIncludes CppParser::findFileIncludes(const QString &filename, bool deleteIt)
|
||||||
|
@ -3531,54 +3530,6 @@ void CppParser::handleVar(const QString& typePrefix,bool isExtern,bool isStatic)
|
||||||
|
|
||||||
PStatement addedVar;
|
PStatement addedVar;
|
||||||
|
|
||||||
//we only check the first token to reduce calculations
|
|
||||||
// if (mIndex>=mTokenizer.tokenCount()
|
|
||||||
// || mTokenizer[mIndex]->text.endsWith('.')
|
|
||||||
// || mTokenizer[mIndex]->text.endsWith("->")) {
|
|
||||||
// //failed to handle
|
|
||||||
// skipNextSemicolon(mIndex);
|
|
||||||
// return ;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// while (mIndex+1<mTokenizer.tokenCount()) {
|
|
||||||
// if (mTokenizer[mIndex]->text=='(') {
|
|
||||||
// if ( mTokenizer[mIndex]->matchIndex<=mTokenizer.tokenCount()
|
|
||||||
// && mTokenizer[mTokenizer[mIndex]->matchIndex]->text=='(') {
|
|
||||||
// //function pointer
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// //error break;
|
|
||||||
// mIndex=indexBackup;
|
|
||||||
// return false;
|
|
||||||
// } else if (mTokenizer[mIndex + 1]->text=='('
|
|
||||||
// || mTokenizer[mIndex + 1]->text==','
|
|
||||||
// || mTokenizer[mIndex + 1]->text==';'
|
|
||||||
// || mTokenizer[mIndex + 1]->text.front()==':'
|
|
||||||
// || mTokenizer[mIndex + 1]->text=='}'
|
|
||||||
// || mTokenizer[mIndex + 1]->text.front()=='#'
|
|
||||||
// || mTokenizer[mIndex + 1]->text=='{') {
|
|
||||||
// //end of type info
|
|
||||||
// break;
|
|
||||||
// } else if (mTokenizer[mIndex]->text!="struct"
|
|
||||||
// && mTokenizer[mIndex]->text!="class"
|
|
||||||
// && mTokenizer[mIndex]->text!="union") {
|
|
||||||
// QString s=mTokenizer[mIndex]->text;
|
|
||||||
// if (s == "extern") {
|
|
||||||
// isExtern = true;
|
|
||||||
// } else if (s == "static") {
|
|
||||||
// isStatic = true;
|
|
||||||
// } else
|
|
||||||
// lastType += ' '+s;
|
|
||||||
// }
|
|
||||||
// mIndex++;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (mIndex+1 >= mTokenizer.tokenCount() || lastType.isEmpty()
|
|
||||||
// || lastType.endsWith(':')) {
|
|
||||||
// mIndex=indexBackup;
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
|
|
||||||
QString tempType;
|
QString tempType;
|
||||||
while(mIndex<mTokenizer.tokenCount()) {
|
while(mIndex<mTokenizer.tokenCount()) {
|
||||||
// Skip bit identifiers,
|
// Skip bit identifiers,
|
||||||
|
@ -3588,6 +3539,7 @@ void CppParser::handleVar(const QString& typePrefix,bool isExtern,bool isStatic)
|
||||||
// as
|
// as
|
||||||
// unsigned short bAppReturnCode,reserved,fBusy,fAck
|
// unsigned short bAppReturnCode,reserved,fBusy,fAck
|
||||||
if (mTokenizer[mIndex]->text.front() == ':') {
|
if (mTokenizer[mIndex]->text.front() == ':') {
|
||||||
|
//handle e.g.: for(auto x:vec)
|
||||||
if (mIndex+1<mTokenizer.tokenCount()
|
if (mIndex+1<mTokenizer.tokenCount()
|
||||||
&& isIdentifier(mTokenizer[mIndex+1]->text)
|
&& isIdentifier(mTokenizer[mIndex+1]->text)
|
||||||
&& isIdentChar(mTokenizer[mIndex+1]->text.back())
|
&& isIdentChar(mTokenizer[mIndex+1]->text.back())
|
||||||
|
@ -3612,13 +3564,26 @@ void CppParser::handleVar(const QString& typePrefix,bool isExtern,bool isStatic)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addedVar.reset();
|
addedVar.reset();
|
||||||
while ( (mIndex < mTokenizer.tokenCount())
|
bool should_exit=false;
|
||||||
&& !(
|
while (mIndex < mTokenizer.tokenCount()) {
|
||||||
mTokenizer[mIndex]->text==','
|
switch(mTokenizer[mIndex]->text[0].unicode()) {
|
||||||
|| mTokenizer[mIndex]->text==';'
|
case ',':
|
||||||
|| mTokenizer[mIndex]->text=='='
|
case ';':
|
||||||
))
|
case '=':
|
||||||
mIndex++;
|
should_exit = true;
|
||||||
|
break;
|
||||||
|
case ')':
|
||||||
|
mIndex++;
|
||||||
|
return;
|
||||||
|
case '(':
|
||||||
|
mIndex=mTokenizer[mIndex]->matchIndex+1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
mIndex++;
|
||||||
|
}
|
||||||
|
if (should_exit)
|
||||||
|
break;
|
||||||
|
}
|
||||||
} else if (mTokenizer[mIndex]->text==';') {
|
} else if (mTokenizer[mIndex]->text==';') {
|
||||||
break;
|
break;
|
||||||
} else if (isWordChar(mTokenizer[mIndex]->text[0])) {
|
} else if (isWordChar(mTokenizer[mIndex]->text[0])) {
|
||||||
|
|
|
@ -179,7 +179,7 @@ PStatement CodeCompletionPopup::selectedStatement()
|
||||||
return PStatement();
|
return PStatement();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CodeCompletionPopup::addChildren(PStatement scopeStatement, const QString &fileName, int line)
|
void CodeCompletionPopup::addChildren(const PStatement& scopeStatement, const QString &fileName, int line)
|
||||||
{
|
{
|
||||||
if (scopeStatement && !isIncluded(scopeStatement->fileName)
|
if (scopeStatement && !isIncluded(scopeStatement->fileName)
|
||||||
&& !isIncluded(scopeStatement->definitionFileName))
|
&& !isIncluded(scopeStatement->definitionFileName))
|
||||||
|
@ -208,7 +208,7 @@ void CodeCompletionPopup::addChildren(PStatement scopeStatement, const QString &
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CodeCompletionPopup::addFunctionWithoutDefinitionChildren(PStatement scopeStatement, const QString &fileName, int line)
|
void CodeCompletionPopup::addFunctionWithoutDefinitionChildren(const PStatement& scopeStatement, const QString &fileName, int line)
|
||||||
{
|
{
|
||||||
if (scopeStatement && !isIncluded(scopeStatement->fileName)
|
if (scopeStatement && !isIncluded(scopeStatement->fileName)
|
||||||
&& !isIncluded(scopeStatement->definitionFileName))
|
&& !isIncluded(scopeStatement->definitionFileName))
|
||||||
|
@ -242,7 +242,7 @@ void CodeCompletionPopup::addFunctionWithoutDefinitionChildren(PStatement scopeS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CodeCompletionPopup::addStatement(PStatement statement, const QString &fileName, int line)
|
void CodeCompletionPopup::addStatement(const PStatement& statement, const QString &fileName, int line)
|
||||||
{
|
{
|
||||||
if (mAddedStatements.contains(statement->command))
|
if (mAddedStatements.contains(statement->command))
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -127,11 +127,11 @@ public:
|
||||||
const QList<PCodeSnippet> &codeSnippets() const;
|
const QList<PCodeSnippet> &codeSnippets() const;
|
||||||
void setCodeSnippets(const QList<PCodeSnippet> &newCodeSnippets);
|
void setCodeSnippets(const QList<PCodeSnippet> &newCodeSnippets);
|
||||||
private:
|
private:
|
||||||
void addChildren(PStatement scopeStatement, const QString& fileName,
|
void addChildren(const PStatement& scopeStatement, const QString& fileName,
|
||||||
int line);
|
int line);
|
||||||
void addFunctionWithoutDefinitionChildren(PStatement scopeStatement, const QString& fileName,
|
void addFunctionWithoutDefinitionChildren(const PStatement& scopeStatement, const QString& fileName,
|
||||||
int line);
|
int line);
|
||||||
void addStatement(PStatement statement, const QString& fileName, int line);
|
void addStatement(const PStatement& statement, const QString& fileName, int line);
|
||||||
void filterList(const QString& member);
|
void filterList(const QString& member);
|
||||||
void getCompletionFor(
|
void getCompletionFor(
|
||||||
const QStringList& ownerExpression,
|
const QStringList& ownerExpression,
|
||||||
|
|
Loading…
Reference in New Issue