Rosetta.ScriptSharp.Definition.AST.ProgramDefinitionASTWalker.Create C# (CSharp) Method

Create() public static method

Factory method for class ProgramASTWalker.
public static Create ( CSharpSyntaxNode node, ASTWalkerContext context = null, Microsoft.CodeAnalysis.SemanticModel semanticModel = null ) : ProgramDefinitionASTWalker
node CSharpSyntaxNode Used to initialize the walker.
context Rosetta.AST.ASTWalkerContext The walking context.
semanticModel Microsoft.CodeAnalysis.SemanticModel The semantic model.
return ProgramDefinitionASTWalker
        public static new ProgramDefinitionASTWalker Create(CSharpSyntaxNode node, ASTWalkerContext context = null, SemanticModel semanticModel = null)
        {
            return new ProgramDefinitionASTWalker(
                node,
                new ProgramDefinitionTranslationUnitFactory(node, semanticModel).Create() as ProgramTranslationUnit,
                semanticModel)
            {
                Context = context
            };
        }

Usage Example

Example #1
0
        protected override void InitializeCore()
        {
            // TODO: In order to target #41, add an option for using the reflector when requested

            // Getting the AST node
            this.tree = ASTExtractor.Extract(this.source);

            // Loading the semantic model
            CSharpCompilation compilation = null;

            if (this.assemblyPath != null)
            {
                compilation = this.GetCompilation(this.assemblyPath, this.tree);
            }

            IASTTransformer transformer = new ScriptNamespaceBasedASTTransformer();

            if (compilation != null)
            {
                transformer.Transform(ref this.tree, ref compilation);
                this.semanticModel = SemanticUtils.RetrieveSemanticModel(compilation, this.tree);
            }
            else
            {
                transformer.Transform(ref this.tree);
            }

            // Creating the walker
            // If no semantic model was loaded, null will just be passed
            var node = this.tree.GetRoot();

            this.walker = ProgramDefinitionASTWalker.Create(node, null, this.semanticModel);
            (this.walker as ProgramDefinitionASTWalker).Logger = this.Logger;

            // Translating
            this.output = this.walker.Walk().Translate();
        }
All Usage Examples Of Rosetta.ScriptSharp.Definition.AST.ProgramDefinitionASTWalker::Create