Skip to content

Commit 0926053

Browse files
solc: Adds language server support via --lsp CLI option.
1 parent 03fc230 commit 0926053

File tree

11 files changed

+1801
-1
lines changed

11 files changed

+1801
-1
lines changed

libsolidity/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,12 @@ set(sources
149149
interface/StorageLayout.h
150150
interface/Version.cpp
151151
interface/Version.h
152+
lsp/LanguageServer.cpp
153+
lsp/LanguageServer.h
154+
lsp/ReferenceCollector.cpp
155+
lsp/ReferenceCollector.h
156+
lsp/Transport.cpp
157+
lsp/Transport.h
152158
parsing/DocStringParser.cpp
153159
parsing/DocStringParser.h
154160
parsing/Parser.cpp

libsolidity/interface/FileReader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ ReadCallback::Result FileReader::readFile(string const& _kind, string const& _so
7373
return ReadCallback::Result{false, "File outside of allowed directories."};
7474

7575
if (!boost::filesystem::exists(canonicalPath))
76-
return ReadCallback::Result{false, "File not found."};
76+
return ReadCallback::Result{false, "File not found: " + canonicalPath.generic_string()};
7777

7878
if (!boost::filesystem::is_regular_file(canonicalPath))
7979
return ReadCallback::Result{false, "Not a valid file."};

libsolidity/lsp/LSPTypes.h

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
This file is part of solidity.
3+
4+
solidity is free software: you can redistribute it and/or modify
5+
it under the terms of the GNU General Public License as published by
6+
the Free Software Foundation, either version 3 of the License, or
7+
(at your option) any later version.
8+
9+
solidity is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
GNU General Public License for more details.
13+
14+
You should have received a copy of the GNU General Public License
15+
along with solidity. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
// SPDX-License-Identifier: GPL-3.0
18+
#pragma once
19+
20+
#include <liblangutil/SourceLocation.h>
21+
#include <liblangutil/SourceReferenceExtractor.h> // LineColumn
22+
23+
#include <optional>
24+
#include <ostream>
25+
#include <string>
26+
#include <vector>
27+
28+
namespace solidity::lsp
29+
{
30+
31+
struct LineColumnRange
32+
{
33+
langutil::LineColumn start;
34+
langutil::LineColumn end;
35+
};
36+
37+
enum class Trace { Off, Messages, Verbose };
38+
39+
struct DocumentPosition {
40+
std::string path;
41+
langutil::LineColumn position;
42+
};
43+
44+
enum class DocumentHighlightKind {
45+
Unspecified,
46+
Text, //!< a textual occurrence
47+
Read, //!< read access to a variable
48+
Write, //!< write access to a variable
49+
};
50+
51+
// Represents a symbol / AST node that is to be highlighted, with some context associated.
52+
struct DocumentHighlight {
53+
langutil::SourceLocation location;
54+
// std::string sourceName;
55+
// LineColumnRange range;
56+
DocumentHighlightKind kind = DocumentHighlightKind::Unspecified;
57+
};
58+
59+
enum class DiagnosticSeverity {
60+
Error = 1,
61+
Warning = 2,
62+
Information = 3,
63+
Hint = 4,
64+
};
65+
66+
/// Represents a related message and source code location for a diagnostic. This should be
67+
/// used to point to code locations that cause or related to a diagnostics, e.g when duplicating
68+
/// a symbol in a scope.
69+
struct DiagnosticRelatedInformation {
70+
langutil::SourceLocation location; // The location of this related diagnostic information.
71+
std::string message; // The message of this related diagnostic information.
72+
};
73+
74+
}

0 commit comments

Comments
 (0)