forked from qt-creator/qt-creator
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 <daniel.teske@digia.com> Reviewed-by: Nikita Baryshnikov <nib952051@gmail.com>
This commit is contained in:
@@ -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
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user