github.com/wolfd/bazel-gazelle@v0.14.0/internal/rule/types.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  package rule
    17  
    18  // MergableAttrs is the set of attribute names for each kind of rule that
    19  // may be merged. When an attribute is mergeable, a generated value may
    20  // replace or augment an existing value. If an attribute is not mergeable,
    21  // existing values are preserved. Generated non-mergeable attributes may
    22  // still be added to a rule if there is no corresponding existing attribute.
    23  type MergeableAttrs map[string]map[string]bool
    24  
    25  // LoadInfo describes a file that Gazelle knows about and the symbols
    26  // it defines.
    27  type LoadInfo struct {
    28  	Name    string
    29  	Symbols []string
    30  	After   []string
    31  }
    32  
    33  // KindInfo stores metadata for a kind or fule, for example, "go_library".
    34  type KindInfo struct {
    35  	// MatchAny is true if a rule of this kind may be matched with any rule
    36  	// of the same kind, regardless of attributes, if exactly one rule is
    37  	// present a build file.
    38  	MatchAny bool
    39  
    40  	// MatchAttrs is a list of attributes used in matching. For example,
    41  	// for go_library, this list contains "importpath". Attributes are matched
    42  	// in order.
    43  	MatchAttrs []string
    44  
    45  	// NonEmptyAttrs is a set of attributes that, if present, disqualify a rule
    46  	// from being deleted after merge.
    47  	NonEmptyAttrs map[string]bool
    48  
    49  	// SubstituteAttrs is a set of attributes that should be substituted
    50  	// after matching and before merging. For example, suppose generated rule A
    51  	// references B via an "embed" attribute, and B matches against rule C.
    52  	// The label for B in A's "embed" must be substituted with a label for C.
    53  	// "embed" would need to be in this set.
    54  	SubstituteAttrs map[string]bool
    55  
    56  	// MergeableAttrs is a set of attributes that should be merged before
    57  	// dependency resolution. See rule.Merge.
    58  	MergeableAttrs map[string]bool
    59  
    60  	// ResolveAttrs is a set of attributes that should be merged after
    61  	// dependency resolution. See rule.Merge.
    62  	ResolveAttrs map[string]bool
    63  }