Example #1
0
        private Ust ParseAndConvert(string code, global::AspxParser.Location location)
        {
            SyntaxTree tree      = CSharpSyntaxTree.ParseText(code, new CSharpParseOptions(kind: SourceCodeKind.Script));
            var        converter = new CSharpRoslynParseTreeConverter();
            RootUst    result    = converter.Convert(new CSharpRoslynParseTree(tree)
            {
                SourceCodeFile = sourceCodeFile
            });

            result.ApplyActionToDescendants(ust => ust.TextSpan = ust.TextSpan.AddOffset(location.Start));
            return(result);
        }
Example #2
0
        private Ust ParseExpressionAndConvert(string expression, int offset)
        {
            ExpressionSyntax node = SyntaxFactory.ParseExpression(expression);
            var     converter     = new CSharpRoslynParseTreeConverter();
            Ust     result        = converter.Visit(node);
            RootUst resultRoot    =
                result as RootUst ?? new RootUst(sourceFile, Language.CSharp, result.TextSpan)
            {
                Node = result
            };

            resultRoot.SourceFile = sourceFile;
            result.ApplyActionToDescendantsAndSelf(ust => ust.TextSpan = ust.TextSpan.AddOffset(offset));
            return(result);
        }