mirror of
https://github.com/g-plane/wasm-language-tools.git
synced 2025-12-23 11:12:52 +00:00
feat(service): hide "index" inlay hint when identifier is present
This commit is contained in:
parent
0037ed6d57
commit
aead348f2a
9 changed files with 23 additions and 50 deletions
|
|
@ -1,7 +1,9 @@
|
|||
use crate::{
|
||||
LanguageService,
|
||||
binder::{SymbolKind, SymbolTable},
|
||||
helpers, types_analyzer,
|
||||
helpers,
|
||||
idx::Idx,
|
||||
types_analyzer,
|
||||
};
|
||||
use lspt::{InlayHint, InlayHintKind, InlayHintParams, Union2};
|
||||
use rowan::ast::support;
|
||||
|
|
@ -95,7 +97,10 @@ impl LanguageService {
|
|||
});
|
||||
}
|
||||
if options.index
|
||||
&& let Some(num) = symbol.idx.num
|
||||
&& let Idx {
|
||||
num: Some(num),
|
||||
name: None,
|
||||
} = symbol.idx
|
||||
&& let Some(keyword) =
|
||||
support::token(&symbol.key.to_node(&root), SyntaxKind::KEYWORD)
|
||||
{
|
||||
|
|
@ -151,7 +156,10 @@ impl LanguageService {
|
|||
| SymbolKind::TableDef
|
||||
| SymbolKind::TagDef => {
|
||||
if options.index
|
||||
&& let Some(num) = symbol.idx.num
|
||||
&& let Idx {
|
||||
num: Some(num),
|
||||
name: None,
|
||||
} = symbol.idx
|
||||
&& let Some(keyword) =
|
||||
support::token(&symbol.key.to_node(&root), SyntaxKind::KEYWORD)
|
||||
{
|
||||
|
|
@ -172,7 +180,10 @@ impl LanguageService {
|
|||
}
|
||||
SymbolKind::Param | SymbolKind::Local | SymbolKind::FieldDef => {
|
||||
if options.index
|
||||
&& let Some(num) = symbol.idx.num
|
||||
&& let Idx {
|
||||
num: Some(num),
|
||||
name: None,
|
||||
} = symbol.idx
|
||||
{
|
||||
let end = support::token(&symbol.key.to_node(&root), SyntaxKind::KEYWORD)
|
||||
.filter(|token| matches!(token.text(), "param" | "local" | "field"))
|
||||
|
|
|
|||
|
|
@ -324,8 +324,8 @@ fn index_only() {
|
|||
let uri = "untitled:test".to_string();
|
||||
let source = "
|
||||
(module
|
||||
(global $g i32)
|
||||
(func (param $p i32) (param f32 i64) (local (ref 0)))
|
||||
(global i32)
|
||||
(func (param i32) (param f32 i64) (local (ref 0)))
|
||||
(memory 1 2)
|
||||
(table 1 2 funcref)
|
||||
(type (struct (field (mut i32))))
|
||||
|
|
|
|||
|
|
@ -10,13 +10,5 @@ expression: response
|
|||
},
|
||||
"label": "(func $name)",
|
||||
"paddingLeft": true
|
||||
},
|
||||
{
|
||||
"position": {
|
||||
"line": 2,
|
||||
"character": 9
|
||||
},
|
||||
"label": "(;0;)",
|
||||
"paddingLeft": true
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -3,14 +3,6 @@ source: crates/service/tests/inlay_hint/mod.rs
|
|||
expression: response
|
||||
---
|
||||
[
|
||||
{
|
||||
"position": {
|
||||
"line": 2,
|
||||
"character": 11
|
||||
},
|
||||
"label": "(;0;)",
|
||||
"paddingLeft": true
|
||||
},
|
||||
{
|
||||
"position": {
|
||||
"line": 3,
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ expression: response
|
|||
{
|
||||
"position": {
|
||||
"line": 3,
|
||||
"character": 14
|
||||
"character": 18
|
||||
},
|
||||
"label": "(;0;)",
|
||||
"paddingLeft": true
|
||||
|
|
@ -30,7 +30,7 @@ expression: response
|
|||
{
|
||||
"position": {
|
||||
"line": 3,
|
||||
"character": 33
|
||||
"character": 30
|
||||
},
|
||||
"label": "(;1;)",
|
||||
"paddingLeft": true
|
||||
|
|
@ -38,7 +38,7 @@ expression: response
|
|||
{
|
||||
"position": {
|
||||
"line": 3,
|
||||
"character": 37
|
||||
"character": 34
|
||||
},
|
||||
"label": "(;2;)",
|
||||
"paddingLeft": true
|
||||
|
|
@ -46,7 +46,7 @@ expression: response
|
|||
{
|
||||
"position": {
|
||||
"line": 3,
|
||||
"character": 53
|
||||
"character": 50
|
||||
},
|
||||
"label": "(;3;)",
|
||||
"paddingLeft": true
|
||||
|
|
|
|||
|
|
@ -11,14 +11,6 @@ expression: response
|
|||
"label": "(;0;)",
|
||||
"paddingLeft": true
|
||||
},
|
||||
{
|
||||
"position": {
|
||||
"line": 2,
|
||||
"character": 16
|
||||
},
|
||||
"label": "(;0;)",
|
||||
"paddingLeft": true
|
||||
},
|
||||
{
|
||||
"position": {
|
||||
"line": 3,
|
||||
|
|
|
|||
|
|
@ -11,14 +11,6 @@ expression: response
|
|||
"label": "(;0;)",
|
||||
"paddingLeft": true
|
||||
},
|
||||
{
|
||||
"position": {
|
||||
"line": 2,
|
||||
"character": 16
|
||||
},
|
||||
"label": "(;0;)",
|
||||
"paddingLeft": true
|
||||
},
|
||||
{
|
||||
"position": {
|
||||
"line": 3,
|
||||
|
|
|
|||
|
|
@ -11,14 +11,6 @@ expression: response
|
|||
"label": "(;0;)",
|
||||
"paddingLeft": true
|
||||
},
|
||||
{
|
||||
"position": {
|
||||
"line": 2,
|
||||
"character": 16
|
||||
},
|
||||
"label": "(;0;)",
|
||||
"paddingLeft": true
|
||||
},
|
||||
{
|
||||
"position": {
|
||||
"line": 3,
|
||||
|
|
|
|||
|
|
@ -15,3 +15,5 @@ It only shows when the function or block contains an identifier.
|
|||
|
||||
This inlay hint shows numeric idx of functions, types, globals, memories, tables, tags and etc in their definitions.
|
||||
This can be helpful when calling these functions or referencing these items elsewhere.
|
||||
|
||||
It will be hidden when an identifier is present.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue