| | |
| | | using System.IO;
|
| | | using System.Runtime.InteropServices;
|
| | | using System.Threading.Tasks;
|
| | | using Microsoft.VisualStudio.Shell.Interop;
|
| | | using QtVsTools.QtMsBuild;
|
| | | using QtVsTools.VisualStudio;
|
| | | using Microsoft.VisualStudio.Shell;
|
| | |
|
| | | using Task = System.Threading.Tasks.Task;
|
| | |
|
| | | namespace QtVsTools.Editors
|
| | | {
|
| | | using QtMsBuild;
|
| | | using VisualStudio;
|
| | |
|
| | | [Guid(GuidString)]
|
| | | public class QtDesigner : Editor
|
| | | {
|
| | |
| | |
|
| | | protected override void OnStart(Process process)
|
| | | {
|
| | | ThreadHelper.ThrowIfNotOnUIThread();
|
| | |
|
| | | base.OnStart(process);
|
| | | var document = VsShell.GetDocument(Context, ItemId);
|
| | | if (document == null)
|
| | | return;
|
| | |
|
| | | var project = document.ProjectItem?.ContainingProject;
|
| | | if (project == null || !QtProjectTracker.IsTracked(project))
|
| | | if (project == null || !QtProjectTracker.IsTracked(project.FullName))
|
| | | return;
|
| | | string projectPath = project.FullName;
|
| | | string filePath = document.FullName;
|
| | | string[] itemId = new[] { document.ProjectItem?.Name };
|
| | | var lastWriteTime = File.GetLastWriteTime(filePath);
|
| | | Task.Run(() =>
|
| | | _ = Task.Run(async () =>
|
| | | {
|
| | | while (!process.WaitForExit(1000)) {
|
| | | var latestWriteTime = File.GetLastWriteTime(filePath);
|
| | | if (lastWriteTime != latestWriteTime) {
|
| | | lastWriteTime = latestWriteTime;
|
| | | QtProjectIntellisense.Refresh(project, selectedFiles: itemId);
|
| | | await QtProjectIntellisense.RefreshAsync(project, projectPath);
|
| | | }
|
| | | }
|
| | | if (lastWriteTime != File.GetLastWriteTime(filePath)) {
|
| | | QtProjectIntellisense.Refresh(project, selectedFiles: itemId);
|
| | | await QtProjectIntellisense.RefreshAsync(project, projectPath);
|
| | | }
|
| | | });
|
| | | }
|