Skip to content

Commit d0b55ec

Browse files
christianparpartMarenz
authored andcommitted
Adding Changelog entry.
1 parent f6b8cf2 commit d0b55ec

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Language Features:
44

55

66
Compiler Features:
7+
* Language Server: Add configuration option to apply custom remappings via ``remappings`` in the LSP settings object.
78

89

910
Bugfixes:

libsolidity/lsp/LanguageServer.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,12 @@ void LanguageServer::changeConfiguration(Json::Value const& _settings)
222222
vector<frontend::ImportRemapper::Remapping> remappings;
223223
for (Json::Value const& jsonPath: jsonRemappings)
224224
{
225-
if (jsonPath.isObject())
225+
if (
226+
jsonPath.isObject() &&
227+
jsonPath.get("context", "").isString() &&
228+
jsonPath.get("prefix", "").isString() &&
229+
jsonPath.get("target", "").isString()
230+
)
226231
remappings.emplace_back(ImportRemapper::Remapping{
227232
jsonPath.get("context", "").asString(),
228233
jsonPath.get("prefix", "").asString(),

test/lsp.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1541,6 +1541,28 @@ def test_custom_includes(self, solc: JsonRpcProcess) -> None:
15411541
self.expect_equal(len(diagnostics), 1, "no diagnostics")
15421542
self.expect_diagnostic(diagnostics[0], code=2018, lineNo=5, startEndColumns=(4, 62))
15431543

1544+
def test_remapping_wrong_paramateres(self, solc: JsonRpcProcess) -> None:
1545+
self.setup_lsp(solc, expose_project_root=False)
1546+
solc.send_notification(
1547+
'workspace/didChangeConfiguration', {
1548+
'settings': {
1549+
'remappings': [
1550+
{
1551+
'context': False,
1552+
'prefix': 1,
1553+
'target': f"{self.project_root_dir}/other-include-dir/otherlib/"
1554+
}
1555+
]
1556+
}
1557+
}
1558+
)
1559+
1560+
response = solc.receive_message()
1561+
self.expect_equal(response["method"], "$/logTrace")
1562+
1563+
if not response["params"]["message"].startswith("Invalid JSON configuration passed."):
1564+
raise Exception("Expected JSON error.")
1565+
15441566
def test_remapping(self, solc: JsonRpcProcess) -> None:
15451567
self.setup_lsp(solc, expose_project_root=False)
15461568
solc.send_notification(

0 commit comments

Comments
 (0)