Beispiel #1
0
        private async void DocumentSaved(object sender, TextDocumentFileActionEventArgs e)
        {
            if (e.FileActionType != FileActionTypes.ContentSavedToDisk)
            {
                return;
            }

            var document = (ITextDocument)sender;

            if (!document.TextBuffer.Properties.TryGetProperty("p_item", out ProjectItem item))
            {
                return;
            }


            TranspilerStatus status = await Microsoft.VisualStudio.Shell.ThreadHelper.JoinableTaskFactory.RunAsync(async() =>
            {
                try
                {
                    return(await item.Transpile());
                }
                catch (Exception ex)
                {
                    Logger.Log(ex);
                    return(TranspilerStatus.Exception);
                }
            });
        }
Beispiel #2
0
        public static async Task <TranspilerStatus> Transpile(this ProjectItem item)
        {
            TranspilerStatus status = CanTranspile(item);

            if (status != TranspilerStatus.Ok)
            {
                return(status);
            }

            _isProcessing = true;

            try
            {
                return(await BuildProject(item.ContainingProject));
            }
            finally
            {
                _isProcessing = false;
            }
        }
Beispiel #3
0
        private async void Execute(object sender, EventArgs e)
        {
            if (_item == null || _item.ContainingProject == null)
            {
                return;
            }

            try
            {
                string projectRoot = _item.ContainingProject.Properties.Item("FullPath").Value.ToString();

                if (Directory.Exists(projectRoot))
                {
                    string configPath = await CreateConfigFile(projectRoot);

                    VsHelpers.OpenFileAndSelect(_item.DTE, configPath);
                    TranspilerStatus status = await _item.Transpile();
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
            }
        }