-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added factory * added abstract node * added more logic in abstract node * updated the packages * added syntax token * added diagnostics * added source text * added docs * enhanced text cursor * improved test cursor * fixed peek method * enhanced text cursor * fixed the lock files * fixed sonar comments
- Loading branch information
1 parent
e0052d8
commit 3b8d882
Showing
56 changed files
with
5,078 additions
and
271 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
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,47 @@ | ||
<Solution> | ||
<Folder Name="/Solution Items/"> | ||
<File Path=".editorconfig" /> | ||
<File Path=".gitattributes" /> | ||
<File Path=".gitignore" /> | ||
<File Path=".netconfig" /> | ||
<File Path="README.md" /> | ||
<File Path="Directory.Build.targets" /> | ||
<File Path="stryker-config.json" /> | ||
<File Path="LICENSE" /> | ||
<File Path="Directory.Build.props" /> | ||
<File Path="stylecop.json" /> | ||
<File Path="Directory.Packages.props" /> | ||
<File Path=".deepsource.toml" /> | ||
</Folder> | ||
<Folder Name="/Solution Items/.config/"> | ||
<File Path=".config\dotnet-tools.json" /> | ||
</Folder> | ||
<Folder Name="/Solution Items/.github/"> | ||
<File Path=".github\CODEOWNERS" /> | ||
<File Path=".github\dependabot.yml" /> | ||
</Folder> | ||
<Folder Name="/Solution Items/.github/workflows/"> | ||
<File Path=".github\workflows\dotnet.yml" /> | ||
<File Path=".github\workflows\codeql.yml" /> | ||
<File Path=".github\workflows\dependency-review.yml" /> | ||
<File Path=".github\workflows\scorecard.yml" /> | ||
</Folder> | ||
<Folder Name="/Solution Items/tools/"> | ||
<File Path="tools\code-coverage.bat" /> | ||
<File Path="tools\code-coverage.ps1" /> | ||
<File Path="tools\mutation-testing.bat" /> | ||
<File Path="tools\mutation-testing.ps1" /> | ||
<File Path="tools\benchmarks.bat" /> | ||
<File Path="tools\benchmarks.ps1" /> | ||
</Folder> | ||
<Folder Name="/src/"> | ||
<Project Path="src\OffDotNet.CodeAnalysis.Pdf\OffDotNet.CodeAnalysis.Pdf.csproj" Type="Classic C#" /> | ||
<Project Path="src\OffDotNet.CodeAnalysis\OffDotNet.CodeAnalysis.csproj" Type="Classic C#" /> | ||
<File Path="src\Directory.Build.props" /> | ||
</Folder> | ||
<Folder Name="/tests/"> | ||
<Project Path="tests\OffDotNet.CodeAnalysis.Pdf.Tests\OffDotNet.CodeAnalysis.Pdf.Tests.csproj" Type="Classic C#" /> | ||
<Project Path="tests\OffDotNet.CodeAnalysis.Tests\OffDotNet.CodeAnalysis.Tests.csproj" Type="Classic C#" /> | ||
<File Path="tests\Directory.Build.props" /> | ||
</Folder> | ||
</Solution> |
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
13 changes: 13 additions & 0 deletions
13
src/OffDotNet.CodeAnalysis.Pdf/Configs/DiagnosticOptions.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,13 @@ | ||
// <copyright file="DiagnosticOptions.cs" company="Sunt Programator"> | ||
// Copyright (c) Sunt Programator. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
// </copyright> | ||
|
||
namespace OffDotNet.CodeAnalysis.Pdf.Configs; | ||
|
||
/// <summary>Represents the diagnostic options for the PDF analysis.</summary> | ||
public sealed record DiagnosticOptions | ||
{ | ||
/// <summary>Gets the help link associated with the diagnostic.</summary> | ||
public required string HelpLink { get; init; } | ||
} |
21 changes: 21 additions & 0 deletions
21
src/OffDotNet.CodeAnalysis.Pdf/Configs/RootConfigurations.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,21 @@ | ||
// <copyright file="RootConfigurations.cs" company="Sunt Programator"> | ||
// Copyright (c) Sunt Programator. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
// </copyright> | ||
|
||
namespace OffDotNet.CodeAnalysis.Pdf.Configs; | ||
|
||
using OffDotNet.CodeAnalysis.Configs; | ||
|
||
/// <summary>Represents the root configurations for the OffDotNet analysis.</summary> | ||
public sealed record RootConfigurations | ||
{ | ||
/// <summary>The section name for the OffDotNet configurations.</summary> | ||
public const string SectionName = "OffDotNet"; | ||
|
||
/// <summary>Gets the diagnostic options for the PDF analysis.</summary> | ||
public required DiagnosticOptions Diagnostic { get; init; } | ||
|
||
/// <summary>Gets the text cursor options for the PDF analysis.</summary> | ||
public required TextCursorOptions TextCursor { get; init; } | ||
} |
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,33 @@ | ||
// <copyright file="Dependencies.cs" company="Sunt Programator"> | ||
// Copyright (c) Sunt Programator. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
// </copyright> | ||
|
||
namespace OffDotNet.CodeAnalysis.Pdf; | ||
|
||
using Configs; | ||
using Diagnostics; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using OffDotNet.CodeAnalysis.Diagnostics; | ||
using OffDotNet.CodeAnalysis.Lexer; | ||
|
||
/// <summary> | ||
/// Provides extension methods for registering code analysis services. | ||
/// </summary> | ||
public static class Dependencies | ||
{ | ||
/// <summary> | ||
/// Adds the code analysis services to the specified <see cref="IServiceCollection"/>. | ||
/// </summary> | ||
/// <param name="services">The service collection to which the services will be added.</param> | ||
/// <returns>The same service collection so that multiple calls can be chained.</returns> | ||
public static IServiceCollection AddPdfCodeAnalysis(this IServiceCollection services) | ||
{ | ||
services.AddOptions<RootConfigurations>(RootConfigurations.SectionName).ValidateOnStart(); | ||
|
||
services.AddCoreCodeAnalysis(); | ||
services.AddSingleton<ILexer, Lexer.Lexer>(); | ||
services.AddSingleton<IMessageProvider, MessageProvider>(); | ||
return services; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/OffDotNet.CodeAnalysis.Pdf/Diagnostics/DiagnosticCode.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,17 @@ | ||
// <copyright file="DiagnosticCode.cs" company="Sunt Programator"> | ||
// Copyright (c) Sunt Programator. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
// </copyright> | ||
|
||
namespace OffDotNet.CodeAnalysis.Pdf.Diagnostics; | ||
|
||
/// <summary> | ||
/// Represents the diagnostic codes for the PDF analysis. | ||
/// </summary> | ||
public enum DiagnosticCode | ||
{ | ||
/// <summary> | ||
/// Represents an unknown diagnostic code. | ||
/// </summary> | ||
Unknown = 0, | ||
} |
74 changes: 74 additions & 0 deletions
74
src/OffDotNet.CodeAnalysis.Pdf/Diagnostics/MessageProvider.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,74 @@ | ||
// <copyright file="MessageProvider.cs" company="Sunt Programator"> | ||
// Copyright (c) Sunt Programator. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
// </copyright> | ||
|
||
namespace OffDotNet.CodeAnalysis.Pdf.Diagnostics; | ||
|
||
using Configs; | ||
using Microsoft.Extensions.Localization; | ||
using Microsoft.Extensions.Options; | ||
using OffDotNet.CodeAnalysis.Diagnostics; | ||
|
||
/// <summary> | ||
/// Provides localized messages for diagnostics in PDF analysis. | ||
/// </summary> | ||
internal sealed class MessageProvider : AbstractMessageProvider | ||
{ | ||
private const string TitleSuffix = "_Title"; | ||
private const string DescriptionSuffix = "_Description"; | ||
|
||
private readonly IStringLocalizer<MessageProvider> _localizer; | ||
private readonly DiagnosticOptions _options; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="MessageProvider"/> class. | ||
/// </summary> | ||
/// <param name="localizer">The localizer for retrieving localized strings.</param> | ||
/// <param name="options">The diagnostic options.</param> | ||
public MessageProvider(IStringLocalizer<MessageProvider> localizer, IOptions<DiagnosticOptions> options) | ||
{ | ||
_localizer = localizer; | ||
_options = options.Value ?? throw new ArgumentNullException(nameof(options)); | ||
} | ||
|
||
/// <summary> | ||
/// Gets the language prefix for the diagnostics. | ||
/// </summary> | ||
public override string LanguagePrefix => "PDF"; | ||
|
||
/// <summary> | ||
/// Gets the localized title for the specified diagnostic code. | ||
/// </summary> | ||
/// <param name="code">The diagnostic code.</param> | ||
/// <returns>The localized title.</returns> | ||
public override LocalizedString GetTitle(ushort code) => _localizer[$"{(DiagnosticCode)code}{TitleSuffix}"]; | ||
|
||
/// <summary> | ||
/// Gets the localized description for the specified diagnostic code. | ||
/// </summary> | ||
/// <param name="code">The diagnostic code.</param> | ||
/// <returns>The localized description.</returns> | ||
public override LocalizedString GetDescription(ushort code) => _localizer[$"{(DiagnosticCode)code}{DescriptionSuffix}"]; | ||
|
||
/// <summary> | ||
/// Gets the help link for the specified diagnostic code. | ||
/// </summary> | ||
/// <param name="code">The diagnostic code.</param> | ||
/// <returns>The help link.</returns> | ||
public override string GetHelpLink(ushort code) => string.Format(_options.HelpLink, GetIdForDiagnosticCode(code)); | ||
|
||
/// <summary> | ||
/// Gets the severity for the specified diagnostic code. | ||
/// </summary> | ||
/// <param name="code">The diagnostic code.</param> | ||
/// <returns>The severity as a byte value.</returns> | ||
public override byte GetSeverity(ushort code) | ||
{ | ||
switch (code) | ||
{ | ||
default: | ||
return (byte)DiagnosticSeverity.Hidden; | ||
} | ||
} | ||
} |
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 @@ | ||
// <copyright file="Lexer.cs" company="Sunt Programator"> | ||
// Copyright (c) Sunt Programator. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
// </copyright> | ||
|
||
namespace OffDotNet.CodeAnalysis.Pdf.Lexer; | ||
|
||
using OffDotNet.CodeAnalysis.Lexer; | ||
|
||
/// <summary> | ||
/// Represents the lexer for PDF code analysis. | ||
/// </summary> | ||
public class Lexer : ILexer; |
6 changes: 6 additions & 0 deletions
6
src/OffDotNet.CodeAnalysis.Pdf/OffDotNet.CodeAnalysis.Pdf.csproj
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,6 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" /> | ||
<ProjectReference Include="..\OffDotNet.CodeAnalysis\OffDotNet.CodeAnalysis.csproj" /> | ||
</ItemGroup> | ||
</Project> |
Oops, something went wrong.