kythe.io@v0.0.68-0.20240422202219-7225dbc01741/kythe/cxx/indexer/textproto/plugin_registry.cc (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  #include "plugin_registry.h"
    18  
    19  #include "absl/flags/flag.h"
    20  #include "kythe/cxx/indexer/textproto/plugins/example/plugin.h"
    21  
    22  ABSL_FLAG(bool, enable_example_plugin, false,
    23            "Enable the 'example' textproto plugin");
    24  
    25  namespace kythe {
    26  namespace lang_textproto {
    27  
    28  std::vector<std::unique_ptr<Plugin>> LoadRegisteredPlugins(
    29      const google::protobuf::Message& proto) {
    30    std::vector<std::unique_ptr<Plugin>> plugins;
    31    std::string msg_name = proto.GetDescriptor()->full_name();
    32    if (absl::GetFlag(FLAGS_enable_example_plugin) &&
    33        msg_name == "kythe_plugin_example.Person") {
    34      plugins.push_back(
    35          std::make_unique<kythe::lang_textproto::ExamplePlugin>(proto));
    36    }
    37    return plugins;
    38  }
    39  
    40  }  // namespace lang_textproto
    41  }  // namespace kythe