sql-lint.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. from: CodeMirror.Pos(
  12. response[idx].fromLine, response[idx].fromColumn
  13. ),
  14. to: CodeMirror.Pos(
  15. response[idx].toLine, response[idx].toColumn
  16. ),
  17. messageHTML: response[idx].message,
  18. severity : response[idx].severity
  19. });
  20. }
  21. updateLinting(cm, found);
  22. }
  23. $.ajax({
  24. method: 'POST',
  25. url: 'lint.php',
  26. dataType: 'json',
  27. data: {
  28. sql_query: text,
  29. server: PMA_commonParams.get('server'),
  30. options: options.lintOptions,
  31. no_history: true,
  32. },
  33. success: handleResponse
  34. });
  35. };