forked from madskristensen/JavaScriptPrettier
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrettierPackage.cs
More file actions
48 lines (42 loc) · 1.99 KB
/
PrettierPackage.cs
File metadata and controls
48 lines (42 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using EnvDTE80;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Threading;
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Threading;
using IServiceProvider = Microsoft.VisualStudio.OLE.Interop.IServiceProvider;
namespace JavaScriptPrettier
{
[PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)]
[InstalledProductRegistration("#110", "#112", Vsix.Version, IconResourceID = 400)]
[Guid(PackageGuids.guidPrettierPackageString)]
[ProvideMenuResource("Menus.ctmenu", 1)]
[ProvideOptionPage(typeof(OptionPageGrid), "Prettier", "General", 0, 0, true)]
[ProvideAutoLoad(cmdUiContextGuid: VSConstants.UICONTEXT.NotBuildingAndNotDebugging_string, flags: PackageAutoLoadFlags.BackgroundLoad)]
public sealed class PrettierPackage : AsyncPackage
{
internal DTE2 _dte;
internal RunningDocumentTable _runningDocTable;
internal OptionPageGrid optionPage;
internal ServiceProvider _serviceProvider;
protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress<ServiceProgressData> progress)
{
await JoinableTaskFactory.SwitchToMainThreadAsync();
_dte = ServiceProvider.GlobalProvider.GetService(typeof(EnvDTE.DTE)) as DTE2;
_serviceProvider = new ServiceProvider((IServiceProvider)_dte);
_runningDocTable = new RunningDocumentTable(_serviceProvider);
_runningDocTable.Advise(new RunningDocTableEventsHandler(this));
optionPage = (OptionPageGrid)GetDialogPage(typeof(OptionPageGrid));
await base.InitializeAsync(cancellationToken, progress);
}
}
public class OptionPageGrid : DialogPage
{
[Category("Prettier")]
[DisplayName("Format On Save")]
[Description("Run Pretter whenever a file is saved")]
public bool FormatOnSave { get; set; }
}
}