jenkins-bot has submitted this change and it was merged.
Change subject: Improve SPARQL hint
......................................................................
Improve SPARQL hint
More SPARQL keywords. More places to complete. Auto complete #.
Change-Id: Ib961117f1f3c530b5f445495850cea0295e948dd
---
M wikibase/queryService/ui/editor/Editor.js
M wikibase/queryService/ui/editor/hint/Sparql.js
2 files changed, 25 insertions(+), 5 deletions(-)
Approvals:
Smalyshev: Looks good to me, approved
jenkins-bot: Verified
diff --git a/wikibase/queryService/ui/editor/Editor.js
b/wikibase/queryService/ui/editor/Editor.js
index fc9d731..44e1bbb 100644
--- a/wikibase/queryService/ui/editor/Editor.js
+++ b/wikibase/queryService/ui/editor/Editor.js
@@ -63,7 +63,8 @@
this._editor.on( 'change', function ( editor, changeObj ) {
self.storeValue( self.getValue() );
self.clearError();
- if( changeObj.text[0] === '?' ){
+ if( changeObj.text[0] === '?' ||
+ changeObj.text[0] === '#' ){
editor.showHint({closeCharacters: /[\s]/});
}
} );
diff --git a/wikibase/queryService/ui/editor/hint/Sparql.js
b/wikibase/queryService/ui/editor/hint/Sparql.js
index d1776dd..af56a4a 100755
--- a/wikibase/queryService/ui/editor/hint/Sparql.js
+++ b/wikibase/queryService/ui/editor/hint/Sparql.js
@@ -12,15 +12,34 @@
var SPARQL_KEYWORDS = [
'SELECT',
'OPTIONAL',
+ 'OPTIONAL {\n\n}',
'WHERE',
+ 'WHERE {\n\n}',
'ORDER',
'ORDER BY',
'DISTINCT',
- 'WHERE {\n\n}',
'SERVICE',
'SERVICE wikibase:label {\n bd:serviceParam
wikibase:language "en" .\n}',
'BASE', 'PREFIX', 'REDUCED', 'FROM', 'LIMIT',
'OFFSET', 'HAVING',
'UNION',
+ 'SAMPLE',
+ '(SAMPLE() AS )',
+ 'COUNT',
+ '(COUNT() AS )',
+ 'DESC',
+ 'DESC()',
+ 'ASC',
+ 'ASC()',
+ 'FILTER ()',
+ 'FILTER NOT EXISTS',
+ 'FILTER NOT EXISTS {\n\n}',
+ 'UNION',
+ 'UNION {\n\n}',
+ 'BIND',
+ 'BIND ()',
+ 'GROUP_CONCAT',
+ '(GROUP_CONCAT() as )',
+ 'ORDER BY',
'#defaultView:Map', '#defaultView:ImageGrid'
];
@@ -67,7 +86,7 @@
var list = [];
$.each( SPARQL_KEYWORDS, function ( key, keyword ) {
- if ( keyword.toLowerCase().indexOf( term.toLowerCase()
) === 0 ) {
+ if ( keyword.toLowerCase().indexOf( term.toLowerCase()
) >= 0 ) {
list.push( keyword );
}
} );
@@ -119,7 +138,7 @@
pos = 0;
}
- while( line.charAt( pos ) !== ' ' ){
+ while( line.charAt( pos ).match(/[\w?#]/) ){
pos--;
if( pos < 0 ){
break;
@@ -128,7 +147,7 @@
var left = pos + 1;
pos = position;
- while( line.charAt( pos ) !== ' ' ){
+ while( line.charAt( pos ).match(/[\w]/) ){
pos++;
if( pos >= line.length ){
break;
--
To view, visit https://gerrit.wikimedia.org/r/278725
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib961117f1f3c530b5f445495850cea0295e948dd
Gerrit-PatchSet: 1
Gerrit-Project: wikidata/query/gui
Gerrit-Branch: master
Gerrit-Owner: Jonas Kress (WMDE) <[email protected]>
Gerrit-Reviewer: Smalyshev <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits