sql-lint.js 968 B

12345678910111213141516171819202122232425262728293031323334
  1. CodeMirror.sqlLint = function (text, updateLinting, options, cm) {
  2. // Skipping check if text box is empty.
  3. if (text.trim() === '') {
  4. updateLinting(cm, []);
  5. return;
  6. }
  7. function handleResponse(response) {
  8. var found = [];
  9. for (var idx in response) {
  10. found.push({
  11. // eslint-disable-next-line new-cap
  12. from: CodeMirror.Pos(response[idx].fromLine, response[idx].fromColumn),
  13. // eslint-disable-next-line new-cap
  14. to: CodeMirror.Pos(response[idx].toLine, response[idx].toColumn),
  15. messageHTML: response[idx].message,
  16. severity: response[idx].severity
  17. });
  18. }
  19. updateLinting(cm, found);
  20. }
  21. $.ajax({
  22. method: 'POST',
  23. url: 'index.php?route=/lint',
  24. dataType: 'json',
  25. data: {
  26. 'sql_query': text,
  27. 'server': CommonParams.get('server'),
  28. 'options': options.lintOptions,
  29. 'no_history': true,
  30. 'ajax_request': true
  31. },
  32. success: handleResponse
  33. });
  34. };