@@ -483,6 +483,29 @@ func (tv *tokenVisitor) inspect(n ast.Node) (descend bool) {
483
483
return true
484
484
}
485
485
486
+ func underlineType (obj types.Object ) (semtok.TokenType , []string ) {
487
+ switch obj .Type ().Underlying ().(type ) {
488
+ case * types.Interface :
489
+ return semtok .TokType , []string {"interface" }
490
+ case * types.Struct :
491
+ return semtok .TokType , []string {"struct" }
492
+ case * types.Pointer :
493
+ return semtok .TokType , []string {"pointer" }
494
+ case * types.Array :
495
+ return semtok .TokType , []string {"array" }
496
+ case * types.Map :
497
+ return semtok .TokType , []string {"map" }
498
+ case * types.Slice :
499
+ return semtok .TokType , []string {"slice" }
500
+ case * types.Chan :
501
+ return semtok .TokType , []string {"chan" }
502
+ case * types.Basic :
503
+ return semtok .TokType , []string {"defaultLibrary" }
504
+ default :
505
+ return semtok .TokType , nil
506
+ }
507
+ }
508
+
486
509
func (tv * tokenVisitor ) ident (id * ast.Ident ) {
487
510
var obj types.Object
488
511
@@ -535,10 +558,9 @@ func (tv *tokenVisitor) ident(id *ast.Ident) {
535
558
case * types.TypeName : // could be a TypeParam
536
559
if is [* types.TypeParam ](aliases .Unalias (obj .Type ())) {
537
560
emit (semtok .TokTypeParam )
538
- } else if is [* types.Basic ](obj .Type ()) {
539
- emit (semtok .TokType , "defaultLibrary" )
540
561
} else {
541
- emit (semtok .TokType )
562
+ tok , mods := underlineType (obj )
563
+ emit (tok , mods ... )
542
564
}
543
565
case * types.Var :
544
566
if is [* types.Signature ](aliases .Unalias (obj .Type ())) {
@@ -795,11 +817,15 @@ func (tv *tokenVisitor) definitionFor(id *ast.Ident, obj types.Object) (semtok.T
795
817
if fld , ok := fldm .(* ast.Field ); ok {
796
818
// if len(fld.names) == 0 this is a semtok.TokType, being used
797
819
if len (fld .Names ) == 0 {
798
- return semtok .TokType , nil
820
+ tok , mods := underlineType (obj )
821
+ modifiers = append (modifiers , mods ... )
822
+ return tok , modifiers
799
823
}
800
824
return semtok .TokVariable , modifiers
801
825
}
802
- return semtok .TokType , modifiers
826
+ tok , mods := underlineType (obj )
827
+ modifiers = append (modifiers , mods ... )
828
+ return tok , modifiers
803
829
}
804
830
}
805
831
// can't happen
0 commit comments