Skip to content
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
54 changes: 53 additions & 1 deletion ClassificationTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,57 @@ internal static class ClassificationTypes
[Export(typeof(ClassificationTypeDefinition))]
[Name("modifier - static")]
internal static ClassificationTypeDefinition StaticModifierType = null;


[Export(typeof(ClassificationTypeDefinition))]
[Name("control flow - if")]
internal static ClassificationTypeDefinition ControlFlowIfType = null;

[Export(typeof(ClassificationTypeDefinition))]
[Name("control flow - else")]
internal static ClassificationTypeDefinition ControlFlowElseType = null;


[Export(typeof(ClassificationTypeDefinition))]
[Name("control flow - while")]
internal static ClassificationTypeDefinition ControlFlowWhileType = null;

[Export(typeof(ClassificationTypeDefinition))]
[Name("control flow - do")]
internal static ClassificationTypeDefinition ControlFlowDoType = null;

[Export(typeof(ClassificationTypeDefinition))]
[Name("control flow - switch")]
internal static ClassificationTypeDefinition ControlFlowSwitchType = null;

[Export(typeof(ClassificationTypeDefinition))]
[Name("control flow - break")]
internal static ClassificationTypeDefinition ControlFlowBreakType = null;

[Export(typeof(ClassificationTypeDefinition))]
[Name("control flow - continue")]
internal static ClassificationTypeDefinition ControlFlowContinueType = null;

[Export(typeof(ClassificationTypeDefinition))]
[Name("control flow - for")]
internal static ClassificationTypeDefinition ControlFlowForType = null;

[Export(typeof(ClassificationTypeDefinition))]
[Name("control flow - foreach")]
internal static ClassificationTypeDefinition ControlFlowForeachType = null;

[Export(typeof(ClassificationTypeDefinition))]
[Name("control flow - return")]
internal static ClassificationTypeDefinition ControlFlowReturnType = null;

[Export(typeof(ClassificationTypeDefinition))]
[Name("control flow - goto")]
internal static ClassificationTypeDefinition ControlFlowGotoType = null;

[Export(typeof(ClassificationTypeDefinition))]
[Name("control flow - throw")]
internal static ClassificationTypeDefinition ControlFlowThrowType = null;

[Export(typeof(ClassificationTypeDefinition))]
[Name("control flow - yield")]
internal static ClassificationTypeDefinition ControlFlowYieldType = null;
}
197 changes: 196 additions & 1 deletion FormatDefinitions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,199 @@ public StaticModifierFormat()
DisplayName = "C# Modifier - Static";
ForegroundColor = Colors.Gray;
}
}
}

[Export(typeof(EditorFormatDefinition))]
[ClassificationType(ClassificationTypeNames = "control flow - if")]
[Name("Control Flow If Format")]
[UserVisible(true)]
[Priority(9999)]
[Order(After = Priority.High)]
internal sealed class ControlFlowIfFormat : ClassificationFormatDefinition
{
public ControlFlowIfFormat()
{
DisplayName = "C# Control Flow - if";
ForegroundColor = Colors.OrangeRed;
}
}

[Export(typeof(EditorFormatDefinition))]
[ClassificationType(ClassificationTypeNames = "control flow - else")]
[Name("Control Flow Else Format")]
[UserVisible(true)]
[Priority(9999)]
[Order(After = Priority.High)]
internal sealed class ControlFlowElseFormat : ClassificationFormatDefinition
{
public ControlFlowElseFormat()
{
DisplayName = "C# Control Flow - else";
ForegroundColor = Colors.OrangeRed;
}
}

[Export(typeof(EditorFormatDefinition))]
[ClassificationType(ClassificationTypeNames = "control flow - while")]
[Name("Control Flow While Format")]
[UserVisible(true)]
[Priority(9999)]
[Order(After = Priority.High)]
internal sealed class ControlFlowWhileFormat : ClassificationFormatDefinition
{
public ControlFlowWhileFormat()
{
DisplayName = "C# Control Flow - while";
ForegroundColor = Colors.OrangeRed;
}
}

[Export(typeof(EditorFormatDefinition))]
[ClassificationType(ClassificationTypeNames = "control flow - do")]
[Name("Control Flow Do Format")]
[UserVisible(true)]
[Priority(9999)]
[Order(After = Priority.High)]
internal sealed class ControlFlowDoFormat : ClassificationFormatDefinition
{
public ControlFlowDoFormat()
{
DisplayName = "C# Control Flow - do";
ForegroundColor = Colors.OrangeRed;
}
}

[Export(typeof(EditorFormatDefinition))]
[ClassificationType(ClassificationTypeNames = "control flow - for")]
[Name("Control Flow For Format")]
[UserVisible(true)]
[Priority(9999)]
[Order(After = Priority.High)]
internal sealed class ControlFlowForFormat : ClassificationFormatDefinition
{
public ControlFlowForFormat()
{
DisplayName = "C# Control Flow - for";
ForegroundColor = Colors.OrangeRed;
}
}

[Export(typeof(EditorFormatDefinition))]
[ClassificationType(ClassificationTypeNames = "control flow - foreach")]
[Name("Control Flow Foreach Format")]
[UserVisible(true)]
[Priority(9999)]
[Order(After = Priority.High)]
internal sealed class ControlFlowForeachFormat : ClassificationFormatDefinition
{
public ControlFlowForeachFormat()
{
DisplayName = "C# Control Flow - foreach";
ForegroundColor = Colors.OrangeRed;
}
}

