public override void EnterDeclareStmt(VBAParser.DeclareStmtContext context) { var accessibility = GetMemberAccessibility(context.visibility()); var nameContext = context.identifier(); if (nameContext == null) { return; } var name = nameContext.GetText(); var hasReturnType = context.FUNCTION() != null; var asTypeClause = context.asTypeClause(); var asTypeName = hasReturnType ? asTypeClause == null ? Tokens.Variant : asTypeClause.type().GetText() : null; var selection = nameContext.GetSelection(); var declarationType = hasReturnType ? DeclarationType.LibraryFunction : DeclarationType.LibraryProcedure; var declaration = CreateDeclaration(name, asTypeName, accessibility, declarationType, context, selection); OnNewDeclaration(declaration); SetCurrentScope(declaration, name); // treat like a procedure block, to correctly scope parameters. }
public static string GetName(VBAParser.DeclareStmtContext context, out Interval tokenInterval) { var nameContext = context.identifier(); return(GetName(nameContext, out tokenInterval)); }