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(); }
public static IEnumerable <PythonNode> SingleChild(PythonNode node) { return((node != null) ? new List <PythonNode>() { node } : null); }
public static IEnumerable <PythonNode> InOrderSort(PythonNode ast) { var visitor = new PythonNodeVisitor(); ast.Walk(visitor); return(visitor.SortedNodes); }
private static bool FindReferenceNode(Pattern template, PythonNode node, ref PythonNode match) { if (template.Match(node)) { match = node; return(true); } return(false); }
public static IEnumerable <PythonNode> Apply(PythonNode ast, Patch patch) { var inputs = new List <PythonNode>() { ast }; var asts = patch.Run(ast); return(asts); }
public bool Visit(PythonNode pythonNode) { PythonNode target = null; if (TryMatch(pythonNode, _pattern, ref target) && target != null) { Matches.Add(target); } return(true); }
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(); }
public override bool Match(PythonNode root) { if (Type.Equals("any")) { return(true); } if (!root.GetType().Name.Equals(Type)) { return(false); } return(true); }
private bool TryMatch(PythonNode node, Pattern template, ref PythonNode target) { if (template.Match(node)) { target = node; } else { return(false); } return(true); }
public PythonNode Rewrite(PythonNode pythonNode) { var result = pythonNode.Clone(); foreach (var edit in _edits) { if (edit.CanApply2(pythonNode)) { result = edit.Apply(result); } } return(result); }
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); }
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"); }