forked from qt-creator/qt-creator
Merge branch '1.0.0' of git@scm.dev.nokia.troll.no:creator/mainline
This commit is contained in:
@@ -829,33 +829,45 @@ void CppCodeCompletion::addKeywords()
|
|||||||
|
|
||||||
void CppCodeCompletion::addMacros(const LookupContext &context)
|
void CppCodeCompletion::addMacros(const LookupContext &context)
|
||||||
{
|
{
|
||||||
// macro completion items.
|
|
||||||
QSet<QByteArray> macroNames;
|
|
||||||
QSet<QString> processed;
|
QSet<QString> processed;
|
||||||
QList<QString> todo;
|
QSet<QString> definedMacros;
|
||||||
todo.append(context.thisDocument()->fileName());
|
|
||||||
while (! todo.isEmpty()) {
|
|
||||||
QString fn = todo.last();
|
|
||||||
todo.removeLast();
|
|
||||||
if (processed.contains(fn))
|
|
||||||
continue;
|
|
||||||
processed.insert(fn);
|
|
||||||
if (Document::Ptr doc = context.document(fn)) {
|
|
||||||
foreach (const Macro ¯o, doc->definedMacros()) {
|
|
||||||
macroNames.insert(macro.name());
|
|
||||||
}
|
|
||||||
todo += doc->includedFiles();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (const QByteArray ¯oName, macroNames) {
|
addMacros_helper(context, context.thisDocument()->fileName(),
|
||||||
|
&processed, &definedMacros);
|
||||||
|
|
||||||
|
foreach (const QString ¯oName, definedMacros) {
|
||||||
TextEditor::CompletionItem item(this);
|
TextEditor::CompletionItem item(this);
|
||||||
item.m_text = QString::fromUtf8(macroName.constData(), macroName.length());
|
item.m_text = macroName;
|
||||||
item.m_icon = m_icons.macroIcon();
|
item.m_icon = m_icons.macroIcon();
|
||||||
m_completions.append(item);
|
m_completions.append(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CppCodeCompletion::addMacros_helper(const LookupContext &context,
|
||||||
|
const QString &fileName,
|
||||||
|
QSet<QString> *processed,
|
||||||
|
QSet<QString> *definedMacros)
|
||||||
|
{
|
||||||
|
Document::Ptr doc = context.document(fileName);
|
||||||
|
|
||||||
|
if (! doc || processed->contains(doc->fileName()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
processed->insert(doc->fileName());
|
||||||
|
|
||||||
|
foreach (const Document::Include &i, doc->includes()) {
|
||||||
|
addMacros_helper(context, i.fileName(), processed, definedMacros);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (const Macro ¯o, doc->definedMacros()) {
|
||||||
|
const QString macroName = QString::fromUtf8(macro.name().constData(), macro.name().length());
|
||||||
|
if (! macro.isHidden())
|
||||||
|
definedMacros->insert(macroName);
|
||||||
|
else
|
||||||
|
definedMacros->remove(macroName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CppCodeCompletion::addCompletionItem(Symbol *symbol)
|
void CppCodeCompletion::addCompletionItem(Symbol *symbol)
|
||||||
{
|
{
|
||||||
ConvertToCompletionItem toCompletionItem(this);
|
ConvertToCompletionItem toCompletionItem(this);
|
||||||
|
@@ -84,6 +84,10 @@ public:
|
|||||||
private:
|
private:
|
||||||
void addKeywords();
|
void addKeywords();
|
||||||
void addMacros(const CPlusPlus::LookupContext &context);
|
void addMacros(const CPlusPlus::LookupContext &context);
|
||||||
|
void addMacros_helper(const CPlusPlus::LookupContext &context,
|
||||||
|
const QString &fileName,
|
||||||
|
QSet<QString> *processed,
|
||||||
|
QSet<QString> *definedMacros);
|
||||||
void addCompletionItem(CPlusPlus::Symbol *symbol);
|
void addCompletionItem(CPlusPlus::Symbol *symbol);
|
||||||
|
|
||||||
bool completeConstructorOrFunction(CPlusPlus::FullySpecifiedType exprTy,
|
bool completeConstructorOrFunction(CPlusPlus::FullySpecifiedType exprTy,
|
||||||
|
@@ -388,8 +388,9 @@ bool CheckSpecifier::visit(TypeofSpecifierAST *ast)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheckSpecifier::visit(AttributeSpecifierAST *)
|
bool CheckSpecifier::visit(AttributeSpecifierAST *ast)
|
||||||
{
|
{
|
||||||
|
accept(ast->next);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user