Skip to content

Commit 65f0a7c

Browse files
Merge branch 'kythe:master' into master
2 parents 9db9df3 + ede6dfb commit 65f0a7c

File tree

11 files changed

+970
-28
lines changed

11 files changed

+970
-28
lines changed

RELEASES.md

+42-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,45 @@
11
# Release Notes
22

3+
## [v0.0.68] - 2025-01-06
4+
#### Bug Fixes
5+
* **go_indexer:**
6+
* emit docs nodes for interface methods (#6060) ([07be8602](https://github.com/kythe/kythe/commit/07be8602deb772705ed78c71fe5b74137c7fce09))
7+
* emit bindings for named interface method params (#6061) ([e1713667](https://github.com/kythe/kythe/commit/e17136673a160d087e86ca0cab2ac43b7564cb36))
8+
* emit nodes for anonymous interface params (#6062) ([1d7a58a1](https://github.com/kythe/kythe/commit/1d7a58a1797801462a2cd1a86128a2328c9256dd))
9+
* only handle top-level flags (#6063) ([f6b2e265](https://github.com/kythe/kythe/commit/f6b2e265012974038c7bcbea2fa9c7677fc90185))
10+
* **bazel:**
11+
* remove cyclic dependency by removing usage of assign_external_projects_to_separate_corpora config_setting flag (#6146) ([46275ee6](https://github.com/kythe/kythe/commit/46275ee670cab83d0c86ed3a5fbcfe826d386dac))
12+
* **java_indexer:**
13+
* emit node kinds for jvm nodes (#6077) ([22726c4e](https://github.com/kythe/kythe/commit/22726c4ec9f911a2bb38c2284f2064eaff4641af))
14+
* emit jvm refs for enum constants (#6103) ([b6c04946](https://github.com/kythe/kythe/commit/b6c049462ed9b8a5cca671c3d3e2a9b2fa9e71c3))
15+
* **cxx_indexer:**
16+
* use flat_hash_map, not unordered_map; fix rehashing (#6083) ([cba4452d](https://github.com/kythe/kythe/commit/cba4452dc97187e1172d412961d7da494fa32182))
17+
* clarify the use of llvm::dyn_cast on ClaimTokens (#6093) ([ae3434e7](https://github.com/kythe/kythe/commit/ae3434e763027ae747996ca2f6daaf0de71613fd))
18+
* **verifier_test:** ensure tools use the same configuration as indexer (#6113) ([d19f7f30](https://github.com/kythe/kythe/commit/d19f7f30d69c72bf673465a60c47d2303756cc40))
19+
* **extraction:** add proto rule to simple vnames config (#6068) ([28c16cff](https://github.com/kythe/kythe/commit/28c16cff1815c8980004d5192e02dcc07bd87762))
20+
21+
#### Features
22+
* **go_indexer:**
23+
* support flag field vars (#6064) ([df747be8](https://github.com/kythe/kythe/commit/df747be8fb4b999d813e7a57eb0c270a32f6ebe5))
24+
* ref/writes for flag.Set invocations (#6085) ([ae1f3644](https://github.com/kythe/kythe/commit/ae1f36447dc41e74a2ec6b23e703b62ebd349e51))
25+
* **cxx_indexer:**
26+
* experiment with variable initializer types (#6080) ([68671474](https://github.com/kythe/kythe/commit/68671474b72d5387f14fab7133cc29de75ebf86c))
27+
* only emit flattened type representations once (#6082) ([a7f7af76](https://github.com/kythe/kythe/commit/a7f7af76587c9d9a0637ccdff9c5be90f62b3b62))
28+
* look through the obvious casts for init types (#6081) ([49d98e25](https://github.com/kythe/kythe/commit/49d98e258bdaf930924d3b56ebd3ab77e467967c))
29+
* emit symbols for extern C function defns (#6104) ([5b920720](https://github.com/kythe/kythe/commit/5b9207200c01371ddb29293cc3831d0b63f58faa))
30+
* emit name nodes for flags (#6094) ([b1cc57f6](https://github.com/kythe/kythe/commit/b1cc57f64ac7833be44aace759211a98baf15d8c))
31+
* **typescript_indexer:**
32+
* support xrefs in nested object literals (#6125) ([3a66d508](https://github.com/kythe/kythe/commit/3a66d508dbd7094139c14a745fc72058756dbb47))
33+
* add flag to fail analysis on plugin error (#6079) ([65d37c97](https://github.com/kythe/kythe/commit/65d37c972697b201b8c6916811a7607a473ae568))
34+
* **java_indexer:**
35+
* add names for native methods (#6108) ([f13abd65](https://github.com/kythe/kythe/commit/f13abd65999cdbce234fb189cc1e48a70184fe61))
36+
* **protobuf:** add types for protobuf service RPCs (#6109) ([9cd1af59](https://github.com/kythe/kythe/commit/9cd1af596659580469c0aa6a060b4c4a526235aa))
37+
* **tools:** --render_marked_source added to kythe docs cli (#6097) ([cc445fd5](https://github.com/kythe/kythe/commit/cc445fd57ca2d99322e35a65dd723bf1c2398c65))
38+
* **tooling:** entrystream support for textproto output (#6087) ([94e76f87](https://github.com/kythe/kythe/commit/94e76f8791f17a847eb497f78df10f19fbbfdb01))
39+
* define a Language schema enum (#6067) ([7206b16d](https://github.com/kythe/kythe/commit/7206b16d0a7618b1e346edda93cf63612ba2bd6b))
40+
* **build:** regenerate checked-in source artifacts in pre-commit (#6072) ([9db7d1c4](https://github.com/kythe/kythe/commit/9db7d1c4d50f9e8f1a0d827fb57215c40032a943))
41+
* **testing:** provide ability to save logs from indexers in verifier_test (#6075) ([97d1980e](https://github.com/kythe/kythe/commit/97d1980e425da3218d7d235edc38ce61d6286542))
42+
343
## [v0.0.67] - 2024-03-14
444

545
#### Bug Fixes
@@ -1753,7 +1793,8 @@ https://github.com/kythe/kythe/compare/v0.0.26...v0.0.27
17531793

17541794
Initial release
17551795

1756-
[Unreleased] https://github.com/kythe/kythe/compare/v0.0.67...HEAD
1796+
[Unreleased] https://github.com/kythe/kythe/compare/v0.0.68...HEAD
1797+
[v0.0.68] https://github.com/kythe/kythe/compare/v0.0.67...v0.0.68
17571798
[v0.0.67] https://github.com/kythe/kythe/compare/v0.0.66...v0.0.67
17581799
[v0.0.66] https://github.com/kythe/kythe/compare/v0.0.65...v0.0.66
17591800
[v0.0.65] https://github.com/kythe/kythe/compare/v0.0.64...v0.0.65

kythe/cxx/common/json_proto.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ absl::Status WriteMessageAsJsonToStringInternal(
9898
options.preserve_proto_field_names = true;
9999

100100
auto status = google::protobuf::util::BinaryToJsonString(
101-
resolver.get(), message.GetDescriptor()->full_name(),
101+
resolver.get(), std::string(message.GetDescriptor()->full_name()),
102102
message.SerializeAsString(), out, options);
103103
if (!status.ok()) {
104104
return absl::Status(static_cast<absl::StatusCode>(status.code()),
@@ -143,8 +143,8 @@ absl::Status ParseFromJsonStream(
143143
std::string binary;
144144
google::protobuf::io::StringOutputStream output(&binary);
145145
auto status = google::protobuf::util::JsonToBinaryStream(
146-
resolver.get(), message->GetDescriptor()->full_name(), input, &output,
147-
options);
146+
resolver.get(), std::string(message->GetDescriptor()->full_name()), input,
147+
&output, options);
148148

149149
if (!status.ok()) {
150150
return absl::Status(static_cast<absl::StatusCode>(status.code()),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,246 @@
1+
/*
2+
* Copyright 2014 The Kythe Authors. All rights reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.devtools.kythe.platform.java.helpers;
18+
19+
import com.google.common.flogger.FluentLogger;
20+
import com.sun.source.tree.BlockTree;
21+
import com.sun.source.tree.CatchTree;
22+
import com.sun.source.tree.ClassTree;
23+
import com.sun.source.tree.CompilationUnitTree;
24+
import com.sun.source.tree.EnhancedForLoopTree;
25+
import com.sun.source.tree.ForLoopTree;
26+
import com.sun.source.tree.MethodTree;
27+
import com.sun.source.tree.Tree;
28+
import com.sun.source.util.TreePath;
29+
import com.sun.source.util.TreeScanner;
30+
import com.sun.tools.javac.tree.JCTree;
31+
import com.sun.tools.javac.tree.JCTree.JCBlock;
32+
import com.sun.tools.javac.tree.JCTree.JCClassDecl;
33+
import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
34+
import java.util.HashMap;
35+
import java.util.Map;
36+
import javax.lang.model.element.Element;
37+
import org.checkerframework.checker.nullness.qual.Nullable;
38+
39+
/**
40+
* This class is responsible for generating signatures for blocks and anonymous classes. The maps
41+
* used for caching in this class are specific through out the life of analyzer and they can be used
42+
* for one or more compilation units which are part of one compilation context.
43+
*/
44+
public class BlockAnonymousSignatureGenerator
45+
extends TreeScanner<Void, BlockAnonymousSignatureGenerator.BlockAnonymousData> {
46+
/*
47+
* Blocks are numbered sequentially from zero within a class scope or a method scope.
48+
* Here is an example of block numbering:
49+
* <code><pre>
50+
* class A {// block 0
51+
* {// block 1
52+
* {// block 2
53+
* }
54+
* }
55+
* {// block 3
56+
* }
57+
* void method() {// block 0
58+
* {// block 1
59+
* }
60+
* if (true) {// block 2
61+
* } else {// block 3
62+
* }
63+
* }
64+
* }
65+
* </code></pre>
66+
*/
67+
68+
static class BlockAnonymousData {
69+
int blockNumber;
70+
int anonymousNumber;
71+
final String topLevelSignature;
72+
73+
public BlockAnonymousData(int blockNumber, int anonymousNumber, String topLevelSignature) {
74+
this.blockNumber = blockNumber;
75+
this.anonymousNumber = anonymousNumber;
76+
this.topLevelSignature = topLevelSignature;
77+
}
78+
}
79+
80+
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
81+
private final SignatureGenerator signatureGenerator;
82+
83+
BlockAnonymousSignatureGenerator(SignatureGenerator signatureGenerator) {
84+
this.signatureGenerator = signatureGenerator;
85+
}
86+
87+
// Indicates whether the compilation unit has already been processed or not.
88+
private boolean unitProcessed = false;
89+
90+
// Holds the signature for each block visited.
91+
// Holds the signature for each anonymous class.
92+
// Anonymous classes are numbered with respect to their first enclosing class declaration or
93+
// block. They are numbered from zero.
94+
private final Map<Tree, String> blockAnonymousMap = new HashMap<>();
95+
96+
/** Returns the block signature of the corresponding element */
97+
String getBlockSignature(Element element) {
98+
TreePath path = signatureGenerator.getPath(element);
99+
if (path == null) {
100+
throw new IllegalStateException("path was null for element: " + element);
101+
}
102+
return getBlockSignature(path);
103+
}
104+
105+
/** Returns the block signature of the corresponding path */
106+
String getBlockSignature(TreePath path) {
107+
this.process(path.getCompilationUnit());
108+
path = path.getParentPath();
109+
JCTree parent = (JCTree) path.getLeaf();
110+
while (!(parent.getTag() == JCTree.Tag.BLOCK
111+
|| parent.getTag() == JCTree.Tag.CLASSDEF
112+
|| parent.getTag() == JCTree.Tag.FORLOOP
113+
|| parent.getTag() == JCTree.Tag.FOREACHLOOP
114+
|| parent.getTag() == JCTree.Tag.METHODDEF
115+
|| parent.getTag() == JCTree.Tag.CATCH)) {
116+
path = path.getParentPath();
117+
parent = (JCTree) path.getLeaf();
118+
}
119+
if (parent.getTag() == JCTree.Tag.BLOCK
120+
|| parent.getTag() == JCTree.Tag.FORLOOP
121+
|| parent.getTag() == JCTree.Tag.FOREACHLOOP
122+
|| parent.getTag() == JCTree.Tag.CATCH) {
123+
return blockAnonymousMap.get(parent);
124+
} else if (parent.getTag() == JCTree.Tag.METHODDEF) {
125+
JCMethodDecl methodDecl = (JCMethodDecl) parent;
126+
StringBuilder methodSignature = new StringBuilder();
127+
methodDecl.sym.accept(this.signatureGenerator, methodSignature);
128+
return methodSignature.toString();
129+
} else {
130+
JCClassDecl classDecl = (JCClassDecl) parent;
131+
StringBuilder classSignature = new StringBuilder();
132+
classDecl.sym.accept(this.signatureGenerator, classSignature);
133+
return classSignature.toString();
134+
}
135+
}
136+
137+
boolean isInBlock(Element e) {
138+
TreePath tp = signatureGenerator.getPath(e);
139+
JCTree parent = null;
140+
do {
141+
if (tp != null) {
142+
parent = (JCTree) tp.getLeaf();
143+
} else {
144+
return false;
145+
}
146+
tp = tp.getParentPath();
147+
} while (parent.getTag() != JCTree.Tag.BLOCK);
148+
return parent.getTag() == JCTree.Tag.BLOCK;
149+
}
150+
151+
// Returns the anonymous signature of the corresponding element. Element is supposed to be an
152+
// anonymous class definition.
153+
@Nullable String getAnonymousSignature(Element e) {
154+
TreePath tp = signatureGenerator.getPath(e);
155+
if (tp == null) {
156+
return null;
157+
}
158+
this.process(tp.getCompilationUnit());
159+
return blockAnonymousMap.get(tp.getLeaf());
160+
}
161+
162+
private void process(CompilationUnitTree unit) {
163+
if (!unitProcessed) {
164+
unitProcessed = true;
165+
unit.accept(this, new BlockAnonymousData(0, 0, ""));
166+
}
167+
}
168+
169+
@Override
170+
public Void visitMethod(MethodTree methodTree, BlockAnonymousData blockData) {
171+
JCMethodDecl methodDecl = (JCMethodDecl) methodTree;
172+
StringBuilder methodSignature = new StringBuilder();
173+
if (methodDecl.sym == null) {
174+
logger.atInfo().log("methodDecl symbol was null");
175+
return null;
176+
}
177+
methodDecl.sym.accept(signatureGenerator, methodSignature);
178+
return super.visitMethod(methodTree, new BlockAnonymousData(-1, 0, methodSignature.toString()));
179+
}
180+
181+
@Override
182+
public Void visitClass(ClassTree classTree, BlockAnonymousData blockData) {
183+
JCClassDecl classDecl = (JCClassDecl) classTree;
184+
if (classTree.getSimpleName().contentEquals("")) {
185+
StringBuilder anonymousClassSignature = new StringBuilder();
186+
if (classDecl.sym != null) {
187+
anonymousClassSignature.append(getBlockSignature(classDecl.sym));
188+
} else {
189+
String name = classDecl.name == null ? "" : classDecl.name.toString();
190+
logger.atWarning().log(
191+
"BlockAnonymous class symbol was null: %s#%d", name, blockData.anonymousNumber);
192+
}
193+
anonymousClassSignature.append(SignatureGenerator.ANONYMOUS);
194+
anonymousClassSignature.append("#");
195+
anonymousClassSignature.append(blockData.anonymousNumber);
196+
blockAnonymousMap.put(classDecl, anonymousClassSignature.toString());
197+
blockData.anonymousNumber++;
198+
return super.visitClass(
199+
classTree, new BlockAnonymousData(0, 0, blockAnonymousMap.get(classDecl)));
200+
} else {
201+
StringBuilder classSignature = new StringBuilder();
202+
classDecl.sym.accept(this.signatureGenerator, classSignature);
203+
return super.visitClass(classTree, new BlockAnonymousData(0, 0, classSignature.toString()));
204+
}
205+
}
206+
207+
@Override
208+
public Void visitEnhancedForLoop(
209+
EnhancedForLoopTree enhancedForLoopTree, BlockAnonymousData blockData) {
210+
blockAnonymousMap.put(
211+
enhancedForLoopTree, blockData.topLevelSignature + ".{}" + (blockData.blockNumber + 1));
212+
if (enhancedForLoopTree.getStatement().getKind() != Tree.Kind.BLOCK) {
213+
blockData.blockNumber++;
214+
}
215+
return super.visitEnhancedForLoop(enhancedForLoopTree, blockData);
216+
}
217+
218+
@Override
219+
public Void visitForLoop(ForLoopTree forLoopTree, BlockAnonymousData blockData) {
220+
blockAnonymousMap.put(
221+
forLoopTree, blockData.topLevelSignature + ".{}" + (blockData.blockNumber + 1));
222+
if (forLoopTree.getStatement().getKind() != Tree.Kind.BLOCK) {
223+
blockData.blockNumber++;
224+
}
225+
return super.visitForLoop(forLoopTree, blockData);
226+
}
227+
228+
@Override
229+
public Void visitCatch(CatchTree catchTree, BlockAnonymousData blockData) {
230+
blockAnonymousMap.put(
231+
catchTree, blockData.topLevelSignature + ".{}" + (blockData.blockNumber + 1));
232+
return super.visitCatch(catchTree, blockData);
233+
}
234+
235+
@Override
236+
public Void visitBlock(BlockTree b, BlockAnonymousData blockData) {
237+
blockData.blockNumber++;
238+
JCBlock block = (JCBlock) b;
239+
blockAnonymousMap.put(block, blockData.topLevelSignature + ".{}" + blockData.blockNumber);
240+
BlockAnonymousData newBlockAnonymousData =
241+
new BlockAnonymousData(blockData.blockNumber, 0, blockData.topLevelSignature);
242+
super.visitBlock(block, newBlockAnonymousData);
243+
blockData.blockNumber = newBlockAnonymousData.blockNumber;
244+
return null;
245+
}
246+
}

0 commit comments

Comments
 (0)