Exemplo n.º 1
0
        /// <summary>
        /// Checks for errors before applying a rule.
        /// </summary>
        /// <param name="node">The node instance to check.</param>
        /// <param name="dataList">Optional data collected during inspection of sources.</param>
        /// <param name="data">Private data to give to Apply() upon return.</param>
        /// <returns>True if an error occured.</returns>
        public override bool CheckConsistency(IKeywordAnchoredType node, IDictionary <ISourceTemplate, object> dataList, out object data)
        {
            bool Success = true;

            data = null;

            // The 'Current' case is handled in KeywordAnchoredTypeCurrentRuleTemplate.
            if (node.Anchor != BaseNode.Keyword.Current)
            {
                IClass     EmbeddingClass = node.EmbeddingClass;
                IErrorList CheckErrorList = new ErrorList();
                if (!KeywordExpression.IsKeywordAvailable(node.Anchor, node, CheckErrorList, out ITypeName ResultTypeName, out ICompiledType ResultType))
                {
                    AddSourceErrorList(CheckErrorList);
                    Success = false;
                }
                else
                {
                    data = new Tuple <ITypeName, ICompiledType>(ResultTypeName, ResultType);
                }
            }
Exemplo n.º 2
0
        /// <summary>
        /// Checks for errors before applying a rule.
        /// </summary>
        /// <param name="node">The node instance to check.</param>
        /// <param name="dataList">Optional data collected during inspection of sources.</param>
        /// <param name="data">Private data to give to Apply() upon return.</param>
        /// <returns>True if an error occured.</returns>
        public override bool CheckConsistency(IKeywordAnchoredType node, IDictionary <ISourceTemplate, object> dataList, out object data)
        {
            bool Success = true;

            data = null;

            if (node.Anchor == BaseNode.Keyword.Current)
            {
                IClass     EmbeddingClass = node.EmbeddingClass;
                IErrorList CheckErrorList = new ErrorList();

                // 'Current' is always available.
                Success = KeywordExpression.IsKeywordAvailable(node.Anchor, node, CheckErrorList, out ITypeName ResultTypeName, out ICompiledType ResultType);
                Debug.Assert(Success);

                data = new Tuple <ITypeName, ICompiledType>(ResultTypeName, ResultType);
            }
            else
            {
                data = new Tuple <ITypeName, ICompiledType>(Class.ClassAny.ResolvedClassTypeName.Item, Class.ClassAny.ResolvedClassType.Item);
            }

            return(Success);
        }