Commit 37f6b439 authored by Eike Ziller's avatar Eike Ziller
Browse files

Merge remote-tracking branch 'origin/3.5'

Change-Id: I1ce0fa92e5c469d591d3030d1a4f168dcee232ba
parents d567dfff 053b2b64
doc/images/qtcreator-add-online-doc.png

8.51 KB | W: | H:

doc/images/qtcreator-add-online-doc.png

11.2 KB | W: | H:

doc/images/qtcreator-add-online-doc.png
doc/images/qtcreator-add-online-doc.png
doc/images/qtcreator-add-online-doc.png
doc/images/qtcreator-add-online-doc.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -55,19 +55,20 @@
\endlist
An IDE needs a parser for the language and the semantic analyzes. The only
difference between a code model and a compiler is that a code model does not
generate an executable.
An IDE needs a parser for the language and the semantic analyzes.
As \l{http://clang.llvm.org/}{Clang} is a compiler, as well as a code model,
it provides accurate information. The feedback you get through warning and
error markers is the same as the compiler will give you, not an incomplete
\section1 Using Clang Code Model
The \l{http://clang.llvm.org/}{Clang} project provides libraries for parsing
C and C++ source files. The feedback you get through warning and
error markers is the same as a compiler will give you, not an incomplete
set or a close approximation, as when using the built-in \QC code model.
Clang focuses on detailed information for diagnostics, which is really
useful if the code contains typos, for example.
Also, Clang already supports C++98/03, C89 and C99, Objective-C (and
Objective-C++), and C++11 support is in active development.
Clang keeps up with the development of the C++ language. At the time of this
writing, it supports C++98/03, C++11, C++14, C89, C99, Objective-C, and
Objective-C++.
On the downside, for large projects using Clang as code model is slower than
using the built-in code model. Clang does not need to generate object files,
......@@ -84,14 +85,14 @@
\list
\li Highlighting
\li Code completion
\li Syntactic and semantic highlighting
\endlist
To use the plugin, you must build it and configure it in \QC.
\section1 Building Clang Code Model Plugin
\section2 Building Clang Code Model Plugin
\list 1
......@@ -138,7 +139,7 @@
\li Installed via package manager on Linux:
\c {LLVM_INSTALL_DIR=/usr/lib/llvm-3.4}
\c {LLVM_INSTALL_DIR=/usr/lib/llvm-3.6}
\li Manually built on Unix in release mode:
......@@ -154,7 +155,7 @@
\endlist
\section1 Configuring Clang Code Model Plugin
\section2 Configuring Clang Code Model Plugin
\list 1
......
......@@ -168,8 +168,8 @@
\key {Ctrl+E,F2} to follow the symbol in the next split. If necessary, the
view is automatically split. To change the default behavior, select
\uicontrol Tools > \uicontrol Options > \uicontrol {Text Editor} >
\uicontrol Display, and then select
\uicontrol {Always Open Links in Next Split}. Additional symbols are
\uicontrol Display > \uicontrol {Always open links in another split}.
Additional symbols are
displayed and switching between definition and declaration is done in
another split. If you change the default behavior, the shortcuts for opening
link targets in the next split are used to open them in the current split.
......@@ -197,5 +197,5 @@
\QC underlines semantic errors in olive in the C++ code editor. To check the
correct paths for includes that are not resolved or that are resolved to the
wrong file, select \uicontrol {Project Parts} > \uicontrol {Include Paths}.
wrong file, select \uicontrol {Project Parts} > \uicontrol {Header Paths}.
*/
......@@ -787,9 +787,9 @@
Select \uicontrol Tools > \uicontrol Options > \uicontrol {Text Editor}
> \uicontrol Completion.
By default, code completion considers only the first letter case-sensitive.
To apply full or no case-sensitivity, select the option in the
\uicontrol {Case-sensitivity} field.
By default, code completion does not consider case. To apply full or
first-letter case-sensitivity, select \uicontrol Full or
\uicontrol {First Letter} in the \uicontrol {Case-sensitivity} field.
\section2 Summary of Available Types
......@@ -1291,7 +1291,8 @@
\section2 Specifying Tabs and Indentation
You can specify tab policy and tab size in the \uicontrol Typing group. In
You can specify tab policy and tab size in the
\uicontrol {Tabs and Indentation} group. In
the \uicontrol {Tab policy} field, select whether to use only spaces or
only tabs for indentation, or to use a mixture of them.
......@@ -1416,7 +1417,7 @@
\li To search only whole words, select \uicontrol {Whole Words Only}.
\li To search using regular expressions, select
\uicontrol {Regular Expressions}. Regular expressions used in \QC
\uicontrol {Use Regular Expressions}. Regular expressions used in \QC
are modeled on Perl regular expressions. For more information on
using regular expressions, see the documentation for the
QRegularExpression Class.
......@@ -1444,7 +1445,7 @@
The \uicontrol {Preserve Case when Replacing} option can be selected to
preserve the case of the original text when replacing. This option is not
compatible with the \uicontrol {Regular Expressions} search option, and will
compatible with the \uicontrol {Use Regular Expressions} search option, and will
thus be disabled when regular expressions are used. When the option is used,
the case of the occurrence will be conserved, according to the following
rules:
......@@ -1469,7 +1470,7 @@
The locations of search hits, breakpoints, and bookmarks in your document
are highlighted on the editor scroll bar. To turn highlighting off, select
\uicontrol Tools > \uicontrol Options > \uicontrol {Text Editor} >
\uicontrol {Highlight search results on the scrollbar}.
\uicontrol Display > \uicontrol {Highlight search results on the scrollbar}.
\section1 Advanced Search
......@@ -2532,8 +2533,8 @@
\li Specify the prefix string.
\li To show only results matching this filter, select
\uicontrol {Limit to prefix}.
\li To implicitly include the filter even when not typing a prefix as a
part of the search string, select \uicontrol {Include by default}.
\li Specify other available options. For more information, see
\l{Adding Web Search Engines}.
......@@ -2601,8 +2602,9 @@
\li Specify the prefix string.
To show only results matching this filter, select
\uicontrol {Limit to prefix}.
To implicitly include the filter even when not typing a prefix
as a part of the search string, select
\uicontrol {Include by default}.
\image qtcreator-navigate-customfilter.png
......
......@@ -50,19 +50,20 @@
and integrated into \QC. The correct folder to place the plugins depends on
whether you use the standalone \QD or the integrated \QD.
The integrated \QD fetches plugins from the \c {%SDK%\bin\designer} folder
on Windows and Linux. For information about how to configure plugins on
OS X, see \l{Configuring Qt Designer Plugins on OS X}.
The integrated \QD fetches plugins from the \c {\bin\plugins\designer}
directory in the \QC installation directory on Windows and Linux. For
information about how to configure plugins on OS X, see
\l{Configuring Qt Designer Plugins on OS X}.
To check which plugins
were loaded successfully and which failed, choose \uicontrol{Tools > Form Editor >
About Qt Designer Plugins}.
To check which plugins were loaded successfully and which failed, choose
\uicontrol Tools > \uicontrol {Form Editor} >
\uicontrol {About Qt Designer Plugins}.
The standalone \QD is part of the Qt library used for building projects,
located under \c {%SDK%\qt}. Therefore, it fetches plugins from the
following folder: \c {%SDK%\qt\plugins\designer}. To check which plugins
were loaded successfully and which failed, choose \uicontrol{Help >
About Plugins}.
located in \c {<Qt_version>\<compiler>\bin} in the Qt installation
directory. It fetches plugins from the \c {\plugins\designer} subdirectory
of \c bin. To check which plugins were loaded successfully and which failed,
choose \uicontrol Help > \uicontrol {About Plugins}.
\section2 Configuring Qt Designer Plugins on OS X
......
#!/bin/sh
################################################################################
# Copyright (C) 2015 The Qt Company Ltd.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of The Qt Company Ltd, nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
################################################################################
# --- helpers -----------------------------------------------------------------
printUsage()
{
echo "Usage: $0 [-v] [-c clang-executable] file line column"
echo
echo "Options:"
echo " -v Run c-index-test instead of clang to get more details."
echo " -c clang-executable Use the provided clang-executable."
echo
echo "The clang executable is determined by this order:"
echo " 1. Use clang from the -c option."
echo " 2. Use clang from environment variable CLANG_FOR_COMPLETION."
echo " 3. Use clang from \$PATH."
echo
echo "Path to c-index-test will be determined with the help of the clang executable."
}
# There is no readlink on cygwin.
hasReadLink()
{
return $(command -v readlink >/dev/null 2>&1)
}
checkIfFileExistsOrDie()
{
[ ! -f "$1" ] && echo "'$1' is not a file or does not exist." && exit 1
}
checkIfFileExistsAndIsExecutableOrDie()
{
checkIfFileExistsOrDie "$1"
[ ! -x "$1" ] && echo "'$1' is not executable." && exit 2
}
findClangOrDie()
{
if [ -z "$CLANG_EXEC" ]; then
if [ -n "${CLANG_FOR_COMPLETION}" ]; then
CLANG_EXEC=${CLANG_FOR_COMPLETION}
else
CLANG_EXEC=$(which clang)
fi
fi
hasReadLink && CLANG_EXEC=$(readlink -e "$CLANG_EXEC")
checkIfFileExistsAndIsExecutableOrDie "$CLANG_EXEC"
}
findCIndexTestOrDie()
{
if [ -n "$RUN_WITH_CINDEXTEST" ]; then
CINDEXTEST_EXEC=$(echo $CLANG_EXEC | sed -e 's/clang/c-index-test/g')
hasReadLink && CINDEXTEST_EXEC=$(readlink -e "$CINDEXTEST_EXEC")
checkIfFileExistsAndIsExecutableOrDie "$CINDEXTEST_EXEC"
fi
}
printClangVersion()
{
command="${CLANG_EXEC} --version"
echo "Command: $command"
eval $command
}
runCodeCompletion()
{
if [ -n "${CINDEXTEST_EXEC}" ]; then
command="${CINDEXTEST_EXEC} -code-completion-at=${FILE}:${LINE}:${COLUMN} ${FILE}"
else
command="${CLANG_EXEC} -cc1 -code-completion-at ${FILE}:${LINE}:${COLUMN} ${FILE}"
fi
echo "Command: $command"
eval $command
}
# --- Process arguments -------------------------------------------------------
CLANG_EXEC=
RUN_WITH_CINDEXTEST=
FILE=
LINE=
COLUMN=
while [ -n "$1" ]; do
param=$1
shift
case $param in
-h | -help | --help)
printUsage
exit 0
;;
-v | -verbose | --verbose)
RUN_WITH_CINDEXTEST=1
;;
-c | -clang | --clang)
CLANG_EXEC=$1
shift
;;
*)
break;
;;
esac
done
[ "$#" -ne 2 ] && printUsage && exit 1
checkIfFileExistsOrDie "$param"
FILE=$param
LINE=$1
COLUMN=$2
# --- main --------------------------------------------------------------------
findClangOrDie
findCIndexTestOrDie
printClangVersion
echo
runCodeCompletion
......@@ -56,6 +56,6 @@ QtcProduct {
Group {
fileTagsFilter: product.type
qbs.install: true
qbs.installDir: project.ide_app_path
qbs.installDir: project.ide_bin_path
}
}
......@@ -847,7 +847,6 @@ void PluginManagerPrivate::nextDelayedInitialize()
\internal
*/
PluginManagerPrivate::PluginManagerPrivate(PluginManager *pluginManager) :
m_failedTests(0),
delayedInitializeTimer(0),
shutdownEventLoop(0),
m_profileElapsedMS(0),
......@@ -1127,6 +1126,7 @@ void PluginManagerPrivate::startTests()
return;
}
int failedTests = 0;
foreach (const PluginManagerPrivate::TestSpec &testSpec, testSpecs) {
IPlugin *plugin = testSpec.pluginSpec->plugin();
if (!plugin)
......@@ -1144,10 +1144,10 @@ void PluginManagerPrivate::startTests()
? generateCompleteTestPlan(plugin, testObjects)
: generateCustomTestPlan(plugin, testObjects, testSpec.testFunctionsOrObjects);
m_failedTests += executeTestPlan(testPlan);
failedTests += executeTestPlan(testPlan);
}
if (!testSpecs.isEmpty())
QTimer::singleShot(1, this, SLOT(exitWithNumberOfFailedTests()));
QTimer::singleShot(0, this, [failedTests]() { emit m_instance->testsFinished(failedTests); });
}
#endif
......@@ -1270,14 +1270,6 @@ void PluginManagerPrivate::asyncShutdownFinished()
shutdownEventLoop->exit();
}
/*!
\internal
*/
void PluginManagerPrivate::exitWithNumberOfFailedTests()
{
QCoreApplication::exit(m_failedTests);
}
/*!
\internal
*/
......
......@@ -158,6 +158,7 @@ signals:
void pluginsChanged();
void initializationDone();
void testsFinished(int failedTests);
public slots:
void remoteArguments(const QString &serializedArguments, QObject *socket);
......
......@@ -102,7 +102,6 @@ public:
QHash<QString, PluginCollection *> pluginCategories;
QList<PluginSpec *> pluginSpecs;
QList<TestSpec> testSpecs;
int m_failedTests;
QStringList pluginPaths;
QString pluginIID;
QList<QObject *> allObjects; // ### make this a QList<QPointer<QObject> > > ?
......@@ -138,7 +137,6 @@ public:
private slots:
void nextDelayedInitialize();
void asyncShutdownFinished();
void exitWithNumberOfFailedTests();
private:
PluginCollection *defaultCollection;
......
......@@ -440,6 +440,8 @@ Import LinkPrivate::importNonFile(Document::Ptr doc, const ImportInfo &importInf
"Import paths:\n"
"%1\n\n"
"For qmake projects, use the QML_IMPORT_PATH variable to add import paths.\n"
"For qbs projects, declare and set a qmlImportPaths property in your product "
"to add import paths.\n"
"For qmlproject projects, use the importPaths property to add import paths.").arg(
importPaths.join(QLatin1Char('\n'))));
}
......
The ClangCodeModel plugin
=========================
The ClangCodeModel plugin integrates the clang frontend into Qt Creator. Clang
is "a C language family frontend for LLVM". You can find more information at
http://clang.llvm.org/.
At the time of writing the plugin can replace the following functionality of
the built-in code model:
* Highlighting
* Completion
All other functionality relies on the built-in code model (indexing, quick
fixes, follow symbol, find usages, ...).
Setup
=====
Compile the plugin
------------------
1. Get libclang
You need to have libclang (and thus llvm) installed on your system. Either
build llvm/clang yourself [1], install some ready-to-use package [2] or use the
package manager of your system.
[1] http://clang.llvm.org/get_started.html
See http://llvm.org/docs/GettingStarted.html#git-mirror for git mirrors.
[2] http://llvm.org/releases/ or http://llvm.org/builds/
If you are building llvm/clang yourself, make sure to build it in release mode.
2. Set LLVM_INSTALL_DIR and (re)build Qt Creator
Point the LLVM_INSTALL_DIR variable to the build/installation directory of
llvm, e.g.:
Installed via package manager on GNU/Linux:
LLVM_INSTALL_DIR=/usr/lib/llvm-3.4
Manually build on Unix in release mode:
LLVM_INSTALL_DIR=$HOME/llvm-build/Release+Asserts
Installed a snapshot on Windows:
LLVM_INSTALL_DIR=C:\llvm
Set the variable either as part of the build environment or pass it directly to
qmake and rebuild Qt Creator.
Enable the plugin
-----------------
Enable the "ClangCodeModel" plugin in the dialog "Menu: Help -> About Plugins"
and restart Qt Creator.
Select the file types you want to use the ClangCodeModel for in "Menu: Tools ->
Options -> C++ -> Tab: Code Model". For the next opened file matching the
selected file types the ClangCodeModel will be used (see limitations at the
start of this README).
See ../../../doc/src/editors/creator-clang-codemodel.qdoc
......@@ -44,6 +44,7 @@
#include <QDir>
#include <QFile>
#include <QLoggingCategory>
#include <QRegExp>
#include <QSet>
#include <QString>
......@@ -147,7 +148,17 @@ private:
bool excludeHeaderPath(const QString &path) const override
{
return path.contains(QLatin1String("lib/gcc/i686-apple-darwin"));
if (path.contains(QLatin1String("lib/gcc/i686-apple-darwin")))
return true;
// We already provide a custom clang include path matching the used libclang version,
// so better ignore the clang include paths from the system as this might lead to an
// unfavorable order with regard to include_next.
static QRegExp clangIncludeDir(QLatin1String(".*/lib/clang/\\d+\\.\\d+\\.\\d+/include"));
if (clangIncludeDir.exactMatch(path))
return true;
return false;
}
void addResourceDirOptions()
......
......@@ -79,6 +79,16 @@ void CompletionChunksToTextConverter::setAddExtraVerticalSpaceBetweenBraces(bool
m_addExtraVerticalSpaceBetweenBraces = addExtraVerticalSpaceBetweenBraces;
}
void CompletionChunksToTextConverter::setAddHtmlTags(bool addHtmlTags)
{
m_addHtmlTags = addHtmlTags;
}
void CompletionChunksToTextConverter::setAddOptional(bool addOptional)
{
m_addOptional = addOptional;
}
const QString &CompletionChunksToTextConverter::text() const
{
return m_text;
......@@ -99,6 +109,7 @@ QString CompletionChunksToTextConverter::convertToFunctionSignature(const ClangB
CompletionChunksToTextConverter converter;
converter.setAddPlaceHolderText(true);
converter.setAddResultType(true);
converter.setAddOptional(true);
converter.parseChunks(codeCompletionChunks);
......@@ -120,6 +131,9 @@ QString CompletionChunksToTextConverter::convertToToolTip(const ClangBackEnd::Co
converter.setAddPlaceHolderText(true);
converter.setAddSpaces(true);
converter.setAddExtraVerticalSpaceBetweenBraces(true);
converter.setAddOptional(true);
converter.setAddHtmlTags(true);
converter.setAddResultType(true);
converter.parseChunks(codeCompletionChunks);
......@@ -158,11 +172,15 @@ void CompletionChunksToTextConverter::parseText(const Utf8String &text)
void CompletionChunksToTextConverter::parseOptional(const ClangBackEnd::CodeCompletionChunk &optionalCodeCompletionChunk)
{
if (m_addOptional) {
if (m_addHtmlTags)
m_text += QStringLiteral("<i>");
m_text += convertToFunctionSignature(optionalCodeCompletionChunk.optionalChunks());
if (m_addHtmlTags)
m_text += QStringLiteral("</i>");
}
}
void CompletionChunksToTextConverter::parsePlaceHolder(const ClangBackEnd::CodeCompletionChunk &codeCompletionChunk)
......
......@@ -52,6 +52,8 @@ public:
void setAddResultType(bool addResultType);
void setAddSpaces(bool addSpaces);
void setAddExtraVerticalSpaceBetweenBraces(bool addExtraVerticalSpaceBetweenBraces);
void setAddHtmlTags(bool addHtmlTags);
void setAddOptional(bool addOptional);
const QString &text() const;
const std::vector<int> &placeholderPositions() const;
......@@ -83,6 +85,8 @@ private:
bool m_addResultType = false;
bool m_addSpaces = false;
bool m_addExtraVerticalSpaceBetweenBraces = false;
bool m_addHtmlTags = false;
bool m_addOptional = false;
};
} // namespace Internal
......
......@@ -868,8 +868,8 @@ void ClangCodeCompletionTest::testCompleteFunctions()
QVERIFY(hasItem(t.proposal, "void f()"));
QVERIFY(hasItem(t.proposal, "void f(int a)"));
QVERIFY(hasItem(t.proposal, "void f(const QString &s)"));
QVERIFY(hasItem(t.proposal, "void f(char c<i>, int optional</i>)")); // TODO: No default argument?
QVERIFY(hasItem(t.proposal, "void f(char c<i>, int optional1, int optional2</i>)")); // TODO: No default argument?
QVERIFY(hasItem(t.proposal, "void f(char c, int optional)")); // TODO: No default argument?
QVERIFY(hasItem(t.proposal, "void f(char c, int optional1, int optional2)")); // TODO: No default argument?
QVERIFY(hasItem(t.proposal, "void f(const TType<QString> *t)"));
QVERIFY(hasItem(t.proposal, "TType<QString> f(bool)"));
}
......
......@@ -323,6 +323,10 @@ ICore::ICore(MainWindow *mainwindow)
// Save settings once after all plugins are initialized:
connect(PluginManager::instance(), SIGNAL(initializationDone()),
this, SLOT(saveSettings()));
connect(PluginManager::instance(), &PluginManager::testsFinished, [this] (int failedTests) {
emit coreAboutToClose();