Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix(inlay-hints): don't show size hint for toCellI() in method chain #432

Merged
merged 1 commit into from
Mar 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions server/src/e2e/suite/testcases/inlayHints/toCell.test
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,77 @@ fun foo() {
from: address(""),
}.toCell()/* Size: 367 bits plus up to 120 bits */
}

========================================================================
toCell call in method chain
========================================================================
primitive Int;
primitive Address;

message(0x7362d09c) TokenNotification {
query_id: Int as uint64;
amount: Int as coins;
from: Address;
}

fun foo() {
const bits = TokenNotification{
query_id: 10,
amount: 20,
from: address(""),
}.toCell().bits()
}
------------------------------------------------------------------------
primitive Int;
primitive Address;

message(0x7362d09c) TokenNotification {
query_id: Int as uint64;
amount: Int as coins;
from: Address;
}

fun foo() {
const bits = TokenNotification{
query_id: 10,
amount: 20,
from: address(""),
}.toCell().bits()
}

========================================================================
toCell call with field access
========================================================================
primitive Int;
primitive Address;

message(0x7362d09c) TokenNotification {
query_id: Int as uint64;
amount: Int as coins;
from: Address;
}

fun foo() {
const bits = TokenNotification{
query_id: 10,
amount: 20,
from: address(""),
}.toCell().bits
}
------------------------------------------------------------------------
primitive Int;
primitive Address;

message(0x7362d09c) TokenNotification {
query_id: Int as uint64;
amount: Int as coins;
from: Address;
}

fun foo() {
const bits = TokenNotification{
query_id: 10,
amount: 20,
from: address(""),
}.toCell().bits
}
9 changes: 9 additions & 0 deletions server/src/inlays/collect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@ function processToCellCall(call: CallLike, result: InlayHint[], showToCellSize:
if (!showToCellSize) return
if (call.node.type !== "method_call_expression" || call.name() !== "toCell") return

const parent = call.node.parent

// if:
// Foo{}.asCell().bits()
// Foo{}.asCell().bits
if (parent?.type === "method_call_expression" || parent?.type === "field_access_expression") {
return
}

const qualifier = call.node.childForFieldName("object")
if (!qualifier) {
return
Expand Down