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)
 | 
			
		||||
{
 | 
			
		||||
    // macro completion items.
 | 
			
		||||
    QSet<QByteArray> macroNames;
 | 
			
		||||
    QSet<QString> processed;
 | 
			
		||||
    QList<QString> todo;
 | 
			
		||||
    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();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    QSet<QString> definedMacros;
 | 
			
		||||
 | 
			
		||||
    foreach (const QByteArray ¯oName, macroNames) {
 | 
			
		||||
    addMacros_helper(context, context.thisDocument()->fileName(),
 | 
			
		||||
                     &processed, &definedMacros);
 | 
			
		||||
 | 
			
		||||
    foreach (const QString ¯oName, definedMacros) {
 | 
			
		||||
        TextEditor::CompletionItem item(this);
 | 
			
		||||
        item.m_text = QString::fromUtf8(macroName.constData(), macroName.length());
 | 
			
		||||
        item.m_text = macroName;
 | 
			
		||||
        item.m_icon = m_icons.macroIcon();
 | 
			
		||||
        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)
 | 
			
		||||
{
 | 
			
		||||
    ConvertToCompletionItem toCompletionItem(this);
 | 
			
		||||
 
 | 
			
		||||
@@ -84,6 +84,10 @@ public:
 | 
			
		||||
private:
 | 
			
		||||
    void addKeywords();
 | 
			
		||||
    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);
 | 
			
		||||
 | 
			
		||||
    bool completeConstructorOrFunction(CPlusPlus::FullySpecifiedType exprTy,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user