Documentation
¶
Overview ¶
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Index ¶
- Variables
- func DefinitionFor(uri protocol.URI, text string, pos protocol.Position, program ast.Program, ...) ([]protocol.Location, error)
- func DiagnosticsByFile(errs []source.SyntaxError) map[protocol.URI][]protocol.Diagnostic
- func DocumentSymbolsFor(uri protocol.URI, program ast.Program, srcmaps source.Maps[any]) ([]interface{}, error)
- func FormattingFor(uri protocol.URI, text string) ([]protocol.TextEdit, error)
- func HoverFor(uri protocol.URI, text string, pos protocol.Position, program ast.Program, ...) (*protocol.Hover, error)
- func PrepareRenameFor(uri protocol.URI, text string, pos protocol.Position, program ast.Program, ...) (*protocol.Range, error)
- func ReferencesFor(uri protocol.URI, text string, pos protocol.Position, includeDecl bool, ...) ([]protocol.Location, error)
- func RenameFor(uri protocol.URI, text string, pos protocol.Position, newName string, ...) (*protocol.WorkspaceEdit, error)
- func SemanticTokensFor(uri protocol.URI, text string) (*protocol.SemanticTokens, error)
- func SignatureHelpFor(uri protocol.URI, text string, pos protocol.Position, program ast.Program) (*protocol.SignatureHelp, error)
- type SemTokOptions
Constants ¶
This section is empty.
Variables ¶
var SemTokLegend = protocol.SemanticTokensLegend{ TokenTypes: []protocol.SemanticTokenTypes{ protocol.SemanticTokenKeyword, protocol.SemanticTokenComment, protocol.SemanticTokenString, protocol.SemanticTokenNumber, protocol.SemanticTokenOperator, protocol.SemanticTokenType, protocol.SemanticTokenFunction, protocol.SemanticTokenVariable, }, TokenModifiers: []protocol.SemanticTokenModifiers{}, }
SemTokLegend declares the token types the server emits. The index of each entry is the numeric value encoded in SemanticTokens.Data.
Functions ¶
func DefinitionFor ¶
func DefinitionFor( uri protocol.URI, text string, pos protocol.Position, program ast.Program, srcmaps source.Maps[any], ) ([]protocol.Location, error)
DefinitionFor returns the source location of the top-level declaration named by the identifier under the cursor at pos. The caller supplies an already-compiled program and its associated source maps (typically taken from an IncrementalCompiler), so this function does not itself parse or compile the source — it only lexes the supplied document text to find the identifier under the cursor.
Returns nil when no definition is available, e.g. the cursor is on a keyword or whitespace, or the identifier does not name a top-level declaration in program.
func DiagnosticsByFile ¶
func DiagnosticsByFile(errs []source.SyntaxError) map[protocol.URI][]protocol.Diagnostic
DiagnosticsByFile groups the given syntax errors by their source file and converts each to a protocol.Diagnostic. The returned map is keyed by the URI of every affected file; files with no errors do not appear, so callers that need to clear previously-published diagnostics must track that separately.
func DocumentSymbolsFor ¶
func DocumentSymbolsFor( uri protocol.URI, program ast.Program, srcmaps source.Maps[any], ) ([]interface{}, error)
DocumentSymbolsFor returns a protocol.DocumentSymbol for each top-level declaration defined in the file identified by uri. Declarations from included files are filtered out by comparing the source file recorded in srcmaps against uri. The caller supplies an already-compiled program and its source maps (typically taken from an IncrementalCompiler), so this function does no parsing or compilation of its own.
func FormattingFor ¶
FormattingFor formats the given document text and returns a single TextEdit that replaces the entire document with its canonical form. Returns nil (no edits) when the document has parse errors or is already correctly formatted.
func HoverFor ¶
func HoverFor( uri protocol.URI, text string, pos protocol.Position, program ast.Program, srcmaps source.Maps[any], ) (*protocol.Hover, error)
HoverFor returns hover information for the symbol under the cursor at pos. The caller supplies an already-compiled program and source maps (typically taken from an IncrementalCompiler); this function only lexes the supplied document text to find the identifier under the cursor. Returns nil when no hover content is available (e.g. the cursor is on punctuation or the identifier names neither a local nor a top-level declaration).
func PrepareRenameFor ¶
func PrepareRenameFor( uri protocol.URI, text string, pos protocol.Position, program ast.Program, srcmaps source.Maps[any], ) (*protocol.Range, error)
PrepareRenameFor returns the range of the identifier under the cursor when it names something the server knows how to rename: a top-level declaration (function, constant, memory, type alias) or a local variable in the enclosing function. Returns nil for any other token, signalling the editor not to start a rename session.
func ReferencesFor ¶
func ReferencesFor( uri protocol.URI, text string, pos protocol.Position, includeDecl bool, program ast.Program, srcmaps source.Maps[any], ) ([]protocol.Location, error)
ReferencesFor returns the locations of every use of the top-level declaration named by the identifier under the cursor at pos. When includeDecl is true, the declaration's own site is included in the results. Returns nil when no identifier is under the cursor or when the identifier does not name a top-level declaration.
func RenameFor ¶
func RenameFor( uri protocol.URI, text string, pos protocol.Position, newName string, program ast.Program, srcmaps source.Maps[any], ) (*protocol.WorkspaceEdit, error)
RenameFor produces a workspace edit which renames the identifier under the cursor to newName. Top-level declarations are renamed across every file in the program; local variables (parameters, returns, and `var` bindings) are renamed only within the enclosing function. Returns nil when no rename is possible — the cursor is not on a renameable identifier, newName is not a valid identifier, or newName equals the existing name.
func SemanticTokensFor ¶
SemanticTokensFor lexes the given document text and returns a SemanticTokens response for the full document.
func SignatureHelpFor ¶
func SignatureHelpFor( uri protocol.URI, text string, pos protocol.Position, program ast.Program, ) (*protocol.SignatureHelp, error)
SignatureHelpFor returns signature help for the function call the cursor is inside. The caller supplies an already-compiled program (typically taken from an IncrementalCompiler); this function only lexes the supplied document text to locate the enclosing call and active parameter. Returns nil when the cursor is not inside a function-call argument list or the callee cannot be resolved.
Types ¶
type SemTokOptions ¶
type SemTokOptions struct {
Legend protocol.SemanticTokensLegend `json:"legend"`
Full bool `json:"full"`
}
SemTokOptions is a local replacement for protocol.SemanticTokensOptions, which in go.lsp.dev/protocol@v0.12.0 is missing the Legend and Full fields.