public RuleAction(ParseInfo parseInfo, Scope scope, DeltinScriptParser.Ow_ruleContext ruleContext) { Name = Extras.RemoveQuotes(ruleContext.STRINGLITERAL().GetText()); Disabled = ruleContext.DISABLED() != null; DocRange ruleInfoRange = DocRange.GetRange(ruleContext.RULE_WORD()); missingBlockRange = ruleInfoRange; GetRuleSettings(parseInfo, scope, ruleContext); // Store restricted calls CallInfo callInfo = new CallInfo(parseInfo.Script); // Get the conditions. if (ruleContext.rule_if() == null) { Conditions = new RuleIfAction[0]; } else { Conditions = new RuleIfAction[ruleContext.rule_if().Length]; for (int i = 0; i < Conditions.Length; i++) { parseInfo.Script.AddCompletionRange(new CompletionRange( scope, DocRange.GetRange(ruleContext.rule_if(i).LEFT_PAREN(), ruleContext.rule_if(i).RIGHT_PAREN()), CompletionRangeKind.Catch )); Conditions[i] = new RuleIfAction(parseInfo.SetCallInfo(callInfo), scope, ruleContext.rule_if(i)); missingBlockRange = DocRange.GetRange(ruleContext.rule_if(i)); } } // Get the block. if (ruleContext.block() != null) { Block = new BlockAction(parseInfo.SetCallInfo(callInfo), scope, ruleContext.block()); } else { parseInfo.Script.Diagnostics.Error("Missing block.", missingBlockRange); } // Check restricted calls. callInfo.CheckRestrictedCalls(EventType); // Get the rule order priority. if (ruleContext.number() != null) { Priority = double.Parse(ruleContext.number().GetText()); } ElementCountLens = new ElementCountCodeLens(ruleInfoRange, parseInfo.TranslateInfo.OptimizeOutput); parseInfo.Script.AddCodeLensRange(ElementCountLens); }
public RuleAction(ParseInfo parseInfo, Scope scope, RuleContext ruleContext) { Name = ruleContext.Name; Disabled = ruleContext.Disabled != null; DocRange ruleInfoRange = ruleContext.RuleToken.Range; GetRuleSettings(parseInfo, scope, ruleContext); // Store restricted calls CallInfo callInfo = new CallInfo(parseInfo.Script); // Get the conditions. Conditions = new ConditionAction[ruleContext.Conditions.Count]; for (int i = 0; i < Conditions.Length; i++) { // Make sure both left and right parentheses exists. if (ruleContext.Conditions[i].LeftParen && ruleContext.Conditions[i].RightParen) { parseInfo.Script.AddCompletionRange(new CompletionRange( parseInfo.TranslateInfo, scope, ruleContext.Conditions[i].LeftParen.Range + ruleContext.Conditions[i].RightParen.Range, CompletionRangeKind.Catch )); } Conditions[i] = new ConditionAction( parseInfo.SetCallInfo(callInfo).GetExpression(scope, ruleContext.Conditions[i].Expression), ruleContext.Conditions[i].Comment ); } // Get the block. Block = parseInfo.SetCallInfo(callInfo).GetStatement(scope, ruleContext.Statement); // Check restricted calls. callInfo.CheckRestrictedCalls(EventType); // Get the rule order priority. if (ruleContext.Order != null) { Priority = ruleContext.Order.Value; } ElementCountLens = new ElementCountCodeLens(ruleInfoRange); parseInfo.Script.AddCodeLensRange(ElementCountLens); }