diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c4efe2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,261 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +project.fragment.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +#*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignoreable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc \ No newline at end of file diff --git a/NuGet.config b/NuGet.config new file mode 100644 index 0000000..67f74b8 --- /dev/null +++ b/NuGet.config @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ZMBA.Common.targets b/ZMBA.Common.targets new file mode 100644 index 0000000..23a3c0a --- /dev/null +++ b/ZMBA.Common.targets @@ -0,0 +1,59 @@ + + + 15.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + + Debug + AnyCPU + 2.0 + Properties + true + true + CS0649, CS4014 + v4.6.2 + 7.1 + ShowAllFiles + prompt + + + + true + + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + embedded + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ZMBA.SyntaxColorizer.VS2015/Properties/AssemblyInfo.cs b/ZMBA.SyntaxColorizer.VS2015/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..e87d711 --- /dev/null +++ b/ZMBA.SyntaxColorizer.VS2015/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ZMBA.SyntaxColorizer.VS2015")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Derek Ziemba")] +[assembly: AssemblyProduct("ZMBA.SyntaxColorizer.VS2015")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("2015.0.0.*")] +[assembly: AssemblyFileVersion("2015.0.0.1")] diff --git a/ZMBA.SyntaxColorizer.VS2015/ZMBA.SyntaxColorizer.VS2015.csproj b/ZMBA.SyntaxColorizer.VS2015/ZMBA.SyntaxColorizer.VS2015.csproj new file mode 100644 index 0000000..a116a5d --- /dev/null +++ b/ZMBA.SyntaxColorizer.VS2015/ZMBA.SyntaxColorizer.VS2015.csproj @@ -0,0 +1,246 @@ + + + + + {82b43b9b-a64c-4715-b499-d71e9ca2bd60};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + {E04EE368-B501-4EC3-9E74-3AA3977B2D69} + VS2015 + C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\ + + + + + + + + Designer + + + Designer + + + Designer + + + + + ..\packages\Microsoft.CodeAnalysis.Common.1.3.2\lib\net45\Microsoft.CodeAnalysis.dll + True + + + ..\packages\Microsoft.CodeAnalysis.CSharp.1.3.2\lib\net45\Microsoft.CodeAnalysis.CSharp.dll + True + + + ..\packages\Microsoft.CodeAnalysis.EditorFeatures.1.3.2\lib\net46\Microsoft.CodeAnalysis.CSharp.EditorFeatures.dll + True + + + ..\packages\Microsoft.CodeAnalysis.CSharp.Workspaces.1.3.2\lib\net45\Microsoft.CodeAnalysis.CSharp.Workspaces.dll + True + + + ..\packages\Microsoft.CodeAnalysis.EditorFeatures.1.3.2\lib\net46\Microsoft.CodeAnalysis.EditorFeatures.dll + True + + + ..\packages\Microsoft.CodeAnalysis.EditorFeatures.Text.1.3.2\lib\net46\Microsoft.CodeAnalysis.EditorFeatures.Text.dll + True + + + ..\packages\Microsoft.CodeAnalysis.Features.1.3.2\lib\net45\Microsoft.CodeAnalysis.Features.dll + True + + + ..\packages\Microsoft.CodeAnalysis.VisualBasic.1.3.2\lib\net45\Microsoft.CodeAnalysis.VisualBasic.dll + True + + + ..\packages\Microsoft.CodeAnalysis.EditorFeatures.1.3.2\lib\net46\Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.dll + True + + + ..\packages\Microsoft.CodeAnalysis.VisualBasic.Workspaces.1.3.2\lib\net45\Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll + True + + + ..\packages\Microsoft.CodeAnalysis.Workspaces.Common.1.3.2\lib\net45\Microsoft.CodeAnalysis.Workspaces.dll + True + + + ..\packages\Microsoft.CodeAnalysis.Workspaces.Common.1.3.2\lib\net45\Microsoft.CodeAnalysis.Workspaces.Desktop.dll + True + + + ..\packages\Microsoft.VisualStudio.CoreUtility.14.3.25407\lib\net45\Microsoft.VisualStudio.CoreUtility.dll + True + + + ..\packages\Microsoft.VisualStudio.Editor.14.3.25407\lib\net45\Microsoft.VisualStudio.Editor.dll + True + + + ..\packages\Microsoft.VisualStudio.OLE.Interop.7.10.6070\lib\Microsoft.VisualStudio.OLE.Interop.dll + True + + + ..\packages\Microsoft.VisualStudio.Shell.Interop.7.10.6071\lib\Microsoft.VisualStudio.Shell.Interop.dll + True + + + ..\packages\Microsoft.VisualStudio.Text.Data.14.3.25407\lib\net45\Microsoft.VisualStudio.Text.Data.dll + True + + + ..\packages\Microsoft.VisualStudio.Text.Logic.14.3.25407\lib\net45\Microsoft.VisualStudio.Text.Logic.dll + True + + + ..\packages\Microsoft.VisualStudio.Text.UI.14.3.25407\lib\net45\Microsoft.VisualStudio.Text.UI.dll + True + + + ..\packages\Microsoft.VisualStudio.Text.UI.Wpf.14.3.25407\lib\net45\Microsoft.VisualStudio.Text.UI.Wpf.dll + True + + + ..\packages\Microsoft.VisualStudio.TextManager.Interop.7.10.6070\lib\Microsoft.VisualStudio.TextManager.Interop.dll + True + + + ..\packages\Microsoft.VisualStudio.TextManager.Interop.8.0.8.0.50727\lib\Microsoft.VisualStudio.TextManager.Interop.8.0.dll + True + + + ..\packages\Microsoft.VisualStudio.Threading.14.1.131\lib\net45\Microsoft.VisualStudio.Threading.dll + True + + + ..\packages\Microsoft.VisualStudio.Utilities.14.3.25407\lib\net45\Microsoft.VisualStudio.Utilities.dll + True + + + ..\packages\Microsoft.VisualStudio.Validation.14.1.111\lib\net45\Microsoft.VisualStudio.Validation.dll + True + + + ..\packages\System.AppContext.4.1.0\lib\net46\System.AppContext.dll + True + + + ..\packages\System.Collections.Immutable.1.2.0\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll + True + + + + ..\packages\Microsoft.Composition.1.0.27\lib\portable-net45+win8+wp8+wpa81\System.Composition.AttributedModel.dll + True + + + ..\packages\Microsoft.Composition.1.0.27\lib\portable-net45+win8+wp8+wpa81\System.Composition.Convention.dll + True + + + ..\packages\Microsoft.Composition.1.0.27\lib\portable-net45+win8+wp8+wpa81\System.Composition.Hosting.dll + True + + + ..\packages\Microsoft.Composition.1.0.27\lib\portable-net45+win8+wp8+wpa81\System.Composition.Runtime.dll + True + + + ..\packages\Microsoft.Composition.1.0.27\lib\portable-net45+win8+wp8+wpa81\System.Composition.TypedParts.dll + True + + + ..\packages\System.Console.4.0.0\lib\net46\System.Console.dll + True + + + ..\packages\System.Diagnostics.FileVersionInfo.4.0.0\lib\net46\System.Diagnostics.FileVersionInfo.dll + True + + + ..\packages\System.Diagnostics.StackTrace.4.0.1\lib\net46\System.Diagnostics.StackTrace.dll + True + + + ..\packages\System.IO.FileSystem.4.0.1\lib\net46\System.IO.FileSystem.dll + True + + + ..\packages\System.IO.FileSystem.Primitives.4.0.1\lib\net46\System.IO.FileSystem.Primitives.dll + True + + + ..\packages\System.Reflection.4.1.0\lib\net462\System.Reflection.dll + True + + + ..\packages\System.Reflection.Metadata.1.3.0\lib\portable-net45+win8\System.Reflection.Metadata.dll + True + + + ..\packages\System.Runtime.4.1.0\lib\net462\System.Runtime.dll + True + + + ..\packages\System.Runtime.Extensions.4.1.0\lib\net462\System.Runtime.Extensions.dll + True + + + ..\packages\System.Runtime.InteropServices.4.1.0\lib\net462\System.Runtime.InteropServices.dll + True + + + ..\packages\System.Security.Cryptography.Algorithms.4.2.0\lib\net461\System.Security.Cryptography.Algorithms.dll + True + + + ..\packages\System.Security.Cryptography.Encoding.4.0.0\lib\net46\System.Security.Cryptography.Encoding.dll + True + + + ..\packages\System.Security.Cryptography.Primitives.4.0.0\lib\net46\System.Security.Cryptography.Primitives.dll + True + + + ..\packages\System.Security.Cryptography.X509Certificates.4.1.0\lib\net461\System.Security.Cryptography.X509Certificates.dll + True + + + ..\packages\System.Text.Encoding.CodePages.4.0.1\lib\net46\System.Text.Encoding.CodePages.dll + True + + + ..\packages\System.Threading.Thread.4.0.0\lib\net46\System.Threading.Thread.dll + True + + + ..\packages\System.ValueTuple.4.4.0\lib\net461\System.ValueTuple.dll + True + true + + + ..\packages\System.Xml.XmlDocument.4.0.1\lib\net46\System.Xml.XmlDocument.dll + True + + + ..\packages\System.Xml.XPath.4.0.1\lib\net46\System.Xml.XPath.dll + True + + + ..\packages\System.Xml.XPath.XDocument.4.0.1\lib\net46\System.Xml.XPath.XDocument.dll + True + + + + + + \ No newline at end of file diff --git a/ZMBA.SyntaxColorizer.VS2015/app.config b/ZMBA.SyntaxColorizer.VS2015/app.config new file mode 100644 index 0000000..26fb182 --- /dev/null +++ b/ZMBA.SyntaxColorizer.VS2015/app.config @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ZMBA.SyntaxColorizer.VS2015/packages.config b/ZMBA.SyntaxColorizer.VS2015/packages.config new file mode 100644 index 0000000..2c2aea8 --- /dev/null +++ b/ZMBA.SyntaxColorizer.VS2015/packages.config @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ZMBA.SyntaxColorizer.VS2015/source.extension.vsixmanifest b/ZMBA.SyntaxColorizer.VS2015/source.extension.vsixmanifest new file mode 100644 index 0000000..40ead41 --- /dev/null +++ b/ZMBA.SyntaxColorizer.VS2015/source.extension.vsixmanifest @@ -0,0 +1,29 @@ + + + + + ZMBA.SyntaxColorizer.VS2015 + Style code Font and Color based on Syntax and Semantic meaning. Font Style Font and Color based on Syntax and Semantic meaning. +Supported languages: C#, Visual Basic, JavaScript, HTML + + + + + + + + + + + + + + + + + + + + + + diff --git a/ZMBA.SyntaxColorizer.VS2017/Properties/AssemblyInfo.cs b/ZMBA.SyntaxColorizer.VS2017/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..ac092bd --- /dev/null +++ b/ZMBA.SyntaxColorizer.VS2017/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ZMBA.SyntaxColorizer.VS2017")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Derek Ziemba")] +[assembly: AssemblyProduct("ZMBA.SyntaxColorizer.VS2017")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("2017.0.0.*")] +[assembly: AssemblyFileVersion("2017.0.0.1")] diff --git a/ZMBA.SyntaxColorizer.VS2017/ZMBA.SyntaxColorizer.VS2017.csproj b/ZMBA.SyntaxColorizer.VS2017/ZMBA.SyntaxColorizer.VS2017.csproj new file mode 100644 index 0000000..32f7715 --- /dev/null +++ b/ZMBA.SyntaxColorizer.VS2017/ZMBA.SyntaxColorizer.VS2017.csproj @@ -0,0 +1,257 @@ + + + + + {82b43b9b-a64c-4715-b499-d71e9ca2bd60};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + {0DD30895-F150-413D-A20B-B34DBA7AACA1} + VS2017 + $(DevEnvDir) + + + TRACE;RELEASE + + + + + + + + Designer + + + Designer + + + Designer + + + + + ..\packages\ManagedEsent.1.9.4\lib\net40\Esent.Interop.dll + True + False + + + ..\packages\Microsoft.CodeAnalysis.Common.2.3.2\lib\netstandard1.3\Microsoft.CodeAnalysis.dll + True + + + ..\packages\Microsoft.CodeAnalysis.CSharp.2.3.2\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.dll + True + + + ..\packages\Microsoft.CodeAnalysis.EditorFeatures.2.3.2\lib\net46\Microsoft.CodeAnalysis.CSharp.EditorFeatures.dll + True + + + ..\packages\Microsoft.CodeAnalysis.CSharp.Features.2.3.2\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.Features.dll + True + + + ..\packages\Microsoft.CodeAnalysis.CSharp.Workspaces.2.3.2\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.Workspaces.dll + True + + + ..\packages\Microsoft.CodeAnalysis.EditorFeatures.2.3.2\lib\net46\Microsoft.CodeAnalysis.EditorFeatures.dll + True + + + ..\packages\Microsoft.CodeAnalysis.EditorFeatures.Text.2.3.2\lib\net46\Microsoft.CodeAnalysis.EditorFeatures.Text.dll + True + + + ..\packages\Microsoft.CodeAnalysis.Elfie.0.10.6\lib\net46\Microsoft.CodeAnalysis.Elfie.dll + True + + + ..\packages\Microsoft.CodeAnalysis.Features.2.3.2\lib\netstandard1.3\Microsoft.CodeAnalysis.Features.dll + True + + + ..\packages\Microsoft.CodeAnalysis.VisualBasic.2.3.2\lib\netstandard1.3\Microsoft.CodeAnalysis.VisualBasic.dll + True + + + ..\packages\Microsoft.CodeAnalysis.EditorFeatures.2.3.2\lib\net46\Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.dll + True + + + ..\packages\Microsoft.CodeAnalysis.VisualBasic.Features.2.3.2\lib\netstandard1.3\Microsoft.CodeAnalysis.VisualBasic.Features.dll + True + + + ..\packages\Microsoft.CodeAnalysis.VisualBasic.Workspaces.2.3.2\lib\netstandard1.3\Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll + True + + + ..\packages\Microsoft.CodeAnalysis.Workspaces.Common.2.3.2\lib\net46\Microsoft.CodeAnalysis.Workspaces.dll + True + + + ..\packages\Microsoft.CodeAnalysis.Workspaces.Common.2.3.2\lib\net46\Microsoft.CodeAnalysis.Workspaces.Desktop.dll + True + + + ..\packages\Microsoft.VisualStudio.CoreUtility.15.0.26606\lib\net45\Microsoft.VisualStudio.CoreUtility.dll + True + + + ..\packages\Microsoft.VisualStudio.Editor.15.0.26606\lib\net45\Microsoft.VisualStudio.Editor.dll + True + + + ..\packages\Microsoft.VisualStudio.Imaging.15.0.26606\lib\net45\Microsoft.VisualStudio.Imaging.dll + True + + + ..\packages\Microsoft.VisualStudio.Language.Intellisense.15.0.26606\lib\net45\Microsoft.VisualStudio.Language.Intellisense.dll + True + + + ..\packages\Microsoft.VisualStudio.Language.StandardClassification.15.0.26606\lib\net45\Microsoft.VisualStudio.Language.StandardClassification.dll + True + + + ..\packages\Microsoft.VisualStudio.OLE.Interop.7.10.6071\lib\Microsoft.VisualStudio.OLE.Interop.dll + True + + + ..\packages\Microsoft.VisualStudio.Shell.15.0.15.0.26606\lib\Microsoft.VisualStudio.Shell.15.0.dll + True + + + ..\packages\Microsoft.VisualStudio.Shell.Framework.15.0.26606\lib\net45\Microsoft.VisualStudio.Shell.Framework.dll + True + + + ..\packages\Microsoft.VisualStudio.Shell.Interop.7.10.6071\lib\Microsoft.VisualStudio.Shell.Interop.dll + True + + + True + ..\packages\Microsoft.VisualStudio.Shell.Interop.15.3.DesignTime.15.0.26606\lib\net20\Microsoft.VisualStudio.Shell.Interop.15.3.DesignTime.dll + True + + + ..\packages\Microsoft.VisualStudio.Shell.Interop.8.0.8.0.50727\lib\Microsoft.VisualStudio.Shell.Interop.8.0.dll + True + + + ..\packages\Microsoft.VisualStudio.Shell.Interop.9.0.9.0.30729\lib\Microsoft.VisualStudio.Shell.Interop.9.0.dll + True + + + ..\packages\Microsoft.VisualStudio.Text.Data.15.0.26606\lib\net45\Microsoft.VisualStudio.Text.Data.dll + True + + + ..\packages\Microsoft.VisualStudio.Text.Logic.15.0.26606\lib\net45\Microsoft.VisualStudio.Text.Logic.dll + True + + + ..\packages\Microsoft.VisualStudio.Text.UI.15.0.26606\lib\net45\Microsoft.VisualStudio.Text.UI.dll + True + + + ..\packages\Microsoft.VisualStudio.Text.UI.Wpf.15.0.26606\lib\net45\Microsoft.VisualStudio.Text.UI.Wpf.dll + True + + + ..\packages\Microsoft.VisualStudio.TextManager.Interop.7.10.6070\lib\Microsoft.VisualStudio.TextManager.Interop.dll + True + + + ..\packages\Microsoft.VisualStudio.TextManager.Interop.8.0.8.0.50727\lib\Microsoft.VisualStudio.TextManager.Interop.8.0.dll + True + + + ..\packages\Microsoft.VisualStudio.Threading.15.4.4\lib\net45\Microsoft.VisualStudio.Threading.dll + True + + + ..\packages\Microsoft.VisualStudio.Utilities.15.0.26607\lib\net46\Microsoft.VisualStudio.Utilities.dll + True + + + ..\packages\Microsoft.VisualStudio.Validation.15.3.32\lib\net45\Microsoft.VisualStudio.Validation.dll + True + + + False + ..\packages\System.Collections.Immutable.1.4.0\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll + True + + + False + ..\packages\System.Composition.AttributedModel.1.1.0\lib\portable-net45+win8+wp8+wpa81\System.Composition.AttributedModel.dll + True + + + False + ..\packages\System.Composition.Convention.1.1.0\lib\portable-net45+win8+wp8+wpa81\System.Composition.Convention.dll + True + + + False + ..\packages\System.Composition.Hosting.1.1.0\lib\portable-net45+win8+wp8+wpa81\System.Composition.Hosting.dll + True + + + False + ..\packages\System.Composition.Runtime.1.1.0\lib\portable-net45+win8+wp8+wpa81\System.Composition.Runtime.dll + True + + + False + ..\packages\System.Composition.TypedParts.1.1.0\lib\portable-net45+win8+wp8+wpa81\System.Composition.TypedParts.dll + True + + + ..\packages\System.Diagnostics.FileVersionInfo.4.3.0\lib\net46\System.Diagnostics.FileVersionInfo.dll + True + + + False + ..\packages\System.Reflection.Metadata.1.5.0\lib\portable-net45+win8\System.Reflection.Metadata.dll + True + + + ..\packages\System.Security.Cryptography.X509Certificates.4.3.1\lib\net461\System.Security.Cryptography.X509Certificates.dll + + + False + ..\packages\System.Text.Encoding.CodePages.4.4.0\lib\net461\System.Text.Encoding.CodePages.dll + True + + + + ..\packages\System.ValueTuple.4.4.0\lib\net461\System.ValueTuple.dll + True + true + + + ..\packages\System.Xml.XPath.4.3.0\lib\net46\System.Xml.XPath.dll + True + + + ..\packages\System.Xml.XPath.XDocument.4.3.0\lib\net46\System.Xml.XPath.XDocument.dll + True + + + + + + + + + + + + + \ No newline at end of file diff --git a/ZMBA.SyntaxColorizer.VS2017/app.config b/ZMBA.SyntaxColorizer.VS2017/app.config new file mode 100644 index 0000000..961e999 --- /dev/null +++ b/ZMBA.SyntaxColorizer.VS2017/app.config @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ZMBA.SyntaxColorizer.VS2017/packages.config b/ZMBA.SyntaxColorizer.VS2017/packages.config new file mode 100644 index 0000000..bfa2802 --- /dev/null +++ b/ZMBA.SyntaxColorizer.VS2017/packages.config @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ZMBA.SyntaxColorizer.VS2017/source.extension.vsixmanifest b/ZMBA.SyntaxColorizer.VS2017/source.extension.vsixmanifest new file mode 100644 index 0000000..cb3efa1 --- /dev/null +++ b/ZMBA.SyntaxColorizer.VS2017/source.extension.vsixmanifest @@ -0,0 +1,31 @@ + + + + + ZMBA.SyntaxColorizer.VS2017 + Style code Font and Color based on Syntax and Semantic meaning. Font Style Font and Color based on Syntax and Semantic meaning. +Supported languages: C#, Visual Basic, JavaScript, HTML + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ZMBA.SyntaxColorizer.sln b/ZMBA.SyntaxColorizer.sln new file mode 100644 index 0000000..f8f1ef8 --- /dev/null +++ b/ZMBA.SyntaxColorizer.sln @@ -0,0 +1,50 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27130.2026 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "ZMBA.SyntaxColorizer", "ZMBA.SyntaxColorizer\ZMBA.SyntaxColorizer.shproj", "{7A1FFCB8-1711-42FE-AC90-8255D2834A27}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZMBA.SyntaxColorizer.VS2017", "ZMBA.SyntaxColorizer.VS2017\ZMBA.SyntaxColorizer.VS2017.csproj", "{0DD30895-F150-413D-A20B-B34DBA7AACA1}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZMBA.SyntaxColorizer.VS2015", "ZMBA.SyntaxColorizer.VS2015\ZMBA.SyntaxColorizer.VS2015.csproj", "{E04EE368-B501-4EC3-9E74-3AA3977B2D69}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{4D950BEF-EC3E-49F1-A545-5B9681FBF6A6}" + ProjectSection(SolutionItems) = preProject + NuGet.config = NuGet.config + ZMBA.Common.targets = ZMBA.Common.targets + ZMBA.SyntaxColorizer.targets = ZMBA.SyntaxColorizer.targets + EndProjectSection +EndProject +Global + GlobalSection(SharedMSBuildProjectFiles) = preSolution + ZMBA.SyntaxColorizer\ZMBA.SyntaxColorizer.projitems*{0dd30895-f150-413d-a20b-b34dba7aaca1}*SharedItemsImports = 4 + ZMBA.SyntaxColorizer\ZMBA.SyntaxColorizer.projitems*{7a1ffcb8-1711-42fe-ac90-8255d2834a27}*SharedItemsImports = 13 + ZMBA.SyntaxColorizer\ZMBA.SyntaxColorizer.projitems*{e04ee368-b501-4ec3-9e74-3aa3977b2d69}*SharedItemsImports = 4 + EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release(debuggable)|Any CPU = Release(debuggable)|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0DD30895-F150-413D-A20B-B34DBA7AACA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0DD30895-F150-413D-A20B-B34DBA7AACA1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0DD30895-F150-413D-A20B-B34DBA7AACA1}.Release(debuggable)|Any CPU.ActiveCfg = Release|Any CPU + {0DD30895-F150-413D-A20B-B34DBA7AACA1}.Release(debuggable)|Any CPU.Build.0 = Release|Any CPU + {0DD30895-F150-413D-A20B-B34DBA7AACA1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0DD30895-F150-413D-A20B-B34DBA7AACA1}.Release|Any CPU.Build.0 = Release|Any CPU + {E04EE368-B501-4EC3-9E74-3AA3977B2D69}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E04EE368-B501-4EC3-9E74-3AA3977B2D69}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E04EE368-B501-4EC3-9E74-3AA3977B2D69}.Release(debuggable)|Any CPU.ActiveCfg = Release|Any CPU + {E04EE368-B501-4EC3-9E74-3AA3977B2D69}.Release(debuggable)|Any CPU.Build.0 = Release|Any CPU + {E04EE368-B501-4EC3-9E74-3AA3977B2D69}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E04EE368-B501-4EC3-9E74-3AA3977B2D69}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {334F8158-74EB-4EE9-91C2-08A0F9207F96} + EndGlobalSection +EndGlobal diff --git a/ZMBA.SyntaxColorizer.targets b/ZMBA.SyntaxColorizer.targets new file mode 100644 index 0000000..4c19b54 --- /dev/null +++ b/ZMBA.SyntaxColorizer.targets @@ -0,0 +1,34 @@ + + + + Library + ZMBA.SyntaxColorizer.$(VSVersion) + ZMBA.SyntaxColorizer.$(VSVersion) + $(VSPath);$(VSPath)PrivateAssemblies\;$(VSPath)PublicAssemblies\;$(VSPath)CommonExtensions\Microsoft\Editor\;$(VSPath)CommonExtensions\Microsoft\ManagedLanguages\VBCSharp\LanguageServices\ + + + Program + $(VSPath)devenv.exe + /rootsuffix Exp + + + + false + true + true + true + true + false + + + + + + + ..\builds + + + + + + \ No newline at end of file diff --git a/ZMBA.SyntaxColorizer/ZMBA.SyntaxColorizer.projitems b/ZMBA.SyntaxColorizer/ZMBA.SyntaxColorizer.projitems new file mode 100644 index 0000000..29ea812 --- /dev/null +++ b/ZMBA.SyntaxColorizer/ZMBA.SyntaxColorizer.projitems @@ -0,0 +1,19 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + 7a1ffcb8-1711-42fe-ac90-8255d2834a27 + + + ZMBA.SyntaxColorizer + + + + + + + + + + \ No newline at end of file diff --git a/ZMBA.SyntaxColorizer/ZMBA.SyntaxColorizer.shproj b/ZMBA.SyntaxColorizer/ZMBA.SyntaxColorizer.shproj new file mode 100644 index 0000000..91e7748 --- /dev/null +++ b/ZMBA.SyntaxColorizer/ZMBA.SyntaxColorizer.shproj @@ -0,0 +1,13 @@ + + + + 7a1ffcb8-1711-42fe-ac90-8255d2834a27 + 14.0 + + + + + + + + diff --git a/ZMBA.SyntaxColorizer/src/ClassifierContext.cs b/ZMBA.SyntaxColorizer/src/ClassifierContext.cs new file mode 100644 index 0000000..5538361 --- /dev/null +++ b/ZMBA.SyntaxColorizer/src/ClassifierContext.cs @@ -0,0 +1,77 @@ +using System; +using System.Linq; +using System.Collections.Generic; +using System.ComponentModel.Composition; +using System.Runtime.CompilerServices; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Shared.Extensions; +using Microsoft.CodeAnalysis.Classification; +using Microsoft.CodeAnalysis.Text; +using Microsoft.VisualStudio.Text; +using Microsoft.VisualStudio.Text.Classification; +using Microsoft.VisualStudio.Text.Tagging; +using Microsoft.VisualStudio.Utilities; + +using VB = Microsoft.CodeAnalysis.VisualBasic; +using CS = Microsoft.CodeAnalysis.CSharp; +using VBKind = Microsoft.CodeAnalysis.VisualBasic.SyntaxKind; +using CSKind = Microsoft.CodeAnalysis.CSharp.SyntaxKind; + +namespace ZMBA.SyntaxColorizer { + + internal class ClassifierContext { + internal ITextSnapshot SnapShot { get; set; } + internal Workspace Workspace { get; set; } + internal SyntaxTree SyntaxTree { get; set; } + internal SyntaxNode RootNode { get; set; } + internal SemanticModel SemanticModel { get; set; } + internal TagSpan TaggedText { get; set; } + + internal static ClassifierContext GetContext(ref ClassifierContext cached, SnapshotSpan snapspan) { + ITextSnapshot txtsnapshot = snapspan.Snapshot; + if (txtsnapshot == null) { return null; } + if (cached != null && cached.SnapShot == txtsnapshot) { return cached; } + + ITextBuffer buffer = txtsnapshot.TextBuffer; + SourceTextContainer srcTextContainer = buffer.AsTextContainer(); + WorkspaceRegistration workRegistration = Workspace.GetWorkspaceRegistration(srcTextContainer); + Workspace workspace = workRegistration.Workspace; + DocumentId docid = workspace.GetDocumentIdInCurrentContext(srcTextContainer); + Solution sol = workspace.CurrentSolution.WithDocumentText(docid, srcTextContainer.CurrentText, PreservationMode.PreserveIdentity); + Document doc = sol.GetDocument(docid); + + if (doc.SupportsSyntaxTree && doc.SupportsSemanticModel) { + ClassifierContext ctx = AsyncGetNewContextHelper().ConfigureAwait(false).GetAwaiter().GetResult(); + Interlocked.Exchange(ref cached, ctx); + return ctx; + } else { + return null; + } + async Task AsyncGetNewContextHelper() { + ClassifierContext ctx = new ClassifierContext(); + ctx.SnapShot = txtsnapshot; + ctx.Workspace = workspace; + ctx.SyntaxTree = await doc.GetSyntaxTreeAsync().ConfigureAwait(false); + ConfiguredTaskAwaitable rootNodeTask = ctx.SyntaxTree.GetRootAsync().ConfigureAwait(false); + ConfiguredTaskAwaitable semanticModelTask = doc.GetSemanticModelAsync().ConfigureAwait(false); + ctx.RootNode = await rootNodeTask; + ctx.SemanticModel = await semanticModelTask; + return ctx; + } + } + + internal List GetClassifiedSpans(SnapshotSpan snapspan) { + IEnumerable result = Classifier.GetClassifiedSpans(this.SemanticModel, new TextSpan(snapspan.Start, snapspan.Length), this.Workspace); + return (List)result; + } + + /** In the future might want to tag a several sub spans, so this can be modified to a enqueue spans. **/ + internal void AssociateTagWithText(ClassificationTag tag, TextSpan text) { + TaggedText = new TagSpan(new SnapshotSpan(this.SnapShot, text.Start, text.Length), tag); + } + + } + +} diff --git a/ZMBA.SyntaxColorizer/src/Definitions.cs b/ZMBA.SyntaxColorizer/src/Definitions.cs new file mode 100644 index 0000000..061b2b5 --- /dev/null +++ b/ZMBA.SyntaxColorizer/src/Definitions.cs @@ -0,0 +1,809 @@ +using System.ComponentModel.Composition; +using System.Windows.Media; +using Microsoft.VisualStudio.Text.Classification; +using Microsoft.VisualStudio.Utilities; + +#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value null +namespace ZMBA.SyntaxColorizer { + + internal static class FormatDefinitions { + + internal static class Syntax { + + [Export(typeof(EditorFormatDefinition))] + [UserVisible(true)] + [Order(After = Priority.High)] + [ClassificationType(ClassificationTypeNames = Key)] + [Name(Key)] + internal sealed class KeyWord : ZMBAFormatDefinition { + public const string Key = "ZMBA.syntax.keyword"; + + [Export(typeof(ClassificationTypeDefinition))] + [Name(Key)] + public static ClassificationTypeDefinition TypeDef; + public static ZMBAFormatDefinition Instance { get; private set; } + + public KeyWord() : base(Key) { + Instance = this; + ForegroundColor = Color.FromRgb(147, 199, 99); + } + } + + + [Export(typeof(EditorFormatDefinition))] + [UserVisible(true)] + [Order(After = Priority.High)] + [ClassificationType(ClassificationTypeNames = Key)] + [Name(Key)] + internal sealed class Operator : ZMBAFormatDefinition { + public const string Key = "ZMBA.syntax.operator"; + + [Export(typeof(ClassificationTypeDefinition))] + [Name(Key)] + public static ClassificationTypeDefinition TypeDef; + public static ZMBAFormatDefinition Instance { get; private set; } + + public Operator() : base(Key) { + Instance = this; + ForegroundColor = Color.FromRgb(255, 255, 128); + } + } + + + [Export(typeof(EditorFormatDefinition))] + [UserVisible(true)] + [Order(After = Priority.High)] + [ClassificationType(ClassificationTypeNames = Key)] + [Name(Key)] + internal sealed class Number : ZMBAFormatDefinition { + public const string Key = "ZMBA.syntax.number"; + + [Export(typeof(ClassificationTypeDefinition))] + [Name(Key)] + public static ClassificationTypeDefinition TypeDef; + public static ZMBAFormatDefinition Instance { get; private set; } + + public Number() : base(Key) { + Instance = this; + ForegroundColor = Color.FromRgb(255, 205, 34); + } + } + + + [Export(typeof(EditorFormatDefinition))] + [UserVisible(true)] + [Order(After = Priority.High)] + [ClassificationType(ClassificationTypeNames = Key)] + [Name(Key)] + internal sealed class Punctuation : ZMBAFormatDefinition { + public const string Key = "ZMBA.syntax.punctuation"; + + [Export(typeof(ClassificationTypeDefinition))] + [Name(Key)] + public static ClassificationTypeDefinition TypeDef; + public static ZMBAFormatDefinition Instance { get; private set; } + + public Punctuation() : base(Key) { + Instance = this; + ForegroundColor = Color.FromRgb(255, 128, 128); + } + } + + [Export(typeof(EditorFormatDefinition))] + [UserVisible(true)] + [Order(After = Priority.High)] + [ClassificationType(ClassificationTypeNames = Key)] + [Name(Key)] + internal sealed class Comment : ZMBAFormatDefinition { + public const string Key = "ZMBA.syntax.comment"; + + [Export(typeof(ClassificationTypeDefinition))] + [Name(Key)] + public static ClassificationTypeDefinition TypeDef; + public static ZMBAFormatDefinition Instance { get; private set; } + + public Comment() : base(Key) { + Instance = this; + ForegroundColor = Color.FromRgb(102, 116, 123); + } + } + } + + + + + [Export(typeof(EditorFormatDefinition))] + [UserVisible(true)] + [Order(After = Priority.High)] + [ClassificationType(ClassificationTypeNames = Key)] + [Name(Key)] + internal class Preprocessor : ZMBAFormatDefinition { + public const string Key = "ZMBA.preprocessor"; + + [Export(typeof(ClassificationTypeDefinition))] + [Name(Key)] + public static ClassificationTypeDefinition TypeDef; + public static ZMBAFormatDefinition Instance { get; private set; } + + private Preprocessor(string id) : base(id) { + ForegroundColor = Color.FromRgb(160, 130, 189); + } + public Preprocessor() : base(Key) { + Instance = this; + } + + [Export(typeof(EditorFormatDefinition))] + [UserVisible(true)] + [Order(After = Priority.High)] + [ClassificationType(ClassificationTypeNames = Key)] + [Name(Key)] + internal sealed class Text : Preprocessor { + public new const string Key = "ZMBA.preprocessor-text"; + + [Export(typeof(ClassificationTypeDefinition))] + [Name(Key)] + public new static ClassificationTypeDefinition TypeDef; + public new static ZMBAFormatDefinition Instance { get; private set; } + public Text() : base(Key) { + Text.Instance = this; + ForegroundColor = Color.FromRgb(198, 224, 194); + } + } + } + + + + [Export(typeof(EditorFormatDefinition))] + [UserVisible(true)] + [Order(After = Priority.High)] + [ClassificationType(ClassificationTypeNames = Key)] + [Name(Key)] + internal class Type : ZMBAFormatDefinition { + public const string Key = "ZMBA.type"; + + [Export(typeof(ClassificationTypeDefinition))] + [Name(Key)] + public static ClassificationTypeDefinition TypeDef; + public static ZMBAFormatDefinition Instance { get; private set; } + + private Type(string id) : base(id) { + ForegroundColor = Color.FromArgb(255, 78, 201, 176); + } + public Type() : this(Key) { + Instance = this; + } + + [Export(typeof(EditorFormatDefinition))] + [UserVisible(true)] + [Order(After = Priority.High)] + [ClassificationType(ClassificationTypeNames = Key)] + [Name(Key)] + internal sealed class Module : Type { + public new const string Key = "ZMBA.type-module"; + + [Export(typeof(ClassificationTypeDefinition))] + [Name(Key)] + public new static ClassificationTypeDefinition TypeDef; + public new static ZMBAFormatDefinition Instance { get; private set; } + public Module() : base(Key) { + Instance = this; + ForegroundColor = Color.FromArgb(255, 138, 219, 201); + } + } + + [Export(typeof(EditorFormatDefinition))] + [UserVisible(true)] + [Order(After = Priority.High)] + [ClassificationType(ClassificationTypeNames = Key)] + [Name(Key)] + internal class Class : Type { + public new const string Key = "ZMBA.type-class"; + + [Export(typeof(ClassificationTypeDefinition))] + [Name(Key)] + public new static ClassificationTypeDefinition TypeDef; + public new static ZMBAFormatDefinition Instance { get; private set; } + + private Class(string id) : base(id) { + ForegroundColor = Color.FromArgb(255, 125, 157, 189); + } + public Class() : this(Key) { + Instance = this; + } + + + //[Export(typeof(EditorFormatDefinition))] + //[UserVisible(false)] + //[Order(After = Priority.High)] + //[ClassificationType(ClassificationTypeNames = Key)] + //[Name(Key)] + //internal sealed class Attribute : Class { + // public new const string Key = "ZMBA.type-class-attribute"; + + // [Export(typeof(ClassificationTypeDefinition))] + // [Name(Key)] + // public new static ClassificationTypeDefinition TypeDef; + // public new static ZMBAFormatDefinition Instance { get; private set; } + // public Attribute() : base(Key) { + // Instance = this; + // IsItalic = true; + // } + //} + } + + [Export(typeof(EditorFormatDefinition))] + [UserVisible(true)] + [Order(After = Priority.High)] + [ClassificationType(ClassificationTypeNames = Key)] + [Name(Key)] + internal sealed class Structure : Type { + public new const string Key = "ZMBA.type-structure"; + + [Export(typeof(ClassificationTypeDefinition))] + [Name(Key)] + public new static ClassificationTypeDefinition TypeDef; + public new static ZMBAFormatDefinition Instance { get; private set; } + public Structure() : base(Key) { + Instance = this; + ForegroundColor = Color.FromArgb(255, 157, 208, 225); + } + } + + [Export(typeof(EditorFormatDefinition))] + [UserVisible(true)] + [Order(After = Priority.High)] + [ClassificationType(ClassificationTypeNames = Key)] + [Name(Key)] + internal sealed class Interface : Type { + public new const string Key = "ZMBA.type-interface"; + + [Export(typeof(ClassificationTypeDefinition))] + [Name(Key)] + public new static ClassificationTypeDefinition TypeDef; + public new static ZMBAFormatDefinition Instance { get; private set; } + public Interface() : base(Key) { + Instance = this; + ForegroundColor = Color.FromArgb(255, 186, 245, 222); + } + } + + + [UserVisible(true)] + [Order(After = Priority.High)] + [ClassificationType(ClassificationTypeNames = Key)] + [Name(Key)] + internal sealed class Delegate : Type { + public new const string Key = "ZMBA.type-delegate"; + + [Export(typeof(ClassificationTypeDefinition))] + [Name(Key)] + public new static ClassificationTypeDefinition TypeDef; + public new static ZMBAFormatDefinition Instance { get; private set; } + public Delegate() : base(Key) { + Instance = this; + ForegroundColor = Color.FromRgb(173, 216, 230); + } + } + + + [Export(typeof(EditorFormatDefinition))] + [UserVisible(true)] + [Order(After = Priority.High)] + [ClassificationType(ClassificationTypeNames = Key)] + [Name(Key)] + internal sealed class Generic : Type { + public new const string Key = "ZMBA.type-generic"; + + [Export(typeof(ClassificationTypeDefinition))] + [Name(Key)] + public new static ClassificationTypeDefinition TypeDef; + public new static ZMBAFormatDefinition Instance { get; private set; } + + public Generic() : base(Key) { + Instance = this; + ForegroundColor = Color.FromArgb(255, 0, 255, 255); + } + } + + + [Export(typeof(EditorFormatDefinition))] + [UserVisible(true)] + [Order(After = Priority.High)] + [ClassificationType(ClassificationTypeNames = Key)] + [Name(Key)] + internal sealed class Dynamic : Type { + public new const string Key = "ZMBA.type-dynamic"; + + [Export(typeof(ClassificationTypeDefinition))] + [Name(Key)] + public new static ClassificationTypeDefinition TypeDef; + public new static ZMBAFormatDefinition Instance { get; private set; } + + public Dynamic() : base(Key) { + Instance = this; + ForegroundColor = Color.FromArgb(255, 180, 180, 180); + } + } + + } + + + + + + [Export(typeof(EditorFormatDefinition))] + [UserVisible(true)] + [Order(After = Priority.High)] + [ClassificationType(ClassificationTypeNames = Key)] + [Name(Key)] + internal class Enum : ZMBAFormatDefinition { + public const string Key = "ZMBA.enum"; + + [Export(typeof(ClassificationTypeDefinition))] + [Name(Key)] + public static ClassificationTypeDefinition TypeDef; + public static ZMBAFormatDefinition Instance { get; private set; } + + private Enum(string id) : base(id) { + ForegroundColor = Color.FromRgb(222, 210, 227); + } + public Enum() : this(Key) { + Instance = this; + } + + + [Export(typeof(EditorFormatDefinition))] + [UserVisible(true)] + [Order(After = Priority.High)] + [ClassificationType(ClassificationTypeNames = Key)] + [Name(Key)] + internal sealed class Member : Enum { + public new const string Key = "ZMBA.enum-member"; + + [Export(typeof(ClassificationTypeDefinition))] + [Name(Key)] + public new static ClassificationTypeDefinition TypeDef; + public new static ZMBAFormatDefinition Instance { get; private set; } + public Member() : base(Key) { + Instance = this; + IsBold = true; + ForegroundColor = Color.FromRgb(198, 176, 206); + } + } + } + + + + + + [Export(typeof(EditorFormatDefinition))] + [UserVisible(true)] + [Order(After = Priority.High)] + [ClassificationType(ClassificationTypeNames = Key)] + [Name(Key)] + internal class String : ZMBAFormatDefinition { + public const string Key = "ZMBA.string"; + + [Export(typeof(ClassificationTypeDefinition))] + [Name(Key)] + public static ClassificationTypeDefinition TypeDef; + public static ZMBAFormatDefinition Instance { get; private set; } + + private String(string id) : base(id) { + ForegroundColor = Color.FromRgb(255, 164, 72); + } + public String() : this(Key) { + Instance = this; + } + + [Export(typeof(EditorFormatDefinition))] + [UserVisible(true)] + [Order(After = Priority.High)] + [ClassificationType(ClassificationTypeNames = Key)] + [Name(Key)] + internal sealed class Token : String { + public new const string Key = "ZMBA.string-token"; + + [Export(typeof(ClassificationTypeDefinition))] + [Name(Key)] + public new static ClassificationTypeDefinition TypeDef; + public new static ZMBAFormatDefinition Instance { get; private set; } + public Token() : base(Key) { + Instance = this; + //ForegroundColor = Color.FromRgb(214,157,133); + //ForegroundColor = Color.FromRgb(255, 143, 32); + //ForegroundColor = Color.FromRgb(255, 148, 40); + ForegroundColor = Color.FromRgb(255, 150, 45); + } + } + + [Export(typeof(EditorFormatDefinition))] + [UserVisible(true)] + [Order(After = Priority.High)] + [ClassificationType(ClassificationTypeNames = Key)] + [Name(Key)] + internal sealed class SingleQuotes : String { + public new const string Key = "ZMBA.string-singlequotes"; + + [Export(typeof(ClassificationTypeDefinition))] + [Name(Key)] + public new static ClassificationTypeDefinition TypeDef; + public new static ZMBAFormatDefinition Instance { get; private set; } + public SingleQuotes() : base(Key) { + Instance = this; + ForegroundColor = Color.FromRgb(255, 198, 140); + } + } + + + [Export(typeof(EditorFormatDefinition))] + [UserVisible(true)] + [Order(After = Priority.High)] + [ClassificationType(ClassificationTypeNames = Key)] + [Name(Key)] + internal sealed class Interpolated : String { + public new const string Key = "ZMBA.string-interpolated"; + + [Export(typeof(ClassificationTypeDefinition))] + [Name(Key)] + public new static ClassificationTypeDefinition TypeDef; + public new static ZMBAFormatDefinition Instance { get; private set; } + + public Interpolated() : base(Key) { + Instance = this; + ForegroundColor = Color.FromArgb(255, 255, 180, 120); + } + } + + } + + + + + + [Export(typeof(EditorFormatDefinition))] + [UserVisible(true)] + [Order(After = Priority.High)] + [ClassificationType(ClassificationTypeNames = Key)] + [Name(Key)] + internal class Variable : ZMBAFormatDefinition { + public const string Key = "ZMBA.variable"; + + [Export(typeof(ClassificationTypeDefinition))] + [Name(Key)] + public static ClassificationTypeDefinition TypeDef; + public static ZMBAFormatDefinition Instance { get; private set; } + + private Variable(string id) : base(id) { + ForegroundColor = Color.FromRgb(255, 255, 255); + } + public Variable() : this(Key) { + Instance = this; + } + + //TODO: Requires more advanced analysis + //[Export(typeof(EditorFormatDefinition))] + //[UserVisible(false)] + //[Order(After = Priority.High)] + //[ClassificationType(ClassificationTypeNames = Key)] + //[Name(Key)] + //internal sealed class Mutated : Variable { + // public new const string Key = "ZMBA.variable-mutated"; + + // [Export(typeof(ClassificationTypeDefinition))] + // [Name(Key)] + // public new static ClassificationTypeDefinition TypeDef; + // public new static ZMBAFormatDefinition Instance { get; private set; } + + // public Mutated() : base(Key) { + // Instance = this; + // IsItalic = true; + // //ForegroundColor = Color.FromRgb(237, 210, 182); + // //ForegroundColor = Color.FromRgb(224, 255, 241); + // } + //} + + } + + + [Export(typeof(EditorFormatDefinition))] + [UserVisible(true)] + [Order(After = Priority.High)] + [ClassificationType(ClassificationTypeNames = Key)] + [Name(Key)] + internal class Param : ZMBAFormatDefinition { + public const string Key = "ZMBA.parameter"; + + [Export(typeof(ClassificationTypeDefinition))] + [Name(Key)] + public static ClassificationTypeDefinition TypeDef; + public static ZMBAFormatDefinition Instance { get; private set; } + + private Param(string id) : base(id) { + ForegroundColor = Color.FromRgb(255, 215, 215); + } + public Param() : this(Key) { + Instance = this; + } + + //TODO: Requires more advanced analysis + //[Export(typeof(EditorFormatDefinition))] + //[UserVisible(false)] + //[Order(After = Priority.High)] + //[ClassificationType(ClassificationTypeNames = Key)] + //[Name(Key)] + //internal new sealed class ParamMutated : Param { + // public new const string Key = "ZMBA.parameter-mutated"; + + // [Export(typeof(ClassificationTypeDefinition))] + // [Name(Key)] + // public new static ClassificationTypeDefinition TypeDef; + // public new static ZMBAFormatDefinition Instance { get; private set; } + + // public Mutated() : base(Key) { + // Instance = this; + // IsItalic = true; + // } + //} + + } + + + + + + [Export(typeof(EditorFormatDefinition))] + [UserVisible(true)] + [Order(After = Priority.High)] + [ClassificationType(ClassificationTypeNames = Key)] + [Name(Key)] + internal class Method : ZMBAFormatDefinition { + public const string Key = "ZMBA.method"; + + [Export(typeof(ClassificationTypeDefinition))] + [Name(Key)] + public static ClassificationTypeDefinition TypeDef; + public static ZMBAFormatDefinition Instance { get; private set; } + + private Method(string id) : base(id) { + ForegroundColor = Color.FromRgb(236, 231, 196); + } + public Method() : this(Key) { + Instance = this; + } + + + [Export(typeof(EditorFormatDefinition))] + [UserVisible(true)] + [Order(After = Priority.High)] + [ClassificationType(ClassificationTypeNames = Key)] + [Name(Key)] + internal sealed class Constructor : Method { + public new const string Key = "ZMBA.method-constructor"; + + [Export(typeof(ClassificationTypeDefinition))] + [Name(Key)] + public new static ClassificationTypeDefinition TypeDef; + public new static ZMBAFormatDefinition Instance { get; private set; } + + public Constructor() : base(Key) { + Instance = this; + IsBold = true; + } + } + + + [Export(typeof(EditorFormatDefinition))] + [UserVisible(true)] + [Order(After = Priority.High)] + [ClassificationType(ClassificationTypeNames = Key)] + [Name(Key)] + internal sealed class Static : Method { + public new const string Key = "ZMBA.method-static"; + + [Export(typeof(ClassificationTypeDefinition))] + [Name(Key)] + public new static ClassificationTypeDefinition TypeDef; + public new static ZMBAFormatDefinition Instance { get; private set; } + + public Static() : base(Key) { + Instance = this; + IsBold = true; + } + } + + + [Export(typeof(EditorFormatDefinition))] + [UserVisible(true)] + [Order(After = Priority.High)] + [ClassificationType(ClassificationTypeNames = Key)] + [Name(Key)] + internal sealed class Extension : Method { + public new const string Key = "ZMBA.method-extension"; + + [Export(typeof(ClassificationTypeDefinition))] + [Name(Key)] + public new static ClassificationTypeDefinition TypeDef; + public new static ZMBAFormatDefinition Instance { get; private set; } + + public Extension() : base(Key) { + Instance = this; + IsItalic = true; + } + } + + } + + + + + + [Export(typeof(EditorFormatDefinition))] + [UserVisible(true)] + [Order(After = Priority.High)] + [ClassificationType(ClassificationTypeNames = Key)] + [Name(Key)] + internal class Identifier : ZMBAFormatDefinition { + public const string Key = "ZMBA.identifier"; + + [Export(typeof(ClassificationTypeDefinition))] + [Name(Key)] + public static ClassificationTypeDefinition TypeDef; + public static ZMBAFormatDefinition Instance { get; private set; } + + private Identifier(string id) : base(id) { + ForegroundColor = Color.FromArgb(200, 240, 240, 240); + } + public Identifier() : this(Key) { + Instance = this; + } + + + [Export(typeof(EditorFormatDefinition))] + [UserVisible(true)] + [Order(After = Priority.High)] + [ClassificationType(ClassificationTypeNames = Key)] + [Name(Key)] + internal sealed class Namespace : Identifier { + public new const string Key = "ZMBA.identifier-namespace"; + + [Export(typeof(ClassificationTypeDefinition))] + [Name(Key)] + public new static ClassificationTypeDefinition TypeDef; + public new static ZMBAFormatDefinition Instance { get; private set; } + public Namespace() : base(Key) { + Instance = this; + ForegroundColor = Color.FromRgb(135, 150, 194); + } + } + + + //TODO: Currently unreliable. + [Export(typeof(EditorFormatDefinition))] + [UserVisible(false)] + [Order(After = Priority.High)] + [ClassificationType(ClassificationTypeNames = Key)] + [Name(Key)] + internal sealed class Attribute : Identifier { + public new const string Key = "ZMBA.identifier-attribute"; + + [Export(typeof(ClassificationTypeDefinition))] + [Name(Key)] + public new static ClassificationTypeDefinition TypeDef; + public new static ZMBAFormatDefinition Instance { get; private set; } + public Attribute() : base(Key) { + Instance = this; + IsItalic = true; + //ForegroundColor = Color.FromRgb(136, 202, 244); + } + } + + + + [Export(typeof(EditorFormatDefinition))] + [UserVisible(true)] + [Order(After = Priority.High)] + [ClassificationType(ClassificationTypeNames = Key)] + [Name(Key)] + internal sealed class Constant : Identifier { + public new const string Key = "ZMBA.identifier-constant"; + + [Export(typeof(ClassificationTypeDefinition))] + [Name(Key)] + public new static ClassificationTypeDefinition TypeDef; + public new static ZMBAFormatDefinition Instance { get; private set; } + public Constant() : base(Key) { + Instance = this; + IsBold = true; + ForegroundColor = Color.FromRgb(198, 176, 206); + } + } + + + [Export(typeof(EditorFormatDefinition))] + [UserVisible(true)] + [Order(After = Priority.High)] + [ClassificationType(ClassificationTypeNames = Key)] + [Name(Key)] + internal sealed class Field : Identifier { + public new const string Key = "ZMBA.identifier-field"; + + [Export(typeof(ClassificationTypeDefinition))] + [Name(Key)] + public new static ClassificationTypeDefinition TypeDef; + public new static ZMBAFormatDefinition Instance { get; private set; } + + public Field() : base(Key) { + Instance = this; + //IsItalic = true; + //ForegroundColor = Color.FromRgb(205, 237, 254); + //ForegroundColor = Color.FromRgb(238, 213, 187); + ForegroundColor = Color.FromRgb(224, 243, 255); + } + } + + + [Export(typeof(EditorFormatDefinition))] + [UserVisible(true)] + [Order(After = Priority.High)] + [ClassificationType(ClassificationTypeNames = Key)] + [Name(Key)] + internal sealed class Property : Identifier { + public new const string Key = "ZMBA.identifier-property"; + + [Export(typeof(ClassificationTypeDefinition))] + [Name(Key)] + public new static ClassificationTypeDefinition TypeDef; + public new static ZMBAFormatDefinition Instance { get; private set; } + public Property() : base(Key) { + Instance = this; + ForegroundColor = Color.FromRgb(205, 237, 254); + } + } + + + [Export(typeof(EditorFormatDefinition))] + [UserVisible(true)] + [Order(After = Priority.High)] + [ClassificationType(ClassificationTypeNames = Key)] + [Name(Key)] + internal sealed class Event : Identifier { + public new const string Key = "ZMBA.identifier-event"; + + [Export(typeof(ClassificationTypeDefinition))] + [Name(Key)] + public new static ClassificationTypeDefinition TypeDef; + public new static ZMBAFormatDefinition Instance { get; private set; } + public Event() : base(Key) { + Instance = this; + ForegroundColor = Color.FromRgb(250, 152, 225); + IsBold = false; + } + } + + + [Export(typeof(EditorFormatDefinition))] + [UserVisible(true)] + [Order(After = Priority.High)] + [ClassificationType(ClassificationTypeNames = Key)] + [Name(Key)] + internal sealed class Label : Identifier { + public new const string Key = "ZMBA.identifier-label"; + + [Export(typeof(ClassificationTypeDefinition))] + [Name(Key)] + public new static ClassificationTypeDefinition TypeDef; + public new static ZMBAFormatDefinition Instance { get; private set; } + public Label() : base(Key) { + Instance = this; + IsBold = true; + } + } + + + } + + } + +} +#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value null \ No newline at end of file diff --git a/ZMBA.SyntaxColorizer/src/Extensions.cs b/ZMBA.SyntaxColorizer/src/Extensions.cs new file mode 100644 index 0000000..133ae86 --- /dev/null +++ b/ZMBA.SyntaxColorizer/src/Extensions.cs @@ -0,0 +1,49 @@ +using System; +using System.Linq; +using System.Collections.Generic; +using System.ComponentModel.Composition; +using System.Runtime.CompilerServices; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Shared.Extensions; +using Microsoft.CodeAnalysis.Classification; +using Microsoft.CodeAnalysis.Text; +using Microsoft.VisualStudio.Text; +using Microsoft.VisualStudio.Text.Classification; +using Microsoft.VisualStudio.Text.Tagging; +using Microsoft.VisualStudio.Utilities; + +using VB = Microsoft.CodeAnalysis.VisualBasic; +using CS = Microsoft.CodeAnalysis.CSharp; +using VBKind = Microsoft.CodeAnalysis.VisualBasic.SyntaxKind; +using CSKind = Microsoft.CodeAnalysis.CSharp.SyntaxKind; + +namespace ZMBA.SyntaxColorizer { + + internal static class Extensions { + + + internal static SyntaxNode FindOuterMostNode(this SyntaxNode rootNode, TextSpan span, bool bTrivia) { + SyntaxNode node = rootNode.FindToken(span.Start, bTrivia).Parent; + SyntaxNode parent; + while (node != null && (parent = node.Parent) != null) { + TextSpan nodespan = node.FullSpan; + if (span.Start < nodespan.Start || nodespan.End < span.End || parent != rootNode && nodespan.Length == parent.FullSpan.Length) { + node = parent; + } else { + break; + } + } + switch (node.RawKind) { + case (int)VBKind.SimpleArgument: node = ((VB.Syntax.SimpleArgumentSyntax)node).Expression; break; + case (int)CSKind.Argument: node = ((CS.Syntax.ArgumentSyntax)node).Expression; break; + case (int)CSKind.AttributeArgument: node = ((CS.Syntax.AttributeArgumentSyntax)node).Expression; break; + } + return node; + } + + + } + +} diff --git a/ZMBA.SyntaxColorizer/src/FormattingTags.cs b/ZMBA.SyntaxColorizer/src/FormattingTags.cs new file mode 100644 index 0000000..e656990 --- /dev/null +++ b/ZMBA.SyntaxColorizer/src/FormattingTags.cs @@ -0,0 +1,103 @@ +using Microsoft.VisualStudio.Text.Classification; +using Microsoft.VisualStudio.Text.Tagging; + + +namespace ZMBA.SyntaxColorizer { + + internal class FormattingTags { + internal ClassificationTag SyntaxKeyword{ get; } + internal ClassificationTag SyntaxOperator{ get; } + internal ClassificationTag SyntaxNumber{ get; } + internal ClassificationTag SyntaxPunctuation{ get; } + internal ClassificationTag SyntaxComment{ get; } + + internal ClassificationTag Preprocessor{ get; } + internal ClassificationTag PreprocessorText{ get; } + + internal ClassificationTag Type{ get; } + internal ClassificationTag TypeModule{ get; } + internal ClassificationTag TypeClass{ get; } + //internal ClassificationTag TypeClassAttribute { get; } + internal ClassificationTag TypeStructure{ get; } + internal ClassificationTag TypeInterface{ get; } + internal ClassificationTag TypeDelegate{ get; } + internal ClassificationTag TypeGeneric{ get; } + internal ClassificationTag TypeDynamic { get; } + + internal ClassificationTag Enum{ get; } + internal ClassificationTag EnumMember{ get; } + + internal ClassificationTag String{ get; } + internal ClassificationTag StringToken { get; } + internal ClassificationTag StringSingleQuote{ get; } + internal ClassificationTag StringInterpolated{ get; } + + internal ClassificationTag Variable{ get; } + //internal ClassificationTag VariableMutated { get; } + internal ClassificationTag Param{ get; } + //internal ClassificationTag ParamMutated{ get; } + + + internal ClassificationTag Method{ get; } + internal ClassificationTag MethodConstructor{ get; } + internal ClassificationTag MethodStatic{ get; } + internal ClassificationTag MethodExtension{ get; } + + internal ClassificationTag Identifier{ get; } + internal ClassificationTag IdentifierNamespace{ get; } + internal ClassificationTag IdentifierAttribute{ get; } + internal ClassificationTag IdentifierConst{ get; } + internal ClassificationTag IdentifierField{ get; } + internal ClassificationTag IdentifierProperty{ get; } + internal ClassificationTag IdentifierEvent { get; } + internal ClassificationTag IdentifierLabel { get; } + + internal FormattingTags(IClassificationTypeRegistryService registry) { + this.SyntaxKeyword = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Syntax.KeyWord.Key)); + this.SyntaxOperator = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Syntax.Operator.Key)); + this.SyntaxNumber = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Syntax.Number.Key)); + this.SyntaxPunctuation = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Syntax.Punctuation.Key)); + this.SyntaxComment = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Syntax.Comment.Key)); + + this.Preprocessor = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Preprocessor.Key)); + this.PreprocessorText = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Preprocessor.Text.Key)); + + this.Type = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Type.Key)); + this.TypeModule = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Type.Module.Key)); + this.TypeClass = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Type.Class.Key)); + //this.TypeClassAttribute = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Type.Class.Attribute.Key)); + this.TypeStructure = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Type.Structure.Key)); + this.TypeInterface = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Type.Interface.Key)); + this.TypeDelegate = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Type.Delegate.Key)); + this.TypeGeneric = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Type.Generic.Key)); + this.TypeDynamic = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Type.Dynamic.Key)); + + this.Enum = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Enum.Key)); + this.EnumMember = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Enum.Member.Key)); + + this.String = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.String.Key)); + this.StringToken = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.String.Token.Key)); + this.StringSingleQuote = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.String.SingleQuotes.Key)); + this.StringInterpolated = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.String.Interpolated.Key)); + + this.Variable = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Variable.Key)); + //this.VariableMutated = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Variable.Mutated.Key)); + this.Param = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Param.Key)); + //this.ParamMutated = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Param.Mutated.Key)); + + this.Method = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Method.Key)); + this.MethodConstructor = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Method.Constructor.Key)); + this.MethodStatic = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Method.Static.Key)); + this.MethodExtension = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Method.Extension.Key)); + + this.Identifier = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Identifier.Key)); + this.IdentifierNamespace = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Identifier.Namespace.Key)); + this.IdentifierAttribute = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Identifier.Attribute.Key)); + this.IdentifierConst = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Identifier.Constant.Key)); + this.IdentifierField = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Identifier.Field.Key)); + this.IdentifierProperty = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Identifier.Property.Key)); + this.IdentifierEvent = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Identifier.Event.Key)); + this.IdentifierLabel = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Identifier.Label.Key)); + } + } +} \ No newline at end of file diff --git a/ZMBA.SyntaxColorizer/src/VBCSTagClassifier.cs b/ZMBA.SyntaxColorizer/src/VBCSTagClassifier.cs new file mode 100644 index 0000000..a6018ae --- /dev/null +++ b/ZMBA.SyntaxColorizer/src/VBCSTagClassifier.cs @@ -0,0 +1,210 @@ +using System; +using System.Linq; +using System.Collections.Generic; +using System.ComponentModel.Composition; +using System.Runtime.CompilerServices; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Shared.Extensions; +using Microsoft.CodeAnalysis.Classification; +using Microsoft.CodeAnalysis.Text; +using Microsoft.VisualStudio.Text; +using Microsoft.VisualStudio.Text.Classification; +using Microsoft.VisualStudio.Text.Tagging; +using Microsoft.VisualStudio.Utilities; + +using VB = Microsoft.CodeAnalysis.VisualBasic; +using CS = Microsoft.CodeAnalysis.CSharp; +using VBKind = Microsoft.CodeAnalysis.VisualBasic.SyntaxKind; +using CSKind = Microsoft.CodeAnalysis.CSharp.SyntaxKind; + +namespace ZMBA.SyntaxColorizer { + + + [Export(typeof(ITaggerProvider))] + [ContentType("Basic")] + [ContentType("CSharp")] + [TagType(typeof(IClassificationTag))] + internal sealed class ClassificationTagProvider: ITaggerProvider { + [Import] internal IClassificationTypeRegistryService ClassificationRegistry; // Set via MEF + + public ITagger CreateTagger(ITextBuffer buffer) where T : ITag { + //Don't need to pass the buffer because we aren't doing anything too complicated. + //Would need it if we had to do some intense tagging on a background thread. + return (ITagger)buffer.Properties.GetOrCreateSingletonProperty(() => new VBCSTagClassifier(ClassificationRegistry)); + } + } + + internal class VBCSTagClassifier: ITagger { + private readonly FormattingTags Tags; + private ClassifierContext CachedContext; + + internal VBCSTagClassifier(IClassificationTypeRegistryService registry) { + this.Tags = new FormattingTags(registry); + } + +#pragma warning disable CS0067 // The event is never used + /** Not sure what this is for or how to use it. **/ + public event EventHandler TagsChanged; +#pragma warning restore CS0067 // The event is never used + + + public IEnumerable> GetTags(NormalizedSnapshotSpanCollection snapshots) { + if (snapshots.Count >= 1) { + SnapshotSpan snapspan = snapshots[0]; + ClassifierContext ctx = ClassifierContext.GetContext(ref this.CachedContext, snapspan); + if(ctx != null) { + List ls = ctx.GetClassifiedSpans(snapspan); + for(int idx = 0; idx < ls.Count; idx++) { + ClassifiedSpan clsspan = ls[idx]; + TextSpan txt = clsspan.TextSpan; + switch(clsspan.ClassificationType) { + case "string": ClassifyString(ctx, txt); break; + case "identifier": ClassifyIdentifier(ctx, txt); break; + case "keyword": ctx.AssociateTagWithText(Tags.SyntaxKeyword, txt); break; + case "operator": ctx.AssociateTagWithText(Tags.SyntaxOperator, txt); break; + case "number": ctx.AssociateTagWithText(Tags.SyntaxNumber, txt); break; + case "punctuation": ctx.AssociateTagWithText(Tags.SyntaxPunctuation, txt); break; + case "comment": ctx.AssociateTagWithText(Tags.SyntaxComment, txt); break; + case "class name": ctx.AssociateTagWithText(Tags.TypeClass, txt); break; + case "module name": ctx.AssociateTagWithText(Tags.TypeModule, txt); break; + case "struct name": ctx.AssociateTagWithText(Tags.TypeStructure, txt); break; + case "interface name": ctx.AssociateTagWithText(Tags.TypeInterface, txt); break; + case "type parameter name": ctx.AssociateTagWithText(Tags.TypeGeneric, txt); break; + case "delegate name": ctx.AssociateTagWithText(Tags.TypeDelegate, txt); break; + case "enum name": ctx.AssociateTagWithText(Tags.Enum, txt); break; + case "preprocessor keyword": ctx.AssociateTagWithText(Tags.Preprocessor, txt); break; + case "preprocessor text": ctx.AssociateTagWithText(Tags.PreprocessorText, txt); break; + default: continue; + } + + if(ctx.TaggedText != null) { + TagSpan tag = ctx.TaggedText; + ctx.TaggedText = null; + yield return tag; + } + } + } + } + } + + + + private void ClassifyString(ClassifierContext ctx, TextSpan txt) { + SyntaxNode node = ctx.RootNode.FindOuterMostNode(txt, false); + if(node == null) { return; } + switch(node.RawKind) { + case (int)VBKind.InterpolatedStringExpression: + case (int)CSKind.InterpolatedVerbatimStringStartToken: + case (int)CSKind.InterpolatedStringStartToken: + case (int)CSKind.InterpolatedStringEndToken: + case (int)CSKind.InterpolatedStringExpression: + ctx.AssociateTagWithText(Tags.StringToken, txt); + break; + case (int)VBKind.CharacterLiteralToken: + case (int)VBKind.CharacterLiteralExpression: + case (int)VBKind.SingleQuoteToken: + case (int)CSKind.CharacterLiteralToken: + case (int)CSKind.CharacterLiteralExpression: + case (int)CSKind.SingleQuoteToken: + ctx.AssociateTagWithText(Tags.StringSingleQuote, txt); + break; + case (int)VBKind.InterpolatedStringTextToken: + case (int)VBKind.InterpolatedStringText: + case (int)CSKind.InterpolatedStringTextToken: + case (int)CSKind.InterpolatedStringText: + case (int)CSKind.InterpolatedStringToken: + ctx.AssociateTagWithText(Tags.StringInterpolated, txt); + break; + case (int)VBKind.StringLiteralToken: + case (int)VBKind.StringLiteralExpression: + case (int)VBKind.XmlEntityLiteralToken: + case (int)VBKind.XmlString: + case (int)CSKind.StringLiteralToken: + case (int)CSKind.StringLiteralExpression: + case (int)CSKind.XmlEntityLiteralToken: + default: + ctx.AssociateTagWithText(Tags.String, txt); + break; + } + } + private void ClassifyIdentifier(ClassifierContext ctx, TextSpan txt) { + SyntaxNode node = ctx.RootNode.FindOuterMostNode(txt, true); + if(node == null) { return; } + switch(node.RawKind) { + case (int)VBKind.Attribute: + case (int)CSKind.Attribute: + ctx.AssociateTagWithText(Tags.IdentifierAttribute, txt); + break; + default: + ISymbol rawsymbol = ctx.SemanticModel.GetSymbolInfo(node).Symbol ?? ctx.SemanticModel.GetDeclaredSymbol(node); + if(rawsymbol != null) { + switch(rawsymbol.Kind) { + case SymbolKind.Field: ClassifyIdentifier_Field(ctx, txt, node, (IFieldSymbol)rawsymbol); break; + case SymbolKind.Method: ClassifyIdentifier_Method(ctx, txt, node, (IMethodSymbol)rawsymbol); break; + case SymbolKind.NamedType: ClassifyIdentifier_NamedType(ctx, txt, node, (INamedTypeSymbol)rawsymbol); break; + case SymbolKind.Local: ClassifyIdentifier_Local(ctx, txt, node, (ILocalSymbol)rawsymbol); break; + case SymbolKind.Parameter: ctx.AssociateTagWithText(Tags.Param, txt); break; + case SymbolKind.TypeParameter: ctx.AssociateTagWithText(Tags.TypeGeneric, txt); break; + case SymbolKind.DynamicType: ctx.AssociateTagWithText(Tags.TypeDynamic, txt); break; + case SymbolKind.Namespace: ctx.AssociateTagWithText(Tags.IdentifierNamespace, txt); break; + case SymbolKind.Property: ctx.AssociateTagWithText(Tags.IdentifierProperty, txt); break; + case SymbolKind.Event: ctx.AssociateTagWithText(Tags.IdentifierEvent, txt); break; + case SymbolKind.Label: ctx.AssociateTagWithText(Tags.IdentifierLabel, txt); break; + case SymbolKind.Preprocessing: ctx.AssociateTagWithText(Tags.PreprocessorText, txt); break; + } + } + break; + } + } + private void ClassifyIdentifier_Field(ClassifierContext ctx, TextSpan txt, SyntaxNode node, IFieldSymbol symbol) { + if(symbol.ContainingType.TypeKind == TypeKind.Enum) { + ctx.AssociateTagWithText(Tags.EnumMember, txt); + } else { + if(symbol.IsConst) { + ctx.AssociateTagWithText(Tags.IdentifierConst, txt); + } else { + ctx.AssociateTagWithText(Tags.IdentifierField, txt); + } + } + } + private void ClassifyIdentifier_Method(ClassifierContext ctx, TextSpan txt, SyntaxNode node, IMethodSymbol symbol) { + switch(node.Parent.RawKind) { + case (int)VBKind.Attribute: + case (int)CSKind.Attribute: + case (int)VBKind.QualifiedName when node.Parent.Parent.RawKind == (int)VBKind.Attribute: + case (int)CSKind.QualifiedName when node.Parent.Parent.RawKind == (int)CSKind.Attribute: + ctx.AssociateTagWithText(Tags.IdentifierAttribute, txt); + break; + default: + if(symbol.MethodKind == MethodKind.Constructor || symbol.MethodKind == MethodKind.StaticConstructor) { + ctx.AssociateTagWithText(Tags.MethodConstructor, txt); + } else if(symbol.IsExtensionMethod) { + ctx.AssociateTagWithText(Tags.MethodExtension, txt); + } else if(symbol.IsStatic) { + ctx.AssociateTagWithText(Tags.MethodStatic, txt); + } else { + ctx.AssociateTagWithText(Tags.Method, txt); + } + break; + } + } + private void ClassifyIdentifier_NamedType(ClassifierContext ctx, TextSpan txt, SyntaxNode node, INamedTypeSymbol symbol) { + if(symbol.SpecialType != SpecialType.None) { + ctx.AssociateTagWithText(Tags.Type, txt); + } else { + ctx.AssociateTagWithText(Tags.TypeClass, txt); + } + } + private void ClassifyIdentifier_Local(ClassifierContext ctx, TextSpan txt, SyntaxNode node, ILocalSymbol symbol) { + if(symbol.IsConst) { + ctx.AssociateTagWithText(Tags.IdentifierConst, txt); + } else { + ctx.AssociateTagWithText(Tags.Variable, txt); + } + } + + + } +} diff --git a/ZMBA.SyntaxColorizer/src/ZMBAFormatDefinition.cs b/ZMBA.SyntaxColorizer/src/ZMBAFormatDefinition.cs new file mode 100644 index 0000000..9c9032f --- /dev/null +++ b/ZMBA.SyntaxColorizer/src/ZMBAFormatDefinition.cs @@ -0,0 +1,14 @@ +using Microsoft.VisualStudio.Text.Classification; +using Microsoft.VisualStudio.Text.Tagging; + + +namespace ZMBA.SyntaxColorizer { + + //TODO: Pull format settings from a config file eventually. + internal abstract class ZMBAFormatDefinition : ClassificationFormatDefinition { + + public ZMBAFormatDefinition(string identifier) { + this.DisplayName = identifier; + } + } +} \ No newline at end of file