kythe.io@v0.0.68-0.20240422202219-7225dbc01741/kythe/proto/serving.proto (about)

     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  syntax = "proto3";
    18  
    19  package kythe.proto.serving;
    20  
    21  option go_package = "kythe.io/kythe/proto/serving_go_proto";
    22  option java_package = "com.google.devtools.kythe.proto";
    23  
    24  import "kythe/proto/common.proto";
    25  
    26  // A derivative of xref.NodeInfo for serving.
    27  message Node {
    28    string ticket = 1;
    29    repeated kythe.proto.common.Fact fact = 2;
    30  
    31    // This node's definition location (anchor).
    32    ExpandedAnchor definition_location = 3;
    33  
    34    double rank = 4;
    35  }
    36  
    37  // Full representation of a Kythe edge; useful during post-processing.
    38  message Edge {
    39    Node source = 1;
    40    string kind = 2;
    41    int32 ordinal = 5;
    42    Node target = 3;
    43  
    44    repeated kythe.proto.common.Fact fact = 4;
    45  }
    46  
    47  // An EdgeGroup represents a set of edges with the same kind and source.
    48  //
    49  // Note: this is a derivative of xref.EdgeSet_Group
    50  message EdgeGroup {
    51    message Edge {
    52      Node target = 1;
    53      int32 ordinal = 2;
    54    }
    55    string kind = 1;
    56    repeated Edge edge = 2;
    57  }
    58  
    59  // PagedEdgeSets are used for efficiently storing EdgeSets, all originating from
    60  // the same source ticket, in order to handle pagination requests.
    61  message PagedEdgeSet {
    62    // The source node for all the edges in the edge set.
    63    Node source = 1;
    64  
    65    // Each group is a collection of outbound edges from source node sharing a
    66    // given kind.
    67    repeated EdgeGroup group = 2;
    68  
    69    // Total number of edges in all of the EdgePages, including this one.
    70    int32 total_edges = 3 [deprecated = true];
    71  
    72    // Page indices for other EdgePages, sorted by edge kind.
    73    repeated PageIndex page_index = 4;
    74  }
    75  
    76  // PageIndex is a pointer to an EdgePage.  In order to keep the PagedEdgeSet
    77  // small, we don't store edges here.  We just store a key for looking up an
    78  // EdgePage and the type of edge.
    79  message PageIndex {
    80    // The kind of all edges on the referred EdgePage.
    81    string edge_kind = 1;
    82  
    83    // Total number of edges on the referred EdgePage.
    84    int32 edge_count = 2;
    85  
    86    // Key that can be used to lookup the referred EdgePage.
    87    string page_key = 3;
    88  }
    89  
    90  // EdgePages are a group of edges for a particular edge kind and source ticket.
    91  message EdgePage {
    92    // Corresponding PageIndex key that can be used to lookup this page.
    93    string page_key = 1;
    94    string source_ticket = 2;
    95    EdgeGroup edges_group = 3;
    96  }
    97  
    98  // FileDirectory describes a virtual directory of file nodes.
    99  message FileDirectory {
   100    // Each known entry in the directory.
   101    repeated Entry entry = 3;
   102  
   103    message Entry {
   104      // The kind of entry.
   105      Kind kind = 1;
   106  
   107      // The basename of the entry within the directory.
   108      string name = 2;
   109  
   110      // Set of known build configurations of this FILE or all files recursively
   111      // contained in/below this DIRECTORY.
   112      repeated string build_config = 3;
   113  
   114      // True if this entry is generated.
   115      bool generated = 4;
   116  
   117      // Whether the FILE Entry did not have an associated text fact.
   118      bool missing_text = 5;
   119    }
   120    enum Kind {
   121      UNKNOWN = 0;
   122      FILE = 1;
   123      DIRECTORY = 2;
   124    }
   125  
   126    // Set of URIs for each contained sub-directory's corpus, root, and full path.
   127    repeated string subdirectory = 1 [deprecated = true];
   128    // Set of file node tickets contained within this directory.
   129    repeated string file_ticket = 2 [deprecated = true];
   130  }
   131  
   132  // CorpusRoots describes all of the known corpus/root pairs that contain file
   133  // nodes.
   134  message CorpusRoots {
   135    message Corpus {
   136      string corpus = 1;
   137      repeated string root = 2;
   138      repeated string build_config = 3;
   139    }
   140    repeated Corpus corpus = 1;
   141  }
   142  
   143  // A File is a specialized Node structure for file nodes.
   144  message File {
   145    string ticket = 1;
   146    optional bytes text = 2;
   147    string encoding = 3;
   148  
   149    FileInfo info = 4;
   150  }
   151  
   152  // A RawAnchor is a specialized Node structure for anchor nodes.
   153  message RawAnchor {
   154    string ticket = 1;
   155    int32 start_offset = 2;
   156    int32 end_offset = 3;
   157  
   158    int32 snippet_start = 4;
   159    int32 snippet_end = 5;
   160  
   161    string build_configuration = 6;
   162  }
   163  
   164  // ExpandedAnchors are constructed from an RawAnchor and its associated File.
   165  // They contain normalized Spans based on their parent file's text as well as
   166  // the UTF8-encoded text for both the anchor's span and its snippet span.
   167  message ExpandedAnchor {
   168    string ticket = 1;
   169    string kind = 2;
   170    reserved 3;
   171  
   172    string text = 4;
   173    kythe.proto.common.Span span = 5;
   174  
   175    string snippet = 6;
   176    kythe.proto.common.Span snippet_span = 7;
   177  
   178    string build_configuration = 8;
   179  
   180    double rank = 9;
   181  
   182    // Info for parent file
   183    FileInfo file_info = 10;
   184  }
   185  
   186  message FileInfo {
   187    // Structured path of the file
   188    kythe.proto.common.CorpusPath corpus_path = 1;
   189  
   190    string revision = 2;
   191  
   192    // Hash of the file contents; the algorithm of the hash may differ between
   193    // corpora based on the repository from which they were extracted.
   194    kythe.proto.common.Hash hash = 3;
   195  
   196    // Signifies whether there are restrictions for viewing this file in some
   197    // context.
   198    bool view_restricted = 4;
   199  }
   200  
   201  // FileDecorations stores a file's contents and all contained anchor edges.
   202  message FileDecorations {
   203    File file = 1;
   204  
   205    // Represents an edge from an anchor contained within the file to some target.
   206    message Decoration {
   207      RawAnchor anchor = 1;
   208      string kind = 2;
   209      string target = 5;
   210  
   211      string target_definition = 4;
   212      string semantic_scope = 6;
   213    }
   214  
   215    // The decorations located in the file, sorted by starting offset.
   216    repeated Decoration decoration = 2;
   217  
   218    // Set of nodes associated with each Decoration.target and
   219    // target_override.overridden.
   220    repeated Node target = 4;
   221  
   222    // Set of definition locations for each Decoration.target and
   223    // target_override.overridden.
   224    repeated ExpandedAnchor target_definitions = 3;
   225  
   226    // An overrides/extends for a defining Decoration's target.
   227    //
   228    // Example:
   229    //   overriding:  "kythe:#java.lang.String"
   230    //   kind:        EXTENDS
   231    //   overridden:  "kythe:#java.lang.Object"
   232    message Override {
   233      // What kind of override this is.
   234      enum Kind {
   235        OVERRIDES = 0;
   236        EXTENDS = 1;
   237      }
   238  
   239      // Ticket of overriding node (i.e. a Decoration target for a definition)
   240      string overriding = 1;
   241      // Ticket of node that is being overridden/extended.
   242      string overridden = 2;
   243      string overridden_definition = 5;
   244  
   245      Kind kind = 3;
   246  
   247      // MarkedSource for the node being overridden/extended (i.e. node whose
   248      // ticket is overridden).
   249      kythe.proto.common.MarkedSource marked_source = 4;
   250    }
   251  
   252    // List of overrides for target semantic nodes.
   253    repeated Override target_override = 5;
   254  
   255    // List of file diagnostics.
   256    repeated kythe.proto.common.Diagnostic diagnostic = 6;
   257  
   258    // List of tickets for files that generate this file.
   259    repeated string generated_by = 7;
   260  
   261    // List of files referenced in the decorations
   262    repeated FileInfo file_info = 8;
   263  }
   264  
   265  // PagedCrossReferences are used for efficiently storing pre-cached data for
   266  // CrossReferencesReply.{definition,reference,caller} anchors and related
   267  // nodes.
   268  message PagedCrossReferences {
   269    reserved 10;
   270  
   271    // Nodes with cross-references that should be merged into this node's set of
   272    // cross-references.  These are highly related nodes that share a definition.
   273    repeated string merge_with = 7;
   274  
   275    // Node which is related to the source_ticket node.  The relation kind is
   276    // stored in each Group.  See: kythe.proto.CrossReferencesReply.RelatedNode.
   277    message RelatedNode {
   278      Node node = 1;
   279      int32 ordinal = 2;
   280    }
   281  
   282    // References to the source node with an associated semantic scope.
   283    message ScopedReference {
   284      // The definition anchor covering the semantic scope.
   285      ExpandedAnchor scope = 1;
   286      // The semantic ticket for the scope.
   287      string semantic_scope = 2;
   288  
   289      // MarkedSource for the scope.
   290      kythe.proto.common.MarkedSource marked_source = 3;
   291  
   292      // Specific locations within the scope that reference the source node.
   293      repeated ExpandedAnchor reference = 4;
   294    }
   295  
   296    // Caller of the source node with all associated callsites within the caller.
   297    message Caller {
   298      // The anchor covering the caller.
   299      ExpandedAnchor caller = 1;
   300  
   301      // The relevant semantic ticket for the caller.
   302      string semantic_caller = 2;
   303      // MarkedSource for the caller.
   304      kythe.proto.common.MarkedSource marked_source = 3;
   305  
   306      // Specific locations within the caller that caused the relationship to
   307      // exist.
   308      repeated ExpandedAnchor callsite = 4;
   309    }
   310  
   311    message Group {
   312      string kind = 1;
   313  
   314      // Build configuration for all anchors contained within the group.
   315      string build_config = 5;
   316  
   317      // A group is composed entirely of anchors, related nodes, or callers.
   318      repeated ExpandedAnchor anchor = 2;
   319      repeated RelatedNode related_node = 3;
   320      repeated Caller caller = 4;
   321      repeated ScopedReference scoped_reference = 7;
   322  
   323      // List of files referenced in the group
   324      repeated FileInfo file_info = 6;
   325    }
   326  
   327    message Page {
   328      string page_key = 1;
   329      string source_ticket = 2;
   330      Group group = 3;
   331    }
   332  
   333    // A PageIndex is a reference to a Page.
   334    message PageIndex {
   335      string kind = 1;
   336      int32 count = 2;
   337      string page_key = 3;
   338      string build_config = 4;
   339    }
   340  
   341    string source_ticket = 1;
   342    Node source_node = 8;
   343    repeated Group group = 2;
   344    repeated PageIndex page_index = 3;
   345    int32 total_references = 4 [deprecated = true];
   346  
   347    // Whether the source node is incomplete.  This changes whether
   348    // /kythe/edge/defines edges are considered declarations or definitions.
   349    // /kythe/edge/completedby edges are always grouped as definitions.
   350    bool incomplete = 5;
   351  
   352    // The source node's MarkedSource.
   353    kythe.proto.common.MarkedSource marked_source = 6;
   354  
   355    message PageSearchIndex {
   356      message Pages {
   357        // Set of page indices.
   358        //
   359        // These indices are sorted and then encoded as the difference between
   360        // consecutive elements.
   361        //
   362        // Example:
   363        //   [2, 5, 6] would be encoded here as [2, 3, 1]
   364        repeated uint32 page_index = 1 [packed = true];
   365      }
   366      message Postings {
   367        // trigram -> set of pages containing trigram
   368        map<uint32, Pages> index = 1;
   369      }
   370  
   371      Postings by_corpus = 1;
   372      Postings by_root = 2;
   373      Postings by_path = 3;
   374      Postings by_resolved_path = 4;
   375    }
   376  
   377    // Trigram search index for this set's xref Pages.
   378    PageSearchIndex page_search_index = 11;
   379  }
   380  
   381  // A single node's documentation for the xrefs Documentation API.
   382  message Document {
   383    string ticket = 1;
   384  
   385    // The node's MarkedSource.
   386    kythe.proto.common.MarkedSource marked_source = 2;
   387  
   388    // Raw text that can be displayed to the user (but may also contain markup
   389    // that can be interpreted, like Doxygen comments). Links are marked using [].
   390    // \ is an escape character (where possible escape sequences are \[, \], and
   391    // \\).
   392    string raw_text = 3;
   393  
   394    // Annotations for spans in raw_text. The ith Link corresponds to the span
   395    // starting at the ith [.
   396    repeated kythe.proto.common.Link link = 4;
   397  
   398    // Tickets for this document node's immediate children.
   399    repeated string child_ticket = 5;
   400  
   401    // Nodes referenced by documentation Links.
   402    repeated Node node = 6;
   403  
   404    // If non-empty, this is the ticket of a node whose documentation should
   405    // subsume this node's documentation.
   406    string documented_by = 7;
   407  }
   408  
   409  // A single identifier's information for the Identifier API
   410  message IdentifierMatch {
   411    message Node {
   412      // Kythe ticket for the matched node.
   413      string ticket = 1;
   414  
   415      // Ticket for the canonical node, if there is one. For example, if there is
   416      // a definition node and a declaration node only one will be the canonical
   417      // node.
   418      string canonical_node_ticket = 4;
   419  
   420      // Kind of the node being referenced.
   421      string node_kind = 2;
   422  
   423      // Subkind of the node being referenced.
   424      string node_subkind = 3;
   425    }
   426  
   427    // The fully qualified identifier for the node.
   428    string qualified_name = 1;
   429  
   430    // The local identifier for the node.
   431    string base_name = 2;
   432    repeated Node node = 3;
   433  }
   434  
   435  // Relatives stores the nodes connected to a reference node via childOf edges:
   436  // "parents" (nodes that the reference node is a childOf)
   437  // or "children" (nodes that are each a childOf of the reference node).
   438  // Used by ExploreService for the Parents and Children APIs.
   439  message Relatives {
   440    enum Type {
   441      UNKNOWN = 0;   // never a valid value
   442      PARENTS = 1;   // the reference node is a childOf each element of 'tickets'
   443      CHILDREN = 2;  // each element of 'tickets' is a childOf the reference node
   444    }
   445  
   446    // Nodes connected to a reference node via childOf edges.
   447    repeated string tickets = 1;
   448  
   449    Type type = 2;
   450  }
   451  
   452  // Callgraph stores the tickets for semantic nodes of functions that call, or
   453  // are called by, a reference function semantic node.
   454  // Used by ExploreService for the Caller and Callee APIs.
   455  message Callgraph {
   456    enum Type {
   457      UNKNOWN = 0;  // never a valid value
   458      CALLER = 1;   // each element of 'tickets' is a caller of the reference node
   459      CALLEE = 2;   // each element of 'tickets' is called by the reference node
   460    }
   461  
   462    // Nodes connected to a reference node via the call relationship.
   463    repeated string tickets = 1;
   464  
   465    Type type = 2;
   466  }
   467  
   468  // A Diff is a lossy, offset-only representation of a diff between two texts.
   469  message Diff {
   470    enum Type {
   471      EQUAL = 0;
   472      INSERT = 1;
   473      DELETE = 2;
   474    }
   475  
   476    // Parallel array of diff spans so the values are packed.
   477    repeated int32 span_length = 1 [packed = true];
   478    repeated Type span_type = 2 [packed = true];
   479    repeated int32 span_newlines = 3 [packed = true];
   480    repeated int32 span_first_newline = 4 [packed = true];
   481    repeated int32 span_last_newline = 5 [packed = true];
   482  }