Пример #1
0
            public ISingleTarget <CompilationUnitSyntax> SelectNew(string path)
            {
                var  filename        = Path.GetFileName(path);
                Guid guid            = Guid.NewGuid();
                var  compilationUnit = SyntaxFactory.CompilationUnit().WithAdditionalAnnotations(new SyntaxAnnotation(guid.ToString()));
                var  result          = new CSharpSingleTarget <CompilationUnitSyntax>(this, guid, path);
                var  document        = CurrentProject.AddDocument(filename, compilationUnit, filePath: path);

                CurrentProject = document.Project;
                return(result);
            }
Пример #2
0
            public ISingleTarget <TOutputNode> ProccessTarget <TSpecificCommand, TNode, TOutputNode>(ISingleTargeter <TNode> target, ICodeGenerationEngine engine)
                where TSpecificCommand : ICommandOn <TNode>, ICommandResult <TOutputNode>, TCommand
                where TNode : CSharpSyntaxNode
                where TOutputNode : CSharpSyntaxNode
            {
                var doc = engine.CurrentProject.GetDocument(target.Node.SyntaxTree);

                this.DocumentEditor = DocumentEditor.CreateAsync(doc).Result;//TODO: make async???
                this.Id             = Guid.NewGuid();
                target.Node.Accept(this);
                var result   = new CSharpSingleTarget <TOutputNode>(engine, this.Id, doc.FilePath);
                var document = this.DocumentEditor.GetChangedDocument();

                engine.CurrentProject = document.Project;
                return(result);
            }