Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Summpot committed Nov 12, 2023
1 parent f472e5e commit 3594269
Show file tree
Hide file tree
Showing 30 changed files with 447 additions and 221 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
- name: Do pack
run: |
dotnet build native/native.csproj -p:Configuration=Release -p:RuntimeIdentifier=${{ matrix.rid }}
dotnet pack src/NativeLibrary/NativeLibrary.runtime.csproj -p:RuntimeIdentifier=${{ matrix.rid }}
dotnet pack native/NativeLibrary.runtime.csproj -p:RuntimeIdentifier=${{ matrix.rid }}
- name: Upload build artifacts
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:

- name: Do pack
run: |
dotnet pack src/NativeLibrary/NativeLibrary.csproj
dotnet pack native/NativeLibrary.csproj
dotnet pack
- name: Upload build artifacts
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- name: Do pack
run: |
dotnet build native/native.csproj -p:Configuration=Release -p:RuntimeIdentifier=${{ matrix.rid }}
dotnet pack src/NativeLibrary/NativeLibrary.runtime.csproj -p:RuntimeIdentifier=${{ matrix.rid }}
dotnet pack native/NativeLibrary.runtime.csproj -p:RuntimeIdentifier=${{ matrix.rid }}
- name: Upload build artifacts
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -69,7 +69,7 @@ jobs:

