示例#1
0
        public DefinedEnumMember(ParseInfo parseInfo, DefinedEnum type, string name, LanguageServer.Location definedAt, ExpressionOrWorkshopValue value)
        {
            Enum            = type;
            Name            = name;
            DefinedAt       = definedAt;
            _translateInfo  = parseInfo.TranslateInfo;
            ValueExpression = value;

            _translateInfo.GetComponent <SymbolLinkComponent>().AddSymbolLink(this, definedAt, true);
            parseInfo.Script.AddCodeLensRange(new ReferenceCodeLensRange(this, parseInfo, CodeLensSourceType.EnumValue, DefinedAt.range));
        }
示例#2
0
        public AutoForAction(ParseInfo parseInfo, Scope scope, DeltinScriptParser.For_autoContext autoForContext)
        {
            RawContinue = true;

            // Get the auto-for variable. (Required)
            if (autoForContext.forVariable != null)
            {
                IExpression variable = parseInfo.GetExpression(scope, autoForContext.forVariable);

                // Get the variable being set.
                VariableResolve = new VariableResolve(new VariableResolveOptions()
                {
                    // The for cannot be indexed and should be on the rule-level.
                    CanBeIndexed = false,
                    FullVariable = true
                }, variable, DocRange.GetRange(autoForContext.forVariable), parseInfo.Script.Diagnostics);

                if (autoForContext.EQUALS() != null)
                {
                    if (autoForContext.start == null)
                    {
                        parseInfo.Script.Diagnostics.Error("Expected expression.", DocRange.GetRange(autoForContext.EQUALS()));
                    }
                    else
                    {
                        InitialResolveValue = parseInfo.GetExpression(scope, autoForContext.start);
                    }
                }
            }
            // Get the defined variable.
            else if (autoForContext.forDefine != null)
            {
                DefinedVariable = new AutoForVariable(scope, new DefineContextHandler(parseInfo, autoForContext.forDefine));
            }
            else
            {
                parseInfo.Script.Diagnostics.Error("Expected define or variable.", DocRange.GetRange(autoForContext.FOR()));
            }

            // Get the auto-for end. (Required)
            if (autoForContext.stop == null)
            {
                parseInfo.Script.Diagnostics.Error("Expected end expression.", DocRange.GetRange(autoForContext.startSep));
            }
            else
            {
                Stop = parseInfo.GetExpression(scope, autoForContext.stop);
            }

            // Get the auto-for step. (Not Required)
            if (autoForContext.step == null)
            {
                Step = new ExpressionOrWorkshopValue(new V_Number(1));
            }
            else
            {
                Step = new ExpressionOrWorkshopValue(parseInfo.GetExpression(scope, autoForContext.step));
            }

            // Get the block.
            if (autoForContext.block() == null)
            {
                parseInfo.Script.Diagnostics.Error("Missing block.", DocRange.GetRange(autoForContext.RIGHT_PAREN()));
            }
            else
            {
                Block = new BlockAction(parseInfo.SetLoop(this), scope, autoForContext.block());
                Path  = new PathInfo(Block, DocRange.GetRange(autoForContext.block()), false);
            }
        }
 public CodeParameter(string name, string documentation, ExpressionOrWorkshopValue defaultValue)
 {
     Name          = name;
     Documentation = documentation;
     DefaultValue  = defaultValue;
 }
 public CodeParameter(string name, CodeType type, ExpressionOrWorkshopValue defaultValue)
 {
     Name         = name;
     Type         = type;
     DefaultValue = defaultValue;
 }
示例#5
0
 public CodeParameter(string name, MarkupBuilder documentation, ICodeTypeSolver type, ExpressionOrWorkshopValue defaultValue)
 {
     Name          = name;
     _type         = type;
     DefaultValue  = defaultValue;
     Documentation = documentation;
 }
示例#6
0
        public DefinedEnumMember(ParseInfo parseInfo, DefinedEnum type, string name, LanguageServer.Location definedAt, ExpressionOrWorkshopValue value)
        {
            Enum            = type;
            Name            = name;
            DefinedAt       = definedAt;
            _deltinScript   = parseInfo.TranslateInfo;
            ValueExpression = value;

            parseInfo.Script.Elements.AddDeclarationCall(this, new(definedAt.range, true));
            parseInfo.Script.AddCodeLensRange(new ReferenceCodeLensRange(this, parseInfo, CodeLensSourceType.EnumValue, DefinedAt.range));
        }