github.com/bazelbuild/bazel-gazelle@v0.36.1-0.20240520142334-61b277ba6fed/internal/gazellebinarytest/xlang.go (about)

     1  /* Copyright 2018 The Bazel Authors. All rights reserved.
     2  
     3  Licensed under the Apache License, Version 2.0 (the "License");
     4  you may not use this file except in compliance with the License.
     5  You may obtain a copy of the License at
     6  
     7     http://www.apache.org/licenses/LICENSE-2.0
     8  
     9  Unless required by applicable law or agreed to in writing, software
    10  distributed under the License is distributed on an "AS IS" BASIS,
    11  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  See the License for the specific language governing permissions and
    13  limitations under the License.
    14  */
    15  
    16  // gazellebinarytest provides a minimal implementation of language.Language.
    17  // This is used to verify that gazelle_binary builds plugins and runs them
    18  // in the correct order.
    19  package gazellebinarytest
    20  
    21  import (
    22  	"flag"
    23  
    24  	"github.com/bazelbuild/bazel-gazelle/config"
    25  	"github.com/bazelbuild/bazel-gazelle/label"
    26  	"github.com/bazelbuild/bazel-gazelle/language"
    27  	"github.com/bazelbuild/bazel-gazelle/repo"
    28  	"github.com/bazelbuild/bazel-gazelle/resolve"
    29  	"github.com/bazelbuild/bazel-gazelle/rule"
    30  )
    31  
    32  type xlang struct{}
    33  
    34  func NewLanguage() language.Language {
    35  	return &xlang{}
    36  }
    37  
    38  func (x *xlang) Name() string {
    39  	return "x"
    40  }
    41  
    42  func (x *xlang) Kinds() map[string]rule.KindInfo {
    43  	return map[string]rule.KindInfo{
    44  		"x_library": {},
    45  	}
    46  }
    47  
    48  func (x *xlang) Loads() []rule.LoadInfo {
    49  	return nil
    50  }
    51  
    52  func (x *xlang) RegisterFlags(fs *flag.FlagSet, cmd string, c *config.Config) {
    53  }
    54  
    55  func (x *xlang) CheckFlags(fs *flag.FlagSet, c *config.Config) error {
    56  	return nil
    57  }
    58  
    59  func (x *xlang) KnownDirectives() []string {
    60  	return nil
    61  }
    62  
    63  func (x *xlang) Configure(c *config.Config, rel string, f *rule.File) {
    64  }
    65  
    66  func (x *xlang) GenerateRules(args language.GenerateArgs) language.GenerateResult {
    67  	return language.GenerateResult{
    68  		Gen:     []*rule.Rule{rule.NewRule("x_library", "x_default_library")},
    69  		Imports: []interface{}{nil},
    70  	}
    71  }
    72  
    73  func (x *xlang) Fix(c *config.Config, f *rule.File) {
    74  }
    75  
    76  func (x *xlang) Imports(c *config.Config, r *rule.Rule, f *rule.File) []resolve.ImportSpec {
    77  	return nil
    78  }
    79  
    80  func (x *xlang) Embeds(r *rule.Rule, from label.Label) []label.Label {
    81  	return nil
    82  }
    83  
    84  func (x *xlang) Resolve(c *config.Config, ix *resolve.RuleIndex, rc *repo.RemoteCache, r *rule.Rule, imports interface{}, from label.Label) {
    85  }