mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
LSP: Implement semantic tokens
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
// SPDX-License-Identifier: UNLICENSED
|
||||
pragma solidity >=0.8.0;
|
||||
|
||||
enum Weather {
|
||||
Sunny,
|
||||
Cloudy,
|
||||
Rainy
|
||||
}
|
||||
|
||||
enum Color {
|
||||
Red,
|
||||
Green,
|
||||
Blue
|
||||
}
|
||||
|
||||
function getColorEnum() pure returns (Color result)
|
||||
{
|
||||
result = Color.Red;
|
||||
}
|
||||
|
||||
// ----
|
||||
// -> textDocument/semanticTokens/full {
|
||||
// }
|
||||
// <- {
|
||||
// "data": [
|
||||
// 1, 0, 24, 8, 0,
|
||||
// 2, 5, 7, 2, 0,
|
||||
// 1, 4, 5, 3, 0,
|
||||
// 1, 4, 6, 3, 0,
|
||||
// 1, 4, 5, 3, 0,
|
||||
// 3, 5, 5, 2, 0,
|
||||
// 1, 4, 3, 3, 0,
|
||||
// 1, 4, 5, 3, 0,
|
||||
// 1, 4, 4, 3, 0,
|
||||
// 3, 9, 12, 5, 0,
|
||||
// 0, 29, 5, 2, 0,
|
||||
// 0, 6, 6, 19, 0,
|
||||
// 2, 4, 6, 2, 0,
|
||||
// 0, 9, 5, 2, 0,
|
||||
// 0, 6, 3, 3, 0
|
||||
// ]
|
||||
// }
|
||||
@@ -0,0 +1,52 @@
|
||||
// SPDX-License-Identifier: UNLICENSED
|
||||
pragma solidity >=0.8.0;
|
||||
|
||||
library Lib
|
||||
{
|
||||
function add(uint a, uint b) public pure returns (uint result)
|
||||
{
|
||||
result = a + b;
|
||||
}
|
||||
|
||||
function warningWithUnused() public pure
|
||||
{
|
||||
uint unused;
|
||||
// ^^^^^^^^^^^ @unusedVariable
|
||||
}
|
||||
}
|
||||
|
||||
contract Contract
|
||||
{
|
||||
function doNothing() pure public returns (bool)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// ----
|
||||
// functions: @unusedVariable 2072
|
||||
// -> textDocument/semanticTokens/full {
|
||||
// }
|
||||
// <- {
|
||||
// "data": [
|
||||
// 1, 0, 24, 8, 0,
|
||||
// 2, 8, 3, 0, 0,
|
||||
// 2, 13, 3, 5, 0,
|
||||
// 0, 4, 4, 11, 0,
|
||||
// 0, 5, 1, 19, 0,
|
||||
// 0, 3, 4, 11, 0,
|
||||
// 0, 5, 1, 19, 0,
|
||||
// 0, 24, 4, 11, 0,
|
||||
// 0, 5, 6, 19, 0,
|
||||
// 2, 8, 6, 19, 0,
|
||||
// 0, 9, 1, 19, 0,
|
||||
// 0, 4, 1, 19, 0,
|
||||
// 3, 13, 17, 5, 0,
|
||||
// 2, 8, 4, 11, 0,
|
||||
// 0, 5, 6, 19, 0,
|
||||
// 5, 9, 8, 0, 0,
|
||||
// 2, 13, 9, 5, 0,
|
||||
// 0, 33, 4, 11, 0,
|
||||
// 2, 15, 4, 11, 0
|
||||
// ]
|
||||
// }
|
||||
@@ -0,0 +1,81 @@
|
||||
// SPDX-License-Identifier: UNLICENSED
|
||||
pragma solidity >=0.8.0;
|
||||
|
||||
contract C
|
||||
{
|
||||
bool public locked = false;
|
||||
int public calls = 0;
|
||||
int public totalSum = 0;
|
||||
|
||||
function add(uint a, uint b) lock() monitor(a, b) public returns (uint result)
|
||||
{
|
||||
result = a + b;
|
||||
}
|
||||
|
||||
modifier lock()
|
||||
{
|
||||
require(!locked);
|
||||
locked = true;
|
||||
_;
|
||||
locked = false;
|
||||
}
|
||||
|
||||
modifier monitor(uint a, uint b)
|
||||
{
|
||||
calls++;
|
||||
totalSum = totalSum + a + b;
|
||||
// ^^^^^^^^^^^^^^^^ @totalSumWarning
|
||||
// ^^^^^^^^^^^^ @totalSumWarningSub
|
||||
_;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// modifiers: @totalSumWarningSub 2271 @totalSumWarning 2271
|
||||
// -> textDocument/semanticTokens/full {
|
||||
// }
|
||||
// <- {
|
||||
// "data": [
|
||||
// 1, 0, 24, 8, 0,
|
||||
// 2, 9, 1, 0, 0,
|
||||
// 2, 4, 4, 11, 0,
|
||||
// 0, 12, 6, 19, 0,
|
||||
// 0, 9, 5, 11, 0,
|
||||
// 1, 4, 3, 11, 0,
|
||||
// 0, 11, 5, 19, 0,
|
||||
// 0, 8, 1, 11, 0,
|
||||
// 1, 4, 3, 11, 0,
|
||||
// 0, 11, 8, 19, 0,
|
||||
// 0, 11, 1, 11, 0,
|
||||
// 2, 13, 3, 5, 0,
|
||||
// 0, 4, 4, 11, 0,
|
||||
// 0, 5, 1, 19, 0,
|
||||
// 0, 3, 4, 11, 0,
|
||||
// 0, 5, 1, 19, 0,
|
||||
// 0, 40, 4, 11, 0,
|
||||
// 0, 5, 6, 19, 0,
|
||||
// 0, -42, 4, 19, 0,
|
||||
// 0, 7, 7, 19, 0,
|
||||
// 0, 8, 1, 19, 0,
|
||||
// 0, 3, 1, 19, 0,
|
||||
// 2, 8, 6, 19, 0,
|
||||
// 0, 9, 1, 19, 0,
|
||||
// 0, 4, 1, 19, 0,
|
||||
// 3, 13, 4, 10, 0,
|
||||
// 2, 8, 7, 19, 0,
|
||||
// 0, 9, 6, 19, 0,
|
||||
// 1, 8, 6, 19, 0,
|
||||
// 0, 9, 4, 11, 0,
|
||||
// 2, 8, 6, 19, 0,
|
||||
// 0, 9, 5, 11, 0,
|
||||
// 3, 13, 7, 10, 0,
|
||||
// 0, 8, 4, 11, 0,
|
||||
// 0, 5, 1, 19, 0,
|
||||
// 0, 3, 4, 11, 0,
|
||||
// 0, 5, 1, 19, 0,
|
||||
// 2, 8, 5, 19, 0,
|
||||
// 1, 8, 8, 19, 0,
|
||||
// 0, 11, 8, 19, 0,
|
||||
// 0, 11, 1, 19, 0,
|
||||
// 0, 4, 1, 19, 0
|
||||
// ]
|
||||
// }
|
||||
@@ -0,0 +1,48 @@
|
||||
// SPDX-License-Identifier: UNLICENSED
|
||||
pragma solidity >=0.8.0;
|
||||
|
||||
struct Tag
|
||||
{
|
||||
uint id;
|
||||
string name;
|
||||
}
|
||||
|
||||
struct RGBColor
|
||||
{
|
||||
uint8 red;
|
||||
uint8 green;
|
||||
uint8 blue;
|
||||
Tag tag;
|
||||
}
|
||||
|
||||
function memberAccess(RGBColor memory color) pure returns(uint)
|
||||
{
|
||||
return color.red + color.green + color.blue;
|
||||
}
|
||||
// ----
|
||||
// -> textDocument/semanticTokens/full {
|
||||
// }
|
||||
// <- {
|
||||
// "data": [
|
||||
// 1, 0, 24, 8, 0,
|
||||
// 4, 4, 4, 11, 0,
|
||||
// 0, 5, 2, 19, 0,
|
||||
// 1, 4, 6, 17, 0,
|
||||
// 0, 7, 4, 19, 0,
|
||||
// 5, 4, 5, 11, 0,
|
||||
// 0, 6, 3, 19, 0,
|
||||
// 1, 4, 5, 11, 0,
|
||||
// 0, 6, 5, 19, 0,
|
||||
// 1, 4, 5, 11, 0,
|
||||
// 0, 6, 4, 19, 0,
|
||||
// 1, 4, 3, 16, 0,
|
||||
// 0, 4, 3, 19, 0,
|
||||
// 3, 9, 12, 5, 0,
|
||||
// 0, 13, 8, 16, 0,
|
||||
// 0, 16, 5, 19, 0,
|
||||
// 0, 20, 4, 11, 0,
|
||||
// 2, 17, 3, 19, 0,
|
||||
// 0, 12, 5, 19, 0,
|
||||
// 0, 14, 4, 19, 0
|
||||
// ]
|
||||
// }
|
||||
Reference in New Issue
Block a user