This commit is contained in:
parent
730bed9587
commit
0405a51206
1
NEWS.md
1
NEWS.md
|
@ -82,6 +82,7 @@ Red Panda C++ Version 2.27
|
||||||
- fix: Caret on '('/',' in string/comment shouldn't invoke function info tips.
|
- fix: Caret on '('/',' in string/comment shouldn't invoke function info tips.
|
||||||
- fix: Function name not correctly found if it and the '(' is not in one line;
|
- fix: Function name not correctly found if it and the '(' is not in one line;
|
||||||
- fix: Register names in the cpu info are not in correct order.
|
- fix: Register names in the cpu info are not in correct order.
|
||||||
|
- enhancement: Auto type induction for new / temp class object.
|
||||||
|
|
||||||
Red Panda C++ Version 2.26
|
Red Panda C++ Version 2.26
|
||||||
- enhancement: Code suggestion for embedded std::vectors.
|
- enhancement: Code suggestion for embedded std::vectors.
|
||||||
|
|
|
@ -4007,7 +4007,7 @@ void CppParser::handleVar(const QString& typePrefix,bool isExtern,bool isStatic,
|
||||||
int endIndex = indexOfNextSemicolon(mIndex+1, maxIndex);
|
int endIndex = indexOfNextSemicolon(mIndex+1, maxIndex);
|
||||||
QString expressionText;
|
QString expressionText;
|
||||||
for (int i=mIndex+1;i<endIndex;i++) {
|
for (int i=mIndex+1;i<endIndex;i++) {
|
||||||
expressionText+=mTokenizer[i]->text;
|
expressionText+=mTokenizer[i]->text+" ";
|
||||||
}
|
}
|
||||||
QStringList phraseExpression = splitExpression(expressionText);
|
QStringList phraseExpression = splitExpression(expressionText);
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
@ -4068,6 +4068,7 @@ void CppParser::handleVar(const QString& typePrefix,bool isExtern,bool isStatic,
|
||||||
QString expressionText;
|
QString expressionText;
|
||||||
for (int i=mIndex+1;i<endIndex;i++) {
|
for (int i=mIndex+1;i<endIndex;i++) {
|
||||||
expressionText.append(mTokenizer[i]->text);
|
expressionText.append(mTokenizer[i]->text);
|
||||||
|
expressionText.append(" ");
|
||||||
}
|
}
|
||||||
QStringList phraseExpression = splitExpression(expressionText);
|
QStringList phraseExpression = splitExpression(expressionText);
|
||||||
PEvalStatement aliasStatement = doEvalExpression(mCurrentFile,
|
PEvalStatement aliasStatement = doEvalExpression(mCurrentFile,
|
||||||
|
@ -4077,6 +4078,7 @@ void CppParser::handleVar(const QString& typePrefix,bool isExtern,bool isStatic,
|
||||||
PEvalStatement(),
|
PEvalStatement(),
|
||||||
true,false);
|
true,false);
|
||||||
if(aliasStatement) {
|
if(aliasStatement) {
|
||||||
|
qDebug()<<phraseExpression<<aliasStatement->pointerLevel;
|
||||||
if (aliasStatement->effectiveTypeStatement) {
|
if (aliasStatement->effectiveTypeStatement) {
|
||||||
addedVar->type = aliasStatement->effectiveTypeStatement->fullName;
|
addedVar->type = aliasStatement->effectiveTypeStatement->fullName;
|
||||||
if (!addedVar->type.endsWith(">"))
|
if (!addedVar->type.endsWith(">"))
|
||||||
|
@ -4158,6 +4160,7 @@ void CppParser::handleVar(const QString& typePrefix,bool isExtern,bool isStatic,
|
||||||
QString expressionText;
|
QString expressionText;
|
||||||
for (int i=mIndex+1;i<endIndex;i++) {
|
for (int i=mIndex+1;i<endIndex;i++) {
|
||||||
expressionText.append(mTokenizer[i]->text);
|
expressionText.append(mTokenizer[i]->text);
|
||||||
|
expressionText.append(" ");
|
||||||
}
|
}
|
||||||
QStringList phraseExpression = splitExpression(expressionText);
|
QStringList phraseExpression = splitExpression(expressionText);
|
||||||
PEvalStatement aliasStatement = doEvalExpression(mCurrentFile,
|
PEvalStatement aliasStatement = doEvalExpression(mCurrentFile,
|
||||||
|
@ -4894,19 +4897,8 @@ PEvalStatement CppParser::doEvalMemberAccess(const QString &fileName,
|
||||||
pos++; //just skip it
|
pos++; //just skip it
|
||||||
} else if (phraseExpression[pos] == "(") {
|
} else if (phraseExpression[pos] == "(") {
|
||||||
if (result->kind == EvalStatementKind::Type) {
|
if (result->kind == EvalStatementKind::Type) {
|
||||||
pos++; // skip "("
|
doSkipInExpression(phraseExpression,pos,"(",")");
|
||||||
PEvalStatement newResult = doEvalExpression(
|
result->kind = EvalStatementKind::Variable;
|
||||||
fileName,
|
|
||||||
phraseExpression,
|
|
||||||
pos,
|
|
||||||
scope,
|
|
||||||
PEvalStatement(),
|
|
||||||
true,
|
|
||||||
false);
|
|
||||||
if (newResult)
|
|
||||||
newResult->assignType(result);
|
|
||||||
pos++; // skip ")"
|
|
||||||
result = newResult;
|
|
||||||
} else if (result->kind == EvalStatementKind::Function) {
|
} else if (result->kind == EvalStatementKind::Function) {
|
||||||
doSkipInExpression(phraseExpression,pos,"(",")");
|
doSkipInExpression(phraseExpression,pos,"(",")");
|
||||||
// qDebug()<<"????"<<(result->baseStatement!=nullptr)<<(lastResult!=nullptr);
|
// qDebug()<<"????"<<(result->baseStatement!=nullptr)<<(lastResult!=nullptr);
|
||||||
|
@ -4951,7 +4943,6 @@ PEvalStatement CppParser::doEvalMemberAccess(const QString &fileName,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// qDebug()<<"baseType:"<<result->baseType;
|
// qDebug()<<"baseType:"<<result->baseType;
|
||||||
// if (result->baseStatement)
|
// if (result->baseStatement)
|
||||||
|
@ -4961,8 +4952,14 @@ PEvalStatement CppParser::doEvalMemberAccess(const QString &fileName,
|
||||||
// if (result->effectiveTypeStatement)
|
// if (result->effectiveTypeStatement)
|
||||||
// qDebug()<<"typeStatement"<<result->effectiveTypeStatement->fullName;
|
// qDebug()<<"typeStatement"<<result->effectiveTypeStatement->fullName;
|
||||||
result->kind = EvalStatementKind::Variable;
|
result->kind = EvalStatementKind::Variable;
|
||||||
} else
|
} else {
|
||||||
result = PEvalStatement();
|
result = PEvalStatement();
|
||||||
|
}
|
||||||
|
} else if (phraseExpression[pos] == "{") {
|
||||||
|
if (result->kind == EvalStatementKind::Type) {
|
||||||
|
doSkipInExpression(phraseExpression,pos,"{","}");
|
||||||
|
result->kind = EvalStatementKind::Variable;
|
||||||
|
}
|
||||||
} else if (phraseExpression[pos] == "[") {
|
} else if (phraseExpression[pos] == "[") {
|
||||||
//skip to "]"
|
//skip to "]"
|
||||||
doSkipInExpression(phraseExpression,pos,"[","]");
|
doSkipInExpression(phraseExpression,pos,"[","]");
|
||||||
|
@ -5173,17 +5170,25 @@ PEvalStatement CppParser::doEvalTerm(const QString &fileName,
|
||||||
if (token=="*") // for expression like (const * char)?
|
if (token=="*") // for expression like (const * char)?
|
||||||
pointerLevel++;
|
pointerLevel++;
|
||||||
else if (mCppTypeKeywords.contains(token)
|
else if (mCppTypeKeywords.contains(token)
|
||||||
|| !mCppKeywords.contains(token))
|
|| !mCppKeywords.contains(token)) {
|
||||||
break;
|
break;
|
||||||
|
} else if (token=="new") {
|
||||||
|
break;
|
||||||
|
}
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pos>=phraseExpression.length() || phraseExpression[pos]==")")
|
if (pos>=phraseExpression.length() || phraseExpression[pos]==")")
|
||||||
return result;
|
return result;
|
||||||
if (mCppKeywords.contains(phraseExpression[pos])) {
|
if (mCppTypeKeywords.contains(phraseExpression[pos])) {
|
||||||
result = doCreateEvalType(phraseExpression[pos]);
|
result = doCreateEvalType(phraseExpression[pos]);
|
||||||
pos++;
|
pos++;
|
||||||
} else if (isIdentifier(phraseExpression[pos])) {
|
} else if (isIdentifier(phraseExpression[pos])) {
|
||||||
|
bool isNew = (phraseExpression[pos] == "new");
|
||||||
|
if (isNew) {
|
||||||
|
pos++;
|
||||||
|
if (pos>=phraseExpression.length())
|
||||||
|
return PEvalStatement();
|
||||||
|
}
|
||||||
PStatement statement;
|
PStatement statement;
|
||||||
if (freeScoped) {
|
if (freeScoped) {
|
||||||
if (!previousResult) {
|
if (!previousResult) {
|
||||||
|
@ -5272,6 +5277,22 @@ PEvalStatement CppParser::doEvalTerm(const QString &fileName,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (result && isNew) {
|
||||||
|
if (result->kind != EvalStatementKind::Type) {
|
||||||
|
return PEvalStatement();
|
||||||
|
} else {
|
||||||
|
if (pos >= phraseExpression.length())
|
||||||
|
return PEvalStatement();
|
||||||
|
if (phraseExpression[pos]=='{')
|
||||||
|
doSkipInExpression(phraseExpression,pos,"{","}");
|
||||||
|
else if (phraseExpression[pos]=='(')
|
||||||
|
doSkipInExpression(phraseExpression,pos,"(",")");
|
||||||
|
else
|
||||||
|
return PEvalStatement();
|
||||||
|
result->kind = EvalStatementKind::Variable;
|
||||||
|
result->pointerLevel++;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (isIntegerLiteral(phraseExpression[pos])) {
|
} else if (isIntegerLiteral(phraseExpression[pos])) {
|
||||||
result = doCreateEvalLiteral("int");
|
result = doCreateEvalLiteral("int");
|
||||||
pos++;
|
pos++;
|
||||||
|
|
Loading…
Reference in New Issue