public RustProjectConfig(RustProjectNode project, string configuration) : base(project, configuration) { this.UserCfg = new Configuration.MsBuildConfiguration(project.UserConfig, configuration, "default"); if (!initialized) { // Determine IDE version and whether GDB engine is installed (only in VS2015+) var env = (EnvDTE.DTE)project.GetService(typeof(SDTE)); Version ver; if (Version.TryParse(env.Version, out ver)) { isGdbSupported = ver.Major >= 14; } var debugger = (IVsDebugger2)project.GetService(typeof(SVsShellDebugger)); string name; Guid gdbEngine = Constants.GdbEngine; if (debugger.GetEngineName(ref gdbEngine, out name) == 0) { isGdbInstalled = true; isGdbSupported = true; } initialized = true; } DebugType = isGdbInstalled ? Constants.GdbDebugger : Constants.BuiltinDebugger; }
public static void Replace(RustProjectNode root, HierarchyNode old, Func<HierarchyNode> newN) { if (root == null) throw new ArgumentNullException("root"); if (old == null) throw new ArgumentNullException("old"); if (newN == null) throw new ArgumentNullException("newN"); __VSHIERARCHYITEMSTATE visualState = old.GetItemState(__VSHIERARCHYITEMSTATE.HIS_Selected | __VSHIERARCHYITEMSTATE.HIS_Expanded); HierarchyNode parent = old.Parent; HierarchyNode newNode; if(parent is UntrackedFolderNode) { using(((UntrackedFolderNode)parent).SuspendChildrenTracking()) { newNode = ReplaceCore(root, old, newN, parent); ((UntrackedFolderNode)parent).OnChildReplaced(old, newNode); } } else { newNode = ReplaceCore(root, old, newN, parent); } if ((visualState & __VSHIERARCHYITEMSTATE.HIS_Expanded) != 0) newNode.ExpandItem(EXPANDFLAGS.EXPF_ExpandFolder); if ((visualState & __VSHIERARCHYITEMSTATE.HIS_Selected) != 0) newNode.ExpandItem(EXPANDFLAGS.EXPF_SelectItem); }
internal override ProjectNode CreateProject() { RustProjectNode project = new RustProjectNode(this.pkg); project.SetSite((IOleServiceProvider)((IServiceProvider)this.Package).GetService(typeof(IOleServiceProvider))); return(project); }
public DefaultRustLauncher(RustProjectNode project) { Utilities.ArgumentNotNull("project", project); this.project = project; string currConfig = this.project.GetProjectProperty(ProjectFileConstants.Configuration); projectConfig = (RustProjectConfig)this.project.ConfigProvider.GetProjectConfiguration(currConfig); debugConfig = Configuration.Debug.LoadFrom(new[] { projectConfig.UserCfg }); }
// Mass delete all sbunodes that were orphaned by the // removal of a subnode with path `rootPath` public static void DeleteSubnode(RustProjectNode root, string srcpath) { if (root == null) throw new ArgumentNullException("root"); if (String.IsNullOrEmpty(srcpath)) throw new ArgumentException("srcpath"); var forRemoval = root.ModuleTracker.DeleteModule(srcpath); foreach (string path in forRemoval.Orphans) { TreeOperations.RemoveSubnodeFromHierarchy(root, path, (!forRemoval.IsReferenced) && path.Equals(srcpath, StringComparison.InvariantCultureIgnoreCase)); } }
public RustProjectLauncher(RustProjectNode project) { Utilities.ArgumentNotNull("project", project); string currConfig = project.GetProjectProperty(ProjectFileConstants.Configuration); RustProjectConfig projectConfig = (RustProjectConfig)project.ConfigProvider.GetProjectConfiguration(currConfig); debugConfig = Configuration.Debug.LoadFrom(new[] { projectConfig.UserCfg }); if (debugConfig.StartAction == Configuration.StartAction.Project && project.GetProjectProperty("OutputType") != "exe") { throw new InvalidOperationException("A project with an Output Type of Library cannot be started directly."); } this.environment = new LauncherEnvironment(project, debugConfig, projectConfig); }
internal static RustProjectNode GetSelectedRustProjectNode() { IVsSolution ivsSolution = GetIVsSolution(); EnvDTE80.DTE2 dte = GetDTE2(); GetActiveSolutionsProject(); //Get first project details EnvDTE.Project proj = dte.Solution.Projects.Item(1); var containingProj = proj.ProjectItems.ContainingProject; OAProject oaProj = containingProj as OAProject; RustProjectNode rustProjNode = oaProj.ProjectNode as RustProjectNode; return(rustProjNode); }
private static HierarchyNode ReplaceCore(RustProjectNode root, HierarchyNode old, Func<HierarchyNode> newN, HierarchyNode parent) { HierarchyNode newNode = newN(); while (old.FirstChild != null) { HierarchyNode current = old.FirstChild; root.ProjectMgr.OnItemDeleted(current); old.RemoveChild(current); current.ID = root.ProjectMgr.ItemIdMap.Add(current); newNode.AddChild(current); } TreeOperations.RemoveSubnodeFromHierarchy(root, old, false); parent.AddChild(newNode); return newNode; }
private static HierarchyNode ReplaceCore(RustProjectNode root, HierarchyNode old, Func <HierarchyNode> newN, HierarchyNode parent) { HierarchyNode newNode = newN(); while (old.FirstChild != null) { HierarchyNode current = old.FirstChild; root.ProjectMgr.OnItemDeleted(current); old.RemoveChild(current); current.ID = root.ProjectMgr.ItemIdMap.Add(current); newNode.AddChild(current); } TreeOperations.RemoveSubnodeFromHierarchy(root, old, false); parent.AddChild(newNode); return(newNode); }
// Mass delete all sbunodes that were orphaned by the // removal of a subnode with path `rootPath` public static void DeleteSubnode(RustProjectNode root, string srcpath) { if (root == null) { throw new ArgumentNullException("root"); } if (String.IsNullOrEmpty(srcpath)) { throw new ArgumentException("srcpath"); } var forRemoval = root.ModuleTracker.DeleteModule(srcpath); foreach (string path in forRemoval.Orphans) { TreeOperations.RemoveSubnodeFromHierarchy(root, path, (!forRemoval.IsReferenced) && path.Equals(srcpath, StringComparison.InvariantCultureIgnoreCase)); } }
internal static RustProjectNode GetActiveRustProject() { IVsSolution ivsSolution = GetIVsSolution(); EnvDTE80.DTE2 dte = GetDTE2(); var activeSolutions = dte.Solution.DTE.ActiveSolutionProjects as object[]; RustProjectNode rustProject = null; if (activeSolutions != null && activeSolutions.Length > 0) { OAProject oaProject = activeSolutions[0] as OAProject; if (oaProject != null && oaProject.FileName.EndsWith(".rsproj")) { rustProject = oaProject.Project as RustProjectNode; } } return(rustProject); }
public static bool RemoveSubnodeFromHierarchy(RustProjectNode root, string path, bool deleteFromStorage) { if (root == null) throw new ArgumentNullException("root"); if (String.IsNullOrEmpty(path)) throw new ArgumentException("path"); uint item; root.ParseCanonicalName(path, out item); if (item != (uint)VSConstants.VSITEMID.Nil) { HierarchyNode node = root.NodeFromItemId(item); if (node != null) { TreeOperations.RemoveSubnodeFromHierarchy(root, node, deleteFromStorage); return true; } } return false; }
public static void Replace(RustProjectNode root, HierarchyNode old, Func <HierarchyNode> newN) { if (root == null) { throw new ArgumentNullException("root"); } if (old == null) { throw new ArgumentNullException("old"); } if (newN == null) { throw new ArgumentNullException("newN"); } __VSHIERARCHYITEMSTATE visualState = old.GetItemState(__VSHIERARCHYITEMSTATE.HIS_Selected | __VSHIERARCHYITEMSTATE.HIS_Expanded); HierarchyNode parent = old.Parent; HierarchyNode newNode; if (parent is UntrackedFolderNode) { using (((UntrackedFolderNode)parent).SuspendChildrenTracking()) { newNode = ReplaceCore(root, old, newN, parent); ((UntrackedFolderNode)parent).OnChildReplaced(old, newNode); } } else { newNode = ReplaceCore(root, old, newN, parent); } if ((visualState & __VSHIERARCHYITEMSTATE.HIS_Expanded) != 0) { newNode.ExpandItem(EXPANDFLAGS.EXPF_ExpandFolder); } if ((visualState & __VSHIERARCHYITEMSTATE.HIS_Selected) != 0) { newNode.ExpandItem(EXPANDFLAGS.EXPF_SelectItem); } }
public static void AddTask( string message, string file, int line, int endLine, int column, int endColumn, IVsHierarchy hierarchy, TaskCategory category, TaskErrorCategory errorCategory, TaskPriority priority = TaskPriority.Normal) { //errorListProvider.Tasks.Clear(); TextSpan span = new TextSpan() { iStartLine = line, iStartIndex = column, iEndLine = endLine, iEndIndex = endColumn }; VisualRust.Project.RustProjectNode rustProject = hierarchy as VisualRust.Project.RustProjectNode; Add(new ErrorTask() //DocumentTask(serviceProvider, null!!!, MARKERTYPE.MARKER_COMPILE_ERROR, span, file) { Category = TaskCategory.BuildCompile, ErrorCategory = errorCategory, Line = line, Column = column, Priority = priority, Text = message, HierarchyItem = hierarchy }); Refresh(); // make sure it is visible }
public static bool RemoveSubnodeFromHierarchy(RustProjectNode root, string path, bool deleteFromStorage) { if (root == null) { throw new ArgumentNullException("root"); } if (String.IsNullOrEmpty(path)) { throw new ArgumentException("path"); } uint item; root.ParseCanonicalName(path, out item); if (item != (uint)VSConstants.VSITEMID.Nil) { HierarchyNode node = root.NodeFromItemId(item); if (node != null) { TreeOperations.RemoveSubnodeFromHierarchy(root, node, deleteFromStorage); return(true); } } return(false); }
private static bool RemoveSubnodeFromHierarchy(RustProjectNode root, HierarchyNode node, bool deleteFromStorage) { node.Remove(deleteFromStorage); return true; }
public UntrackedFolderNode(RustProjectNode root, ProjectElement elm) : base(root, elm) { ProjectMgr = root; }
public RustProjectConfig(RustProjectNode project, string configuration) : base(project, configuration) { }
public RustFolderNode(RustProjectNode rustProjectNode, ProjectElement element) : base(rustProjectNode, element) { }
public static void QueueMessage( string subCategory, string errorCode, string file, string msg, int line, int column, int endLine, int endColumn, IVsHierarchy hierarchy, bool isError = true, string helpKeyword = "", string senderName = "", bool refresh = true) { if (Contains(subCategory, errorCode, file, msg, line, column, hierarchy, isError, helpKeyword, senderName)) { return; } // This enqueues a function that will later be run on the main (UI) thread TextSpan span; string filePath; MARKERTYPE marker; TaskErrorCategory category; VisualRust.Project.RustProjectNode rustProject = hierarchy as VisualRust.Project.RustProjectNode; var ivsSolution = (IVsSolution)Package.GetGlobalService(typeof(IVsSolution)); var dte = (EnvDTE80.DTE2)Package.GetGlobalService(typeof(EnvDTE.DTE)); span = new TextSpan(); // spans require zero-based indices span.iStartLine = line - 1; span.iEndLine = endLine - 1; span.iStartIndex = column - 1; span.iEndIndex = endColumn - 1; filePath = Path.Combine(Path.GetDirectoryName(rustProject.GetCanonicalName()), file); if (isError) { marker = MARKERTYPE.MARKER_CODESENSE_ERROR; // red squiggles category = TaskErrorCategory.Error; } else { marker = MARKERTYPE.MARKER_COMPILE_ERROR; // red squiggles category = TaskErrorCategory.Warning; } if (span.iEndLine == -1) { span.iEndLine = span.iStartLine; } if (span.iEndIndex == -1) { span.iEndIndex = span.iStartIndex; } IVsUIShellOpenDocument openDoc = serviceProvider.GetService(typeof(IVsUIShellOpenDocument)) as IVsUIShellOpenDocument; if (openDoc == null) { throw new NotImplementedException(); // TODO } IVsWindowFrame frame; IOleServiceProvider sp; IVsUIHierarchy hier; uint itemid; Guid logicalView = Microsoft.VisualStudio.VSConstants.LOGVIEWID_Code; IVsTextLines buffer = null; // Notes about acquiring the buffer: // If the file physically exists then this will open the document in the current project. It doesn't matter if the file is a member of the project. // Also, it doesn't matter if this is a Rust file. For example, an error in Microsoft.Common.targets will cause a file to be opened here. // However, opening the document does not mean it will be shown in VS. if (!Microsoft.VisualStudio.ErrorHandler.Failed(openDoc.OpenDocumentViaProject(file, ref logicalView, out sp, out hier, out itemid, out frame)) && frame != null) { object docData; frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out docData); // Get the text lines buffer = docData as IVsTextLines; if (buffer == null) { IVsTextBufferProvider bufferProvider = docData as IVsTextBufferProvider; if (bufferProvider != null) { bufferProvider.GetTextBuffer(out buffer); } } } if (span.iEndLine > span.iStartLine) { span.iEndLine = span.iStartLine; int lineLength = 0; if (buffer.GetLengthOfLine(span.iStartLine, out lineLength) == Microsoft.VisualStudio.VSConstants.S_OK) { span.iEndIndex = lineLength - 1; } } DocumentTask task = new DocumentTask(serviceProvider, buffer, marker, span, file); task.ErrorCategory = category; task.Document = file; task.Line = span.iStartLine; task.Column = span.iStartIndex; task.Priority = category == TaskErrorCategory.Error ? TaskPriority.High : TaskPriority.Normal; task.Text = msg; task.Category = TaskCategory.BuildCompile; task.HierarchyItem = hierarchy; Add(task); if (refresh) { Refresh(); } // NOTE: Unlike output we dont want to interactively report the tasks. So we never queue // call ReportQueuedTasks here. We do this when the build finishes. }
public UntrackedFileNode(RustProjectNode root, string file) : base(root, new VirtualProjectElement(root, file), file) { }
public BaseFileNode(RustProjectNode node, ProjectElement elm, string path) : base(node, elm) { ProjectMgr = node; }
private static bool RemoveSubnodeFromHierarchy(RustProjectNode root, HierarchyNode node, bool deleteFromStorage) { node.Remove(deleteFromStorage); return(true); }
public DefaultRustLauncher(RustProjectNode project) { Utilities.ArgumentNotNull("project", project); _project = project; }
internal override ProjectNode CreateProject() { RustProjectNode project = new RustProjectNode(this.pkg); project.SetSite((IOleServiceProvider)((IServiceProvider)this.Package).GetService(typeof(IOleServiceProvider))); return project; }
public TrackedFileNode(RustProjectNode root, ProjectElement elm) : base(root, elm, elm.GetMetadata(ProjectFileConstants.Include)) { }