-set script to "import json,sys\ndef read():\n h={}\n while True:\n line=sys.stdin.buffer.readline()\n if line==b'\\r\\n': break\n n,v=line.decode('ascii').split(':',1);h[n.lower()]=v.strip()\n return json.loads(sys.stdin.buffer.read(int(h['content-length'])))\ndef send(m):\n p=json.dumps(m,separators=(',',':'),ensure_ascii=False).encode();sys.stdout.buffer.write(b'Content-Length: '+str(len(p)).encode()+b'\\r\\n\\r\\n'+p);sys.stdout.buffer.flush()\ninit=read();assert init['method']=='initialize' and init['params']['rootUri']=='file:///workspace';assert init['params']['clientInfo']=={'name':'DynLex'};assert init['params']['capabilities']['general']['positionEncodings']==['utf-16']\nsend({'jsonrpc':'2.0','id':init['id'],'result':{'capabilities':{'positionEncoding':'utf-16','textDocumentSync':{'openClose':True,'change':2,'save':{'includeText':True}},'workspace':{'workspaceFolders':{'supported':True}}},'serverInfo':{'name':'fake'}}})\nassert read()['method']=='initialized'\nopened=read();td=opened['params']['textDocument'];assert opened['method']=='textDocument/didOpen' and td['version']==1 and td['text']=='a😀b\\nline😀'\nchanged=read();assert changed['method']=='textDocument/didChange';assert changed['params']['textDocument']['version']==2;change=changed['params']['contentChanges'][0];assert change['range']=={'start':{'line':0,'character':1},'end':{'line':0,'character':3}} and change['text']=='X'\nreplaced=read();assert replaced['method']=='textDocument/didChange';assert replaced['params']['textDocument']['version']==3;change=replaced['params']['contentChanges'][0];assert change['range']=={'start':{'line':0,'character':0},'end':{'line':1,'character':6}} and change['text']=='final'\nsaved=read();assert saved['method']=='textDocument/didSave' and saved['params']=={'textDocument':{'uri':'file:///workspace/main.dl'},'text':'final'}\nrelated={'location':{'uri':'file:///workspace/other.dl','range':{'start':{'line':1,'character':2},'end':{'line':1,'character':3}}},'message':'related'}\ndiagnostic={'range':{'start':{'line':0,'character':0},'end':{'line':0,'character':1}},'severity':2,'code':7,'codeDescription':{'href':'https://example.invalid/7'},'source':'fake','message':'sample','tags':[1,2],'relatedInformation':[related],'data':{'value':True}}\nsys.stderr.write('first-server-stderr\\n');sys.stderr.flush()\nsend({'jsonrpc':'2.0','method':'textDocument/publishDiagnostics','params':{'uri':'file:///workspace/main.dl','version':3,'diagnostics':[diagnostic]}})\nsend({'jsonrpc':'2.0','id':9007199254740993,'method':'workspace/applyEdit','params':{'edit':{'changes':{'file:///workspace/main.dl':[]}}}})\nreply=read();assert reply['id']==9007199254740993 and reply['error']['code']==-32601\nclosed=read();assert closed['method']=='textDocument/didClose' and closed['params']['textDocument']['uri']=='file:///workspace/main.dl'\nshutdown=read();assert shutdown['method']=='shutdown' and 'params' not in shutdown\nsend({'jsonrpc':'2.0','id':shutdown['id'],'result':None})\nassert read()['method']=='exit'\nsys.stderr.write('final-server-stderr\\n');sys.stderr.flush()"
0 commit comments