forked from qt-creator/qt-creator
Merge branch 'master' of git@scm.dev.nokia.troll.no:creator/mainline
This commit is contained in:
@@ -512,22 +512,21 @@ int CppCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
|
|||||||
context = typeOfExpression.lookupContext();
|
context = typeOfExpression.lookupContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! resolvedTypes.isEmpty() && resolvedTypes.first().first) {
|
if (! resolvedTypes.isEmpty()) {
|
||||||
FullySpecifiedType exprTy = resolvedTypes.first().first;
|
if (m_completionOperator == T_LPAREN && completeConstructorOrFunction(resolvedTypes)) {
|
||||||
|
|
||||||
if (exprTy->isReferenceType())
|
|
||||||
exprTy = exprTy->asReferenceType()->elementType();
|
|
||||||
|
|
||||||
if (m_completionOperator == T_LPAREN && completeConstructorOrFunction(exprTy, resolvedTypes)) {
|
|
||||||
return m_startPosition;
|
return m_startPosition;
|
||||||
|
|
||||||
} else if ((m_completionOperator == T_DOT || m_completionOperator == T_ARROW) &&
|
} else if ((m_completionOperator == T_DOT || m_completionOperator == T_ARROW) &&
|
||||||
completeMember(resolvedTypes, context)) {
|
completeMember(resolvedTypes, context)) {
|
||||||
return m_startPosition;
|
return m_startPosition;
|
||||||
|
|
||||||
} else if (m_completionOperator == T_COLON_COLON && completeScope(resolvedTypes, context)) {
|
} else if (m_completionOperator == T_COLON_COLON && completeScope(resolvedTypes, context)) {
|
||||||
return m_startPosition;
|
return m_startPosition;
|
||||||
} else if (m_completionOperator == T_SIGNAL && completeSignal(exprTy, resolvedTypes, context)) {
|
|
||||||
|
} else if (m_completionOperator == T_SIGNAL && completeSignal(resolvedTypes, context)) {
|
||||||
return m_startPosition;
|
return m_startPosition;
|
||||||
} else if (m_completionOperator == T_SLOT && completeSlot(exprTy, resolvedTypes, context)) {
|
|
||||||
|
} else if (m_completionOperator == T_SLOT && completeSlot(resolvedTypes, context)) {
|
||||||
return m_startPosition;
|
return m_startPosition;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -550,8 +549,7 @@ int CppCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
|
|||||||
// If it's a class, add completions for the constructors
|
// If it's a class, add completions for the constructors
|
||||||
foreach (const TypeOfExpression::Result &result, results) {
|
foreach (const TypeOfExpression::Result &result, results) {
|
||||||
if (result.first->isClassType()) {
|
if (result.first->isClassType()) {
|
||||||
FullySpecifiedType exprTy = result.first;
|
if (completeConstructorOrFunction(results))
|
||||||
if (completeConstructorOrFunction(exprTy, QList<TypeOfExpression::Result>()))
|
|
||||||
return m_startPosition;
|
return m_startPosition;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -563,14 +561,16 @@ int CppCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CppCodeCompletion::completeConstructorOrFunction(FullySpecifiedType exprTy,
|
bool CppCodeCompletion::completeConstructorOrFunction(const QList<TypeOfExpression::Result> &results)
|
||||||
const QList<TypeOfExpression::Result> &resolvedTypes)
|
|
||||||
{
|
{
|
||||||
ConvertToCompletionItem toCompletionItem(this);
|
ConvertToCompletionItem toCompletionItem(this);
|
||||||
Overview o;
|
Overview o;
|
||||||
o.setShowReturnTypes(true);
|
o.setShowReturnTypes(true);
|
||||||
o.setShowArgumentNames(true);
|
o.setShowArgumentNames(true);
|
||||||
|
|
||||||
|
foreach (const TypeOfExpression::Result &result, results) {
|
||||||
|
FullySpecifiedType exprTy = result.first;
|
||||||
|
|
||||||
if (Class *klass = exprTy->asClassType()) {
|
if (Class *klass = exprTy->asClassType()) {
|
||||||
for (unsigned i = 0; i < klass->memberCount(); ++i) {
|
for (unsigned i = 0; i < klass->memberCount(); ++i) {
|
||||||
Symbol *member = klass->memberAt(i);
|
Symbol *member = klass->memberAt(i);
|
||||||
@@ -585,10 +585,17 @@ bool CppCodeCompletion::completeConstructorOrFunction(FullySpecifiedType exprTy,
|
|||||||
m_completions.append(item);
|
m_completions.append(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_completions.isEmpty()) {
|
||||||
QSet<QString> signatures;
|
QSet<QString> signatures;
|
||||||
foreach (TypeOfExpression::Result p, resolvedTypes) {
|
|
||||||
|
foreach (const TypeOfExpression::Result &p, results) {
|
||||||
FullySpecifiedType ty = p.first;
|
FullySpecifiedType ty = p.first;
|
||||||
|
|
||||||
if (Function *fun = ty->asFunctionType()) {
|
if (Function *fun = ty->asFunctionType()) {
|
||||||
if (TextEditor::CompletionItem item = toCompletionItem(fun)) {
|
if (TextEditor::CompletionItem item = toCompletionItem(fun)) {
|
||||||
QString signature;
|
QString signature;
|
||||||
@@ -819,33 +826,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);
|
||||||
@@ -902,8 +921,7 @@ void CppCodeCompletion::completeClass(const QList<Symbol *> &candidates,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CppCodeCompletion::completeQtMethod(CPlusPlus::FullySpecifiedType,
|
bool CppCodeCompletion::completeQtMethod(const QList<TypeOfExpression::Result> &results,
|
||||||
const QList<TypeOfExpression::Result> &results,
|
|
||||||
const LookupContext &context,
|
const LookupContext &context,
|
||||||
bool wantSignals)
|
bool wantSignals)
|
||||||
{
|
{
|
||||||
@@ -919,7 +937,7 @@ bool CppCodeCompletion::completeQtMethod(CPlusPlus::FullySpecifiedType,
|
|||||||
o.setShowFunctionSignatures(true);
|
o.setShowFunctionSignatures(true);
|
||||||
|
|
||||||
QSet<QString> signatures;
|
QSet<QString> signatures;
|
||||||
foreach (TypeOfExpression::Result p, results) {
|
foreach (const TypeOfExpression::Result &p, results) {
|
||||||
FullySpecifiedType ty = p.first;
|
FullySpecifiedType ty = p.first;
|
||||||
if (ReferenceType *refTy = ty->asReferenceType())
|
if (ReferenceType *refTy = ty->asReferenceType())
|
||||||
ty = refTy->elementType();
|
ty = refTy->elementType();
|
||||||
|
@@ -84,10 +84,13 @@ 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(const QList<CPlusPlus::TypeOfExpression::Result> &);
|
||||||
const QList<CPlusPlus::TypeOfExpression::Result> &);
|
|
||||||
|
|
||||||
bool completeMember(const QList<CPlusPlus::TypeOfExpression::Result> &,
|
bool completeMember(const QList<CPlusPlus::TypeOfExpression::Result> &,
|
||||||
const CPlusPlus::LookupContext &context);
|
const CPlusPlus::LookupContext &context);
|
||||||
@@ -104,20 +107,17 @@ private:
|
|||||||
|
|
||||||
bool completeConstructors(CPlusPlus::Class *klass);
|
bool completeConstructors(CPlusPlus::Class *klass);
|
||||||
|
|
||||||
bool completeQtMethod(CPlusPlus::FullySpecifiedType exprTy,
|
bool completeQtMethod(const QList<CPlusPlus::TypeOfExpression::Result> &,
|
||||||
const QList<CPlusPlus::TypeOfExpression::Result> &,
|
|
||||||
const CPlusPlus::LookupContext &context,
|
const CPlusPlus::LookupContext &context,
|
||||||
bool wantSignals);
|
bool wantSignals);
|
||||||
|
|
||||||
bool completeSignal(CPlusPlus::FullySpecifiedType exprTy,
|
bool completeSignal(const QList<CPlusPlus::TypeOfExpression::Result> &results,
|
||||||
const QList<CPlusPlus::TypeOfExpression::Result> &results,
|
|
||||||
const CPlusPlus::LookupContext &context)
|
const CPlusPlus::LookupContext &context)
|
||||||
{ return completeQtMethod(exprTy, results, context, true); }
|
{ return completeQtMethod(results, context, true); }
|
||||||
|
|
||||||
bool completeSlot(CPlusPlus::FullySpecifiedType exprTy,
|
bool completeSlot(const QList<CPlusPlus::TypeOfExpression::Result> &results,
|
||||||
const QList<CPlusPlus::TypeOfExpression::Result> &results,
|
|
||||||
const CPlusPlus::LookupContext &context)
|
const CPlusPlus::LookupContext &context)
|
||||||
{ return completeQtMethod(exprTy, results, context, false); }
|
{ return completeQtMethod(results, context, false); }
|
||||||
|
|
||||||
int findStartOfName(int pos = -1) const;
|
int findStartOfName(int pos = -1) const;
|
||||||
|
|
||||||
|
@@ -1130,7 +1130,7 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data)
|
|||||||
sendCommand("info proc", GdbInfoProc);
|
sendCommand("info proc", GdbInfoProc);
|
||||||
#endif
|
#endif
|
||||||
#if defined(Q_OS_MAC)
|
#if defined(Q_OS_MAC)
|
||||||
sendCommand("info pid", GdbInfoProc, QVariant(), true);
|
sendCommand("info pid", GdbInfoProc);
|
||||||
#endif
|
#endif
|
||||||
reloadSourceFiles();
|
reloadSourceFiles();
|
||||||
tryLoadCustomDumpers();
|
tryLoadCustomDumpers();
|
||||||
|
@@ -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