internal/lsp/protocol: fix whitespace in comments

There's one case when doing something about newlines in comments is
necessary, but the existing code removed newlines from comments in
several other places. The new code fixes that and a few other
leftovers.

Change-Id: Ia7905f07584ea1774f4fde786bdd5ee732acc818
Reviewed-on: https://go-review.googlesource.com/c/tools/+/368214
Run-TryBot: Peter Weinberger <pjw@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Trust: Peter Weinberger <pjw@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
Peter Weinberger 2021-12-01 11:03:28 -05:00
parent 3c63f30840
commit d99d6faea5
2 changed files with 32 additions and 13 deletions

View File

@ -5,7 +5,7 @@
// Package protocol contains data types and code for LSP jsonrpcs
// generated automatically from vscode-languageserver-node
// commit: d959faf4be476a6e0a08d5612e91fcac14ff9929
// last fetched Mon Nov 29 2021 15:51:05 GMT-0500 (Eastern Standard Time)
// last fetched Wed Dec 01 2021 09:27:34 GMT-0500 (Eastern Standard Time)
package protocol
// Code generated (see typescript/README.md) DO NOT EDIT.
@ -382,7 +382,13 @@ type CodeActionClientCapabilities struct {
* The code action kind is support with the following value
* set.
*/
CodeActionKind struct { /** * The code action kind values the client supports. When this * property exists the client also guarantees that it will * handle values outside its set gracefully and falls back * to a default value when unknown. */
CodeActionKind struct {
/**
* The code action kind values the client supports. When this
* property exists the client also guarantees that it will
* handle values outside its set gracefully and falls back
* to a default value when unknown.
*/
ValueSet []CodeActionKind `json:"valueSet"`
} `json:"codeActionKind"`
} `json:"codeActionLiteralSupport,omitempty"`
@ -745,7 +751,10 @@ type CompletionClientCapabilities struct {
*
* @since 3.15.0
*/
TagSupport struct { /** * The tags supported by the client. */
TagSupport struct {
/**
* The tags supported by the client.
*/
ValueSet []CompletionItemTag `json:"valueSet"`
} `json:"tagSupport,omitempty"`
/**
@ -762,7 +771,10 @@ type CompletionClientCapabilities struct {
*
* @since 3.16.0
*/
ResolveSupport struct { /** * The properties that a client can resolve lazily. */
ResolveSupport struct {
/**
* The properties that a client can resolve lazily.
*/
Properties []string `json:"properties"`
} `json:"resolveSupport,omitempty"`
/**
@ -4139,7 +4151,13 @@ type SignatureHelpClientCapabilities struct {
/**
* Client capabilities specific to parameter information.
*/
ParameterInformation struct { /** * The client supports processing label offsets instead of a * simple label string. * * @since 3.14.0 */
ParameterInformation struct {
/**
* The client supports processing label offsets instead of a
* simple label string.
*
* @since 3.14.0
*/
LabelOffsetSupport bool `json:"labelOffsetSupport,omitempty"`
} `json:"parameterInformation,omitempty"`
/**
@ -5113,7 +5131,7 @@ type WorkspaceEdit struct {
/**
* Holds changes to existing resources.
*/
Changes map[DocumentURI]interface{}/*[uri: DocumentUri]: TextEdit[];*/ `json:"changes,omitempty"`
Changes map[DocumentURI][]TextEdit/*[uri: DocumentUri]: TextEdit[];*/ `json:"changes,omitempty"`
/**
* Depending on the client capability `workspace.workspaceEdit.resourceOperations` document changes
* are either an array of `TextDocumentEdit`s to express changes to n different text documents

View File

@ -876,9 +876,8 @@ function goUnionType(n: ts.UnionTypeNode, nm: string): string {
if (a == 'NumberKeyword' && b == 'StringKeyword') { // ID
return `interface{} ${help}`;
}
if (b == 'NullKeyword' || n.types[1].getText() === 'null') {
// PJW: fix this. it looks like 'null' is now being parsed as LiteralType
// and check the other keyword cases
// for null, b is not useful (LiternalType)
if (n.types[1].getText() === 'null') {
if (nm == 'textDocument/codeAction') {
// (Command | CodeAction)[] | null
return `[]CodeAction ${help}`;
@ -948,8 +947,8 @@ function goUnionType(n: ts.UnionTypeNode, nm: string): string {
if (nm == 'documentChanges') return `TextDocumentEdit ${help} `;
if (nm == 'textDocument/prepareRename') return `Range ${help} `;
break;
case 8: // LSPany
break;
case 8: // LSPany
break;
default:
throw new Error(`957 goUnionType len=${n.types.length} nm=${nm} ${n.getText()}`);
}
@ -1075,7 +1074,9 @@ function goTypeLiteral(n: ts.TypeLiteralNode, nm: string): string {
let json = u.JSON(nx);
let typ = goType(nx.type, nx.name.getText());
// }/*\n*/`json:v` is not legal, the comment is a newline
typ = typ.replace(/\n\t*/g, ' '); // PJW: try to do this only when needed
if (typ.includes('\n') && typ.indexOf('*/') === typ.length - 2) {
typ = typ.replace(/\n\t*/g, ' ');
}
const v = getComments(nx) || '';
starred.forEach(([a, b]) => {
if (a != nm || b != typ.toLowerCase()) return;
@ -1094,7 +1095,7 @@ function goTypeLiteral(n: ts.TypeLiteralNode, nm: string): string {
} else if (nx.getText().startsWith('[uri: string')) {
res = 'map[string]interface{}';
} else if (nx.getText().startsWith('[uri: DocumentUri')) {
res = 'map[DocumentURI]interface{}'; //PJW make this more precise
res = 'map[DocumentURI][]TextEdit';
} else if (nx.getText().startsWith('[key: string')) {
res = 'map[string]interface{}';
} else {