forked from qt-creator/qt-creator
Merge remote branch 'origin/1.3'
Conflicts: src/plugins/cpptools/CppTools.pluginspec src/plugins/help/Help.pluginspec src/plugins/locator/Locator.pluginspec src/plugins/projectexplorer/ProjectExplorer.pluginspec src/plugins/texteditor/TextEditor.pluginspec
This commit is contained in:
@@ -21,6 +21,6 @@ will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.</license>
|
||||
<dependencyList>
|
||||
<dependency name="TextEditor" version="1.3.80"/>
|
||||
<dependency name="ProjectExplorer" version="1.3.80"/>
|
||||
<dependency name="QuickOpen" version="1.3.80"/>
|
||||
<dependency name="Locator" version="1.3.80"/>
|
||||
</dependencyList>
|
||||
</plugin>
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
using namespace CppTools::Internal;
|
||||
|
||||
CppClassesFilter::CppClassesFilter(CppModelManager *manager, Core::EditorManager *editorManager)
|
||||
: CppQuickOpenFilter(manager, editorManager)
|
||||
: CppLocatorFilter(manager, editorManager)
|
||||
{
|
||||
setShortcutString("c");
|
||||
setIncludedByDefault(false);
|
||||
|
||||
@@ -30,12 +30,12 @@
|
||||
#ifndef CPPCLASSESFILTER_H
|
||||
#define CPPCLASSESFILTER_H
|
||||
|
||||
#include <cppquickopenfilter.h>
|
||||
#include <cpplocatorfilter.h>
|
||||
|
||||
namespace CppTools {
|
||||
namespace Internal {
|
||||
|
||||
class CppClassesFilter : public CppQuickOpenFilter
|
||||
class CppClassesFilter : public CppLocatorFilter
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
@@ -860,7 +860,7 @@ int CppCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
|
||||
}
|
||||
|
||||
if (! resolvedTypes.isEmpty()) {
|
||||
if (m_completionOperator == T_LPAREN && completeConstructorOrFunction(resolvedTypes)) {
|
||||
if (m_completionOperator == T_LPAREN && completeConstructorOrFunction(resolvedTypes, context)) {
|
||||
return m_startPosition;
|
||||
|
||||
} else if ((m_completionOperator == T_DOT || m_completionOperator == T_ARROW) &&
|
||||
@@ -887,16 +887,19 @@ int CppCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
|
||||
|
||||
QTextCursor tc(edit->document());
|
||||
tc.setPosition(index);
|
||||
QString baseExpression = expressionUnderCursor(tc);
|
||||
|
||||
const QString baseExpression = expressionUnderCursor(tc);
|
||||
|
||||
// Resolve the type of this expression
|
||||
QList<TypeOfExpression::Result> results =
|
||||
typeOfExpression(baseExpression, thisDocument, lastVisibleSymbol, TypeOfExpression::Preprocess);
|
||||
const QList<TypeOfExpression::Result> results =
|
||||
typeOfExpression(baseExpression, thisDocument,
|
||||
lastVisibleSymbol,
|
||||
TypeOfExpression::Preprocess);
|
||||
|
||||
// If it's a class, add completions for the constructors
|
||||
foreach (const TypeOfExpression::Result &result, results) {
|
||||
if (result.first->isClassType()) {
|
||||
if (completeConstructorOrFunction(results))
|
||||
if (completeConstructorOrFunction(results, context))
|
||||
return m_startPosition;
|
||||
break;
|
||||
}
|
||||
@@ -908,12 +911,13 @@ int CppCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool CppCodeCompletion::completeConstructorOrFunction(const QList<TypeOfExpression::Result> &results)
|
||||
bool CppCodeCompletion::completeConstructorOrFunction(const QList<TypeOfExpression::Result> &results,
|
||||
const LookupContext &context)
|
||||
{
|
||||
QList<Function *> functions;
|
||||
|
||||
foreach (const TypeOfExpression::Result &result, results) {
|
||||
FullySpecifiedType exprTy = result.first;
|
||||
FullySpecifiedType exprTy = result.first.simplified();
|
||||
|
||||
if (Class *klass = exprTy->asClassType()) {
|
||||
Name *className = klass->name();
|
||||
@@ -943,8 +947,8 @@ bool CppCodeCompletion::completeConstructorOrFunction(const QList<TypeOfExpressi
|
||||
}
|
||||
|
||||
if (functions.isEmpty()) {
|
||||
foreach (const TypeOfExpression::Result &p, results) {
|
||||
FullySpecifiedType ty = p.first;
|
||||
foreach (const TypeOfExpression::Result &result, results) {
|
||||
FullySpecifiedType ty = result.first.simplified();
|
||||
|
||||
if (Function *fun = ty->asFunctionType()) {
|
||||
|
||||
@@ -953,10 +957,6 @@ bool CppCodeCompletion::completeConstructorOrFunction(const QList<TypeOfExpressi
|
||||
else if (! functions.isEmpty() && functions.first()->scope() != fun->scope())
|
||||
continue; // skip fun, it's an hidden declaration.
|
||||
|
||||
Name *name = fun->name();
|
||||
if (QualifiedNameId *q = fun->name()->asQualifiedNameId())
|
||||
name = q->unqualifiedNameId();
|
||||
|
||||
bool newOverload = true;
|
||||
|
||||
foreach (Function *f, functions) {
|
||||
@@ -970,7 +970,35 @@ bool CppCodeCompletion::completeConstructorOrFunction(const QList<TypeOfExpressi
|
||||
functions.append(fun);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (functions.isEmpty()) {
|
||||
ResolveExpression resolveExpression(context);
|
||||
ResolveClass resolveClass;
|
||||
Name *functionCallOp = context.control()->operatorNameId(OperatorNameId::FunctionCallOp);
|
||||
|
||||
foreach (const TypeOfExpression::Result &result, results) {
|
||||
FullySpecifiedType ty = result.first.simplified();
|
||||
|
||||
if (NamedType *namedTy = ty->asNamedType()) {
|
||||
const QList<Symbol *> classObjectCandidates = resolveClass(namedTy->name(), result, context);
|
||||
|
||||
foreach (Symbol *classObjectCandidate, classObjectCandidates) {
|
||||
if (Class *klass = classObjectCandidate->asClass()) {
|
||||
const QList<TypeOfExpression::Result> overloads =
|
||||
resolveExpression.resolveMember(functionCallOp, klass,
|
||||
namedTy->name());
|
||||
|
||||
foreach (const TypeOfExpression::Result &overloadResult, overloads) {
|
||||
FullySpecifiedType overloadTy = overloadResult.first.simplified();
|
||||
|
||||
if (Function *funTy = overloadTy->asFunctionType())
|
||||
functions.append(funTy);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! functions.isEmpty()) {
|
||||
@@ -987,135 +1015,42 @@ bool CppCodeCompletion::completeConstructorOrFunction(const QList<TypeOfExpressi
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CppCodeCompletion::completeMember(const QList<TypeOfExpression::Result> &results,
|
||||
bool CppCodeCompletion::completeMember(const QList<TypeOfExpression::Result> &baseResults,
|
||||
const LookupContext &context)
|
||||
{
|
||||
if (results.isEmpty())
|
||||
if (baseResults.isEmpty())
|
||||
return false;
|
||||
|
||||
TypeOfExpression::Result result = results.first();
|
||||
ResolveExpression resolveExpression(context);
|
||||
ResolveClass resolveClass;
|
||||
|
||||
bool replacedDotOperator = false;
|
||||
const QList<TypeOfExpression::Result> classObjectResults =
|
||||
resolveExpression.resolveBaseExpression(baseResults,
|
||||
m_completionOperator,
|
||||
&replacedDotOperator);
|
||||
|
||||
if (replacedDotOperator) {
|
||||
// Replace . with ->
|
||||
int length = m_editor->position() - m_startPosition + 1;
|
||||
m_editor->setCurPos(m_startPosition - 1);
|
||||
m_editor->replace(length, QLatin1String("->"));
|
||||
++m_startPosition;
|
||||
}
|
||||
|
||||
QList<Symbol *> classObjectCandidates;
|
||||
foreach (const TypeOfExpression::Result &r, classObjectResults) {
|
||||
FullySpecifiedType ty = r.first.simplified();
|
||||
|
||||
if (m_completionOperator == T_ARROW) {
|
||||
FullySpecifiedType ty = result.first.simplified();
|
||||
if (Class *klass = ty->asClassType())
|
||||
classObjectCandidates.append(klass);
|
||||
|
||||
if (Class *classTy = ty->asClassType()) {
|
||||
Symbol *symbol = result.second;
|
||||
if (symbol && ! symbol->isClass())
|
||||
classObjectCandidates.append(classTy);
|
||||
} else if (NamedType *namedTy = ty->asNamedType()) {
|
||||
// ### This code is pretty slow.
|
||||
const QList<Symbol *> candidates = context.resolve(namedTy->name());
|
||||
foreach (Symbol *candidate, candidates) {
|
||||
if (candidate->isTypedef()) {
|
||||
ty = candidate->type();
|
||||
const ResolveExpression::Result r(ty, candidate);
|
||||
result = r;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (NamedType *namedTy = ty->asNamedType()) {
|
||||
Name *className = namedTy->name();
|
||||
const QList<Symbol *> classes = resolveClass(className, r, context);
|
||||
|
||||
if (NamedType *namedTy = ty->asNamedType()) {
|
||||
ResolveExpression resolveExpression(context);
|
||||
ResolveClass resolveClass;
|
||||
|
||||
const QList<Symbol *> candidates = resolveClass(namedTy->name(), result, context);
|
||||
foreach (Symbol *classObject, candidates) {
|
||||
const QList<TypeOfExpression::Result> overloads =
|
||||
resolveExpression.resolveArrowOperator(result, namedTy,
|
||||
classObject->asClass());
|
||||
|
||||
foreach (TypeOfExpression::Result r, overloads) {
|
||||
FullySpecifiedType ty = r.first;
|
||||
Function *funTy = ty->asFunctionType();
|
||||
if (! funTy)
|
||||
continue;
|
||||
|
||||
ty = funTy->returnType().simplified();
|
||||
|
||||
if (PointerType *ptrTy = ty->asPointerType()) {
|
||||
FullySpecifiedType elementTy = ptrTy->elementType().simplified();
|
||||
if (NamedType *namedTy = elementTy->asNamedType()) {
|
||||
const QList<Symbol *> classes =
|
||||
resolveClass(namedTy->name(), result, context);
|
||||
|
||||
foreach (Symbol *c, classes) {
|
||||
if (! classObjectCandidates.contains(c))
|
||||
classObjectCandidates.append(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (PointerType *ptrTy = ty->asPointerType()) {
|
||||
FullySpecifiedType elementTy = ptrTy->elementType().simplified();
|
||||
if (NamedType *namedTy = elementTy->asNamedType()) {
|
||||
ResolveClass resolveClass;
|
||||
|
||||
const QList<Symbol *> classes = resolveClass(namedTy->name(), result,
|
||||
context);
|
||||
|
||||
foreach (Symbol *c, classes) {
|
||||
if (! classObjectCandidates.contains(c))
|
||||
classObjectCandidates.append(c);
|
||||
}
|
||||
} else if (Class *classTy = elementTy->asClassType()) {
|
||||
// typedef struct { int x } *Ptr;
|
||||
// Ptr p;
|
||||
// p->
|
||||
classObjectCandidates.append(classTy);
|
||||
}
|
||||
}
|
||||
} else if (m_completionOperator == T_DOT) {
|
||||
FullySpecifiedType ty = result.first.simplified();
|
||||
|
||||
NamedType *namedTy = 0;
|
||||
|
||||
if (ArrayType *arrayTy = ty->asArrayType()) {
|
||||
// Replace . with [0]. when `ty' is an array type.
|
||||
FullySpecifiedType elementTy = arrayTy->elementType().simplified();
|
||||
|
||||
if (elementTy->isNamedType() || elementTy->isPointerType()) {
|
||||
ty = elementTy;
|
||||
|
||||
const int length = m_editor->position() - m_startPosition + 1;
|
||||
m_editor->setCurPos(m_startPosition - 1);
|
||||
m_editor->replace(length, QLatin1String("[0]."));
|
||||
m_startPosition += 3;
|
||||
}
|
||||
}
|
||||
|
||||
if (PointerType *ptrTy = ty->asPointerType()) {
|
||||
if (ptrTy->elementType()->isNamedType()) {
|
||||
// Replace . with ->
|
||||
int length = m_editor->position() - m_startPosition + 1;
|
||||
m_editor->setCurPos(m_startPosition - 1);
|
||||
m_editor->replace(length, QLatin1String("->"));
|
||||
++m_startPosition;
|
||||
namedTy = ptrTy->elementType()->asNamedType();
|
||||
}
|
||||
} else if (Class *classTy = ty->asClassType()) {
|
||||
Symbol *symbol = result.second;
|
||||
if (symbol && ! symbol->isClass())
|
||||
classObjectCandidates.append(classTy);
|
||||
} else {
|
||||
namedTy = ty->asNamedType();
|
||||
if (! namedTy) {
|
||||
Function *fun = ty->asFunctionType();
|
||||
if (fun && fun->scope() && (fun->scope()->isBlockScope() || fun->scope()->isNamespaceScope()))
|
||||
namedTy = fun->returnType()->asNamedType();
|
||||
}
|
||||
}
|
||||
|
||||
if (namedTy) {
|
||||
ResolveClass resolveClass;
|
||||
const QList<Symbol *> symbols = resolveClass(namedTy->name(), result,
|
||||
context);
|
||||
foreach (Symbol *symbol, symbols) {
|
||||
if (classObjectCandidates.contains(symbol))
|
||||
continue;
|
||||
if (Class *klass = symbol->asClass())
|
||||
foreach (Symbol *c, classes) {
|
||||
if (Class *klass = c->asClass())
|
||||
classObjectCandidates.append(klass);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +116,8 @@ private:
|
||||
|
||||
bool completeInclude(const QTextCursor &cursor);
|
||||
|
||||
bool completeConstructorOrFunction(const QList<CPlusPlus::TypeOfExpression::Result> &);
|
||||
bool completeConstructorOrFunction(const QList<CPlusPlus::TypeOfExpression::Result> &,
|
||||
const CPlusPlus::LookupContext &);
|
||||
|
||||
bool completeMember(const QList<CPlusPlus::TypeOfExpression::Result> &,
|
||||
const CPlusPlus::LookupContext &context);
|
||||
|
||||
@@ -58,11 +58,11 @@ CppCurrentDocumentFilter::CppCurrentDocumentFilter(CppModelManager *manager, Cor
|
||||
this, SLOT(onEditorAboutToClose(Core::IEditor*)));
|
||||
}
|
||||
|
||||
QList<QuickOpen::FilterEntry> CppCurrentDocumentFilter::matchesFor(const QString & origEntry)
|
||||
QList<Locator::FilterEntry> CppCurrentDocumentFilter::matchesFor(const QString & origEntry)
|
||||
{
|
||||
QString entry = trimWildcards(origEntry);
|
||||
QList<QuickOpen::FilterEntry> goodEntries;
|
||||
QList<QuickOpen::FilterEntry> betterEntries;
|
||||
QList<Locator::FilterEntry> goodEntries;
|
||||
QList<Locator::FilterEntry> betterEntries;
|
||||
QStringMatcher matcher(entry, Qt::CaseInsensitive);
|
||||
const QRegExp regexp("*"+entry+"*", Qt::CaseInsensitive, QRegExp::Wildcard);
|
||||
if (!regexp.isValid())
|
||||
@@ -86,7 +86,7 @@ QList<QuickOpen::FilterEntry> CppCurrentDocumentFilter::matchesFor(const QString
|
||||
{
|
||||
QString symbolName = info.symbolName;// + (info.type == ModelItemInfo::Declaration ? ";" : " {...}");
|
||||
QVariant id = qVariantFromValue(info);
|
||||
QuickOpen::FilterEntry filterEntry(this, symbolName, id, info.icon);
|
||||
Locator::FilterEntry filterEntry(this, symbolName, id, info.icon);
|
||||
filterEntry.extraInfo = info.symbolType;
|
||||
|
||||
if (info.symbolName.startsWith(entry))
|
||||
@@ -102,7 +102,7 @@ QList<QuickOpen::FilterEntry> CppCurrentDocumentFilter::matchesFor(const QString
|
||||
return betterEntries;
|
||||
}
|
||||
|
||||
void CppCurrentDocumentFilter::accept(QuickOpen::FilterEntry selection) const
|
||||
void CppCurrentDocumentFilter::accept(Locator::FilterEntry selection) const
|
||||
{
|
||||
ModelItemInfo info = qvariant_cast<CppTools::Internal::ModelItemInfo>(selection.internalData);
|
||||
TextEditor::BaseTextEditor::openEditorAt(info.fileName, info.line);
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#define CPPCURRENTDOCUMENTFILTER_H
|
||||
|
||||
#include "searchsymbols.h"
|
||||
#include <quickopen/iquickopenfilter.h>
|
||||
#include <locator/ilocatorfilter.h>
|
||||
|
||||
namespace Core {
|
||||
class EditorManager;
|
||||
@@ -42,7 +42,7 @@ namespace Internal {
|
||||
|
||||
class CppModelManager;
|
||||
|
||||
class CppCurrentDocumentFilter : public QuickOpen::IQuickOpenFilter
|
||||
class CppCurrentDocumentFilter : public Locator::ILocatorFilter
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -53,8 +53,8 @@ public:
|
||||
QString trName() const { return tr("Methods in current Document"); }
|
||||
QString name() const { return QLatin1String("Methods in current Document"); }
|
||||
Priority priority() const { return Medium; }
|
||||
QList<QuickOpen::FilterEntry> matchesFor(const QString &entry);
|
||||
void accept(QuickOpen::FilterEntry selection) const;
|
||||
QList<Locator::FilterEntry> matchesFor(const QString &entry);
|
||||
void accept(Locator::FilterEntry selection) const;
|
||||
void refresh(QFutureInterface<void> &future);
|
||||
|
||||
private slots:
|
||||
|
||||
@@ -77,7 +77,8 @@ public:
|
||||
_doc(doc),
|
||||
_snapshot(snapshot),
|
||||
_source(_doc->source()),
|
||||
_sem(doc->control())
|
||||
_sem(doc->control()),
|
||||
_inSimpleDeclaration(0)
|
||||
{
|
||||
_snapshot.insert(_doc);
|
||||
}
|
||||
@@ -435,8 +436,8 @@ protected:
|
||||
for (PtrOperatorAST *ptr_op = declarator->ptr_operators; ptr_op; ptr_op = ptr_op->next)
|
||||
accept(ptr_op);
|
||||
|
||||
// ### TODO: well, not exactly. We need to look at qualified-name-ids and nested-declarators.
|
||||
// accept(declarator->core_declarator);
|
||||
if (! _inSimpleDeclaration) // visit the core declarator only if we are not in simple-declaration.
|
||||
accept(declarator->core_declarator);
|
||||
|
||||
for (PostfixDeclaratorAST *fx_op = declarator->postfix_declarators; fx_op; fx_op = fx_op->next)
|
||||
accept(fx_op);
|
||||
@@ -469,6 +470,15 @@ protected:
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool visit(SimpleDeclarationAST *)
|
||||
{
|
||||
++_inSimpleDeclaration;
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void endVisit(SimpleDeclarationAST *)
|
||||
{ --_inSimpleDeclaration; }
|
||||
|
||||
private:
|
||||
QFutureInterface<Utils::FileSearchResult> *_future;
|
||||
Identifier *_id; // ### remove me
|
||||
@@ -482,6 +492,7 @@ private:
|
||||
QList<PostfixExpressionAST *> _postfixExpressionStack;
|
||||
QList<QualifiedNameAST *> _qualifiedNameStack;
|
||||
QList<int> _references;
|
||||
int _inSimpleDeclaration;
|
||||
};
|
||||
|
||||
} // end of anonymous namespace
|
||||
@@ -682,6 +693,8 @@ static void applyChanges(QTextDocument *doc, const QString &text, const QList<Fi
|
||||
void CppFindReferences::onReplaceButtonClicked(const QString &text,
|
||||
const QList<Find::SearchResultItem> &items)
|
||||
{
|
||||
Core::EditorManager::instance()->hideEditorInfoBar(QLatin1String("CppEditor.Rename"));
|
||||
|
||||
if (text.isEmpty())
|
||||
return;
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
using namespace CppTools::Internal;
|
||||
|
||||
CppFunctionsFilter::CppFunctionsFilter(CppModelManager *manager, Core::EditorManager *editorManager)
|
||||
: CppQuickOpenFilter(manager, editorManager)
|
||||
: CppLocatorFilter(manager, editorManager)
|
||||
{
|
||||
setShortcutString("m");
|
||||
setIncludedByDefault(false);
|
||||
|
||||
@@ -30,12 +30,12 @@
|
||||
#ifndef CPPFUNCTIONSFILTER_H
|
||||
#define CPPFUNCTIONSFILTER_H
|
||||
|
||||
#include <cppquickopenfilter.h>
|
||||
#include <cpplocatorfilter.h>
|
||||
|
||||
namespace CppTools {
|
||||
namespace Internal {
|
||||
|
||||
class CppFunctionsFilter : public CppQuickOpenFilter
|
||||
class CppFunctionsFilter : public CppLocatorFilter
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include "cppquickopenfilter.h"
|
||||
#include "cpplocatorfilter.h"
|
||||
#include "cppmodelmanager.h"
|
||||
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
using namespace CppTools::Internal;
|
||||
|
||||
CppQuickOpenFilter::CppQuickOpenFilter(CppModelManager *manager, Core::EditorManager *editorManager)
|
||||
CppLocatorFilter::CppLocatorFilter(CppModelManager *manager, Core::EditorManager *editorManager)
|
||||
: m_manager(manager),
|
||||
m_editorManager(editorManager),
|
||||
m_forceNewSearchList(true)
|
||||
@@ -54,36 +54,36 @@ CppQuickOpenFilter::CppQuickOpenFilter(CppModelManager *manager, Core::EditorMan
|
||||
this, SLOT(onAboutToRemoveFiles(QStringList)));
|
||||
}
|
||||
|
||||
CppQuickOpenFilter::~CppQuickOpenFilter()
|
||||
CppLocatorFilter::~CppLocatorFilter()
|
||||
{ }
|
||||
|
||||
void CppQuickOpenFilter::onDocumentUpdated(CPlusPlus::Document::Ptr doc)
|
||||
void CppLocatorFilter::onDocumentUpdated(CPlusPlus::Document::Ptr doc)
|
||||
{
|
||||
m_searchList[doc->fileName()] = Info(doc);
|
||||
}
|
||||
|
||||
void CppQuickOpenFilter::onAboutToRemoveFiles(const QStringList &files)
|
||||
void CppLocatorFilter::onAboutToRemoveFiles(const QStringList &files)
|
||||
{
|
||||
foreach (const QString &file, files)
|
||||
m_searchList.remove(file);
|
||||
}
|
||||
|
||||
void CppQuickOpenFilter::refresh(QFutureInterface<void> &future)
|
||||
void CppLocatorFilter::refresh(QFutureInterface<void> &future)
|
||||
{
|
||||
Q_UNUSED(future)
|
||||
}
|
||||
|
||||
static bool compareLexigraphically(const QuickOpen::FilterEntry &a,
|
||||
const QuickOpen::FilterEntry &b)
|
||||
static bool compareLexigraphically(const Locator::FilterEntry &a,
|
||||
const Locator::FilterEntry &b)
|
||||
{
|
||||
return a.displayName < b.displayName;
|
||||
}
|
||||
|
||||
QList<QuickOpen::FilterEntry> CppQuickOpenFilter::matchesFor(const QString &origEntry)
|
||||
QList<Locator::FilterEntry> CppLocatorFilter::matchesFor(const QString &origEntry)
|
||||
{
|
||||
QString entry = trimWildcards(origEntry);
|
||||
QList<QuickOpen::FilterEntry> goodEntries;
|
||||
QList<QuickOpen::FilterEntry> betterEntries;
|
||||
QList<Locator::FilterEntry> goodEntries;
|
||||
QList<Locator::FilterEntry> betterEntries;
|
||||
QStringMatcher matcher(entry, Qt::CaseInsensitive);
|
||||
const QRegExp regexp("*"+entry+"*", Qt::CaseInsensitive, QRegExp::Wildcard);
|
||||
if (!regexp.isValid())
|
||||
@@ -108,7 +108,7 @@ QList<QuickOpen::FilterEntry> CppQuickOpenFilter::matchesFor(const QString &orig
|
||||
|| (!hasWildcard && matcher.indexIn(info.symbolName) != -1)) {
|
||||
|
||||
QVariant id = qVariantFromValue(info);
|
||||
QuickOpen::FilterEntry filterEntry(this, info.symbolName, id, info.icon);
|
||||
Locator::FilterEntry filterEntry(this, info.symbolName, id, info.icon);
|
||||
if (! info.symbolType.isEmpty())
|
||||
filterEntry.extraInfo = info.symbolType;
|
||||
else
|
||||
@@ -131,7 +131,7 @@ QList<QuickOpen::FilterEntry> CppQuickOpenFilter::matchesFor(const QString &orig
|
||||
return betterEntries;
|
||||
}
|
||||
|
||||
void CppQuickOpenFilter::accept(QuickOpen::FilterEntry selection) const
|
||||
void CppLocatorFilter::accept(Locator::FilterEntry selection) const
|
||||
{
|
||||
ModelItemInfo info = qvariant_cast<CppTools::Internal::ModelItemInfo>(selection.internalData);
|
||||
TextEditor::BaseTextEditor::openEditorAt(info.fileName, info.line);
|
||||
@@ -27,12 +27,12 @@
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef CPPQUICKOPENFILTER_H
|
||||
#define CPPQUICKOPENFILTER_H
|
||||
#ifndef CPPLOCATORFILTER_H
|
||||
#define CPPLOCATORFILTER_H
|
||||
|
||||
#include "searchsymbols.h"
|
||||
|
||||
#include <quickopen/iquickopenfilter.h>
|
||||
#include <locator/ilocatorfilter.h>
|
||||
|
||||
namespace Core {
|
||||
class EditorManager;
|
||||
@@ -43,18 +43,18 @@ namespace Internal {
|
||||
|
||||
class CppModelManager;
|
||||
|
||||
class CppQuickOpenFilter : public QuickOpen::IQuickOpenFilter
|
||||
class CppLocatorFilter : public Locator::ILocatorFilter
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CppQuickOpenFilter(CppModelManager *manager, Core::EditorManager *editorManager);
|
||||
~CppQuickOpenFilter();
|
||||
CppLocatorFilter(CppModelManager *manager, Core::EditorManager *editorManager);
|
||||
~CppLocatorFilter();
|
||||
|
||||
QString trName() const { return tr("Classes and Methods"); }
|
||||
QString name() const { return QLatin1String("Classes and Methods"); }
|
||||
Priority priority() const { return Medium; }
|
||||
QList<QuickOpen::FilterEntry> matchesFor(const QString &entry);
|
||||
void accept(QuickOpen::FilterEntry selection) const;
|
||||
QList<Locator::FilterEntry> matchesFor(const QString &entry);
|
||||
void accept(Locator::FilterEntry selection) const;
|
||||
void refresh(QFutureInterface<void> &future);
|
||||
|
||||
protected:
|
||||
@@ -86,4 +86,4 @@ private:
|
||||
} // namespace Internal
|
||||
} // namespace CppTools
|
||||
|
||||
#endif // CPPQUICKOPENFILTER_H
|
||||
#endif // CPPLOCATORFILTER_H
|
||||
@@ -1,7 +1,7 @@
|
||||
TEMPLATE = lib
|
||||
TARGET = CppTools
|
||||
include(../../qtcreatorplugin.pri)
|
||||
include(../../plugins/quickopen/quickopen.pri)
|
||||
include(../../plugins/locator/locator.pri)
|
||||
include(cpptools_dependencies.pri)
|
||||
|
||||
# DEFINES += QT_NO_CAST_FROM_ASCII
|
||||
@@ -15,7 +15,7 @@ HEADERS += completionsettingspage.h \
|
||||
cppfunctionsfilter.h \
|
||||
cppmodelmanager.h \
|
||||
cppmodelmanagerinterface.h \
|
||||
cppquickopenfilter.h \
|
||||
cpplocatorfilter.h \
|
||||
cpptools_global.h \
|
||||
cpptoolsconstants.h \
|
||||
cpptoolseditorsupport.h \
|
||||
@@ -31,7 +31,7 @@ SOURCES += completionsettingspage.cpp \
|
||||
cppcurrentdocumentfilter.cpp \
|
||||
cppfunctionsfilter.cpp \
|
||||
cppmodelmanager.cpp \
|
||||
cppquickopenfilter.cpp \
|
||||
cpplocatorfilter.cpp \
|
||||
cpptoolseditorsupport.cpp \
|
||||
cpptoolsplugin.cpp \
|
||||
searchsymbols.cpp \
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include "cppcurrentdocumentfilter.h"
|
||||
#include "cppmodelmanager.h"
|
||||
#include "cpptoolsconstants.h"
|
||||
#include "cppquickopenfilter.h"
|
||||
#include "cpplocatorfilter.h"
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
@@ -104,9 +104,9 @@ bool CppToolsPlugin::initialize(const QStringList &arguments, QString *error)
|
||||
|
||||
addAutoReleasedObject(new CppQuickFixCollector(m_modelManager));
|
||||
|
||||
CppQuickOpenFilter *quickOpenFilter = new CppQuickOpenFilter(m_modelManager,
|
||||
CppLocatorFilter *locatorFilter = new CppLocatorFilter(m_modelManager,
|
||||
core->editorManager());
|
||||
addAutoReleasedObject(quickOpenFilter);
|
||||
addAutoReleasedObject(locatorFilter);
|
||||
addAutoReleasedObject(new CppClassesFilter(m_modelManager, core->editorManager()));
|
||||
addAutoReleasedObject(new CppFunctionsFilter(m_modelManager, core->editorManager()));
|
||||
addAutoReleasedObject(new CppCurrentDocumentFilter(m_modelManager, core->editorManager()));
|
||||
|
||||
Reference in New Issue
Block a user