1
- use std:: { collections :: HashMap , path:: PathBuf , sync :: LazyLock } ;
1
+ use std:: path:: PathBuf ;
2
2
3
3
use async_lsp:: lsp_types:: { MarkupContent , MarkupKind } ;
4
4
5
5
use crate :: {
6
- context:: hoverable:: Hoverables , state:: ProtoLanguageState , utils:: split_identifier_package,
6
+ context:: hoverable:: Hoverables , docs, state:: ProtoLanguageState ,
7
+ utils:: split_identifier_package,
7
8
} ;
8
9
9
- static BUITIN_DOCS : LazyLock < HashMap < & ' static str , & ' static str > > = LazyLock :: new ( || {
10
- HashMap :: from ( [
11
- ( "int32" , include_str ! ( "docs/builtin/int32.md" ) ) ,
12
- ( "int64" , include_str ! ( "docs/builtin/int64.md" ) ) ,
13
- ( "uint32" , include_str ! ( "docs/builtin/uint32.md" ) ) ,
14
- ( "uint64" , include_str ! ( "docs/builtin/uint64.md" ) ) ,
15
- ( "sint32" , include_str ! ( "docs/builtin/sint32.md" ) ) ,
16
- ( "sint64" , include_str ! ( "docs/builtin/sint64.md" ) ) ,
17
- ( "fixed32" , include_str ! ( "docs/builtin/fixed32.md" ) ) ,
18
- ( "fixed64" , include_str ! ( "docs/builtin/fixed64.md" ) ) ,
19
- ( "sfixed32" , include_str ! ( "docs/builtin/sfixed32.md" ) ) ,
20
- ( "sfixed64" , include_str ! ( "docs/builtin/sfixed64.md" ) ) ,
21
- ( "float" , include_str ! ( "docs/builtin/float.md" ) ) ,
22
- ( "double" , include_str ! ( "docs/builtin/double.md" ) ) ,
23
- ( "string" , include_str ! ( "docs/builtin/string.md" ) ) ,
24
- ( "bytes" , include_str ! ( "docs/builtin/bytes.md" ) ) ,
25
- ( "bool" , include_str ! ( "docs/builtin/bool.md" ) ) ,
26
- ( "default" , include_str ! ( "docs/builtin/default.md" ) ) ,
27
- ] )
28
- } ) ;
29
-
30
- static WELLKNOWN_DOCS : LazyLock < HashMap < & ' static str , & ' static str > > = LazyLock :: new ( || {
31
- HashMap :: from ( [
32
- ( "google.protobuf.Any" , include_str ! ( "docs/wellknown/Any.md" ) ) ,
33
- ( "google.protobuf.Api" , include_str ! ( "docs/wellknown/Api.md" ) ) ,
34
- ( "google.protobuf.BoolValue" , include_str ! ( "docs/wellknown/BoolValue.md" ) ) ,
35
- ( "google.protobuf.BytesValue" , include_str ! ( "docs/wellknown/BytesValue.md" ) ) ,
36
- ( "google.protobuf.DoubleValue" , include_str ! ( "docs/wellknown/DoubleValue.md" ) ) ,
37
- ( "google.protobuf.Duration" , include_str ! ( "docs/wellknown/Duration.md" ) ) ,
38
- ( "google.protobuf.Empty" , include_str ! ( "docs/wellknown/Empty.md" ) ) ,
39
- ( "google.protobuf.Enum" , include_str ! ( "docs/wellknown/Enum.md" ) ) ,
40
- ( "google.protobuf.EnumValue" , include_str ! ( "docs/wellknown/EnumValue.md" ) ) ,
41
- ( "google.protobuf.Field" , include_str ! ( "docs/wellknown/Field.md" ) ) ,
42
- ( "google.protobuf.Field.Cardinality" , include_str ! ( "docs/wellknown/Field.Cardinality.md" ) ) ,
43
- ( "google.protobuf.Field.Kind" , include_str ! ( "docs/wellknown/Field.Kind.md" ) ) ,
44
- ( "google.protobuf.FieldMask" , include_str ! ( "docs/wellknown/FieldMask.md" ) ) ,
45
- ( "google.protobuf.FloatValue" , include_str ! ( "docs/wellknown/FloatValue.md" ) ) ,
46
- ( "google.protobuf.Int32Value" , include_str ! ( "docs/wellknown/Int32Value.md" ) ) ,
47
- ( "google.protobuf.Int64Value" , include_str ! ( "docs/wellknown/Int64Value.md" ) ) ,
48
- ( "google.protobuf.ListValue" , include_str ! ( "docs/wellknown/ListValue.md" ) ) ,
49
- ( "google.protobuf.Method" , include_str ! ( "docs/wellknown/Method.md" ) ) ,
50
- ( "google.protobuf.Mixin" , include_str ! ( "docs/wellknown/Mixin.md" ) ) ,
51
- ( "google.protobuf.NullValue" , include_str ! ( "docs/wellknown/NullValue.md" ) ) ,
52
- ( "google.protobuf.Option" , include_str ! ( "docs/wellknown/Option.md" ) ) ,
53
- ( "google.protobuf.SourceContext" , include_str ! ( "docs/wellknown/SourceContext.md" ) ) ,
54
- ( "google.protobuf.StringValue" , include_str ! ( "docs/wellknown/StringValue.md" ) ) ,
55
- ( "google.protobuf.Struct" , include_str ! ( "docs/wellknown/Struct.md" ) ) ,
56
- ( "google.protobuf.Syntax" , include_str ! ( "docs/wellknown/Syntax.md" ) ) ,
57
- ( "google.protobuf.Timestamp" , include_str ! ( "docs/wellknown/Timestamp.md" ) ) ,
58
- ( "google.protobuf.Type" , include_str ! ( "docs/wellknown/Type.md" ) ) ,
59
- ( "google.protobuf.UInt32Value" , include_str ! ( "docs/wellknown/UInt32Value.md" ) ) ,
60
- ( "google.protobuf.UInt64Value" , include_str ! ( "docs/wellknown/UInt64Value.md" ) ) ,
61
- ( "google.protobuf.Value" , include_str ! ( "docs/wellknown/Value.md" ) ) ,
62
- ] )
63
- } ) ;
64
-
65
10
impl ProtoLanguageState {
66
11
pub fn hover (
67
12
& self ,
@@ -72,7 +17,7 @@ impl ProtoLanguageState {
72
17
let v = match hv {
73
18
Hoverables :: FieldType ( field) => {
74
19
// Type is a builtin
75
- match BUITIN_DOCS . get ( field. as_str ( ) ) {
20
+ match docs :: BUITIN . get ( field. as_str ( ) ) {
76
21
Some ( docs) => docs. to_string ( ) ,
77
22
_ => String :: new ( ) ,
78
23
}
@@ -97,7 +42,7 @@ Included from {}"#,
97
42
98
43
// Node is user defined type or well known type
99
44
// If user defined,
100
- let mut result = WELLKNOWN_DOCS
45
+ let mut result = docs :: WELLKNOWN
101
46
. get ( format ! ( "{package}.{identifier}" ) . as_str ( ) )
102
47
. map ( |& s| s. to_string ( ) )
103
48
. unwrap_or_default ( ) ;
0 commit comments