fix #326 - enhancement: Suggest macro names after "#ifdef"/"#ifndef".
This commit is contained in:
parent
5c7e7fb793
commit
40777386a9
1
NEWS.md
1
NEWS.md
|
@ -90,6 +90,7 @@ Red Panda C++ Version 2.27
|
|||
- enhancement: Shortcut key for buttons in find/replace and "find in files" dialogs.
|
||||
|
||||
- enhancement: Auto define macro "_DEBUG" for "Debug" compiler set(like visual studio).
|
||||
- enhancement: Suggest macro names after "#ifdef"/"#ifndef".
|
||||
|
||||
Red Panda C++ Version 2.26
|
||||
- enhancement: Code suggestion for embedded std::vectors.
|
||||
|
|
|
@ -926,6 +926,11 @@ void Editor::keyPressEvent(QKeyEvent *event)
|
|||
|
||||
//last word is a type keyword, this is a var or param define, and dont show suggestion
|
||||
return;
|
||||
} else if (lastWord == "#ifdef" || lastWord == "#ifndef") {
|
||||
processCommand(QSynedit::EditCommand::Char,ch,nullptr);
|
||||
showCompletion(lastWord,false, CodeCompletionType::Macros);
|
||||
handled=true;
|
||||
return;
|
||||
}
|
||||
PStatement statement = mParser->findStatementOf(
|
||||
mFilename,
|
||||
|
@ -4991,6 +4996,7 @@ QString Editor::getPreviousWordAtPositionForSuggestion(const QSynedit::BufferCoo
|
|||
while ((wordBegin >= 0) && (isIdentChar(s[wordBegin]) || s[wordBegin]==':') ) {
|
||||
wordBegin--;
|
||||
}
|
||||
if (wordBegin<0 || s[wordBegin]!='#')
|
||||
wordBegin++;
|
||||
|
||||
if (s[wordBegin]>='0' && s[wordBegin]<='9') // not valid word
|
||||
|
|
|
@ -113,6 +113,10 @@ void CodeCompletionPopup::prepareSearch(
|
|||
mIncludedFiles.clear();
|
||||
getKeywordCompletionFor(customKeywords);
|
||||
break;
|
||||
case CodeCompletionType::Macros:
|
||||
mIncludedFiles = mParser->getIncludedFiles(filename);
|
||||
getMacroCompletionList(filename, line);
|
||||
break;
|
||||
default:
|
||||
mIncludedFiles = mParser->getIncludedFiles(filename);
|
||||
getCompletionFor(ownerExpression,memberOperator,memberExpression, filename,line, customKeywords);
|
||||
|
@ -583,6 +587,15 @@ void CodeCompletionPopup::getKeywordCompletionFor(const QSet<QString> &customKey
|
|||
}
|
||||
}
|
||||
|
||||
void CodeCompletionPopup::getMacroCompletionList(const QString &fileName, int line)
|
||||
{
|
||||
const StatementMap& statementMap = mParser->statementList().childrenStatements(nullptr);
|
||||
foreach(const PStatement& statement, statementMap.values()) {
|
||||
if (statement->kind==StatementKind::skPreprocessor)
|
||||
addStatement(statement,fileName,line);
|
||||
}
|
||||
}
|
||||
|
||||
void CodeCompletionPopup::getCompletionFor(
|
||||
QStringList ownerExpression,
|
||||
const QString& memberOperator,
|
||||
|
|
|
@ -43,6 +43,7 @@ enum class CodeCompletionType {
|
|||
FunctionWithoutDefinition,
|
||||
Namespaces,
|
||||
Types,
|
||||
Macros,
|
||||
KeywordsOnly
|
||||
};
|
||||
|
||||
|
@ -136,6 +137,7 @@ private:
|
|||
void addStatement(const PStatement& statement, const QString& fileName, int line);
|
||||
void filterList(const QString& member);
|
||||
void getKeywordCompletionFor(const QSet<QString>& customKeywords);
|
||||
void getMacroCompletionList(const QString &fileName, int line);
|
||||
void getCompletionFor(
|
||||
QStringList ownerExpression,
|
||||
const QString& memberOperator,
|
||||
|
|
Loading…
Reference in New Issue