Mirror: TypeScript LSP plugin that finds GraphQL documents in your code and provides diagnostics, auto-complete and hover-information.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add diagnostic

+48 -1
+48 -1
src/index.ts
··· 38 38 // TODO: we have to initialize a watcher for schema changes 39 39 const schema = loadSchema(info.project.getProjectName(), info.config.schema); 40 40 41 + proxy.getProgram = (): ts.Program | undefined => { 42 + console.log('getProgram'); 43 + return info.languageService.getProgram(); 44 + }; 45 + 41 46 proxy.getSemanticDiagnostics = (filename: string): ts.Diagnostic[] => { 42 47 const originalDiagnostics = info.languageService.getSemanticDiagnostics(filename) 43 48 const source = getSource(info, filename) ··· 83 88 const suffix = source.text.substring(span.start + span.length, source.text.length); 84 89 const text = prefix + imp + suffix; 85 90 91 + const scriptInfo = info.project.projectService.getScriptInfo(filename); 92 + const snapshot = scriptInfo!.getSnapshot(); 93 + const length = snapshot.getLength(); 94 + 95 + // scriptInfo!.editContent(0, length, text); 96 + // info.languageServiceHost.writeFile!(source.fileName, text); 97 + // scriptInfo!.registerFileUpdate(); 98 + 99 + /* 86 100 info.session!.send({ 87 101 seq: 0, 88 102 type: 'request', 103 + command: 'window/showMessage', 104 + arguments: { 105 + type: 1, 106 + message: 'GraphQL Type Annotation', 107 + }, 108 + } as any); 109 + */ 110 + 111 + info.session!.event({ 112 + file: filename, 113 + diagnostics: [ 114 + { 115 + source: 'gql-test', 116 + relatedInformation: [ 117 + { 118 + category: 0, 119 + code: 4242, 120 + sourceFile: source, 121 + start: node.getStart(), 122 + length: node.getEnd() - node.getStart(), 123 + messageText: 'Shit is fucked', 124 + }, 125 + ], 126 + }, 127 + ], 128 + }, 'suggestionDiag'); 129 + 130 + /* 131 + info.session!.send({ 132 + seq: 0, 133 + type: 'response', 89 134 command: 'workspace/applyEdit', 90 135 arguments: { 91 136 label: 'GraphQL Type Annotation', ··· 101 146 character: 2, 102 147 }, 103 148 }, 104 - newText: '', 149 + newText: 'x', 105 150 }], 106 151 }, 107 152 }, 108 153 } as any); 154 + */ 109 155 110 156 // source.update(text, { span, newLength: imp.length }) 111 157 // info.languageServiceHost.writeFile!(source.fileName, text); 112 158 }); 113 159 } catch (e) { 114 160 console.error(e) 161 + throw e 115 162 } 116 163 117 164 const diagnostics = nodes.map(x => {