Beispiel #1
0
        private SimplifiedClassificationInfo(string name)
        {
            Name = name;

            var info = ClassificationService.GetDefaultOption(name);

            IsDisabled            = info.IsDisabled;
            IsDisabledInXml       = info.IsDisabledInXml;
            IsDisabledInEditor    = info.IsDisabledInEditor;
            IsDisabledInQuickInfo = info.IsDisabledInQuickInfo;
        }
Beispiel #2
0
        /// <summary>
        /// Creates the default classification from <paramref name="formatting"/>
        /// which doesn't set the default values for properties that can be reset
        /// </summary>
        public static ClassificationSettings ToDefaultSettings(
            this TextFormattingRunProperties formatting, string classificationName)
        {
            var defaultOption = ClassificationService.GetDefaultOption(classificationName);

            return(new ClassificationSettings
            {
                Name = classificationName,
                FontFamily = formatting.GetFontFamily(),
                IsBold = formatting.Bold,
                FontStyle = formatting.GetFontStyleName(),
                IsOverline = formatting.TextDecorations.Contains(TextDecorations.OverLine[0]),
                IsUnderline = formatting.TextDecorations.Contains(TextDecorations.Underline[0]),
                IsStrikethrough = formatting.TextDecorations.Contains(TextDecorations.Strikethrough[0]),
                IsBaseline = formatting.TextDecorations.Contains(TextDecorations.Baseline[0]),
                IsDisabled = defaultOption.IsDisabled,
                IsDisabledInXml = defaultOption.IsDisabledInXml,
                IsDisabledInEditor = defaultOption.IsDisabledInEditor,
                IsDisabledInQuickInfo = defaultOption.IsDisabledInQuickInfo,
            });
        }
Beispiel #3
0
        private static RoslynTextBufferClassifier GetClassifier(
            ProgrammingLanguage language, IReadOnlyList <SimplifiedClassificationInfo> infos)
        {
            var dictionary          = infos?.ToDictionary(x => x.Name);
            var classificationTypes = new Dictionary <string, ClassificationInfo>(32);
            var names = language == ProgrammingLanguage.VisualBasic ? VisualBasicNames.All : CSharpNames.All;

            foreach (var name in names)
            {
                var option = dictionary is null || !dictionary.TryGetValue(name, out var simplifiedInfo)
                    ? ClassificationService.GetDefaultOption(name)
                    : simplifiedInfo;
                classificationTypes.Add(name, new ClassificationInfo(new ClassificationType(name), option));
            }

            if (language == ProgrammingLanguage.VisualBasic)
            {
                VisualBasicClassifierService.Reset();
                return(new VisualBasicTextBufferClassifier(classificationTypes));
            }

            CSharpClassifierService.Reset();
            return(new CSharpTextBufferClassifier(classificationTypes));
        }