github.com/bazelbuild/bazel-gazelle@v0.36.1-0.20240520142334-61b277ba6fed/language/base.go (about) 1 /* Copyright 2023 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 package language 17 18 import ( 19 "flag" 20 21 "github.com/bazelbuild/bazel-gazelle/config" 22 "github.com/bazelbuild/bazel-gazelle/label" 23 "github.com/bazelbuild/bazel-gazelle/repo" 24 "github.com/bazelbuild/bazel-gazelle/resolve" 25 "github.com/bazelbuild/bazel-gazelle/rule" 26 ) 27 28 // BaseLang implements the minimum of language.Language interface. 29 // This is not meant to be used directly by Gazelle, but to be used by 30 // a downstream struct through composition. End users could use this to 31 // write an extensions iteratively without having to implement every 32 // functions in the interface right away. 33 // 34 // Example usage: 35 // 36 // type MyLang struct { 37 // language.BaseLang 38 // } 39 // 40 // func NewLanguage() language.Language { 41 // return &MyLang{} 42 // } 43 type BaseLang struct{} 44 45 func (b *BaseLang) RegisterFlags(fs *flag.FlagSet, cmd string, c *config.Config) {} 46 47 func (b *BaseLang) CheckFlags(fs *flag.FlagSet, c *config.Config) error { 48 return nil 49 } 50 51 func (b *BaseLang) KnownDirectives() []string { 52 return nil 53 } 54 55 func (b *BaseLang) Configure(c *config.Config, rel string, f *rule.File) {} 56 57 func (b *BaseLang) Name() string { 58 return "BaseLang" 59 } 60 61 func (b *BaseLang) Imports(c *config.Config, r *rule.Rule, f *rule.File) []resolve.ImportSpec { 62 return nil 63 } 64 65 func (b *BaseLang) Embeds(r *rule.Rule, from label.Label) []label.Label { 66 return nil 67 } 68 69 func (b *BaseLang) Resolve(c *config.Config, ix *resolve.RuleIndex, rc *repo.RemoteCache, r *rule.Rule, imports interface{}, from label.Label) { 70 } 71 72 func (b *BaseLang) Kinds() map[string]rule.KindInfo { 73 return nil 74 } 75 76 func (b *BaseLang) Loads() []rule.LoadInfo { 77 return nil 78 } 79 80 func (b *BaseLang) GenerateRules(args GenerateArgs) GenerateResult { 81 return GenerateResult{} 82 } 83 84 func (b *BaseLang) Fix(c *config.Config, f *rule.File) {}