Commit e8fab22a authored by Nikolai Kosjar's avatar Nikolai Kosjar

C++: Disable "Replace Dot for Arrow" auto-correction for ObjC sources

In the light of Obj-C properties this seems to annoy more than to help.

Change-Id: I48f92d505035369f48e8798d0972ef00306bdde0
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@digia.com>
parent db5f2f14
......@@ -201,9 +201,10 @@ IAssistProcessor *ClangCompletionAssistProvider::createProcessor() const
IAssistInterface *ClangCompletionAssistProvider::createAssistInterface(
ProjectExplorer::Project *project, TextEditor::BaseTextEditor *editor,
QTextDocument *document, int position, AssistReason reason) const
QTextDocument *document, bool isObjCEnabled, int position, AssistReason reason) const
{
Q_UNUSED(project);
Q_UNUSED(isObjCEnabled);
QString fileName = editor->document()->filePath();
CppModelManagerInterface *modelManager = CppModelManagerInterface::instance();
......
......@@ -58,7 +58,8 @@ public:
virtual TextEditor::IAssistProcessor *createProcessor() const;
virtual TextEditor::IAssistInterface *createAssistInterface(
ProjectExplorer::Project *project, TextEditor::BaseTextEditor *editor,
QTextDocument *document, int position, TextEditor::AssistReason reason) const;
QTextDocument *document, bool isObjCEnabled, int position,
TextEditor::AssistReason reason) const;
private:
ClangCodeModel::ClangCompleter::Ptr m_clangCompletionWrapper;
......
......@@ -1621,7 +1621,8 @@ TextEditor::IAssistInterface *CPPEditorWidget::createAssistInterface(
if (cap) {
return cap->createAssistInterface(
ProjectExplorer::ProjectExplorerPlugin::currentProject(),
editor(), document(), position(), reason);
editor(), document(), cppEditorDocument()->isObjCEnabled(), position(),
reason);
}
} else if (kind == TextEditor::QuickFix) {
if (!semanticInfo().doc || isOutdated())
......
......@@ -422,14 +422,15 @@ IAssistProcessor *InternalCompletionAssistProvider::createProcessor() const
TextEditor::IAssistInterface *InternalCompletionAssistProvider::createAssistInterface(
ProjectExplorer::Project *project, BaseTextEditor *editor, QTextDocument *document,
int position, TextEditor::AssistReason reason) const
bool isObjCEnabled, int position, TextEditor::AssistReason reason) const
{
Q_UNUSED(project);
QTC_ASSERT(editor, return 0);
QTC_ASSERT(document, return 0);
CppModelManagerInterface *modelManager = CppModelManagerInterface::instance();
return new CppTools::Internal::CppCompletionAssistInterface(editor, document, position, reason,
return new CppTools::Internal::CppCompletionAssistInterface(editor, document, isObjCEnabled,
position, reason,
modelManager->workingCopy());
}
......@@ -1409,10 +1410,14 @@ bool CppCompletionAssistProcessor::completeMember(const QList<CPlusPlus::LookupI
ResolveExpression resolveExpression(context);
bool *replaceDotForArrow = 0;
if (!m_interface->isObjCEnabled())
replaceDotForArrow = &m_model->m_replaceDotForArrow;
if (ClassOrNamespace *binding =
resolveExpression.baseExpression(baseResults,
m_model->m_completionOperator,
&m_model->m_replaceDotForArrow)) {
replaceDotForArrow)) {
if (binding)
completeClass(binding, /*static lookup = */ true);
......
......@@ -94,13 +94,12 @@ class InternalCompletionAssistProvider : public CppCompletionAssistProvider
public:
TextEditor::IAssistProcessor *createProcessor() const QTC_OVERRIDE;
TextEditor::IAssistInterface *createAssistInterface(
ProjectExplorer::Project *project,
TextEditor::IAssistInterface *createAssistInterface(ProjectExplorer::Project *project,
TextEditor::BaseTextEditor *editor,
QTextDocument *document,
bool isObjCEnabled,
int position,
TextEditor::AssistReason reason) const QTC_OVERRIDE;
};
class CppCompletionAssistProcessor : public TextEditor::IAssistProcessor
......@@ -175,12 +174,14 @@ class CppCompletionAssistInterface : public TextEditor::DefaultAssistInterface
public:
CppCompletionAssistInterface(TextEditor::BaseTextEditor *editor,
QTextDocument *textDocument,
bool isObjCEnabled,
int position,
TextEditor::AssistReason reason,
const CppModelManagerInterface::WorkingCopy &workingCopy)
: TextEditor::DefaultAssistInterface(textDocument, position, editor->document()->filePath(),
reason)
, m_editor(editor)
, m_isObjCEnabled(isObjCEnabled)
, m_gotCppSpecifics(false)
, m_workingCopy(workingCopy)
{}
......@@ -194,12 +195,15 @@ public:
const QStringList &frameworkPaths)
: TextEditor::DefaultAssistInterface(textDocument, position, fileName, reason)
, m_editor(0)
, m_isObjCEnabled(false)
, m_gotCppSpecifics(true)
, m_snapshot(snapshot)
, m_includePaths(includePaths)
, m_frameworkPaths(frameworkPaths)
{}
bool isObjCEnabled() const { return m_isObjCEnabled; }
const CPlusPlus::Snapshot &snapshot() const { getCppSpecifics(); return m_snapshot; }
const QStringList &includePaths() const { getCppSpecifics(); return m_includePaths; }
const QStringList &frameworkPaths() const { getCppSpecifics(); return m_frameworkPaths; }
......@@ -208,6 +212,7 @@ private:
void getCppSpecifics() const;
TextEditor::BaseTextEditor *m_editor;
mutable bool m_isObjCEnabled;
mutable bool m_gotCppSpecifics;
CppModelManagerInterface::WorkingCopy m_workingCopy;
mutable CPlusPlus::Snapshot m_snapshot;
......
......@@ -62,7 +62,8 @@ public:
virtual TextEditor::IAssistInterface *createAssistInterface(
ProjectExplorer::Project *project, TextEditor::BaseTextEditor *editor,
QTextDocument *document, int position, TextEditor::AssistReason reason) const = 0;
QTextDocument *document, bool isObjCEnabled, int position,
TextEditor::AssistReason reason) const = 0;
static int activationSequenceChar(const QChar &ch, const QChar &ch2,
const QChar &ch3, unsigned *kind,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment