private IClassificationType GetClassificationType(NASMTokenTypes type) { switch (type) { case NASMTokenTypes.Default: return(_typeService.GetClassificationType("nasm.default")); case NASMTokenTypes.Comment: return(_typeService.GetClassificationType("nasm.comment")); case NASMTokenTypes.Number: return(_typeService.GetClassificationType("nasm.number")); case NASMTokenTypes.Character: return(_typeService.GetClassificationType("nasm.character")); case NASMTokenTypes.String: return(_typeService.GetClassificationType("nasm.string")); case NASMTokenTypes.Operator: return(_typeService.GetClassificationType("nasm.operator")); case NASMTokenTypes.CPUInstruction: return(_typeService.GetClassificationType("nasm.cpu-instruction")); case NASMTokenTypes.MathInstruction: return(_typeService.GetClassificationType("nasm.math-instruction")); case NASMTokenTypes.Register: return(_typeService.GetClassificationType("nasm.register")); case NASMTokenTypes.Directive: return(_typeService.GetClassificationType("nasm.directive")); case NASMTokenTypes.DirectiveOperand: return(_typeService.GetClassificationType("nasm.directive-operand")); case NASMTokenTypes.ExtInstruction: return(_typeService.GetClassificationType("nasm.ext-instruction")); case NASMTokenTypes.Label: return(_typeService.GetClassificationType("nasm.label")); default: return(_typeService.GetClassificationType("nasm.default")); } }
public NASMTokenTag(NASMTokenTypes type) { this.type = type; }
public IEnumerable <ITagSpan <NASMTokenTag> > GetTags(NormalizedSnapshotSpanCollection spans) { foreach (SnapshotSpan curSpan in spans) { ITextSnapshotLine containingLine = curSpan.Start.GetContainingLine(); int curLoc = containingLine.Start.Position; string[] tokens = Split(containingLine.GetText().ToLower(), _delimiters.ToCharArray()); NASMTokenTypes overrideType = NASMTokenTypes.Default; foreach (string token in tokens) { NASMTokenTypes type = GetTokenType(token); SnapshotSpan tokenSpan; if (type == NASMTokenTypes.Comment) { tokenSpan = new SnapshotSpan(curSpan.Snapshot, new Span(curLoc, containingLine.End.Position - curLoc)); if (tokenSpan.IntersectsWith(curSpan)) { yield return(new TagSpan <NASMTokenTag>(tokenSpan, new NASMTokenTag(type))); break; } } if (overrideType == NASMTokenTypes.String) { if (type == NASMTokenTypes.String) { overrideType = NASMTokenTypes.Default; } else { type = overrideType; } } else { if (type == NASMTokenTypes.String) { overrideType = NASMTokenTypes.String; } } if (overrideType == NASMTokenTypes.Character) { if (type == NASMTokenTypes.Character) { overrideType = NASMTokenTypes.Default; } else { type = NASMTokenTypes.Character; } } else { if (type == NASMTokenTypes.Character) { overrideType = NASMTokenTypes.Character; } } tokenSpan = new SnapshotSpan(curSpan.Snapshot, new Span(curLoc, token.Length)); if (tokenSpan.IntersectsWith(curSpan)) { yield return(new TagSpan <NASMTokenTag>(tokenSpan, new NASMTokenTag(type))); } //add an extra char location because of the space curLoc += token.Length; } } }