mirror of
https://github.com/golang/go
synced 2024-11-18 17:44:47 -07:00
internal/lps/protocol: bring code.ts up to date with latest changes.
This CL makes sure that code.ts will generate the latest version of tsprotocol.go. It has a more succinct way of deciding which fields need to be pointers. Change-Id: I6854cb2f096d3707bc3b828a9601f9384638f475 Reviewed-on: https://go-review.googlesource.com/c/tools/+/212140 Run-TryBot: Peter Weinberger <pjw@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
parent
2ad5dca7a5
commit
a98e7fcfeb
@ -466,6 +466,13 @@ function toGo(d: Data, nm: string) {
|
|||||||
`more cases in toGo ${nm} ${d.as.length} ${d.generics.length} `)
|
`more cases in toGo ${nm} ${d.as.length} ${d.generics.length} `)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// these fields need a *
|
||||||
|
var starred: [string, string][] = [
|
||||||
|
['TextDocumentContentChangeEvent', 'range'], ['CodeAction', 'command'],
|
||||||
|
['DidSaveTextDocumentParams', 'text'], ['CompletionItem', 'command'],
|
||||||
|
['CompletionItem', 'textEdit']
|
||||||
|
];
|
||||||
|
|
||||||
// generate Go code for an interface
|
// generate Go code for an interface
|
||||||
function goInterface(d: Data, nm: string) {
|
function goInterface(d: Data, nm: string) {
|
||||||
let ans = `type ${goName(nm)} struct {\n`;
|
let ans = `type ${goName(nm)} struct {\n`;
|
||||||
@ -479,18 +486,10 @@ function goInterface(d: Data, nm: string) {
|
|||||||
// SelectionRange is a recursive type
|
// SelectionRange is a recursive type
|
||||||
let gt = goType(n.type, n.name.getText());
|
let gt = goType(n.type, n.name.getText());
|
||||||
if (gt == d.name) gt = '*' + gt; // avoid recursive types
|
if (gt == d.name) gt = '*' + gt; // avoid recursive types
|
||||||
// There's a difference between a nil Range and a zero Range (at the
|
// there are several cases where a * is needed
|
||||||
// beginning of files)
|
starred.forEach(([a, b]) => {
|
||||||
if (d.name == 'TextDocumentContentChangeEvent' &&
|
if (d.name == a && n.name.getText() == b) gt = '*' + gt
|
||||||
n.name.getText() == 'range') {
|
});
|
||||||
gt = '*' + gt;
|
|
||||||
}
|
|
||||||
if (d.name == 'CodeAction' && n.name.getText() == 'command') {
|
|
||||||
gt = '*' + gt;
|
|
||||||
}
|
|
||||||
if (d.name == 'DidSaveTextDocumentParams' && n.name.getText() == 'text') {
|
|
||||||
gt = '*' + gt;
|
|
||||||
}
|
|
||||||
ans = ans.concat(`${goName(n.name.getText())} ${gt}`, json, '\n')
|
ans = ans.concat(`${goName(n.name.getText())} ${gt}`, json, '\n')
|
||||||
};
|
};
|
||||||
d.properties.forEach(g)
|
d.properties.forEach(g)
|
||||||
@ -650,8 +649,8 @@ function goUnionType(n: ts.UnionTypeNode, nm: string): string {
|
|||||||
const bb = strKind(n.types[1])
|
const bb = strKind(n.types[1])
|
||||||
const cc = strKind(n.types[2])
|
const cc = strKind(n.types[2])
|
||||||
if (nm == 'DocumentFilter') {
|
if (nm == 'DocumentFilter') {
|
||||||
// not really a union. the first is enough, up to a missing omitempty
|
// not really a union. the first is enough, up to a missing
|
||||||
// but avoid repetitious comments
|
// omitempty but avoid repetitious comments
|
||||||
return `${goType(n.types[0], 'g')}`
|
return `${goType(n.types[0], 'g')}`
|
||||||
}
|
}
|
||||||
if (nm == 'textDocument/documentSymbol') {
|
if (nm == 'textDocument/documentSymbol') {
|
||||||
@ -856,7 +855,8 @@ const notNil = `if r.Params != nil {
|
|||||||
return true
|
return true
|
||||||
}`;
|
}`;
|
||||||
|
|
||||||
// Go code for notifications. Side is client or server, m is the request method
|
// Go code for notifications. Side is client or server, m is the request
|
||||||
|
// method
|
||||||
function goNot(side: side, m: string) {
|
function goNot(side: side, m: string) {
|
||||||
if (m == '$/cancelRequest') return; // handled specially in protocol.go
|
if (m == '$/cancelRequest') return; // handled specially in protocol.go
|
||||||
const n = not.get(m);
|
const n = not.get(m);
|
||||||
|
Loading…
Reference in New Issue
Block a user