[Export(typeof(EditorFormatDefinition))]
[ClassificationType(ClassificationTypeNames = "control flow - switch")]
[Name("Control Flow Switch Format")]
[UserVisible(true)]
[Priority(9999)]
[Order(After = Priority.High)]
internal sealed class ControlFlowSwitchFormat : ClassificationFormatDefinition
{
public ControlFlowSwitchFormat()
{
DisplayName = "C# Control Flow - switch";
ForegroundColor = Colors.OrangeRed;
}
}

[Export(typeof(EditorFormatDefinition))]
[ClassificationType(ClassificationTypeNames = "control flow - break")]
[Name("Control Flow Break Format")]
[UserVisible(true)]
[Priority(9999)]
[Order(After = Priority.High)]
internal sealed class ControlFlowBreakFormat : ClassificationFormatDefinition
{
public ControlFlowBreakFormat()
{
DisplayName = "C# Control Flow - break";
ForegroundColor = Colors.OrangeRed;
}
}

[Export(typeof(EditorFormatDefinition))]
[ClassificationType(ClassificationTypeNames = "control flow - continue")]
[Name("Control Flow Continue Format")]
[UserVisible(true)]
[Priority(9999)]
[Order(After = Priority.High)]
internal sealed class ControlFlowContinueFormat : ClassificationFormatDefinition
{
public ControlFlowContinueFormat()
{
DisplayName = "C# Control Flow - continue";
ForegroundColor = Colors.OrangeRed;
}
}

[Export(typeof(EditorFormatDefinition))]
[ClassificationType(ClassificationTypeNames = "control flow - return")]
[Name("Control Flow Return Format")]
[UserVisible(true)]
[Priority(9999)]
[Order(After = Priority.High)]
internal sealed class ControlFlowReturnFormat : ClassificationFormatDefinition
{
public ControlFlowReturnFormat()
{
DisplayName = "C# Control Flow - return";
ForegroundColor = Colors.OrangeRed;
}
}

[Export(typeof(EditorFormatDefinition))]
[ClassificationType(ClassificationTypeNames = "control flow - goto")]
[Name("Control Flow Goto Format")]
[UserVisible(true)]
[Priority(9999)]
[Order(After = Priority.High)]
internal sealed class ControlFlowGotoFormat : ClassificationFormatDefinition
{
public ControlFlowGotoFormat()
{
DisplayName = "C# Control Flow - goto";
ForegroundColor = Colors.OrangeRed;
}
}

[Export(typeof(EditorFormatDefinition))]
[ClassificationType(ClassificationTypeNames = "control flow - throw")]
[Name("Control Flow Throw Format")]
[UserVisible(true)]
[Priority(9999)]
[Order(After = Priority.High)]
internal sealed class ControlFlowThrowFormat : ClassificationFormatDefinition
{
public ControlFlowThrowFormat()
{
DisplayName = "C# Control Flow - throw";
ForegroundColor = Colors.OrangeRed;
}
}

[Export(typeof(EditorFormatDefinition))]
[ClassificationType(ClassificationTypeNames = "control flow - yield")]
[Name("Control Flow Yield Format")]
[UserVisible(true)]
[Priority(9999)]
[Order(After = Priority.High)]
internal sealed class ControlFlowYieldFormat : ClassificationFormatDefinition
{
public ControlFlowYieldFormat()
{
DisplayName = "C# Control Flow - yield";
ForegroundColor = Colors.OrangeRed;
}
}
17 changes: 15 additions & 2 deletions Tagger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,23 @@ public Tagger(ITextBuffer buffer, IClassificationTypeRegistryService registry, I
["abstract"] = registry.GetClassificationType("modifier - abstract"),
["sealed"] = registry.GetClassificationType("modifier - sealed"),
["override"] = registry.GetClassificationType("modifier - override"),
["static"] = registry.GetClassificationType("modifier - static")
["static"] = registry.GetClassificationType("modifier - static"),
["if"] = registry.GetClassificationType("control flow - if"),
["else"] = registry.GetClassificationType("control flow - else"),
["while"] = registry.GetClassificationType("control flow - while"),
["do"] = registry.GetClassificationType("control flow - do"),
["for"] = registry.GetClassificationType("control flow - for"),
["foreach"] = registry.GetClassificationType("control flow - foreach"),
["switch"] = registry.GetClassificationType("control flow - switch"),
["break"] = registry.GetClassificationType("control flow - break"),
["continue"] = registry.GetClassificationType("control flow - continue"),
["return"] = registry.GetClassificationType("control flow - return"),
["goto"] = registry.GetClassificationType("control flow - goto"),
["throw"] = registry.GetClassificationType("control flow - throw"),
["yield"] = registry.GetClassificationType("control flow - yield"),
};
_lineStartRegex = new Regex($@"^\s*({string.Join("|", _modifierMap.Keys)}|\[)", RegexOptions.IgnoreCase | RegexOptions.Compiled);
}
}

public IEnumerable<ITagSpan<ClassificationTag>> GetTags(NormalizedSnapshotSpanCollection spans)
{
Expand Down