Changeset View
Changeset View
Standalone View
Standalone View
plugins/qmljs/kdevqmljsplugin.cpp
Show First 20 Lines • Show All 171 Lines • ▼ Show 20 Line(s) | 170 | KTextEditor::Range( | |||
---|---|---|---|---|---|
172 | KTextEditor::Cursor(position.line(), col_offset - value.size() - 1 + spacesAtCorner(key, -1)) | 172 | KTextEditor::Cursor(position.line(), col_offset - value.size() - 1 + spacesAtCorner(key, -1)) | ||
173 | ), | 173 | ), | ||
174 | KTextEditor::Range( | 174 | KTextEditor::Range( | ||
175 | KTextEditor::Cursor(position.line(), col_offset - value.size() + spacesAtCorner(value, +1)), | 175 | KTextEditor::Cursor(position.line(), col_offset - value.size() + spacesAtCorner(value, +1)), | ||
176 | KTextEditor::Cursor(position.line(), col_offset + spacesAtCorner(value, -1)) | 176 | KTextEditor::Cursor(position.line(), col_offset + spacesAtCorner(value, -1)) | ||
177 | )); | 177 | )); | ||
178 | } | 178 | } | ||
179 | 179 | | |||
180 | QWidget* KDevQmlJsPlugin::specialLanguageObjectNavigationWidget(const QUrl& url, const KTextEditor::Cursor& position) | 180 | QPair<QWidget*, KTextEditor::Range> KDevQmlJsPlugin::specialLanguageObjectNavigationWidget(const QUrl& url, const KTextEditor::Cursor& position) | ||
181 | { | 181 | { | ||
182 | IDocument* doc = ICore::self()->documentController()->documentForUrl(url); | 182 | IDocument* doc = ICore::self()->documentController()->documentForUrl(url); | ||
183 | if ( doc && doc->textDocument() ) { | 183 | if ( doc && doc->textDocument() ) { | ||
184 | // Check for a QML property, and construct a property preview widget | 184 | // Check for a QML property, and construct a property preview widget | ||
185 | // if the property key is listed in the supported properties. | 185 | // if the property key is listed in the supported properties. | ||
186 | QPair<KTextEditor::Range, KTextEditor::Range> property = parseProperty(doc->textDocument()->line(position.line()), position); | 186 | QPair<KTextEditor::Range, KTextEditor::Range> property = parseProperty(doc->textDocument()->line(position.line()), position); | ||
187 | if ( property.first.isValid() && property.second.isValid() ) { | 187 | if ( property.first.isValid() && property.second.isValid() ) { | ||
188 | Declaration* decl = DUChainUtils::itemUnderCursor(url, property.first.start()).declaration; | 188 | const auto itemUnderCursor = DUChainUtils::itemUnderCursor(url, property.first.start()); | ||
189 | 189 | | |||
190 | return PropertyPreviewWidget::constructIfPossible( | 190 | return {PropertyPreviewWidget::constructIfPossible( | ||
191 | doc->textDocument(), | 191 | doc->textDocument(), | ||
192 | property.first, | 192 | property.first, | ||
193 | property.second, | 193 | property.second, | ||
194 | decl, | 194 | itemUnderCursor.declaration, | ||
195 | textFromDoc(doc, property.first), | 195 | textFromDoc(doc, property.first), | ||
196 | textFromDoc(doc, property.second) | 196 | textFromDoc(doc, property.second) | ||
197 | ); | 197 | ), itemUnderCursor.range}; | ||
198 | } | 198 | } | ||
199 | } | 199 | } | ||
200 | // Otherwise, display no special "navigation" widget. | 200 | // Otherwise, display no special "navigation" widget. | ||
201 | return KDevelop::ILanguageSupport::specialLanguageObjectNavigationWidget(url, position); | 201 | return KDevelop::ILanguageSupport::specialLanguageObjectNavigationWidget(url, position); | ||
202 | } | 202 | } | ||
203 | 203 | | |||
204 | #include "kdevqmljsplugin.moc" | 204 | #include "kdevqmljsplugin.moc" |