Skip to content

Commit

Permalink
Merge pull request #49 from kitagry/add-documentation
Browse files Browse the repository at this point in the history
Add documentation
  • Loading branch information
kitagry authored Aug 13, 2023
2 parents 2a488eb + 0fefa4b commit 49aa261
Show file tree
Hide file tree
Showing 3 changed files with 146 additions and 146 deletions.
2 changes: 1 addition & 1 deletion langserver/initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (h *Handler) handleInitialize(ctx context.Context, conn *jsonrpc2.Conn, req
HoverProvider: true,
CodeActionProvider: true,
CompletionProvider: &lsp.CompletionOptions{
ResolveProvider: true,
ResolveProvider: false,
TriggerCharacters: []string{"*", "."},
},
},
Expand Down
60 changes: 30 additions & 30 deletions langserver/internal/source/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import (
)

type CompletionItem struct {
Kind lsp.CompletionItemKind
NewText string
Detail string
TypedPrefix string
Kind lsp.CompletionItemKind
NewText string
Documentation string
TypedPrefix string
}

func (c CompletionItem) ToLspCompletionItem(position lsp.Position, supportSnippet bool) lsp.CompletionItem {
Expand All @@ -26,7 +26,7 @@ func (c CompletionItem) ToLspCompletionItem(position lsp.Position, supportSnippe
InsertTextFormat: lsp.ITFPlainText,
Kind: c.Kind,
Label: c.NewText,
Detail: c.Detail,
Documentation: c.Documentation,
}
}

Expand All @@ -36,7 +36,7 @@ func (c CompletionItem) ToLspCompletionItem(position lsp.Position, supportSnippe
InsertTextFormat: lsp.ITFSnippet,
Kind: c.Kind,
Label: c.NewText,
Detail: c.Detail,
Documentation: c.Documentation,
TextEdit: &lsp.TextEdit{
NewText: c.NewText,
Range: lsp.Range{
Expand Down Expand Up @@ -183,10 +183,10 @@ func (p *Project) completeTableScanField(ctx context.Context, tableScanNode *ras
if strings.HasPrefix(tableScanNode.Alias(), incompleteColumnName) {
return []CompletionItem{
{
Kind: lsp.CIKField,
NewText: tableScanNode.Alias(),
Detail: tableScanNode.Table().FullName(),
TypedPrefix: incompleteColumnName,
Kind: lsp.CIKField,
NewText: tableScanNode.Alias(),
Documentation: tableScanNode.Table().FullName(),
TypedPrefix: incompleteColumnName,
},
}
}
Expand Down Expand Up @@ -287,10 +287,10 @@ func (p *Project) completeProjectForTablePath(ctx context.Context, param tablePa
}

result = append(result, CompletionItem{
Kind: lsp.CIKModule,
NewText: p.ProjectId,
Detail: p.Name,
TypedPrefix: param.ProjectID,
Kind: lsp.CIKModule,
NewText: p.ProjectId,
Documentation: p.Name,
TypedPrefix: param.ProjectID,
})
}

Expand All @@ -310,10 +310,10 @@ func (p *Project) completeDatasetForTablePath(ctx context.Context, param tablePa
}

result = append(result, CompletionItem{
Kind: lsp.CIKModule,
NewText: d.DatasetID,
Detail: fmt.Sprintf("%s.%s", d.ProjectID, d.DatasetID),
TypedPrefix: param.DatasetID,
Kind: lsp.CIKModule,
NewText: d.DatasetID,
Documentation: fmt.Sprintf("%s.%s", d.ProjectID, d.DatasetID),
TypedPrefix: param.DatasetID,
})
}

Expand All @@ -333,10 +333,10 @@ func (p *Project) completeTableForTablePath(ctx context.Context, param tablePath
}

result = append(result, CompletionItem{
Kind: lsp.CIKModule,
NewText: t.TableID,
Detail: fmt.Sprintf("%s.%s.%s", t.ProjectID, t.DatasetID, t.TableID),
TypedPrefix: param.TableID,
Kind: lsp.CIKModule,
NewText: t.TableID,
Documentation: fmt.Sprintf("%s.%s.%s", t.ProjectID, t.DatasetID, t.TableID),
TypedPrefix: param.TableID,
})
}

Expand Down Expand Up @@ -436,10 +436,10 @@ type columnInterface interface {

func createCompletionItemFromColumn(column columnInterface, incompleteColumnName string) CompletionItem {
return CompletionItem{
Kind: lsp.CIKField,
NewText: column.Name(),
Detail: column.Type().TypeName(types.ProductExternal),
TypedPrefix: incompleteColumnName,
Kind: lsp.CIKField,
NewText: column.Name(),
Documentation: column.Type().TypeName(types.ProductExternal),
TypedPrefix: incompleteColumnName,
}
}

Expand All @@ -449,9 +449,9 @@ func createCompletionItemFromSchema(schema *bigquery.FieldSchema, incompleteColu
detail += "\n" + schema.Description
}
return CompletionItem{
Kind: lsp.CIKField,
NewText: schema.Name,
Detail: detail,
TypedPrefix: incompleteColumnName,
Kind: lsp.CIKField,
NewText: schema.Name,
Documentation: detail,
TypedPrefix: incompleteColumnName,
}
}
Loading

0 comments on commit 49aa261

Please sign in to comment.