public DefinedMacro(ParseInfo parseInfo, Scope objectScope, Scope staticScope, DeltinScriptParser.Define_macroContext context, CodeType returnType)
     : base(parseInfo, context.name.Text, new LanguageServer.Location(parseInfo.Script.Uri, DocRange.GetRange(context.name)))
 {
     this.context = context;
     Static       = context.STATIC() != null;
     SetupScope(Static ? staticScope : objectScope);
     AccessLevel       = context.accessor().GetAccessLevel();
     ReturnType        = returnType;
     ExpressionToParse = context.expr();
 }
Esempio n. 2
0
        public MacroVar(ParseInfo parseInfo, Scope objectScope, Scope staticScope, DeltinScriptParser.Define_macroContext macroContext, CodeType returnType)
        {
            Name        = macroContext.name.Text;
            AccessLevel = macroContext.accessor().GetAccessLevel();
            DefinedAt   = new Location(parseInfo.Script.Uri, DocRange.GetRange(macroContext.name));
            CallInfo    = new CallInfo(this, parseInfo.Script);
            Static      = macroContext.STATIC() != null;

            ReturnType        = returnType;
            ExpressionToParse = macroContext.expr();

            scope          = Static ? staticScope : objectScope;
            this.parseInfo = parseInfo;

            parseInfo.TranslateInfo.AddSymbolLink(this, DefinedAt, true);
            scope.AddVariable(this, parseInfo.Script.Diagnostics, DocRange.GetRange(macroContext.name));
            parseInfo.Script.AddHover(DocRange.GetRange(macroContext.name), GetLabel(true));
        }
        public DefinedMacro(ParseInfo parseInfo, Scope scope, DeltinScriptParser.Define_macroContext context)
            : base(parseInfo, scope, context.name.Text, new LanguageServer.Location(parseInfo.Script.Uri, DocRange.GetRange(context.name)))
        {
            AccessLevel = context.accessor().GetAccessLevel();
            SetupParameters(context.setParameters());

            if (context.TERNARY_ELSE() == null)
            {
                parseInfo.Script.Diagnostics.Error("Expected :", DocRange.GetRange(context).end.ToRange());
            }
            else
            {
                ExpressionToParse = context.expr();
                if (ExpressionToParse == null)
                {
                    parseInfo.Script.Diagnostics.Error("Expected expression.", DocRange.GetRange(context.TERNARY_ELSE()));
                }
            }

            parseInfo.Script.AddHover(DocRange.GetRange(context.name), GetLabel(true));
        }
        public MacroVar(ParseInfo parseInfo, Scope scope, DeltinScriptParser.Define_macroContext macroContext)
        {
            Name        = macroContext.name.Text;
            AccessLevel = macroContext.accessor()?.GetAccessLevel() ?? AccessLevel.Private;
            DefinedAt   = new Location(parseInfo.Script.Uri, DocRange.GetRange(macroContext.name));
            CallInfo    = new CallInfo(this, parseInfo.Script);

            if (macroContext.TERNARY_ELSE() == null)
            {
                parseInfo.Script.Diagnostics.Error("Expected :", DocRange.GetRange(macroContext).end.ToRange());
            }
            else
            {
                ExpressionToParse = macroContext.expr();
                if (ExpressionToParse == null)
                {
                    parseInfo.Script.Diagnostics.Error("Expected expression.", DocRange.GetRange(macroContext.TERNARY_ELSE()));
                }
            }

            this.scope     = scope;
            this.parseInfo = parseInfo;
        }