From 4314d2bf8634ddc573c4f0a4266a6771cb5eb696 Mon Sep 17 00:00:00 2001 From: wuestholz Date: Tue, 11 Jun 2013 10:24:31 -0700 Subject: DafnyExtension: Did some refactoring. --- Source/DafnyExtension/ClassificationTagger.cs | 28 ++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'Source/DafnyExtension/ClassificationTagger.cs') diff --git a/Source/DafnyExtension/ClassificationTagger.cs b/Source/DafnyExtension/ClassificationTagger.cs index 8f6191e5..b3bafa11 100644 --- a/Source/DafnyExtension/ClassificationTagger.cs +++ b/Source/DafnyExtension/ClassificationTagger.cs @@ -4,13 +4,15 @@ using System.ComponentModel.Composition; using System.Windows.Media; using Microsoft.VisualStudio.Text; using Microsoft.VisualStudio.Text.Classification; -using Microsoft.VisualStudio.Text.Editor; using Microsoft.VisualStudio.Text.Tagging; using Microsoft.VisualStudio.Utilities; namespace DafnyLanguage { + + #region Provider + [Export(typeof(ITaggerProvider))] [ContentType("dafny")] [TagType(typeof(ClassificationTag))] @@ -31,11 +33,15 @@ namespace DafnyLanguage } } + #endregion + + #region Tagger + internal sealed class DafnyClassifier : ITagger { ITextBuffer _buffer; ITagAggregator _aggregator; - IDictionary _typeMap; + IDictionary _typeMap; static bool DafnyMenuWasInitialized; @@ -45,14 +51,15 @@ namespace DafnyLanguage _buffer = buffer; _aggregator = tagAggregator; _aggregator.TagsChanged += new EventHandler(_aggregator_TagsChanged); + // use built-in classification types: - _typeMap = new Dictionary(); - _typeMap[DafnyTokenKinds.Keyword] = standards.Keyword; - _typeMap[DafnyTokenKinds.Number] = standards.NumberLiteral; - _typeMap[DafnyTokenKinds.String] = standards.StringLiteral; - _typeMap[DafnyTokenKinds.Comment] = standards.Comment; - _typeMap[DafnyTokenKinds.VariableIdentifier] = standards.Identifier; - _typeMap[DafnyTokenKinds.VariableIdentifierDefinition] = typeService.GetClassificationType("Dafny identifier"); + _typeMap = new Dictionary(); + _typeMap[DafnyTokenKind.Keyword] = standards.Keyword; + _typeMap[DafnyTokenKind.Number] = standards.NumberLiteral; + _typeMap[DafnyTokenKind.String] = standards.StringLiteral; + _typeMap[DafnyTokenKind.Comment] = standards.Comment; + _typeMap[DafnyTokenKind.VariableIdentifier] = standards.Identifier; + _typeMap[DafnyTokenKind.VariableIdentifierDefinition] = typeService.GetClassificationType("Dafny identifier"); if (!DafnyMenuWasInitialized) { @@ -119,4 +126,7 @@ namespace DafnyLanguage [Name("Dafny identifier")] internal static ClassificationTypeDefinition UserType = null; } + + #endregion + } -- cgit v1.2.3