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. }
// eliminate "PtrSafe" public override void EnterDeclareStmt([NotNull] VBAParser.DeclareStmtContext context) { if (context.PTRSAFE() != null) { Rewriter.Replace(context.PTRSAFE().Symbol, ""); } }
private string GetSignature(VBAParser.DeclareStmtContext context) { if (context == null) { return(null); } var args = context.argList() == null ? "()" : context.argList().GetText() + ' '; var asTypeClause = context.asTypeClause() == null ? string.Empty : context.asTypeClause().GetText(); return(args + asTypeClause); }
public override void EnterDeclareStmt(VBAParser.DeclareStmtContext context) { var accessibility = GetMemberAccessibility(context.visibility()); var nameContext = context.ambiguousIdentifier(); 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; _declarations.Add(CreateDeclaration(name, asTypeName, accessibility, declarationType, context, selection)); SetCurrentScope(name); }
public override void ExitDeclareStmt(VBAParser.DeclareStmtContext context) { _contexts.Add(new QualifiedContext <ParserRuleContext>(CurrentModuleName, context)); base.ExitDeclareStmt(context); }
public static string GetName(VBAParser.DeclareStmtContext context, out Interval tokenInterval) { var nameContext = context.identifier(); return(GetName(nameContext, out tokenInterval)); }
public override void ExitDeclareStmt(VBAParser.DeclareStmtContext context) { SetCurrentScope(); }
public override void EnterDeclareStmt(VBAParser.DeclareStmtContext context) { _members.Add(new QualifiedContext <ParserRuleContext>(_qualifiedName, context)); }