@ Nonnull private List < MixinMatch > getRules ( CssFormatter formatter ) throws LessException { if ( mixinRules != null && stackID == formatter . stackID ( ) ) { return mixinRules ; } List < Rule > rules = formatter . getMixin ( name ) ; if ( rules == null ) { rules = mixins . get ( name ) ; } if ( rules == null ) { int idx = name . indexOf ( ' ' ) ; // mixin with namespace? if ( idx > 0 ) { String mainName = name . substring ( 0 , idx ) . trim ( ) ; rules = mixins . get ( mainName ) ; if ( rules != null ) { rules = rules . get ( 0 ) . getMixin ( name . substring ( idx + 1 ) . trim ( ) ) ; } } else { idx = name . indexOf ( ' ' ) ; // mixin with namespace? if ( idx > 0 ) { String mainName = name . substring ( 0 , idx ) . trim ( ) ; rules = mixins . get ( mainName ) ; if ( rules != null ) { rules = rules . get ( 0 ) . getMixin ( name . substring ( idx ) . trim ( ) ) ; } } } if ( rules == null ) { throw createException ( "Undefined mixin: " + name ) ; } } stackID = formatter . stackID ( ) ; mixinRules = new ArrayList <> ( ) ; boolean paramMatch = false ; List < Rule > defaultMixins = null ; for ( Rule rule : rules ) { MixinMatch matching = rule . match ( formatter , paramValues , false ) ; if ( matching != null ) { paramMatch = true ; if ( matching . getGuard ( ) ) { mixinRules . add ( matching ) ; } else if ( matching . wasDefault ( ) ) { if ( defaultMixins == null ) { defaultMixins = new ArrayList <> ( ) ; } defaultMixins . add ( rule ) ; } } } if ( ! paramMatch ) { throw createException ( "No matching definition was found for: " + name ) ; } if ( mixinRules . size ( ) == 0 && defaultMixins != null ) { for ( Rule rule : defaultMixins ) { MixinMatch matching = rule . match ( formatter , paramValues , true ) ; if ( matching != null && matching . getGuard ( ) ) { mixinRules . add ( matching ) ; } } } return mixinRules ; }
Get the rules of the mixin