Пример #1
0
        public static Expression ToExpressionIfRequired(this UstNode node)
        {
            if (node == null)
            {
                return(null);
            }

            Expression result = node as Expression;

            if (result == null)
            {
                result = new WrapperExpression(node);
            }
            return(result);
        }
Пример #2
0
        public static UstNode RemoveNotIncludedNodes(this UstNode root, Language mainLanguage, LanguageFlags dependentLanguages)
        {
            UstNode result;

            if (dependentLanguages.Is(mainLanguage))
            {
                result = root;
            }
            else
            {
                var includedChildren = root.GetAllDescendants(node =>
                                                              node.NodeType == NodeType.NamespaceDeclaration &&
                                                              dependentLanguages.Is(((NamespaceDeclaration)node).Language) &&
                                                              dependentLanguages.ToString().Contains(((NamespaceDeclaration)node).Name.Text));
                result = CreateRootNamespace(includedChildren, mainLanguage, root.FileNode);
            }
            return(result);
        }
Пример #3
0
        public static Statement ToStatementIfRequired(this UstNode node)
        {
            Statement result = node as Statement;

            if (result == null)
            {
                Expression expr = node as Expression;
                if (expr != null)
                {
                    result = new ExpressionStatement(expr);
                }
                else
                {
                    result = new WrapperStatement(node);
                }
            }
            return(result);
        }
Пример #4
0
 public static NamespaceDeclaration CreateLanguageNamespace(this UstNode member, Language language, FileNode fileNode)
 {
     return(new NamespaceDeclaration(new StringLiteral(language.ToString()), new UstNode[] { member }, language, member.TextSpan, fileNode));
 }