- name: Do pack
run: |
dotnet pack src/NativeLibrary/NativeLibrary.csproj
dotnet pack native/NativeLibrary.csproj
dotnet pack
- name: Push packages to nuget
Expand Down
4 changes: 2 additions & 2 deletions TreeSitterSharp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ VisualStudioVersion = 17.8.34004.107
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TreeSitterSharp", "src\TreeSitterSharp\TreeSitterSharp.csproj", "{C794DAB1-EF44-4236-BD00-46CF8738B17F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "解决方案项", "解决方案项", "{02BDF044-8ACA-46C0-9F5B-9DB5B5EF6EA7}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Misc", "Misc", "{02BDF044-8ACA-46C0-9F5B-9DB5B5EF6EA7}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.gitignore = .gitignore
Expand All @@ -30,7 +30,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TreeSitterSharp.Json", "src
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TreeSitterSharp.Json.Tests", "tests\TreeSitterSharp.Json.Tests\TreeSitterSharp.Json.Tests.csproj", "{9CD39ADD-A840-48AF-8A16-5CF16631DE00}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TreeSitterSharp.NodeTypesSourceGenerators", "src\TreeSitterSharp.NodeTypesSourceGenerators\TreeSitterSharp.NodeTypesSourceGenerators.csproj", "{0B76D02A-39E8-482F-A3F6-6BD22358A496}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TreeSitterSharp.NodeTypesSourceGenerators", "src\TreeSitterSharp.NodeTypesSourceGenerators\TreeSitterSharp.NodeTypesSourceGenerators.csproj", "{0B76D02A-39E8-482F-A3F6-6BD22358A496}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
6 changes: 5 additions & 1 deletion native/native.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<Project Sdk="Microsoft.Build.Traversal">
<ItemGroup>
<ProjectReference Include="**\*.cproj" />
<ProjectReference Include="tree-sitter\tree-sitter.cproj" />
<ProjectReference Include="tree-sitter-c\tree-sitter-c.cproj" />
<ProjectReference Include="tree-sitter-cpp\tree-sitter-cpp.cproj" />
<ProjectReference Include="tree-sitter-lua\tree-sitter-lua.cproj" />
<ProjectReference Include="tree-sitter-json\tree-sitter-json.cproj" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion native/tree-sitter-c/tree-sitter-c.cproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Vezel.Zig.Sdk">
<PropertyGroup>
<OutputPath>..\..\src\NativeLibrary\tree-sitter-c\bin\$(Configuration)\$(RuntimeIdedntifier)</OutputPath>
<OutputPath>bin\$(Configuration)\$(RuntimeIdedntifier)</OutputPath>
</PropertyGroup>
<ItemGroup>
<IncludeDirectory Include="src/src"></IncludeDirectory>
Expand Down
2 changes: 1 addition & 1 deletion native/tree-sitter-c/tree-sitter-c.runtime.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<IsPackable>true</IsPackable>
<PackageId>$(AssemblyName).$(RuntimeIdentifier)</PackageId>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<PackageOutputPath>..\..\..\nupkgs</PackageOutputPath>
<PackageOutputPath>..\..\nupkgs</PackageOutputPath>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion native/tree-sitter-cpp/tree-sitter-cpp.cproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Vezel.Zig.Sdk">
<PropertyGroup>
<OutputPath>..\..\src\NativeLibrary\tree-sitter-cpp\bin\$(Configuration)\$(RuntimeIdedntifier)</OutputPath>
<OutputPath>bin\$(Configuration)\$(RuntimeIdedntifier)</OutputPath>
</PropertyGroup>
<ItemGroup>
<IncludeDirectory Include="src/src"></IncludeDirectory>
Expand Down
2 changes: 1 addition & 1 deletion native/tree-sitter-cpp/tree-sitter-cpp.runtime.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<IsPackable>true</IsPackable>
<PackageId>$(AssemblyName).$(RuntimeIdentifier)</PackageId>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<PackageOutputPath>..\..\..\nupkgs</PackageOutputPath>
<PackageOutputPath>..\..\nupkgs</PackageOutputPath>
</PropertyGroup>
<ItemGroup>
<None Include="bin\$(Configuration)\$(RuntimeIdentifier)\*">
Expand Down
2 changes: 1 addition & 1 deletion native/tree-sitter-json/tree-sitter-json.cproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Vezel.Zig.Sdk">
<PropertyGroup>
<OutputPath>..\..\src\NativeLibrary\tree-sitter-json\bin\$(Configuration)\$(RuntimeIdedntifier)</OutputPath>
<OutputPath>bin\$(Configuration)\$(RuntimeIdedntifier)</OutputPath>
</PropertyGroup>
<ItemGroup>
<IncludeDirectory Include="src/src"></IncludeDirectory>
Expand Down
2 changes: 1 addition & 1 deletion native/tree-sitter-json/tree-sitter-json.runtime.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<IsPackable>true</IsPackable>
<PackageId>$(AssemblyName).$(RuntimeIdentifier)</PackageId>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<PackageOutputPath>..\..\..\nupkgs</PackageOutputPath>
<PackageOutputPath>..\..\nupkgs</PackageOutputPath>
</PropertyGroup>
<ItemGroup>
<None Include="bin\$(Configuration)\$(RuntimeIdentifier)\*">
Expand Down
2 changes: 1 addition & 1 deletion native/tree-sitter-lua/tree-sitter-lua.cproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Vezel.Zig.Sdk">
<PropertyGroup>
<OutputPath>..\..\src\NativeLibrary\tree-sitter-lua\bin\$(Configuration)\$(RuntimeIdedntifier)</OutputPath>
<OutputPath>bin\$(Configuration)\$(RuntimeIdedntifier)</OutputPath>
</PropertyGroup>
<ItemGroup>
<IncludeDirectory Include="src/src"></IncludeDirectory>
Expand Down
2 changes: 1 addition & 1 deletion native/tree-sitter-lua/tree-sitter-lua.runtime.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<IsPackable>true</IsPackable>
<PackageId>$(AssemblyName).$(RuntimeIdentifier)</PackageId>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<PackageOutputPath>..\..\..\nupkgs</PackageOutputPath>
<PackageOutputPath>..\..\nupkgs</PackageOutputPath>
</PropertyGroup>
<ItemGroup>
<None Include="bin\$(Configuration)\$(RuntimeIdentifier)\*">
Expand Down
2 changes: 1 addition & 1 deletion native/tree-sitter/tree-sitter.cproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Vezel.Zig.Sdk">
<PropertyGroup>
<OutputPath>..\..\src\NativeLibrary\tree-sitter\bin\$(Configuration)\$(RuntimeIdedntifier)</OutputPath>
<OutputPath>bin\$(Configuration)\$(RuntimeIdedntifier)</OutputPath>
</PropertyGroup>
<ItemGroup>
<IncludeDirectory Include="src/lib/include"></IncludeDirectory>
Expand Down
2 changes: 1 addition & 1 deletion native/tree-sitter/tree-sitter.runtime.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<IsPackable>true</IsPackable>
<PackageId>$(AssemblyName).$(RuntimeIdentifier)</PackageId>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<PackageOutputPath>..\..\..\nupkgs</PackageOutputPath>
<PackageOutputPath>..\..\nupkgs</PackageOutputPath>
</PropertyGroup>
<ItemGroup>
<None Include="bin\$(Configuration)\$(RuntimeIdentifier)\*">
Expand Down
16 changes: 16 additions & 0 deletions src/TreeSitterSharp.Cpp/CppLanguageProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System.Runtime.InteropServices;
using TreeSitterSharp.Native;

namespace TreeSitterSharp.Cpp;

[LanguageName("Cpp")]
internal class CppLanguageProvider : ILanguageProvider
{
[DllImport("tree-sitter-cpp", EntryPoint = "tree_sitter_cpp", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
private static extern unsafe TsLanguage* tree_sitter_cpp();
public static unsafe Language GetLanguage()
{
return new Language(tree_sitter_cpp());
}

}
15 changes: 15 additions & 0 deletions src/TreeSitterSharp.Cpp/CppParser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.Text;
using TreeSitterSharp.Cpp;
using TreeSitterSharp.Native;

namespace TreeSitterSharp.Cpp;

public unsafe class CppParser : Parser<CppSyntaxTree, CppSyntaxNode, CppParser>
{
public CppParser() : base(CppLanguageProvider.GetLanguage())
{

}

public override CppSyntaxTree Parse(Span<byte> code) => new(ParseCore(code));
}
18 changes: 18 additions & 0 deletions src/TreeSitterSharp.Cpp/CppSyntaxNode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TreeSitterSharp.Native;

namespace TreeSitterSharp.Cpp;

public partial class CppSyntaxNode : SyntaxNode<CppSyntaxTree, CppSyntaxNode>, ISyntaxNodeCreation<CppSyntaxTree, CppSyntaxNode>
{
protected internal CppSyntaxNode(TsNode node) : base(node)
{
}


public static partial CppSyntaxNode Create(TsNode node);
}
19 changes: 19 additions & 0 deletions src/TreeSitterSharp.Cpp/CppSyntaxTree.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using Microsoft.CodeAnalysis;
using TreeSitterSharp.Native;

namespace TreeSitterSharp.Cpp;
public unsafe class CppSyntaxTree : SyntaxTree<CppSyntaxNode, CppSyntaxTree>, ISyntaxTreeCreation<CppSyntaxNode, CppSyntaxTree>
{
protected internal CppSyntaxTree(TsTree* tree) : base(tree)
{
}
public override CppSyntaxNode Root => new(Ts.tree_root_node(_tree));
public override CppSyntaxTree Copy() => new(Ts.tree_copy(_tree));
public static CppSyntaxTree Create(TsTree* tree) => new(tree);
}
11 changes: 11 additions & 0 deletions src/TreeSitterSharp.Cpp/TreeSitterSharp.Cpp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\TreeSitterSharp.NodeTypesSourceGenerators\TreeSitterSharp.NodeTypesSourceGenerators.csproj" ReferenceOutputAsembly="false" OutputItemType="Analyzer" />
<ProjectReference Include="..\TreeSitterSharp\TreeSitterSharp.csproj" />
</ItemGroup>

<ItemGroup>
<CompilerVisibleItemMetadata Include="AdditionalFiles" MetadataName="SourceItemGroup" />
<CompilerVisibleItemMetadata Include="NodeTypesSchema" MetadataName="FileName" />
<CompilerVisibleItemMetadata Include="NodeTypesSchema" MetadataName="Extension" />
<NodeTypesSchema Include="..\..\native\tree-sitter-cpp\src\src\node-types.json">
<Visible>false</Visible>
</NodeTypesSchema>
<AdditionalFiles Include="@(NodeTypesSchema)" SourceItemGroup="NodeTypesSchema" />
</ItemGroup>
</Project>
17 changes: 17 additions & 0 deletions src/TreeSitterSharp.Lua/LuaLanguageProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Runtime.InteropServices;
using TreeSitterSharp.Native;
using TreeSitterSharp;

namespace TreeSitterSharp.Lua;

[LanguageName("Lua")]
internal class LuaLanguageProvider : ILanguageProvider
{
[DllImport("tree-sitter-lua", EntryPoint = "tree_sitter_lua", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
private static extern unsafe TsLanguage* tree_sitter_lua();
public static unsafe Language GetLanguage()
{
return new Language(tree_sitter_lua());
}

}
14 changes: 14 additions & 0 deletions src/TreeSitterSharp.Lua/LuaParser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Text;
using TreeSitterSharp.Native;

namespace TreeSitterSharp.Lua;

public unsafe class LuaParser : Parser<LuaSyntaxTree, LuaSyntaxNode, LuaParser>
{
public LuaParser() : base(LuaLanguageProvider.GetLanguage())
{

}

public override LuaSyntaxTree Parse(Span<byte> code) => new(ParseCore(code));
}
18 changes: 18 additions & 0 deletions src/TreeSitterSharp.Lua/LuaSyntaxNode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TreeSitterSharp.Native;

namespace TreeSitterSharp.Lua;

public partial class LuaSyntaxNode : SyntaxNode<LuaSyntaxTree, LuaSyntaxNode>, ISyntaxNodeCreation<LuaSyntaxTree, LuaSyntaxNode>
{
protected internal LuaSyntaxNode(TsNode node) : base(node)
{
}


public static partial LuaSyntaxNode Create(TsNode node);
}
19 changes: 19 additions & 0 deletions src/TreeSitterSharp.Lua/LuaSyntaxTree.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using Microsoft.CodeAnalysis;
using TreeSitterSharp.Native;

namespace TreeSitterSharp.Lua;
public unsafe class LuaSyntaxTree : SyntaxTree<LuaSyntaxNode, LuaSyntaxTree>, ISyntaxTreeCreation<LuaSyntaxNode, LuaSyntaxTree>
{
protected internal LuaSyntaxTree(TsTree* tree) : base(tree)
{
}
public override LuaSyntaxNode Root => new(Ts.tree_root_node(_tree));
public override LuaSyntaxTree Copy() => new(Ts.tree_copy(_tree));
public static LuaSyntaxTree Create(TsTree* tree) => new(tree);
}
11 changes: 11 additions & 0 deletions src/TreeSitterSharp.Lua/TreeSitterSharp.Lua.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\TreeSitterSharp.NodeTypesSourceGenerators\TreeSitterSharp.NodeTypesSourceGenerators.csproj" ReferenceOutputAsembly="false" OutputItemType="Analyzer" />
<ProjectReference Include="..\TreeSitterSharp\TreeSitterSharp.csproj" />
</ItemGroup>

<ItemGroup>
<CompilerVisibleItemMetadata Include="AdditionalFiles" MetadataName="SourceItemGroup" />
<CompilerVisibleItemMetadata Include="NodeTypesSchema" MetadataName="FileName" />
<CompilerVisibleItemMetadata Include="NodeTypesSchema" MetadataName="Extension" />
<NodeTypesSchema Include="..\..\native\tree-sitter-lua\src\src\node-types.json">
<Visible>false</Visible>
</NodeTypesSchema>
<AdditionalFiles Include="@(NodeTypesSchema)" SourceItemGroup="NodeTypesSchema" />
</ItemGroup>
</Project>
Loading

0 comments on commit 3594269

Please sign in to comment.