Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

roslyn language services - Argument Validation Classifier and Method Overload Classifier #287

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added UpgradeLog.htm
Binary file not shown.
50 changes: 48 additions & 2 deletions Viasfora.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2003
# Visual Studio Version 16
VisualStudioVersion = 16.0.29728.190
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{1038A55E-607B-4449-924E-1861530C2C56}"
ProjectSection(SolutionItems) = preProject
Expand All @@ -15,6 +15,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.editorconfig = .editorconfig
appveyor.yml = appveyor.yml
src\AssemblyInfo.Common.cs = src\AssemblyInfo.Common.cs
src\AssemblyInfo.Common.vb = src\AssemblyInfo.Common.vb
Global.props = Global.props
README.md = README.md
EndProjectSection
Expand All @@ -37,6 +38,20 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Viasfora.Rainbow", "src\Via
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Viasfora.Settings", "src\Viasfora.Settings\Viasfora.Settings.csproj", "{DD9ED7C5-417C-43A2-BE13-14CD948566B4}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "LanguageServices", "LanguageServices", "{1C2B4B39-2230-4094-A69D-8120C4BAB37A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Viasfora.LanguageService.Core", "src\Viasfora.LanguageServices\Viasfora.LanguageService.Core\Viasfora.LanguageService.Core.csproj", "{CE8301E8-E5BA-446B-9715-4B0F07E69190}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Viasfora.LanguageService.CSharp", "src\Viasfora.LanguageServices\Viasfora.LanguageService.CSharp\Viasfora.LanguageService.CSharp.csproj", "{003C3D3D-B966-4AC5-A622-D4931810587D}"
EndProject
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Viasfora.LanguageService.Basic", "src\Viasfora.LanguageServices\Viasfora.LanguageService.Basic\Viasfora.LanguageService.Basic.vbproj", "{AC41A83D-0565-47CD-AA55-4A09874D722F}"
EndProject
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Viasfora.LanguageService.Basic.Tests", "tests\Viasfora.LanguageService.Basic.Tests\Viasfora.LanguageService.Basic.Tests.vbproj", "{C7826A1B-55C0-40AA-B9F3-A58D7B155DA9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Viasfora.LanguageService.CSharp.Tests", "tests\Viasfora.LanguageService.CSharp.Tests\Viasfora.LanguageService.CSharp.Tests.csproj", "{51698343-EE6B-44AC-B0A9-3F606AE7FE80}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Viasfora.LanguageService.Core.Tests", "tests\Viasfora.LanguageService.Core.Tests\Viasfora.LanguageService.Core.Tests.csproj", "{04588DE4-349F-466C-A57B-95D00D10269A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -71,6 +86,30 @@ Global
{DD9ED7C5-417C-43A2-BE13-14CD948566B4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DD9ED7C5-417C-43A2-BE13-14CD948566B4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DD9ED7C5-417C-43A2-BE13-14CD948566B4}.Release|Any CPU.Build.0 = Release|Any CPU
{CE8301E8-E5BA-446B-9715-4B0F07E69190}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CE8301E8-E5BA-446B-9715-4B0F07E69190}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CE8301E8-E5BA-446B-9715-4B0F07E69190}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CE8301E8-E5BA-446B-9715-4B0F07E69190}.Release|Any CPU.Build.0 = Release|Any CPU
{003C3D3D-B966-4AC5-A622-D4931810587D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{003C3D3D-B966-4AC5-A622-D4931810587D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{003C3D3D-B966-4AC5-A622-D4931810587D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{003C3D3D-B966-4AC5-A622-D4931810587D}.Release|Any CPU.Build.0 = Release|Any CPU
{AC41A83D-0565-47CD-AA55-4A09874D722F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AC41A83D-0565-47CD-AA55-4A09874D722F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AC41A83D-0565-47CD-AA55-4A09874D722F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AC41A83D-0565-47CD-AA55-4A09874D722F}.Release|Any CPU.Build.0 = Release|Any CPU
{C7826A1B-55C0-40AA-B9F3-A58D7B155DA9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C7826A1B-55C0-40AA-B9F3-A58D7B155DA9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C7826A1B-55C0-40AA-B9F3-A58D7B155DA9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C7826A1B-55C0-40AA-B9F3-A58D7B155DA9}.Release|Any CPU.Build.0 = Release|Any CPU
{51698343-EE6B-44AC-B0A9-3F606AE7FE80}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{51698343-EE6B-44AC-B0A9-3F606AE7FE80}.Debug|Any CPU.Build.0 = Debug|Any CPU
{51698343-EE6B-44AC-B0A9-3F606AE7FE80}.Release|Any CPU.ActiveCfg = Release|Any CPU
{51698343-EE6B-44AC-B0A9-3F606AE7FE80}.Release|Any CPU.Build.0 = Release|Any CPU
{04588DE4-349F-466C-A57B-95D00D10269A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{04588DE4-349F-466C-A57B-95D00D10269A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{04588DE4-349F-466C-A57B-95D00D10269A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{04588DE4-349F-466C-A57B-95D00D10269A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -83,6 +122,13 @@ Global
{3274163B-E647-40E2-8D9F-6DF7E7C50411} = {567EF174-A312-43D2-9955-2396CEA9E6DA}
{944758A5-90A4-4DE7-8EF6-4FB2E7F4EFB3} = {567EF174-A312-43D2-9955-2396CEA9E6DA}
{DD9ED7C5-417C-43A2-BE13-14CD948566B4} = {567EF174-A312-43D2-9955-2396CEA9E6DA}
{1C2B4B39-2230-4094-A69D-8120C4BAB37A} = {567EF174-A312-43D2-9955-2396CEA9E6DA}
{CE8301E8-E5BA-446B-9715-4B0F07E69190} = {1C2B4B39-2230-4094-A69D-8120C4BAB37A}
{003C3D3D-B966-4AC5-A622-D4931810587D} = {1C2B4B39-2230-4094-A69D-8120C4BAB37A}
{AC41A83D-0565-47CD-AA55-4A09874D722F} = {1C2B4B39-2230-4094-A69D-8120C4BAB37A}
{C7826A1B-55C0-40AA-B9F3-A58D7B155DA9} = {6271BFBC-846E-48A5-86BD-0729B65DA933}
{51698343-EE6B-44AC-B0A9-3F606AE7FE80} = {6271BFBC-846E-48A5-86BD-0729B65DA933}
{04588DE4-349F-466C-A57B-95D00D10269A} = {6271BFBC-846E-48A5-86BD-0729B65DA933}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A9497739-5303-4008-905D-EDFF9FC38583}
Expand Down
20 changes: 20 additions & 0 deletions src/AssemblyInfo.Common.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Imports System
Imports System.Reflection
Imports System.Runtime.InteropServices

<assembly: AssemblyConfiguration("")>
<assembly: AssemblyCompany("Winterdom")>
<assembly: AssemblyProduct("Viasfora")>
<assembly: AssemblyCopyright("Copyright (C) Tomas Restrepo")>
<assembly: AssemblyTrademark("")>
<assembly: AssemblyCulture("")>

<assembly: ComVisible(False)>

<assembly: AssemblyVersion("2.5.0.0")>
<assembly: AssemblyFileVersion(VsfVersion.Version)>

Friend Class VsfVersion
Public Const Version As String = "2.9.0.0"
End Class

Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ public static class CodeClassificationDefinitions {
internal static ClassificationTypeDefinition CurrentColumnClassificationType = null;

[Export, Name(Constants.OBFUSCATED_TEXT)]
internal static ClassificationTypeDefinition ObfuscatedTextType = null;
internal static ClassificationTypeDefinition ObfuscatedTextType = null;

[Export, Name(Constants.LANGUAGESERVICE_ARGUMENT_VALIDATION_NAME)]
internal static ClassificationTypeDefinition LANGUAGESERVICE_ARGUMENT_VALIDATION_NAME = null;

[Export, Name(Constants.LANGAUGESERVICE_METHOD_OVERLOAD_NAME)]
internal static ClassificationTypeDefinition LANGAUGESERVICE_METHOD_OVERLOAD_NAME = null;
}
}
4 changes: 3 additions & 1 deletion src/Viasfora.Core/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ public static class Constants {
public const String FORMAT_SPECIFIER_NAME = "viasfora.string.format.specifier";
public const String LINE_HIGHLIGHT = "viasfora.line.current";
public const String COLUMN_HIGHLIGHT = "viasfora.column.current";
public const String DEV_MARGIN = "viasfora.dev.margin";
public const String DEV_MARGIN = "viasfora.dev.margin";
public const String LANGUAGESERVICE_ARGUMENT_VALIDATION_NAME = "viasfora.statement.argument_validation";
public const String LANGAUGESERVICE_METHOD_OVERLOAD_NAME = "viasfora.statement.method_overload";

public const String OBFUSCATED_TEXT = "viasfora.text.obfuscated";

Expand Down
19 changes: 19 additions & 0 deletions src/Viasfora.Core/EditorFormats/ArgumentValidationFormat.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.ComponentModel.Composition;
using System.Windows.Media;
using Microsoft.VisualStudio.Text.Classification;
using Microsoft.VisualStudio.Utilities;

namespace Winterdom.Viasfora.EditorFormats {
[Export(typeof(EditorFormatDefinition))]
[ClassificationType(ClassificationTypeNames = Constants.LANGUAGESERVICE_ARGUMENT_VALIDATION_NAME)]
[Name(Constants.LANGUAGESERVICE_ARGUMENT_VALIDATION_NAME)]
[UserVisible(true)]
[Order(After = Priority.High)]
public sealed class ArgumentValidationFormat : ClassificationFormatDefinition {
public ArgumentValidationFormat() {
this.DisplayName = "Viasfora Argument Validation";
this.ForegroundOpacity = 0.5;
}
}
}
17 changes: 17 additions & 0 deletions src/Viasfora.Core/EditorFormats/MethodOverloadFormat.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.ComponentModel.Composition;
using Microsoft.VisualStudio.Text.Classification;
using Microsoft.VisualStudio.Utilities;

namespace Winterdom.Viasfora.EditorFormats {
[Export(typeof(EditorFormatDefinition))]
[ClassificationType(ClassificationTypeNames = Constants.LANGAUGESERVICE_METHOD_OVERLOAD_NAME)]
[Name(Constants.LANGAUGESERVICE_METHOD_OVERLOAD_NAME)]
[UserVisible(true)]
[Order(After = Priority.High)]
public sealed class MethodOverloadFormat : ClassificationFormatDefinition {
public MethodOverloadFormat() {
this.DisplayName = "Viasfora Method Overload";
this.ForegroundOpacity = 0.5;
}
}
}
7 changes: 5 additions & 2 deletions src/Viasfora.Core/IVsfSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ public interface IVsfSettings : IUpdatableSettings {
bool VisibilityKeywordsEnabled { get; set; }
bool QueryKeywordsEnabled { get; set; }
bool FlowControlUseItalics { get; set; }
bool EscapeSequencesEnabled { get; set; }

bool EscapeSequencesEnabled { get; set; }

bool ArgumentValidationClassifierEnabled { get; set; }
bool MethodOverloadsClassifierEnabled { get; set; }

bool CurrentLineHighlightEnabled { get; set; }
bool CurrentColumnHighlightEnabled { get; set; }
ColumnStyle CurrentColumnHighlightStyle { get; set; }
Expand Down
17 changes: 14 additions & 3 deletions src/Viasfora.Core/Settings/VsfSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,17 @@ public String TextObfuscationRegexes {
public bool TelemetryEnabled {
get { return this.Store.GetBoolean(nameof(TelemetryEnabled), true); }
set { this.Store.SetValue(nameof(TelemetryEnabled), value); }
}

}
public bool ArgumentValidationClassifierEnabled {
get { return this.Store.GetBoolean(nameof(ArgumentValidationClassifierEnabled), true); }
set { this.Store.SetValue(nameof(ArgumentValidationClassifierEnabled), value); }
}

public bool MethodOverloadsClassifierEnabled {
get { return this.Store.GetBoolean(nameof(MethodOverloadsClassifierEnabled), true); }
set { this.Store.SetValue(nameof(MethodOverloadsClassifierEnabled), value); }
}

[ImportingConstructor]
public VsfSettings(ITypedSettingsStore store, IVsfTelemetry telemetry)
: base(store) {
Expand All @@ -103,7 +112,9 @@ public VsfSettings(ITypedSettingsStore store, IVsfTelemetry telemetry)
telemetry.FeatureStatus("EscapeSequences", EscapeSequencesEnabled);
telemetry.FeatureStatus("QueryKeywords", QueryKeywordsEnabled);
telemetry.FeatureStatus("FlowControlKeywords", FlowControlKeywordsEnabled);
telemetry.FeatureStatus("VisibilityKeywords", VisibilityKeywordsEnabled);
telemetry.FeatureStatus("VisibilityKeywords", VisibilityKeywordsEnabled);
telemetry.FeatureStatus("ArgumentValidationClassifier", ArgumentValidationClassifierEnabled);
telemetry.FeatureStatus("MethodOverloadsClassifier", MethodOverloadsClassifierEnabled);
}
}
}
2 changes: 2 additions & 0 deletions src/Viasfora.Core/Viasfora.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,13 @@
<Compile Include="Design\ZoomTrackBar.Designer.cs">
<DependentUpon>ZoomTrackBar.cs</DependentUpon>
</Compile>
<Compile Include="EditorFormats\ArgumentValidationFormat.cs" />
<Compile Include="EditorFormats\CurrentColumnFormat.cs" />
<Compile Include="EditorFormats\CurrentLineFormat.cs" />
<Compile Include="EditorFormats\FlowControlFormat.cs" />
<Compile Include="EditorFormats\FormatSpecifierFormat.cs" />
<Compile Include="EditorFormats\LinqKeywordFormat.cs" />
<Compile Include="EditorFormats\MethodOverloadFormat.cs" />
<Compile Include="EditorFormats\ObfuscatedTextFormat.cs" />
<Compile Include="EditorFormats\StringEscapeSequenceErrorFormat.cs" />
<Compile Include="EditorFormats\StringEscapeSequenceFormat.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.VisualStudio.Text.Classification
Imports Microsoft.VisualStudio.Text.Tagging
Imports Microsoft.VisualStudio.Utilities
Imports System.ComponentModel.Composition
Imports Winterdom.Viasfora.Contracts
Imports Winterdom.Viasfora.Languages
Imports Winterdom.Viasfora.LanguageService.Core.ArgumentValidationTagger

Namespace ArgumentValidationTagger

<Export(GetType(IViewTaggerProvider))>
<ContentType(ContentTypes.VB)>
<TagType(GetType(ArgumentValidationTag))>
Public Class ArgumentValidationTaggerProvider
Inherits BaseArgumentValidationTaggerProvider

<ImportingConstructor>
Public Sub New(
telemetry As IVsfTelemetry,
classificationRegistry As IClassificationTypeRegistryService,
languageFactory As ILanguageFactory,
settings As IVsfSettings
)
MyBase.New(telemetry, classificationRegistry, languageFactory, settings)
End Sub

Public Overrides Function IsArgumentValidationSpan(node As SyntaxNode) As TextSpan
If Not SyntaxHelper.IsAnyIfArgumentThrowSyntaxStatement(node) Then
Return New TextSpan()
End If

Return node.FullSpan
End Function
End Class

End Namespace
Loading