Skip to content

Commit 94742d6

Browse files
improve: cache parsed trees for documents (#19)
Co-authored-by: coder3101 <[email protected]>
1 parent 63c4640 commit 94742d6

23 files changed

+2571
-946
lines changed

Cargo.lock

Lines changed: 30 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ tracing-subscriber = "0.3.18"
2222
tree-sitter = "0.22.6"
2323
tracing-appender = "0.2.3"
2424
protols-tree-sitter-proto = "0.2.0"
25+
walkdir = "2.5.0"

sample/google/protobuf/any.proto

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
// Protocol Buffers - Google's data interchange format
2+
// Copyright 2008 Google Inc. All rights reserved.
3+
// https://developers.google.com/protocol-buffers/
4+
//
5+
// Redistribution and use in source and binary forms, with or without
6+
// modification, are permitted provided that the following conditions are
7+
// met:
8+
//
9+
// * Redistributions of source code must retain the above copyright
10+
// notice, this list of conditions and the following disclaimer.
11+
// * Redistributions in binary form must reproduce the above
12+
// copyright notice, this list of conditions and the following disclaimer
13+
// in the documentation and/or other materials provided with the
14+
// distribution.
15+
// * Neither the name of Google Inc. nor the names of its
16+
// contributors may be used to endorse or promote products derived from
17+
// this software without specific prior written permission.
18+
//
19+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
syntax = "proto3";
31+
32+
package google.protobuf;
33+
34+
option go_package = "google.golang.org/protobuf/types/known/anypb";
35+
option java_package = "com.google.protobuf";
36+
option java_outer_classname = "AnyProto";
37+
option java_multiple_files = true;
38+
option objc_class_prefix = "GPB";
39+
option csharp_namespace = "Google.Protobuf.WellKnownTypes";
40+
// `Any` contains an arbitrary serialized protocol buffer message along with a
41+
// URL that describes the type of the serialized message.
42+
//
43+
// Protobuf library provides support to pack/unpack Any values in the form
44+
// of utility functions or additional generated methods of the Any type.
45+
//
46+
// Example 1: Pack and unpack a message in C++.
47+
//
48+
// Foo foo = ...;
49+
// Any any;
50+
// any.PackFrom(foo);
51+
// ...
52+
// if (any.UnpackTo(&foo)) {
53+
// ...
54+
// }
55+
//
56+
// Example 2: Pack and unpack a message in Java.
57+
//
58+
// Foo foo = ...;
59+
// Any any = Any.pack(foo);
60+
// ...
61+
// if (any.is(Foo.class)) {
62+
// foo = any.unpack(Foo.class);
63+
// }
64+
// // or ...
65+
// if (any.isSameTypeAs(Foo.getDefaultInstance())) {
66+
// foo = any.unpack(Foo.getDefaultInstance());
67+
// }
68+
//
69+
// Example 3: Pack and unpack a message in Python.
70+
//
71+
// foo = Foo(...)
72+
// any = Any()
73+
// any.Pack(foo)
74+
// ...
75+
// if any.Is(Foo.DESCRIPTOR):
76+
// any.Unpack(foo)
77+
// ...
78+
//
79+
// Example 4: Pack and unpack a message in Go
80+
//
81+
// foo := &pb.Foo{...}
82+
// any, err := anypb.New(foo)
83+
// if err != nil {
84+
// ...
85+
// }
86+
// ...
87+
// foo := &pb.Foo{}
88+
// if err := any.UnmarshalTo(foo); err != nil {
89+
// ...
90+
// }
91+
//
92+
// The pack methods provided by protobuf library will by default use
93+
// 'type.googleapis.com/full.type.name' as the type URL and the unpack
94+
// methods only use the fully qualified type name after the last '/'
95+
// in the type URL, for example "foo.bar.com/x/y.z" will yield type
96+
// name "y.z".
97+
//
98+
// JSON
99+
// ====
100+
// The JSON representation of an `Any` value uses the regular
101+
// representation of the deserialized, embedded message, with an
102+
// additional field `@type` which contains the type URL. Example:
103+
//
104+
// package google.profile;
105+
// message Person {
106+
// string first_name = 1;
107+
// string last_name = 2;
108+
// }
109+
//
110+
// {
111+
// "@type": "type.googleapis.com/google.profile.Person",
112+
// "firstName": <string>,
113+
// "lastName": <string>
114+
// }
115+
//
116+
// If the embedded message type is well-known and has a custom JSON
117+
// representation, that representation will be embedded adding a field
118+
// `value` which holds the custom JSON in addition to the `@type`
119+
// field. Example (for message [google.protobuf.Duration][]):
120+
//
121+
// {
122+
// "@type": "type.googleapis.com/google.protobuf.Duration",
123+
// "value": "1.212s"
124+
// }
125+
//
126+
message Any {
127+
// A URL/resource name that uniquely identifies the type of the serialized
128+
// protocol buffer message. This string must contain at least
129+
// one "/" character. The last segment of the URL's path must represent
130+
// the fully qualified name of the type (as in
131+
// `path/google.protobuf.Duration`). The name should be in a canonical form
132+
// (e.g., leading "." is not accepted).
133+
//
134+
// In practice, teams usually precompile into the binary all types that they
135+
// expect it to use in the context of Any. However, for URLs which use the
136+
// scheme `http`, `https`, or no scheme, one can optionally set up a type
137+
// server that maps type URLs to message definitions as follows:
138+
//
139+
// * If no scheme is provided, `https` is assumed.
140+
// * An HTTP GET on the URL must yield a [google.protobuf.Type][]
141+
// value in binary format, or produce an error.
142+
// * Applications are allowed to cache lookup results based on the
143+
// URL, or have them precompiled into a binary to avoid any
144+
// lookup. Therefore, binary compatibility needs to be preserved
145+
// on changes to types. (Use versioned type names to manage
146+
// breaking changes.)
147+
//
148+
// Note: this functionality is not currently available in the official
149+
// protobuf release, and it is not used for type URLs beginning with
150+
// type.googleapis.com. As of May 2023, there are no widely used type server
151+
// implementations and no plans to implement one.
152+
//
153+
// Schemes other than `http`, `https` (or the empty scheme) might be
154+
// used with implementation specific semantics.
155+
//
156+
string type_url = 1;
157+
// Must be a valid serialized protocol buffer of the above specified type.
158+
bytes value = 2; }
159+

0 commit comments

Comments
 (0)