Skip to content

Commit

Permalink
Added user rating prompt
Browse files Browse the repository at this point in the history
[release]
  • Loading branch information
madskristensen committed Jan 25, 2022
1 parent b850f57 commit a0d60d2
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 11 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@ jobs:
vsix-token-source-file: ${{ env.VsixManifestSourcePath }}

- name: Build
run: msbuild /v:m -restore /p:OutDir=../_built
run: msbuild /v:m -restore /p:OutDir=\_built

- name: Setup test
uses: darenm/Setup-VSTest@v1

- name: Test
run: vstest.console.exe _built\*test.dll
run: vstest.console.exe \_built\*test.dll

- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: ${{ github.event.repository.name }}.vsix
path: _built/**/*.vsix
path: /_built/**/*.vsix

publish:
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
Expand Down
2 changes: 2 additions & 0 deletions src/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ public class Constants
public static string[] CommentChars = new[] { ";", "//" };
public const string PkgDefExt = ".pkgdef";
public const string PkgUndefExt = ".pkgundef";

public const string MarketplaceId = "MadsKristensen.PkgdefLanguage";
}
}
27 changes: 26 additions & 1 deletion src/Editor/EditorFeatures.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using Microsoft.VisualStudio.Language.Intellisense;
using Microsoft.VisualStudio.Language.Intellisense.AsyncCompletion;
using Microsoft.VisualStudio.Language.StandardClassification;
using Microsoft.VisualStudio.Text.BraceCompletion;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Text.Tagging;
using Microsoft.VisualStudio.Utilities;

Expand Down Expand Up @@ -75,4 +77,27 @@ internal sealed class BraceMatchingTaggerProvider : BraceMatchingBase
[TagType(typeof(TextMarkerTag))]
public class SameWordHighlighter : SameWordHighlighterBase
{ }

[Export(typeof(IWpfTextViewCreationListener))]
[ContentType(Constants.LanguageName)]
[TextViewRole(PredefinedTextViewRoles.PrimaryDocument)]
public class UserRatings : WpfTextViewCreationListener
{
private DateTime _openedDate;
private RatingPrompt _rating;

protected override void Created(DocumentView docView)
{
_openedDate = DateTime.Now;
_rating = new RatingPrompt(Constants.MarketplaceId, Vsix.Name, AdvancedOptions.Instance, 5);
}

protected override void Closed(IWpfTextView textView)
{
if (_openedDate.AddMinutes(2) < DateTime.Now)
{
_rating.RegisterSuccessfulUsage();
}
}
}
}
6 changes: 3 additions & 3 deletions src/Editor/TokenTagger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ public override Task TokenizeAsync()
return Task.CompletedTask;
}

AddTagToList(list, item);
ConvertItemToTag(list, item);

foreach (ParseItem variable in item.References)
{
AddTagToList(list, variable);
ConvertItemToTag(list, variable);
}
}

OnTagsUpdated(list);
return Task.CompletedTask;
}

private void AddTagToList(List<ITagSpan<TokenTag>> list, ParseItem item)
private void ConvertItemToTag(List<ITagSpan<TokenTag>> list, ParseItem item)
{
var hasTooltip = !item.IsValid;
var supportsOutlining = item is Entry entry && entry.Properties.Any();
Expand Down
17 changes: 17 additions & 0 deletions src/Options/AdvancedOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace PkgdefLanguage
{
internal partial class OptionsProvider
{
[ComVisible(true)]
public class AdvancedOptionsPage : BaseOptionPage<AdvancedOptions> { }
}

public class AdvancedOptions : BaseOptionModel<AdvancedOptions>, IRatingConfig
{
[Browsable(false)]
public int RatingRequests { get; set; }
}
}
2 changes: 0 additions & 2 deletions src/Parser/Document.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@ public Document(ITextBuffer buffer)
_buffer.Changed += BufferChanged;
FileName = buffer.GetFileName();

#pragma warning disable VSTHRD104 // Offer async methods
ThreadHelper.JoinableTaskFactory.Run(async () =>
{
Project project = await VS.Solutions.GetActiveProjectAsync();
ProjectName = project?.Name;
});
#pragma warning restore VSTHRD104 // Offer async methods
}

public bool IsProcessing { get; private set; }
Expand Down
5 changes: 4 additions & 1 deletion src/PkgdefLanguage.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
<UseCodebase>true</UseCodebase>
<AppDesignerFolder>Properties</AppDesignerFolder>
<NoWarn>MSB3277</NoWarn>
<NoWarn>VSTHRD104</NoWarn>
<DisableWarning>MSB3277</DisableWarning>
<DisableWarning>VSTHRD104</DisableWarning>
</PropertyGroup>
<PropertyGroup>
</PropertyGroup>
Expand Down Expand Up @@ -70,7 +72,7 @@
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Community.VisualStudio.Toolkit.16" version="16.0.394" ExcludeAssets="runtime">
<PackageReference Include="Community.VisualStudio.Toolkit.16" version="16.0.408" ExcludeAssets="runtime">
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VSSDK.BuildTools">
Expand All @@ -82,6 +84,7 @@
<ItemGroup>
<Compile Include="Commands\Formatting.cs" />
<Compile Include="Editor\DropdownBars.cs" />
<Compile Include="Options\AdvancedOptions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Commands\Commenting.cs" />
<Compile Include="Constants.cs" />
Expand Down
1 change: 1 addition & 0 deletions src/PkgdefPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace PkgdefLanguage
[PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)]
[Guid(PackageGuids.PkgdefLanguageString)]
[ProvideMenuResource("Menus.ctmenu", 1)]
[ProvideOptionPage(typeof(OptionsProvider.AdvancedOptionsPage), "PkgdefLanguage", "Advanced", 0, 0, true, SupportsProfiles = true, NoShowAllView = true)]

[ProvideLanguageService(typeof(LanguageFactory), Constants.LanguageName, 0, EnableLineNumbers = true, EnableAsyncCompletion = true, ShowCompletion = true, EnableFormatSelection = false, ShowDropDownOptions = true)]
[ProvideLanguageExtension(typeof(LanguageFactory), Constants.PkgDefExt)]
Expand Down
2 changes: 1 addition & 1 deletion test/PkgdefLanguage.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<Compile Remove="C:\Users\madsk\.nuget\packages\community.visualstudio.toolkit.16\16.0.357\build\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Community.VisualStudio.Toolkit.16" Version="16.0.394" />
<PackageReference Include="Community.VisualStudio.Toolkit.16" Version="16.0.408" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.8" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" />
Expand Down

0 comments on commit a0d60d2

Please sign in to comment.