Commit d7048518 authored by Stephen Kelly's avatar Stephen Kelly

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: default avatarDaniel Teske <daniel.teske@digia.com>
Reviewed-by: default avatarNikita Baryshnikov <nib952051@gmail.com>
parent 924edb3d
......@@ -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
//
......
......@@ -55,6 +55,8 @@ public:
Core::IEditor *duplicate();
TextEditor::CompletionAssistProvider *completionAssistProvider();
QString contextHelpId() const;
private slots:
void markAsChanged();
void build();
......
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