CIRCT 22.0.0git
Loading...
Searching...
No Matches
VerilogServer.h
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Main entry function for circt-verilog-lsp-server for when built as standalone
10// binary.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LIB_CIRCT_TOOLS_CIRCT_VERILOG_LSP_SERVER_VERILOGSERVER_H_
15#define LIB_CIRCT_TOOLS_CIRCT_VERILOG_LSP_SERVER_VERILOGSERVER_H_
16
17#include "llvm/ADT/StringRef.h"
18#include "llvm/Support/LSP/Protocol.h"
19
20#include <memory>
21#include <optional>
22#include <vector>
23
24namespace mlir {
25namespace lsp {
26struct Diagnostic;
27struct Position;
28struct Location;
30class URIForFile;
31} // namespace lsp
32} // namespace mlir
33
34namespace circt {
35namespace lsp {
36struct VerilogServerOptions;
38 llvm::lsp::TextDocumentContentChangeEvent;
39using URIForFile = llvm::lsp::URIForFile;
40using Diagnostic = llvm::lsp::Diagnostic;
41
42/// This class implements all of the Verilog related functionality necessary for
43/// a language server. This class allows for keeping the Verilog specific logic
44/// separate from the logic that involves LSP server/client communication.
46public:
49
50 /// Add the document, with the provided `version`, at the given URI. Any
51 /// diagnostics emitted for this document should be added to `diagnostics`.
52 void addDocument(const URIForFile &uri, llvm::StringRef contents,
53 int64_t version, std::vector<Diagnostic> &diagnostics);
54
55 /// Update the document, with the provided `version`, at the given URI. Any
56 /// diagnostics emitted for this document should be added to `diagnostics`.
57 void updateDocument(const URIForFile &uri,
58 llvm::ArrayRef<TextDocumentContentChangeEvent> changes,
59 int64_t version, std::vector<Diagnostic> &diagnostics);
60
61 /// Remove the document with the given uri. Returns the version of the removed
62 /// document, or std::nullopt if the uri did not have a corresponding document
63 /// within the server.
64 std::optional<int64_t> removeDocument(const URIForFile &uri);
65
66 /// Return the locations of the object pointed at by the given position.
67 void getLocationsOf(const URIForFile &uri, const llvm::lsp::Position &defPos,
68 std::vector<llvm::lsp::Location> &locations);
69
70 /// Find all references of the object pointed at by the given position.
71 void findReferencesOf(const URIForFile &uri, const llvm::lsp::Position &pos,
72 std::vector<llvm::lsp::Location> &references);
73
74private:
75 struct Impl;
76 std::unique_ptr<Impl> impl;
77};
78
79} // namespace lsp
80} // namespace circt
81
82#endif // LIB_CIRCT_TOOLS_CIRCT_VERILOG_LSP_SERVER_VERILOGSERVER_H_
This class implements all of the Verilog related functionality necessary for a language server.
std::optional< int64_t > removeDocument(const URIForFile &uri)
Remove the document with the given uri.
void updateDocument(const URIForFile &uri, llvm::ArrayRef< TextDocumentContentChangeEvent > changes, int64_t version, std::vector< Diagnostic > &diagnostics)
Update the document, with the provided version, at the given URI.
void addDocument(const URIForFile &uri, llvm::StringRef contents, int64_t version, std::vector< Diagnostic > &diagnostics)
Add the document, with the provided version, at the given URI.
std::unique_ptr< Impl > impl
void getLocationsOf(const URIForFile &uri, const llvm::lsp::Position &defPos, std::vector< llvm::lsp::Location > &locations)
Return the locations of the object pointed at by the given position.
void findReferencesOf(const URIForFile &uri, const llvm::lsp::Position &pos, std::vector< llvm::lsp::Location > &references)
Find all references of the object pointed at by the given position.
llvm::lsp::TextDocumentContentChangeEvent TextDocumentContentChangeEvent
llvm::lsp::URIForFile URIForFile
llvm::lsp::Diagnostic Diagnostic
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.