1717from robot .output import LOGGER , Message
1818from robot .running .builder import TestSuiteBuilder
1919from robot .running .builder .builders import SuiteStructureParser
20- from robot .utils import NormalizedDict
20+ from robot .utils import NormalizedDict , normalize
2121from robot .utils .filereader import FileReader
2222from robotcode .core .dataclasses import from_json
2323from robotcode .core .lsp .types import (
@@ -234,6 +234,7 @@ def __init__(self) -> None:
234234 self .suites : List [TestItem ] = []
235235 self .tests : List [TestItem ] = []
236236 self .tags : Dict [str , List [TestItem ]] = defaultdict (list )
237+ self .normalized_tags : Dict [str , List [TestItem ]] = defaultdict (list )
237238 self .statistics = Statistics ()
238239 self ._collected = [NormalizedDict (ignore = "_" )]
239240
@@ -321,6 +322,7 @@ def visit_test(self, test: TestCase) -> None:
321322
322323 for tag in test .tags :
323324 self .tags [str (tag )].append (item )
325+ self .normalized_tags [normalize (str (tag ), ignore = "_" )].append (item )
324326
325327 self .tests .append (item )
326328 self ._current .children .append (item )
@@ -662,10 +664,17 @@ class TagsResult:
662664 add_help_option = True ,
663665 epilog = 'Use "-- --help" to see `robot` help.' ,
664666)
667+ @click .option (
668+ "--normalized / --not-normalized" ,
669+ "normalized" ,
670+ default = True ,
671+ help = "Whether or not normalized tags are shown." ,
672+ )
665673@add_options (* ROBOT_OPTIONS )
666674@pass_application
667675def tags (
668676 app : Application ,
677+ normalized : bool ,
669678 by_longname : Tuple [str , ...],
670679 exclude_by_longname : Tuple [str , ...],
671680 robot_options_and_args : Tuple [str , ...],
@@ -692,12 +701,14 @@ def tags(
692701 def print (tags : Dict [str , List [TestItem ]]) -> Iterable [str ]:
693702 for tag , items in tags .items ():
694703 yield f"{ tag } { os .linesep } "
704+ # for t in items:
705+ # yield f" {t.longname}{os.linesep}"
695706
696- if collector .suites :
697- app .echo_via_pager (print (collector .tags ))
707+ if collector .normalized_tags :
708+ app .echo_via_pager (print (collector .normalized_tags if normalized else collector . tags ))
698709
699710 else :
700- app .print_data (TagsResult (collector .tags ), remove_defaults = True )
711+ app .print_data (TagsResult (collector .normalized_tags ), remove_defaults = True )
701712
702713
703714@dataclass
0 commit comments