forked from cake-build/cake-rider
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(cake-build#261) Add LiveTemplates for Frosting (cake-build#286)
- Loading branch information
Showing
39 changed files
with
768 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,3 +53,5 @@ obj/ | |
!/src/projectTemplates/**/build | ||
.vs/ | ||
*.user | ||
/src/dotnet/packages/ | ||
/src/dotnet/test/packages/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<Project> | ||
<PropertyGroup> | ||
<DefineConstants>$(DefineConstants);RIDER</DefineConstants> | ||
<IsPackable>false</IsPackable> | ||
<NoWarn>MSB3277</NoWarn> <!-- Is this a good idea?? --> | ||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> | ||
<DebugType>pdbonly</DebugType> | ||
<!-- will be injected by gradle at build --> | ||
<SdkVersion Condition="'$(SdkVersion)' == ''">2022.2.0</SdkVersion> | ||
<WaveVersion>$(SdkVersion.Substring(2,2))$(SdkVersion.Substring(5,1)).0.0</WaveVersion> | ||
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(Configuration)'=='Debug'"> | ||
<DebugType>full</DebugType> | ||
<DefineConstants>$(DefineConstants);TRACE;DEBUG;JET_MODE_ASSERT</DefineConstants> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
templates.generated.dotSettings |
23 changes: 23 additions & 0 deletions
23
src/dotnet/cake-rider/FrostingTemplates/FrostingTemplatesDefaultSettings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System.IO; | ||
using System.Reflection; | ||
|
||
using JetBrains.Application; | ||
using JetBrains.Application.Settings; | ||
using JetBrains.Diagnostics; | ||
using JetBrains.Lifetimes; | ||
|
||
namespace net.cakebuild.FrostingTemplates; | ||
|
||
[ShellComponent] | ||
public class FrostingTemplatesDefaultSettings : IHaveDefaultSettingsStream | ||
{ | ||
public string Name => "Frosting default LiveTemplates"; | ||
|
||
public Stream GetDefaultSettingsStream(Lifetime lifetime) | ||
{ | ||
var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("net.cakebuild.FrostingTemplates.templates.dotSettings"); | ||
Assertion.AssertNotNull(stream); | ||
lifetime.AddDispose(stream); | ||
return stream; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Templates | ||
|
||
## All | ||
|
||
### Live Templates | ||
|
||
Shortcut | Description | ||
---------|------------ | ||
[cake-async-task](Templates/cake-async-task.md) | Create a new async Cake task. | ||
[cake-async-task-ctx](Templates/cake-async-task-ctx.md) | Create a new async Cake task with a custom build context | ||
[cake-task](Templates/cake-task.md) | define a new Cake task | ||
[cake-task-ctx](Templates/cake-task-ctx.md) | Create a new Cake task with a custom build context | ||
|
49 changes: 49 additions & 0 deletions
49
src/dotnet/cake-rider/FrostingTemplates/ScopeProviders/FrostingFileScopeProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using System.Collections.Generic; | ||
|
||
using JetBrains.Application; | ||
using JetBrains.ProjectModel; | ||
using JetBrains.ReSharper.Feature.Services.LiveTemplates.Context; | ||
using JetBrains.ReSharper.Feature.Services.LiveTemplates.Scope; | ||
using JetBrains.ReSharper.Psi; | ||
|
||
using net.cakebuild.FrostingTemplates.Scopes; | ||
|
||
namespace net.cakebuild.FrostingTemplates.ScopeProviders; | ||
|
||
// Provides the scope points that are valid for the given context | ||
[ShellComponent] | ||
public class FrostingProjectScopeProvider : ScopeProvider | ||
{ | ||
public FrostingProjectScopeProvider() | ||
{ | ||
// Used when creating scope point from settings | ||
Creators.Add(TryToCreate<InFrostingProject>); | ||
} | ||
|
||
public override IEnumerable<ITemplateScopePoint> ProvideScopePoints(TemplateAcceptanceContext context) | ||
{ | ||
var sourceFile = context.SourceFile; | ||
|
||
// Do not dispose IProject! | ||
#pragma warning disable IDISP001 | ||
var project = sourceFile?.GetProject(); | ||
#pragma warning restore IDISP001 | ||
if (project == null) | ||
{ | ||
// not a "real" SourceFile or not in a project. | ||
yield break; | ||
} | ||
|
||
var solution = context.Solution; | ||
var host = solution.GetComponent<IDetectFrostingModules>(); | ||
var isFrostingProject = host.IsCakeFrostingProject(project); | ||
if (!isFrostingProject) | ||
{ | ||
// Cake.Frosting is not referenced -> no Frosting project. | ||
yield break; | ||
} | ||
|
||
// So, we've found Cake.Frosting | ||
yield return new InFrostingProject(); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...net/cake-rider/FrostingTemplates/ScopeProviders/FrostingProjectScopeCategoryUIProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System.Collections.Generic; | ||
|
||
using JetBrains.ReSharper.Feature.Services.LiveTemplates.Scope; | ||
using JetBrains.UI.Icons; | ||
|
||
using net.cakebuild.FrostingTemplates.Scopes; | ||
|
||
namespace net.cakebuild.FrostingTemplates.ScopeProviders; | ||
|
||
// Defines a category for the UI, and the scope points that it includes | ||
[ScopeCategoryUIProvider(Priority = Priority, ScopeFilter = ScopeFilter.Project)] | ||
public class FrostingProjectScopeCategoryUiProvider : ScopeCategoryUIProvider | ||
{ | ||
// Needs to be less than other priorities in R#'s built in ScopeCategoryUIProvider | ||
// to push it to the end of the list | ||
private const int Priority = -200; | ||
|
||
public FrostingProjectScopeCategoryUiProvider() | ||
{ | ||
// The main scope point is used to the UID of the QuickList for this category. | ||
// It does nothing unless there is also a QuickList stored in settings. | ||
MainPoint = new InFrostingProject(); | ||
} | ||
|
||
public override string CategoryCaption => "Frosting"; | ||
|
||
public override IconId Icon => CakeIcons.CakeFile; | ||
|
||
public override IEnumerable<ITemplateScopePoint> BuildAllPoints() | ||
{ | ||
// Only Project-related scopes. (i.e. scopes used in File-Templates) | ||
yield return new InFrostingProject(); | ||
} | ||
} |
Oops, something went wrong.