Exemplo n.º 1
0
        public static PythonNode ReferenceNode(PythonNode ast, Pattern template, int k)
        {
            //var k = magicK.GetK(template);
            var referenceNode = ReferenceNodeHelper(ast, template, ref k);

            return(referenceNode);
        }
        public PythonMigrationAssistantViewModel(PythonNode pythonNode, WorkspaceModel workspace, IPathManager pathManager, Version dynamoVersion)
        {
            PythonNode = pythonNode;
            OldCode    = pythonNode.Script;

            this.workspace     = workspace;
            backupDirectory    = pathManager.BackupDirectory;
            this.dynamoVersion = dynamoVersion;

            try
            {
                MigrateCode();
            }
            catch (PythonException)
            {
                var sidebyside = new SideBySideDiffBuilder();
                diffModel = sidebyside.BuildDiffModel(OldCode, OldCode, false);

                SetSideBySideViewModel();

                CurrentViewModel.DiffState = State.Error;
                return;
            }
            SetSideBySideViewModel();
        }
Exemplo n.º 3
0
 public static IEnumerable <PythonNode> SingleChild(PythonNode node)
 {
     return((node != null) ? new List <PythonNode>()
     {
         node
     } : null);
 }
Exemplo n.º 4
0
        public static IEnumerable <PythonNode> InOrderSort(PythonNode ast)
        {
            var visitor = new PythonNodeVisitor();

            ast.Walk(visitor);
            return(visitor.SortedNodes);
        }
Exemplo n.º 5
0
 private static bool FindReferenceNode(Pattern template, PythonNode node, ref PythonNode match)
 {
     if (template.Match(node))
     {
         match = node;
         return(true);
     }
     return(false);
 }
Exemplo n.º 6
0
        public static IEnumerable <PythonNode> Apply(PythonNode ast, Patch patch)
        {
            var inputs = new List <PythonNode>()
            {
                ast
            };
            var asts = patch.Run(ast);

            return(asts);
        }
Exemplo n.º 7
0
        public bool Visit(PythonNode pythonNode)
        {
            PythonNode target = null;

            if (TryMatch(pythonNode, _pattern, ref target) && target != null)
            {
                Matches.Add(target);
            }
            return(true);
        }
Exemplo n.º 8
0
        public static bool Match(PythonNode ast, Pattern template)
        {
            var        root  = ast;
            PythonNode match = null;

            if (FindReferenceNode(template, root, ref match))
            {
                return(true);
            }
            return(false);
        }
        public void NewPythonNodeUsingSystemDefaultEngine()
        {
            CurrentDynamoModel.PreferenceSettings.DefaultPythonEngine = string.Empty;
            var node = new PythonNode();

            node.GUID = Guid.NewGuid();
            CurrentDynamoModel.ExecuteCommand(new CreateNodeCommand(node, 0, 0, true, false));
            node = CurrentDynamoModel.CurrentWorkspace.FirstNodeFromWorkspace <PythonNode>();
            AssertPreviewValue(node.AstIdentifierGuid, 0);
            Assert.AreEqual(PythonEngineManager.CPython3EngineName, node.EngineName);
        }
        public PythonMigrationAssistantViewModel(PythonNode pythonNode, WorkspaceModel workspace, IPathManager pathManager, Version dynamoVersion)
        {
            this.PythonNode = pythonNode;
            this.OldCode    = pythonNode.Script;

            this.workspace       = workspace;
            this.backupDirectory = pathManager.BackupDirectory;
            this.dynamoVersion   = dynamoVersion;

            MigrateCode();
            SetSideBySideViewModel();
        }
Exemplo n.º 11
0
 public override bool Match(PythonNode root)
 {
     if (Type.Equals("any"))
     {
         return(true);
     }
     if (!root.GetType().Name.Equals(Type))
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 12
0
 private bool TryMatch(PythonNode node, Pattern template, ref PythonNode target)
 {
     if (template.Match(node))
     {
         target = node;
     }
     else
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 13
0
        public PythonNode Rewrite(PythonNode pythonNode)
        {
            var result = pythonNode.Clone();

            foreach (var edit in _edits)
            {
                if (edit.CanApply2(pythonNode))
                {
                    result = edit.Apply(result);
                }
            }
            return(result);
        }
Exemplo n.º 14
0
        public static IEnumerable <PythonNode> Children(PythonNode node, IEnumerable <PythonNode> children)
        {
            if (node == null || children == null)
            {
                return(null);
            }

            var result = new List <PythonNode> {
                node
            };

            result.AddRange(children);
            return(result);
        }
Exemplo n.º 15
0
        public ScriptEditorWindow(
            DynamoViewModel dynamoViewModel,
            PythonNode nodeModel,
            NodeView nodeView,
            ref ModelessChildWindow.WindowRect windowRect
            ) : base(nodeView, ref windowRect)
        {
            this.dynamoViewModel = dynamoViewModel;
            this.nodeModel       = nodeModel;

            completionProvider = new IronPythonCompletionProvider(dynamoViewModel.Model.PathManager.DynamoCoreDirectory);
            completionProvider.MessageLogged += dynamoViewModel.Model.Logger.Log;

            InitializeComponent();

            Dynamo.Logging.Analytics.TrackScreenView("Python");
        }