mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 06:41:48 +00:00
Move completion label functions to display
This commit is contained in:
parent
dfaebd76ab
commit
946b5789d1
4 changed files with 32 additions and 31 deletions
|
@ -3,10 +3,36 @@
|
|||
use super::*;
|
||||
use std::fmt::{self, Display};
|
||||
use join_to_string::join;
|
||||
use ra_syntax::ast::{self, AstNode, NameOwner, VisibilityOwner, TypeParamsOwner};
|
||||
use ra_syntax::{ast::{self, AstNode, NameOwner, VisibilityOwner, TypeParamsOwner}, SyntaxKind::{ATTR, COMMENT}};
|
||||
use std::convert::From;
|
||||
use hir::Docs;
|
||||
|
||||
pub(crate) fn function_label(node: &ast::FnDef) -> String {
|
||||
FunctionSignature::from(node).to_string()
|
||||
}
|
||||
|
||||
pub(crate) fn const_label(node: &ast::ConstDef) -> String {
|
||||
let label: String = node
|
||||
.syntax()
|
||||
.children_with_tokens()
|
||||
.filter(|child| !(child.kind() == COMMENT || child.kind() == ATTR))
|
||||
.map(|node| node.to_string())
|
||||
.collect();
|
||||
|
||||
label.trim().to_owned()
|
||||
}
|
||||
|
||||
pub(crate) fn type_label(node: &ast::TypeAliasDef) -> String {
|
||||
let label: String = node
|
||||
.syntax()
|
||||
.children_with_tokens()
|
||||
.filter(|child| !(child.kind() == COMMENT || child.kind() == ATTR))
|
||||
.map(|node| node.to_string())
|
||||
.collect();
|
||||
|
||||
label.trim().to_owned()
|
||||
}
|
||||
|
||||
/// Contains information about a function signature
|
||||
#[derive(Debug)]
|
||||
pub struct FunctionSignature {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue