File: 15-use-system-tssserver.patch

package info (click to toggle)
ycmd 0%2B20240823%2Bgit8b61f19%2Bds-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,040 kB
  • sloc: python: 44,018; cpp: 6,138; java: 486; sh: 378; cs: 207; javascript: 150; ansic: 82; makefile: 45; xml: 18; objc: 10
file content (120 lines) | stat: -rw-r--r-- 4,968 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
Description: Use tsserver from node-typescript package
Author: David Kalnischkies <donkult@debian.org>
Forwarded: not-needed

--- a/ycmd/completers/typescript/typescript_completer.py
+++ b/ycmd/completers/typescript/typescript_completer.py
@@ -38,10 +38,6 @@
 
 RESPONSE_TIMEOUT_SECONDS = 20
 
-TSSERVER_DIR = os.path.abspath(
-  os.path.join( os.path.dirname( __file__ ), '..', '..', '..', 'third_party',
-                'tsserver' ) )
-
 LOGFILE_FORMAT = 'tsserver_'
 
 
@@ -73,18 +69,12 @@
 
 
 def FindTSServer( user_options_path ):
-  tsserver = utils.FindExecutableWithFallback( user_options_path , None )
-  if tsserver and os.path.isfile( tsserver ):
-    return tsserver
-  # The TSServer executable is installed at the root directory on Windows while
-  # it's installed in the bin folder on other platforms.
-  for executable in [ os.path.join( TSSERVER_DIR,
-                                    'node_modules',
-                                    '.bin',
-                                    'tsserver' ),
-                      'tsserver' ]:
-    tsserver = utils.FindExecutable( executable )
-    if tsserver:
+  if user_options_path:
+      return utils.FindExecutableWithFallback( user_options_path , None )
+  if not os.path.exists( '/usr/share/nodejs/typescript/lib/tsserver.js' ):
+    return None
+  for tsserver in [ '/usr/lib/ycmd/tsserverwrapper', ]:
+    if os.path.exists( tsserver ):
       return tsserver
   return None
 
@@ -92,8 +82,7 @@
 def ShouldEnableTypeScriptCompleter( user_options ):
   tsserver = FindTSServer( user_options[ 'tsserver_binary_path' ] )
   if not tsserver:
-    LOGGER.error( 'Not using TypeScript completer: TSServer not installed '
-                  'in %s', TSSERVER_DIR )
+    LOGGER.error( 'Not using TypeScript completer as package node-typescript is not installed' )
     return False
   LOGGER.info( 'Using TypeScript completer with %s', tsserver )
   return True
@@ -282,10 +271,12 @@
     # At the time of writing, 'Content-Length' is the only supplied header.
     headers = {}
     while True:
-      headerline = self._tsserver_handle.stdout.readline().strip()
+      headerline = utils.ToUnicode(self._tsserver_handle.stdout.readline().strip())
       if not headerline:
         break
-      key, value = utils.ToUnicode( headerline ).split( ':', 1 )
+      if headerline.startswith('npm WARN npm'):
+        continue
+      key, value = headerline.split( ':', 1 )
       headers[ key.strip() ] = value.strip()
 
     # The response message is a JSON object which comes back on one line.
--- a/ycmd/tests/typescript/typescript_completer_test.py
+++ b/ycmd/tests/typescript/typescript_completer_test.py
@@ -24,6 +24,7 @@
     ShouldEnableTypeScriptCompleter,
     FindTSServer )
 from ycmd.tests.typescript import setUpModule, tearDownModule # noqa
+from ycmd.tests.test_utils import NotDebian
 
 
 class TypescriptCompleterTest( TestCase ):
@@ -32,6 +33,7 @@
     assert_that( ShouldEnableTypeScriptCompleter( user_options ) )
 
 
+  @NotDebian
   @patch( 'ycmd.utils.FindExecutable', return_value = None )
   def test_ShouldEnableTypeScriptCompleter_TsserverNotFound( self, *args ):
     user_options = user_options_store.GetAll()
--- a/ycmd/tests/javascriptreact/get_completions_test.py
+++ b/ycmd/tests/javascriptreact/get_completions_test.py
@@ -17,7 +17,7 @@
 
 import pprint
 import requests
-from hamcrest import assert_that, equal_to, has_entries, has_item
+from hamcrest import any_of, assert_that, equal_to, has_entries, has_item
 from ycmd.tests.javascriptreact import setUpModule, tearDownModule # noqa
 from ycmd.tests.javascriptreact import PathToTestFile, SharedYcmd
 from ycmd.tests.test_utils import CombineRequest
@@ -72,14 +72,21 @@
           'completions': has_item( has_entries( {
             'insertion_text':  'alinkColor',
             'extra_menu_info': '(property) Document.alinkColor: string',
-             'detailed_info':  '(property) Document.alinkColor: string\n'
+            'detailed_info':  any_of(equal_to(
+                               '(property) Document.alinkColor: string\n'
+                               '\n'
+                               'Sets or gets the color of all active links '
+                               'in the document.\n'
+                               '\n'
+                               'deprecated'), equal_to(
+                               '(property) Document.alinkColor: string\n'
                                '\n'
                                'Sets or gets the color of all active links '
                                'in the document.\n'
                                '\n'
                                'deprecated: [MDN Reference]'
                                '(https://developer.mozilla.org/docs/Web/'
-                               'API/Document/alinkColor)',
+                               'API/Document/alinkColor)')),
             'kind':            'property',
           } ) )
         } )