diff options
| author | Stephen Kelly <[email protected]> | 2014-06-17 11:33:58 +0200 |
|---|---|---|
| committer | Stephen Kelly <[email protected]> | 2014-06-17 16:06:01 +0200 |
| commit | d70485180a676c3d97108bb87ec1c32223ee0f2b (patch) | |
| tree | 90013340cc3f62dad8ae6d97961d0b3fae2d9935 /src | |
| parent | 924edb3d6153f71cf83d97cedd461de1aa414494 (diff) | |
CMake: Load context-sensitive help.
CMake 3 uses reStructuredText and Sphinx for documentation. Those
tools can generate Qt qch files, which makes it possible to load
the documentation in QtCreator and to enable context-sensitive
help when editing a cmake language file.
Add a simple parser to process commands. This may be extended in the
future to process variables and properties too.
Change-Id: Ic5a49a9ce828ad9a9e8ff4805b48302ee73bcc71
Reviewed-by: Daniel Teske <[email protected]>
Reviewed-by: Nikita Baryshnikov <[email protected]>
Diffstat (limited to 'src')
| -rw-r--r-- | src/plugins/cmakeprojectmanager/cmakeeditor.cpp | 42 | ||||
| -rw-r--r-- | src/plugins/cmakeprojectmanager/cmakeeditor.h | 2 |
2 files changed, 44 insertions, 0 deletions
diff --git a/src/plugins/cmakeprojectmanager/cmakeeditor.cpp b/src/plugins/cmakeprojectmanager/cmakeeditor.cpp index 3552ac7c848..46c26cdf351 100644 --- a/src/plugins/cmakeprojectmanager/cmakeeditor.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeeditor.cpp @@ -106,6 +106,48 @@ void CMakeEditor::build() } } +QString CMakeEditor::contextHelpId() const +{ + int pos = position(); + TextEditor::ITextEditorDocument* doc = const_cast<CMakeEditor*>(this)->textDocument(); + + QChar chr; + do { + --pos; + if (pos < 0) + break; + chr = doc->characterAt(pos); + if (chr == QLatin1Char('(')) + return QString(); + } while (chr.unicode() != QChar::ParagraphSeparator); + + ++pos; + chr = doc->characterAt(pos); + while (chr.isSpace()) { + ++pos; + chr = doc->characterAt(pos); + } + int begin = pos; + + do { + ++pos; + chr = doc->characterAt(pos); + } while (chr.isLetterOrNumber() || chr == QLatin1Char('_')); + int end = pos; + + while (chr.isSpace()) { + ++pos; + chr = doc->characterAt(pos); + } + + // Not a command + if (chr != QLatin1Char('(')) + return QString(); + + QString command = doc->textAt(begin, end - begin).toLower(); + return QLatin1String("command/") + command; +} + // // CMakeEditor // diff --git a/src/plugins/cmakeprojectmanager/cmakeeditor.h b/src/plugins/cmakeprojectmanager/cmakeeditor.h index 412e186dc39..618f2103ddb 100644 --- a/src/plugins/cmakeprojectmanager/cmakeeditor.h +++ b/src/plugins/cmakeprojectmanager/cmakeeditor.h @@ -55,6 +55,8 @@ public: Core::IEditor *duplicate(); TextEditor::CompletionAssistProvider *completionAssistProvider(); + QString contextHelpId() const; + private slots: void markAsChanged(); void build(); |
