Beispiel #1
0
        public override void EnterTypeSpec(GoParser.TypeSpecContext context)
        {
            GoParser.Type_Context typeContext = context.type_();
            string identifier = SanitizedIdentifier(context.IDENTIFIER().GetText());
            string typeName   = $"{PackageImport.Replace('/', '.')}.{identifier}";
            string type       = typeContext.GetText();

            if (type.StartsWith("interface{"))
            {
                Types[typeContext] = new TypeInfo
                {
                    Name         = identifier,
                    TypeName     = typeName,
                    FullTypeName = $"go.{typeName}",
                    TypeClass    = TypeClass.Interface
                };
            }
            else if (type.StartsWith("struct{"))
            {
                Types[typeContext] = new TypeInfo
                {
                    Name         = identifier,
                    TypeName     = typeName,
                    FullTypeName = $"go.{typeName}_package",
                    TypeClass    = TypeClass.Struct
                };
            }
        }
Beispiel #2
0
 public override void ExitType_(GoParser.Type_Context context)
 {
     if (context.type_() != null)
     {
         if (Types.TryGetValue(context.type_(), out TypeInfo typeInfo))
         {
             Types[context] = typeInfo;
         }
         else
         {
             AddWarning(context, $"Failed to find sub-type in type expression \"{context.GetText()}\"");
         }
     }
 }
Beispiel #3
0
        //public override void EnterType_(GoParser.Type_Context context)
        //{
        //    Debug.WriteLine($"Enter type: {context.GetText()} -- {context}");
        //}

        public override void ExitType_(GoParser.Type_Context context)
        {
            TypeInfo typeInfo;

            if (!(context.type_() is null))
            {
                if (Types.TryGetValue(context.type_(), out typeInfo))
                {
                    Types[context] = typeInfo;
                }
                else
                {
                    AddWarning(context, $"Failed to find sub-type in type expression \"{context.GetText()}\"");
                }
            }

            if (context.Parent is GoParser.ElementTypeContext elementType && Types.TryGetValue(context, out typeInfo))
            {
                Types[elementType] = typeInfo;
            }
        }