Skip to content

Commit f1570f3

Browse files
authored
Merge pull request #2 from sourcegraph/olafurpg/hello-world
First stab at implementing an indexer
2 parents 7da5e77 + 8f58694 commit f1570f3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+9458
-87
lines changed

.github/workflows/test.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Test
2-
on:
2+
on:
33
push:
44
branches:
55
- main
@@ -10,13 +10,14 @@ env:
1010
jobs:
1111
format:
1212
runs-on: ubuntu-latest
13-
- uses: actions/checkout@v3
14-
- uses: actions/setup-dotnet@v3
15-
with:
16-
dotnet-version: 6.0.x
17-
- run: dotnet format --verify-no-changes
18-
- run: dotnet format --verify-no-changes
19-
working-directory: snapshots/input/syntax
13+
steps:
14+
- uses: actions/checkout@v3
15+
- uses: actions/setup-dotnet@v3
16+
with:
17+
dotnet-version: 6.0.x
18+
- run: dotnet format --verify-no-changes
19+
- run: dotnet format --verify-no-changes
20+
working-directory: snapshots/input/syntax
2021
test:
2122
runs-on: ${{ matrix.os }}
2223
strategy:
@@ -25,9 +26,8 @@ jobs:
2526
os: [ubuntu-latest, windows-latest, macos-latest]
2627
name: Test
2728
steps:
28-
- uses: actions/checkout@v3
29-
- uses: actions/setup-dotnet@v3
30-
with:
31-
dotnet-version: 6.0.x
32-
- run: dotnet test
33-
29+
- uses: actions/checkout@v3
30+
- uses: actions/setup-dotnet@v3
31+
with:
32+
dotnet-version: 6.0.x
33+
- run: dotnet test

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.DS_Store
2+
.idea
13
## Ignore Visual Studio temporary files, build results, and
24
## files generated by popular Visual Studio add-ons.
35
##
@@ -348,3 +350,4 @@ MigrationBackup/
348350

349351
# Ionide (cross platform F# VS Code tools) working folder
350352
.ionide/
353+

NOTICE

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# tcz717/LsifDotnet
2+
3+
scip-dotnet contains contains parts which are derived from the
4+
tcz717/LsifDotnet project. The original license is Apache 2 and can be
5+
found here: https://github.com/tcz717/LsifDotnet/blob/main/LICENSE
6+
7+
The parts that are derived from LsifDotnet are mostly related to parsing
8+
command-line options and loading the MSBuild Workspace, not the indexing logic
9+
itself.
10+

ScipDotnet.Tests/Position.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using Scip;
2+
3+
namespace ScipDotnet.Tests;
4+
5+
public record Position(int Line, int Character) : IComparable<Position>
6+
{
7+
public int CompareTo(Position? other)
8+
{
9+
if (other == null)
10+
{
11+
return 1;
12+
}
13+
14+
if (other.Line != Line)
15+
{
16+
return Line - other.Line;
17+
}
18+
19+
return Character - other.Character;
20+
}
21+
22+
}

ScipDotnet.Tests/Range.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using Scip;
2+
3+
namespace ScipDotnet.Tests;
4+
5+
public record Range(Position Start, Position End) : IComparable<Range>
6+
{
7+
public int CompareTo(Range? other)
8+
{
9+
if (other == null)
10+
{
11+
return 1;
12+
}
13+
14+
var byStart = Start.CompareTo(other.Start);
15+
if (byStart != 0)
16+
{
17+
return byStart;
18+
}
19+
20+
return End.CompareTo(other.End);
21+
}
22+
23+
public static Range FromOccurrence(Occurrence occ)
24+
{
25+
if (occ.Range.Count == 3)
26+
return new Range(new Position(occ.Range[0], occ.Range[1]), new Position(occ.Range[0], occ.Range[2]));
27+
28+
if (occ.Range.Count == 4)
29+
return new Range(new Position(occ.Range[0], occ.Range[1]), new Position(occ.Range[2], occ.Range[3]));
30+
31+
throw new ArgumentException($"occurrence.range must have length 3 or length 4, obtained {occ.Range}");
32+
}
33+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
<IsPackable>false</IsPackable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="DiffPlex" Version="1.7.1" />
12+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
13+
<PackageReference Include="NUnit" Version="3.13.3" />
14+
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
15+
<PackageReference Include="NUnit.Analyzers" Version="3.3.0" />
16+
<PackageReference Include="coverlet.collector" Version="3.1.2" />
17+
<PackageReference Include="TextCopy" Version="6.2.0" />
18+
<PackageReference Include="Verify.NUnit" Version="19.3.0" />
19+
</ItemGroup>
20+
21+
<ItemGroup>
22+
<ProjectReference Include="..\ScipDotnet\ScipDotnet.csproj" />
23+
</ItemGroup>
24+
25+
</Project>

0 commit comments

Comments
 (0)