kythe.io@v0.0.68-0.20240422202219-7225dbc01741/kythe/proto/explore.proto (about) 1 /* 2 * Copyright 2018 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 syntax = "proto3"; 18 19 package kythe.proto; 20 21 option go_package = "kythe.io/kythe/proto/explore_go_proto"; 22 option java_package = "com.google.devtools.kythe.proto"; 23 option java_multiple_files = true; 24 25 import "kythe/proto/common.proto"; 26 import "kythe/proto/storage.proto"; 27 import "kythe/proto/xref.proto"; 28 29 // This file defines code graph exploration interfaces, based on Kythe data. 30 // Design doc: go/kythe-api-proposal 31 // 32 // Tickets are Kythe URIs (http://www.kythe.io/docs/kythe-uri-spec.html). 33 34 // ExploreService provides read-only access to aspects of the Kythe code graph, 35 // such as type hierarchies, call graphs, function parameters, and 36 // parents/children relationships. Requests should generally take time 37 // proportional to the size of the response (in the absence of filtering, at 38 // least). 39 40 // In cases where properties of a node are requested (e.g. callers of a 41 // function) for which there are no such (e.g., the function has no callers), 42 // the response will not include that node. 43 44 // THIS API IS EXPERIMENTAL; IMPLEMENTATION IS IN PROGRESS, AND THE API AND 45 // IMPLEMENTATION ARE SUBJECT TO CHANGE. PLEASE DO NOT USE WITHOUT CONTACTING 46 // THE KYTHE TEAM (kythe-dev@googlegroups.com). 47 48 service ExploreService { 49 // Returns the (recursive) callers of a specified function, as a directed 50 // graph. 51 // The Callers/Callees functions are distinct from XrefService.CrossReferences 52 // in that these functions capture the semantic relationships between methods, 53 // rather than the locations in the code base where a method is called. 54 rpc Callers(CallersRequest) returns (CallersReply) {} 55 56 // Returns the (recursive) callees of a specified function (that is, what 57 // functions this function calls), as a directed graph. 58 rpc Callees(CalleesRequest) returns (CalleesReply) {} 59 60 // Returns the parents of a specified node (for example, 61 // the file for a class, or the class for a function). 62 // Note that in some cases a node may have more than one parent. 63 rpc Parents(ParentsRequest) returns (ParentsReply) {} 64 65 // Returns the children of a specified node (for example, 66 // the classes contained in a file, or the functions contained in a class). 67 rpc Children(ChildrenRequest) returns (ChildrenReply) {} 68 69 // Returns the hierarchy (supertypes and subtypes, including implementations) 70 // of a specified type, as a directed acyclic graph. 71 // NOT YET IMPLEMENTED 72 rpc TypeHierarchy(TypeHierarchyRequest) returns (TypeHierarchyReply) {} 73 74 // Returns the parameters of a specified function. 75 // NOT YET IMPLEMENTED 76 rpc Parameters(ParametersRequest) returns (ParametersReply) {} 77 } 78 79 // Shared/utility messages 80 81 message NodeData { 82 // the "node/[sub]kind" node facts 83 string kind = 1; 84 string subkind = 2; 85 86 // the relevant locations in which this node is found 87 // TODO: do we want span-specific locations? 88 repeated Location locations = 3; 89 90 // anchor ticket 91 string definition_anchor = 4; 92 93 common.MarkedSource code = 5; 94 } 95 96 // If the RPC request does not specify otherwise, successors and predecessors 97 // are both populated. 98 message GraphNode { 99 NodeData node_data = 1; 100 101 // semantic tickets of nodes connected to this node by incoming edges 102 repeated string predecessors = 2; 103 104 // semantic tickets of nodes connected to this node by outgoing edges 105 repeated string successors = 3; 106 } 107 108 message Graph { 109 map<string, GraphNode> nodes = 1; // semantic ticket -> node/topology data 110 } 111 112 // Imposes restrictions on the nodes returned for a query. 113 // An unset NodeFilter is interpreted as "no restrictions on nodes returned". 114 message NodeFilter { 115 // if set, only return nodes whose languages match any of these strings 116 // TODO: consider enabling VName-based filtering for nodes as well as files 117 repeated string included_languages = 1; 118 119 // if set, only return nodes whose files match any of these VNames 120 // Only the parts of the VName that relate to files are relevant here: 121 // https://kythe.io/docs/schema/#_vname_conventions 122 // TODO: consider also supplying exclusion specs as well as inclusion 123 repeated VName included_files = 2; 124 } 125 126 // Used where we need a collection of tickets (either because we need it for a 127 // map or to be able to distinguish between "unset" and "empty"). 128 // If a Tickets field is unset, that means that it has not been populated; 129 // if it is set but there are no tickets in the list, then there are no tickets 130 // of the designated variety in the containing message. 131 message Tickets { 132 repeated string tickets = 1; 133 } 134 135 // Type hierarchy 136 // The type hierarchy is represented in the response as a graph, with the 137 // input ticket marked. The graph will be acyclic. 138 // node types: "record" (class), "interface" 139 // edge types: "extends", "satisfies" (any given response will likely only 140 // include one edge type unless the type hierarchy crosses a language 141 // boundary). 142 143 message TypeHierarchyRequest { 144 string type_ticket = 1; 145 146 NodeFilter node_filter = 2; 147 } 148 149 // Edge types are implicit (see above) 150 message TypeHierarchyReply { 151 // same as type_ticket in request 152 string type_ticket = 1; 153 154 Graph graph = 2; 155 } 156 157 // Call graph 158 // These APIs are for capturing the graphs induced by the _semantic_ relations 159 // between calling/callable nodes (for example, the functions that call, or are 160 // called by, this function node). 161 // 162 // If you’re looking for a one-ply relationship between functions and the 163 // _locations_ in the code at which they are called, Kythe XRefService's 164 // CrossReferences API should do what you want. 165 166 // Requests the incoming callgraphs for each of the specified nodes. 167 message CallersRequest { 168 repeated string tickets = 1; 169 } 170 171 message CallersReply { 172 // Represents the call relationships to each of the input tickets, from 173 // all callers of those tickets, as a single graph. 174 Graph graph = 1; 175 } 176 177 // Requests the outgoing callgraphs for each of the specified nodes. 178 message CalleesRequest { 179 repeated string tickets = 1; 180 } 181 182 // TODO: consider merging this and CallersReply into a single message 183 // (CallgraphReply) unless we have reason to believe they need to be distinct 184 message CalleesReply { 185 // Represents the call relationships from each of the input tickets, to 186 // all callees of those tickets, as a single graph. 187 Graph graph = 1; 188 } 189 190 // Function parameters 191 // node types: function 192 // edge types: TBD 193 194 // Requests the parameters and return value of the specified function 195 message ParametersRequest { 196 repeated string function_tickets = 1; 197 } 198 199 message ParametersReply { 200 map<string, Tickets> function_to_parameters = 1; 201 202 map<string, string> function_to_return_value = 2; 203 204 // data for functions and parameters 205 map<string, NodeData> node_data = 3; 206 } 207 208 // Parents and children 209 // node types: package, record (class), interface, function, ... 210 // edge type: childof 211 212 // * what package is this file/class/interface in? 213 // * what is the class/interface that this function is in? 214 215 // Fetches the tickets for the enclosing contexts of the specified ticket 216 // (e.g.: what package is this file in? what class is this function in?). 217 message ParentsRequest { 218 repeated string tickets = 1; 219 } 220 221 message ParentsReply { 222 // associates each input ticket with the set of tickets that contain it 223 map<string, Tickets> input_to_parents = 1; 224 } 225 226 // Fetches the tickets for which the specified ticket is the enclosing context 227 // (e.g. what files are in this package? what functions are in this class?). 228 message ChildrenRequest { 229 repeated string tickets = 1; 230 } 231 232 message ChildrenReply { 233 // associates each input ticket with the set of tickets contained by it 234 map<string, Tickets> input_to_children = 1; 235 }