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
|
// CMakeEditor
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -55,6 +55,8 @@ public:
|
|||||||
Core::IEditor *duplicate();
|
Core::IEditor *duplicate();
|
||||||
TextEditor::CompletionAssistProvider *completionAssistProvider();
|
TextEditor::CompletionAssistProvider *completionAssistProvider();
|
||||||
|
|
||||||
|
QString contextHelpId() const;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void markAsChanged();
|
void markAsChanged();
|
||||||
void build();
|
void build();
|
||||||
|
|||||||
Reference in New Issue
Block a user