-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Rider 2024.1
- Loading branch information
Showing
33 changed files
with
912 additions
and
293 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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
Param( | ||
$Version = "2023.4" | ||
$Version = "2024.1-EAP" | ||
) | ||
|
||
Set-StrictMode -Version Latest | ||
|
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,25 @@ | ||
using System.Linq; | ||
|
||
namespace ReSharperPlugin.RimworldDev; | ||
|
||
public class DefNameValue | ||
{ | ||
public readonly string DefType; | ||
|
||
public readonly string DefName; | ||
|
||
public string TagId => $"{DefType}/{DefName}"; | ||
|
||
public DefNameValue(string tagId) | ||
{ | ||
var split = tagId.Split('/'); | ||
DefType = split.First(); | ||
DefName = split.Last(); | ||
} | ||
|
||
public DefNameValue(string defType, string defName) | ||
{ | ||
DefType = defType; | ||
DefName = defName; | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
src/dotnet/ReSharperPlugin.RimworldDev/ItemCompletion/CSharpDefsOfItemProvider.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,60 @@ | ||
using System.Linq; | ||
using JetBrains.ProjectModel; | ||
using JetBrains.ReSharper.Feature.Services.CodeCompletion.Infrastructure; | ||
using JetBrains.ReSharper.Feature.Services.CodeCompletion.Infrastructure.LookupItems; | ||
using JetBrains.ReSharper.Feature.Services.CSharp.CodeCompletion.Infrastructure; | ||
using JetBrains.ReSharper.Psi; | ||
using JetBrains.ReSharper.Psi.CSharp; | ||
using JetBrains.ReSharper.Psi.CSharp.Tree; | ||
using JetBrains.ReSharper.Psi.Tree; | ||
using ReSharperPlugin.RimworldDev.SymbolScope; | ||
using ReSharperPlugin.RimworldDev.TypeDeclaration; | ||
|
||
namespace ReSharperPlugin.RimworldDev.ItemCompletion; | ||
|
||
[Language(typeof(CSharpLanguage))] | ||
public class CSharpDefsOfItemProvider : ItemsProviderOfSpecificContext<CSharpCodeCompletionContext> | ||
{ | ||
private static RimworldCSharpLookupFactory LookupFactory = new(); | ||
|
||
protected override bool IsAvailable(CSharpCodeCompletionContext context) | ||
{ | ||
var node = context.NodeInFile; | ||
if (!node.Language.IsLanguage(CSharpLanguage.Instance)) return false; | ||
if (node.Parent is not IFieldDeclaration fieldDeclaration) return false; | ||
if (fieldDeclaration.Type is not IDeclaredType) return false; | ||
if (fieldDeclaration.GetContainingTypeElement() is not IClass containingClass) return false; | ||
if (containingClass | ||
.GetAttributeInstances(AttributesSource.Self) | ||
.FirstOrDefault(attribute => attribute.GetClrName().FullName == "RimWorld.DefOf") is null) return false; | ||
|
||
return true; | ||
} | ||
|
||
protected override bool AddLookupItems(CSharpCodeCompletionContext context, IItemsCollector collector) | ||
{ | ||
var node = context.NodeInFile; | ||
|
||
if (node.Parent is not IFieldDeclaration fieldDeclaration) return false; | ||
if (fieldDeclaration.Type is not IDeclaredType fieldType) return false; | ||
|
||
var defTypeName = fieldType.GetClrName().ShortName; | ||
var xmlSymbolTable = context.NodeInFile.GetSolution().GetComponent<RimworldSymbolScope>(); | ||
|
||
var allDefs = xmlSymbolTable.GetDefsByType(defTypeName); | ||
|
||
foreach (var key in allDefs) | ||
{ | ||
var defType = key.Split('/').First(); | ||
var defName = key.Split('/').Last(); | ||
|
||
var item = xmlSymbolTable.GetTagByDef(defType, defName); | ||
|
||
var lookup = LookupFactory.CreateDeclaredElementLookupItem(context, defName, | ||
new DeclaredElementInstance(new XMLTagDeclaredElement(item, defType, defName, false))); | ||
collector.Add(lookup); | ||
} | ||
|
||
return base.AddLookupItems(context, collector); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
src/dotnet/ReSharperPlugin.RimworldDev/ItemCompletion/RimworldDefCSharpItemProvider.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,58 @@ | ||
using System.Linq; | ||
using JetBrains.ProjectModel; | ||
using JetBrains.ReSharper.Feature.Services.CodeCompletion.Infrastructure; | ||
using JetBrains.ReSharper.Feature.Services.CodeCompletion.Infrastructure.LookupItems; | ||
using JetBrains.ReSharper.Feature.Services.CSharp.CodeCompletion.Infrastructure; | ||
using JetBrains.ReSharper.Psi; | ||
using JetBrains.ReSharper.Psi.CSharp; | ||
using JetBrains.ReSharper.Psi.CSharp.Impl.Tree; | ||
using JetBrains.ReSharper.Psi.CSharp.Parsing; | ||
using JetBrains.ReSharper.Psi.CSharp.Tree; | ||
using JetBrains.ReSharper.Psi.Tree; | ||
using ReSharperPlugin.RimworldDev.SymbolScope; | ||
using ReSharperPlugin.RimworldDev.TypeDeclaration; | ||
|
||
namespace ReSharperPlugin.RimworldDev.ItemCompletion; | ||
|
||
[Language(typeof(CSharpLanguage))] | ||
public class RimworldDefCSharpItemProvider: ItemsProviderOfSpecificContext<CSharpCodeCompletionContext> | ||
{ | ||
private static RimworldCSharpLookupFactory LookupFactory = new(); | ||
|
||
protected override bool IsAvailable(CSharpCodeCompletionContext context) | ||
{ | ||
var node = context.NodeInFile; | ||
if (!node.Language.IsLanguage(CSharpLanguage.Instance)) return false; | ||
if (node is not CSharpGenericToken) return false; | ||
if (node.NodeType != CSharpTokenType.STRING_LITERAL_REGULAR) return false; | ||
|
||
return true; | ||
} | ||
|
||
protected override bool AddLookupItems(CSharpCodeCompletionContext context, IItemsCollector collector) | ||
{ | ||
var node = context.NodeInFile; | ||
if (node?.Parent?.Parent?.Parent?.Parent is not IInvocationExpression invocationExpression | ||
|| !invocationExpression.GetText().Contains("DefDatabase") | ||
|| invocationExpression.Type() is not IDeclaredType declaredType) return false; | ||
|
||
var defTypeName = declaredType.GetClrName().ShortName; | ||
var xmlSymbolTable = context.NodeInFile.GetSolution().GetComponent<RimworldSymbolScope>(); | ||
|
||
var allDefs = xmlSymbolTable.GetDefsByType(defTypeName); | ||
|
||
foreach (var key in allDefs) | ||
{ | ||
var defType = key.Split('/').First(); | ||
var defName = key.Split('/').Last(); | ||
|
||
var item = xmlSymbolTable.GetTagByDef(defType, defName); | ||
|
||
var lookup = LookupFactory.CreateDeclaredElementLookupItem(context, defName, | ||
new DeclaredElementInstance(new XMLTagDeclaredElement(item, defType, defName, false))); | ||
collector.Add(lookup); | ||
} | ||
|
||
return base.AddLookupItems(context, collector); | ||
} | ||
} |
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
10 changes: 10 additions & 0 deletions
10
...harperPlugin.RimworldDev/ProjectTemplates/RimworldProjectTemplate/Source/MyRimWorldMod.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,10 @@ | ||
using Verse; | ||
|
||
namespace MyRimWorldMod; | ||
|
||
public class MyRimWorldMod : Mod | ||
{ | ||
public MyRimWorldMod(ModContentPack content) : base(content) | ||
{ | ||
} | ||
} |
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
10 changes: 0 additions & 10 deletions
10
...harperPlugin.RimworldDev/ProjectTemplates/RimworldProjectTemplate/Source/MyRimworldMod.cs
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
...t/ReSharperPlugin.RimworldDev/ProjectTemplates/RimworldProjectTemplate/_PublisherPlus.xml
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,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Configuration> | ||
<Excluded> | ||
<exclude>.git</exclude> | ||
<exclude>.idea</exclude> | ||
<exclude>.run</exclude> | ||
<exclude>MyRimWorldMod.sln</exclude> | ||
<exclude>packages</exclude> | ||
<exclude>Source</exclude> | ||
</Excluded> | ||
</Configuration> |
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
Oops, something went wrong.