private IEnumerable <StatementGrammarNode> GetNodesToReplace() { if (!CurrentNode.HasAncestor(CurrentQueryBlock.OrderByClause)) { return(StatementGrammarNode.EmptyArray); } var columnIndexReferences = CurrentQueryBlock.OrderByColumnIndexReferences.Where(r => r.Terminal == CurrentNode); if (CurrentNode.ParentNode == CurrentQueryBlock.OrderByClause) { columnIndexReferences = CurrentQueryBlock.OrderByColumnIndexReferences; } return(columnIndexReferences.Where(r => r.IsValid) .Select(r => r.Terminal)); }
public void AddBranchNode(ASTNode newNode) { if (newNode != null) { if (Root is null) { Root = newNode; CurrentNode = Root; } else { CurrentNode.AddDescendant(newNode); CurrentNode = newNode; } CurrentSession.Diagnostics.Semantic_ReportAddingASTNode(newNode); } }
public void Delete() { var item = (NativeReference)CurrentNode.DataItem; string question = GettextCatalog.GetString( "Are you sure you want to remove the native reference '{0}'?", item.Path.FileNameWithoutExtension); if (!MessageService.Confirm(question, AlertButton.Remove)) { return; } var project = (DotNetProject)CurrentNode.GetParentDataItem(typeof(DotNetProject), true); project.Items.Remove(item); IdeApp.ProjectOperations.Save(project); }
public async void Scaffold() { var project = IdeApp.ProjectOperations.CurrentSelectedProject as DotNetProject; if (project == null) { return; } var folder = CurrentNode.GetParentDataItem(typeof(ProjectFolder), true) as ProjectFolder; string parentFolder = folder?.Path ?? project.BaseDirectory; Xwt.Toolkit.NativeEngine.Invoke(() => { var w = new ScaffolderWizard(project, parentFolder); var res = w.RunWizard(); }); }
public override bool MoveToNextAttribute() { if (CurrentNode is IXmlTextBuilder && ParentNode is IXmlAttributeBuilder) { _enumerators.RemoveLast(); } if (CurrentNode is IXmlElementBuilder && CurrentNode.HasAttributes()) { _enumerators.AddLast(CurrentNode.GetAttributes().GetConservativeEnumerator()); } if (CurrentEnumerator is IEnumerator <IXmlAttributeBuilder> && CurrentEnumerator.MoveNext()) { _nodeType = XmlNodeType.Attribute; return(true); } return(false); }
public override void DeleteItem() { var node = (DependencyNode)CurrentNode.DataItem; if (CurrentNode.MoveToParent(typeof(DnxProject))) { var project = CurrentNode.DataItem as DnxProject; if (project != null && node.IsProject) { project.RemoveProjectReference(node.Name); } else if (project != null && node.IsNuGetPackage) { project.RemoveNuGetPackage(node.GetParentFrameworkShortName(), node.Name); } } }
public void OnAddExtension() { DotNetProject p = CurrentNode.GetParentDataItem(typeof(Project), true) as DotNetProject; AddinData data = AddinData.GetAddinData(p); AddinDescription desc = data.LoadAddinManifest(); ExtensionSelectorDialog dlg = new ExtensionSelectorDialog(data.AddinRegistry, null, desc.IsRoot, false); if (dlg.Run() == (int)ResponseType.Ok) { foreach (object ob in dlg.GetSelection()) { Console.WriteLine("pp s: " + ob); } } dlg.Destroy(); }
/// <summary> /// Selects a field declaration of a given name (if such exists) and makes it the current node. /// </summary> /// <param name="fieldName">Name of the variable being declared</param> /// <returns>True if found and made current, false otherwise.</returns> public T SelectFieldDeclaration([NotBlank] string fieldName) { var fieldDeclarations = CurrentNode?.DescendantNodes().OfType <FieldDeclarationSyntax>().ToList(); foreach (var fieldDeclaration in fieldDeclarations) { var declaratorExists = fieldDeclaration.DescendantNodes().OfType <VariableDeclaratorSyntax>(). Where(d => d.Identifier.ValueText == fieldName).Any(); if (declaratorExists) { NextStep(fieldDeclaration); } } return(Composer); }
private void PushEntity(Vector2Int directionVector, GridNode referenceNode) { TargetNode = null; // check opposite tile to see if it is free if (referenceNode.GetNeighbour(directionVector).isTraversable) { TargetNode = referenceNode.GetNeighbour(directionVector); return; } else { Vector2Int checkVector; if (Direction == -directionVector || Direction == Vector2Int.zero) { // randomly check other adjacent tiles to see if they are free int checkDir = UnityEngine.Random.Range(0, 2); checkDir = (checkDir * 2) - 1; checkVector = new Vector2Int(checkDir * directionVector.y, checkDir * directionVector.x); } else { checkVector = -Direction; } if (CurrentNode.GetNeighbour(checkVector).isTraversable) { TargetNode = referenceNode.GetNeighbour(checkVector); } else if (CurrentNode.GetNeighbour(-checkVector).isTraversable) { TargetNode = referenceNode.GetNeighbour(-checkVector); } } // if no free space is available, kill entity if (TargetNode == null) { Debug.Log("I'm Dead"); player_died?.Invoke(true); TargetNode = CurrentNode; } }
private bool Initialize() { if (CurrentNode.Id == Terminals.Into) { _insertTarget = SemanticModel.InsertTargets.FirstOrDefault(t => CurrentNode.HasAncestor(t.RootNode)); } else { var isSingleTableInsert = CurrentNode.Id == Terminals.Insert && CurrentNode.ParentNode[NonTerminals.SingleTableInsertOrMultiTableInsert, NonTerminals.SingleTableInsert] != null; if (isSingleTableInsert && SemanticModel.InsertTargets.Count == 1) { _insertTarget = SemanticModel.InsertTargets.First(); } } return(_insertTarget?.DataObjectReference != null); }
public void AddView() { var project = CurrentNode.GetParentDataItem <DotNetProject> (true); object currentItem = CurrentNode.DataItem; var folder = CurrentNode.GetParentDataItem(typeof(ProjectFolder), true) as ProjectFolder; string path = folder != null? folder.Path : project.BaseDirectory; AddViewFromControllerCommandHandler.AddView(project, path, null); ITreeNavigator nav = Tree.GetNodeAtObject(currentItem); if (nav != null) { nav.Expanded = true; } }
public void AddController() { var project = (AspMvcProject)CurrentNode.GetParentDataItem(typeof(AspMvcProject), true); object currentItem = CurrentNode.DataItem; var folder = CurrentNode.GetParentDataItem(typeof(ProjectFolder), true) as ProjectFolder; string path = folder != null ? folder.Path : project.BaseDirectory; AddController(project, path, null); ITreeNavigator nav = Tree.GetNodeAtObject(currentItem); if (nav != null) { nav.Expanded = true; } }
public virtual void Pause() { lock (_executionLock) { if (ExecutableState != ExecutableState.Running) { return; } LogService.Log(LogType, LogMessageType.Debug, Name, "Pausing execution"); ExecutableState = ExecutableState.Paused; // Disable transitions out of the current node while paused. This machine // cannot exit the node until the connectors are enabled again. CurrentNode.DisableConnectors(); // Let overrides pass in their own args, but none needed here. OnPaused(null); } }
/// <summary> /// Checks if the last statement being entered must leads to the start of a sentence. /// </summary> public virtual void CheckStartSentenceLastStatement() { if (LastEnteredNode != null) { Node parent = LastEnteredNode.Parent; if (parent is Paragraph || parent is ProcedureDivision) { //JCM Hack: So in this case the statement must be given as parent a Sentence Node. //This hack is perform because using the Enter/Exit mechanism to create a Syntax Tree //Is not appropriate with LALR(1) grammar, because there is not start token that can telle //The beginning of list of statement that belongs to a sentence. //So we check if the statement is part of a paragraph or a procedure division. parent.Remove(LastEnteredNode); //Start a sentence StartSentence(); CurrentNode.Add(LastEnteredNode); } } }
public override void OnNodeDrop(object dataObject, DragOperation operation) { FilePath targetPath = ShowAllFilesBuilderExtension.GetFolderPath(CurrentNode.DataItem); Project targetProject = (Project)CurrentNode.GetParentDataItem(typeof(Project), true); FilePath source = ((SystemFile)dataObject).Path; targetPath = targetPath.Combine(source.FileName); if (targetPath == source) { targetPath = ProjectOperations.GetTargetCopyName(targetPath, false); } using (IProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetStatusProgressMonitor(GettextCatalog.GetString("Copying files..."), Stock.StatusWorking, true)) { bool move = operation == DragOperation.Move; IdeApp.ProjectOperations.TransferFiles(monitor, null, source, targetProject, targetPath, move, false); } }
private void ShootLogic() { if (m_hasShot && shotCooldown >= 3) { // shoot if: node had no bullets already, wont be occupied by the player or a wall next step if (m_shotDirection == Direction && !CurrentNode.GetNeighbour(m_shotDirection).HasObjectOfType <bullet>()) { Shoot(CurrentNode.GetNeighbour(m_shotDirection)); } else if (!CurrentNode.GetNeighbour(m_shotDirection).HasObjectOfType <bullet>() && !CurrentNode.HasObjectOfType <bullet>()) { Shoot(CurrentNode); } m_hasShot = false; shotCooldown = -1; GameController.LevelStats().AddShot(); } }
/// <summary> /// Finds an invocation of a method of the given name which is a descendant of the provided root, and makes it the current node. /// </summary> /// <param name="root">Root node</param> /// <param name="methodName">Method's name</param> /// <returns>True if found and made current, false otherwise</returns> public bool SelectMethodInvocation([NotBlank] string methodName) { var invocations = CurrentNode?.DescendantNodes().OfType <InvocationExpressionSyntax>().ToList(); foreach (var invocation in invocations) { var identifierNames = invocation.DescendantNodes().OfType <IdentifierNameSyntax>().ToList(); bool found = (from name in identifierNames where name.Identifier.ValueText == methodName select name).Any(); if (found) { //return NextStep(invocation); } } return(false); }
/// <summary> /// Calculates the calibration algorithms where the node to be calibrated is the blind node /// </summary> /// <param name="dataSet">The dataset to be processed</param> private void ExecuteCalibrationBlindNode(DataSet dataSet) { Console.WriteLine("Executing the two calibration methods"); foreach (DataRow row in dataSet.Tables[0].Rows) { currentID = row["node"].ToString(); Node CurrentNode; if (currentID == "11") { if (!AnchorNodes.Exists(AN => AN.WsnIdProperty == currentID)) { AnchorNodes.Add(new Node(row["node"].ToString(), MyDb)); CurrentNode = AnchorNodes.Find(AN => AN.WsnIdProperty == currentID); Console.WriteLine("Enter the position of the blind node in doubles!"); Point position = new Point(); Console.Write("X: "); position.x = Convert.ToDouble(Console.ReadLine()); Console.Write("Y: "); position.y = Convert.ToDouble(Console.ReadLine()); CurrentNode.position = new Point(position.x, position.y); } CurrentNode = AnchorNodes.Find(AN => AN.WsnIdProperty == currentID); CurrentNode.UpdateAnchors(row["ANode"].ToString(), Convert.ToDouble(row["RSSI"].ToString()), 1, DateTime.Now); } } RangeBasedPositioning.CalibratePathloss(AnchorNodes, RangeBasedPositioning.AverageFilter); Console.WriteLine("Normal Calibration"); Console.WriteLine(RangeBasedPositioning.pathLossExponent); Console.WriteLine(RangeBasedPositioning.baseLoss); RangeBasedPositioning.CalibratePathlossLS(AnchorNodes, RangeBasedPositioning.AverageFilter); Console.WriteLine("LS Calibration"); Console.WriteLine(RangeBasedPositioning.pathLossExponent); Console.WriteLine(RangeBasedPositioning.baseLoss); AnchorNodes.Clear(); }
public override void RenameItem(string newName) { var file = CurrentNode.DataItem as SystemFolder; string oldname = file.Path; string newname = Path.Combine(Path.GetDirectoryName(oldname), newName); if (newname != oldname) { try { if (!FileService.IsValidPath(newname)) { MessageService.ShowWarning(GettextCatalog.GetString("The name you have chosen contains illegal characters. Please choose a different name.")); } else if (File.Exists(newname) || Directory.Exists(newname)) { MessageService.ShowWarning(GettextCatalog.GetString("File or directory name is already in use. Please choose a different one.")); } else { var oldFiles = Array.ConvertAll( Directory.GetFiles(oldname, "*", SearchOption.AllDirectories), (input) => (FilePath)input).ToList(); FileService.RenameDirectory(oldname, newname); var newFiles = Array.ConvertAll( Directory.GetFiles(newname, "*", SearchOption.AllDirectories), (input) => (FilePath)input).ToList(); var tb = Tree.BuilderContext.GetTreeBuilder(CurrentNode); tb.MoveToParent(); tb.UpdateChildren(); var project = CurrentNode.GetParentDataItem(typeof(FolderBasedProject), true) as FolderBasedProject; if (project == null) { return; } project.OnFilesRenamed(oldFiles, newFiles); } } catch (ArgumentException) { // new file name with wildcard (*, ?) characters in it MessageService.ShowWarning(GettextCatalog.GetString("The name you have chosen contains illegal characters. Please choose a different name.")); } catch (IOException ex) { MessageService.ShowError(GettextCatalog.GetString("There was an error renaming the file."), ex); } } }
public async void NewWebReference() { // Get the project and project folder var project = CurrentNode.GetParentDataItem(typeof(DotNetProject), true) as DotNetProject; // Check and switch the runtime environment for the current project if (project.TargetFramework.Id == TargetFrameworkMoniker.NET_1_1) { string msg1 = GettextCatalog.GetString("The current runtime environment for your project is set to version 1.0."); string msg2 = GettextCatalog.GetString("Web Service is not supported in this version."); string msg3 = GettextCatalog.GetString("Do you want switch the runtime environment for this project version 2.0?"); string question = $"{msg1} {msg2} {msg3}"; var switchButton = new AlertButton(GettextCatalog.GetString("_Switch to .NET 2.0")); if (MessageService.AskQuestion(question, AlertButton.Cancel, switchButton) == switchButton) { project.TargetFramework = Runtime.SystemAssemblyService.GetTargetFramework(TargetFrameworkMoniker.NET_2_0); } else { return; } } var dialog = new WebReferenceDialog(project); dialog.NamespacePrefix = project.DefaultNamespace; try { if (MessageService.RunCustomDialog(dialog) != (int)Gtk.ResponseType.Ok) { return; } await dialog.SelectedService.GenerateFiles(project, dialog.Namespace, dialog.ReferenceName); await IdeApp.ProjectOperations.SaveAsync(project); } catch (Exception exception) { MessageService.ShowError(GettextCatalog.GetString("The web reference could not be added"), exception); } finally { dialog.Destroy(); dialog.Dispose(); } }
public override void DeleteMultipleItems() { var project = CurrentNode.GetParentDataItem(typeof(FolderBasedProject), true) as FolderBasedProject; if (CurrentNodes.Length == 1) { var file = (SystemFolder)CurrentNodes [0].DataItem; if (!MessageService.Confirm(GettextCatalog.GetString("Are you sure you want to permanently delete the directory {0}?", file.Path), AlertButton.Delete)) { return; } } else { if (!MessageService.Confirm(GettextCatalog.GetString("Are you sure you want to permanently delete all selected directories?"), AlertButton.Delete)) { return; } } var foundFiles = new List <FilePath> (); foreach (SystemFolder folder in CurrentNodes.Select(n => (SystemFolder)n.DataItem)) { try { foundFiles = foundFiles.Concat(Array.ConvertAll( Directory.GetFiles(folder.Path, "*", SearchOption.AllDirectories), (input) => (FilePath)input)).ToList(); FileService.DeleteDirectory(folder.Path); } catch (Exception ex) { MessageService.ShowError(GettextCatalog.GetString("The directory {0} could not be deleted", folder.Path), ex); } } var tb = Tree.BuilderContext.GetTreeBuilder(CurrentNode); tb.MoveToParent(); tb.UpdateChildren(); if (project == null) { return; } project.OnFilesRemoved(foundFiles); }
public void NewWebReference() { // Get the project and project folder DotNetProject project = CurrentNode.GetParentDataItem(typeof(DotNetProject), true) as DotNetProject; // Check and switch the runtime environment for the current project if (project.TargetFramework.Id == TargetFrameworkMoniker.NET_1_1) { string question = "The current runtime environment for your project is set to version 1.0."; question += "Web Service is not supported in this version."; question += "Do you want switch the runtime environment for this project version 2.0 ?"; AlertButton switchButton = new AlertButton("_Switch to .NET2"); if (MessageService.AskQuestion(question, AlertButton.Cancel, switchButton) == switchButton) { project.TargetFramework = Runtime.SystemAssemblyService.GetTargetFramework(TargetFrameworkMoniker.NET_2_0); } else { return; } } WebReferenceDialog dialog = new WebReferenceDialog(project); dialog.NamespacePrefix = project.DefaultNamespace; try { if (MessageService.RunCustomDialog(dialog) == (int)Gtk.ResponseType.Ok) { dialog.SelectedService.GenerateFiles(project, dialog.Namespace, dialog.ReferenceName); IdeApp.ProjectOperations.Save(project); } } catch (Exception exception) { MessageService.ShowException(exception); } finally { dialog.Destroy(); } }
public void ManagePackages() { // Get the project and project folder DotNetProject project = CurrentNode.GetParentDataItem(typeof(DotNetProject), true) as DotNetProject; IPackageRepository repository = CreateRepository(); ManagePackagesDialog dialog = new ManagePackagesDialog().SetProject(project).SetPackageRepository(repository); try { if (MessageService.RunCustomDialog(dialog) == (int)Gtk.ResponseType.Ok) { project.AddPackage(dialog.SelectedPackage, repository); IdeApp.ProjectOperations.Save(project); } } catch (Exception exception) { MessageService.ShowException(exception); } finally { dialog.Destroy(); } }
public override void ActivateItem() { var reference = (AssemblyNameReference)CurrentNode.DataItem; if (reference == null) { return; } var loader = (AssemblyLoader)CurrentNode.GetParentDataItem(typeof(AssemblyLoader), false); string fileName = loader.LookupAssembly(reference.FullName); if (fileName == null) { return; } var builder = (AssemblyReferenceNodeBuilder)this.CurrentNode.TypeNodeBuilder; builder.Widget.AddReferenceByFileName(fileName, true); }
protected void OnReloadDesigner() { ProjectFile pf = CurrentNode.DataItem as ProjectFile; Project project = CurrentNode.GetParentDataItem(typeof(Project), true) as Project; GtkDesignInfo info = GtkDesignInfo.FromProject(project); GuiBuilderProject gproject = info.GuiBuilderProject; Document doc = IdeApp.Workbench.GetDocument(pf.FilePath); if (doc != null) { gproject.ReloadFile(pf.FilePath); GuiBuilderView view = doc.ActiveView as GuiBuilderView; if (view != null) { view.ReloadDesigner(project); } } }
public void SerializeObjectArray(string name, IEnumerable <object> items) { var array = new JSONArray(); if (name == null) { CurrentNode.Add(array); } else { CurrentNode.Add(name, array); } Push(name, array); foreach (var item in items) { SerializeObject(null, item); } Pop(); }
public void RemoveItem() { Solution solution = CurrentNode.DataItem as Solution; Workspace parent = CurrentNode.GetParentDataItem(typeof(Workspace), false) as Workspace; if (parent == null) { return; } AlertButton res = MessageService.AskQuestion(GettextCatalog.GetString("Do you really want to remove solution {0} from workspace {1}?", solution.Name, parent.Name), AlertButton.Remove); if (res == AlertButton.Remove) { parent.Items.Remove(solution); solution.Dispose(); IdeApp.Workspace.Save(); } }
protected void ShowProperties() { //IClass cls = (IClass)CurrentNode.DataItem; Project p = (Project)CurrentNode.GetParentDataItem(typeof(Project), false); ProjectFile file = (ProjectFile)CurrentNode.GetParentDataItem(typeof(ProjectFile), false); StringBuilder sb = new StringBuilder(); //sb.AppendFormat("Class: {0}\n", cls.Name); sb.AppendFormat("Project: {0}\n", p.Name); sb.AppendFormat("File: {0}\n", file.Name); sb.AppendFormat("Methods:\n", file.Name); //foreach (IMethod met in cls.Methods) //sb.AppendFormat(" - {0}\n", met.Name); MessageService.ShowMessage(sb.ToString()); }
public XmlNode AddFirstChild(XmlNode newChildNode) { if (CurrentNode == null) { CurrentNode = Document.DocumentElement; } if (Document.DocumentElement == null) { throw new GlException("Xml document must have document element node"); } if (CurrentNode.FirstChild == null) { return(CurrentNode.AppendChild(newChildNode)); } else { return(CurrentNode.InsertBefore(newChildNode, CurrentNode.FirstChild)); } }
public override async void Start() { await Task.Run(() => { while (true) { IsWaitingForIteraction = false; IsBusy = true; State = "Searching..."; DateTime startTime = DateTime.Now; int nodes = CurrentNode.CalculateValue(); OnExpanded(); IsWaitingForIteraction = true; IsBusy = false; State = $"{nodes} tree nodes were searched in time {DateTime.Now - startTime}."; playEvent.WaitOne(); playEvent.Reset(); } }); }