Skip to content

Commit fb28602

Browse files
committed
Merge FreeFunctions trait into Server trait
And rename FreeFunctions struct to Methods.
1 parent 25e3119 commit fb28602

2 files changed

Lines changed: 34 additions & 44 deletions

File tree

crates/proc-macro-srv/src/server_impl/rust_analyzer_span.rs

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ use crate::{
1919
server_impl::literal_from_str,
2020
};
2121

22-
pub struct FreeFunctions;
23-
2422
pub struct RaSpanServer<'a> {
2523
// FIXME: Report this back to the caller to track as dependencies
2624
pub tracked_env_vars: HashMap<Box<str>, Option<Box<str>>>,
@@ -33,13 +31,28 @@ pub struct RaSpanServer<'a> {
3331
}
3432

3533
impl server::Types for RaSpanServer<'_> {
36-
type FreeFunctions = FreeFunctions;
3734
type TokenStream = crate::token_stream::TokenStream<Span>;
3835
type Span = Span;
3936
type Symbol = Symbol;
4037
}
4138

42-
impl server::FreeFunctions for RaSpanServer<'_> {
39+
impl server::Server for RaSpanServer<'_> {
40+
fn globals(&mut self) -> ExpnGlobals<Self::Span> {
41+
ExpnGlobals {
42+
def_site: self.def_site,
43+
call_site: self.call_site,
44+
mixed_site: self.mixed_site,
45+
}
46+
}
47+
48+
fn intern_symbol(ident: &str) -> Self::Symbol {
49+
Symbol::intern(ident)
50+
}
51+
52+
fn with_symbol_string(symbol: &Self::Symbol, f: impl FnOnce(&str)) {
53+
f(symbol.as_str())
54+
}
55+
4356
fn injected_env_var(&mut self, _: &str) -> Option<std::string::String> {
4457
None
4558
}
@@ -276,21 +289,3 @@ impl server::FreeFunctions for RaSpanServer<'_> {
276289
Ok(<Self as server::Server>::intern_symbol(string))
277290
}
278291
}
279-
280-
impl server::Server for RaSpanServer<'_> {
281-
fn globals(&mut self) -> ExpnGlobals<Self::Span> {
282-
ExpnGlobals {
283-
def_site: self.def_site,
284-
call_site: self.call_site,
285-
mixed_site: self.mixed_site,
286-
}
287-
}
288-
289-
fn intern_symbol(ident: &str) -> Self::Symbol {
290-
Symbol::intern(ident)
291-
}
292-
293-
fn with_symbol_string(symbol: &Self::Symbol, f: impl FnOnce(&str)) {
294-
f(symbol.as_str())
295-
}
296-
}

crates/proc-macro-srv/src/server_impl/token_id.rs

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ impl std::fmt::Debug for SpanId {
2525

2626
type Span = SpanId;
2727

28-
pub struct FreeFunctions;
29-
3028
pub struct SpanIdServer<'a> {
3129
// FIXME: Report this back to the caller to track as dependencies
3230
pub tracked_env_vars: HashMap<Box<str>, Option<Box<str>>>,
@@ -39,13 +37,28 @@ pub struct SpanIdServer<'a> {
3937
}
4038

4139
impl server::Types for SpanIdServer<'_> {
42-
type FreeFunctions = FreeFunctions;
4340
type TokenStream = crate::token_stream::TokenStream<Span>;
4441
type Span = Span;
4542
type Symbol = Symbol;
4643
}
4744

48-
impl server::FreeFunctions for SpanIdServer<'_> {
45+
impl server::Server for SpanIdServer<'_> {
46+
fn globals(&mut self) -> ExpnGlobals<Self::Span> {
47+
ExpnGlobals {
48+
def_site: self.def_site,
49+
call_site: self.call_site,
50+
mixed_site: self.mixed_site,
51+
}
52+
}
53+
54+
fn intern_symbol(ident: &str) -> Self::Symbol {
55+
Symbol::intern(ident)
56+
}
57+
58+
fn with_symbol_string(symbol: &Self::Symbol, f: impl FnOnce(&str)) {
59+
f(symbol.as_str())
60+
}
61+
4962
fn injected_env_var(&mut self, _: &str) -> Option<std::string::String> {
5063
None
5164
}
@@ -195,21 +208,3 @@ impl server::FreeFunctions for SpanIdServer<'_> {
195208
Ok(<Self as server::Server>::intern_symbol(string))
196209
}
197210
}
198-
199-
impl server::Server for SpanIdServer<'_> {
200-
fn globals(&mut self) -> ExpnGlobals<Self::Span> {
201-
ExpnGlobals {
202-
def_site: self.def_site,
203-
call_site: self.call_site,
204-
mixed_site: self.mixed_site,
205-
}
206-
}
207-
208-
fn intern_symbol(ident: &str) -> Self::Symbol {
209-
Symbol::intern(ident)
210-
}
211-
212-
fn with_symbol_string(symbol: &Self::Symbol, f: impl FnOnce(&str)) {
213-
f(symbol.as_str())
214-
}
215-
}

0 commit comments

Comments
 (0)