kythe.io@v0.0.68-0.20240422202219-7225dbc01741/kythe/cxx/indexer/textproto/plugins/example/plugin.h (about) 1 /* 2 * Copyright 2020 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 #ifndef KYTHE_CXX_INDEXER_TEXTPROTO_PLUGINS_EXAMPLE_PLUGIN_H_ 18 #define KYTHE_CXX_INDEXER_TEXTPROTO_PLUGINS_EXAMPLE_PLUGIN_H_ 19 20 #include "kythe/cxx/indexer/textproto/plugin.h" 21 22 namespace kythe { 23 namespace lang_textproto { 24 25 // The example plugin demonstrates the implementation of a textproto plugin and 26 // serves as a test that the plugin system works. 27 // 28 // The proto schema defines a very simple social graph. The single message 29 // `Person` has a `name` field and a repeated `friend`s field. The plugin 30 // defines a new kythe semantic node for each person, using their name as the 31 // "signature". Each 'friend' entry in the textproto is treated as a `ref` to 32 // the semantic node representing the person of that name. Note that these 33 // semantic nodes have language="textproto_plugin_example" rather than 34 // "textproto". 35 class ExamplePlugin : public Plugin { 36 public: 37 ExamplePlugin(const google::protobuf::Message& proto) {} 38 39 absl::Status AnalyzeStringField( 40 PluginApi* api, const proto::VName& file_vname, 41 const google::protobuf::FieldDescriptor& field, 42 const std::vector<StringToken>& tokens) override; 43 }; 44 45 } // namespace lang_textproto 46 } // namespace kythe 47 48 #endif // KYTHE_CXX_INDEXER_TEXTPROTO_PLUGINS_EXAMPLE_PLUGIN_H_