server_responses.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #!/usr/bin/env python
  2. #
  3. # Copyright (C) 2013 Strahinja Val Markovic <val@markovic.io>
  4. #
  5. # This file is part of YouCompleteMe.
  6. #
  7. # YouCompleteMe is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation, either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # YouCompleteMe is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
  19. def BuildGoToResponse( filepath, line_num, column_num, description = None ):
  20. response = {
  21. 'filepath': filepath,
  22. 'line_num': line_num,
  23. 'column_num': column_num
  24. }
  25. if description:
  26. response[ 'description' ] = description
  27. return response
  28. def BuildDescriptionOnlyGoToResponse( text ):
  29. return {
  30. 'description': text,
  31. }
  32. def BuildDisplayMessageResponse( text ):
  33. return {
  34. 'message': text
  35. }
  36. def BuildCompletionData( insertion_text,
  37. extra_menu_info = None,
  38. detailed_info = None,
  39. menu_text = None,
  40. kind = None ):
  41. completion_data = {
  42. 'insertion_text': insertion_text
  43. }
  44. if extra_menu_info:
  45. completion_data[ 'extra_menu_info' ] = extra_menu_info
  46. if menu_text:
  47. completion_data[ 'menu_text' ] = menu_text
  48. if detailed_info:
  49. completion_data[ 'detailed_info' ] = detailed_info
  50. if kind:
  51. completion_data[ 'kind' ] = kind
  52. return completion_data
  53. def BuildDiagnosticData( filepath,
  54. line_num,
  55. column_num,
  56. text,
  57. kind ):
  58. return {
  59. 'filepath': filepath,
  60. 'line_num': line_num,
  61. 'column_num': column_num,
  62. 'text': text,
  63. 'kind': kind
  64. }