public void Error(SyntaxType expected) { if (this.testModeLayer <= 0) { if (this.CurrentToken == null) { return; } string text = expected.GetText(); if (string.IsNullOrEmpty(text)) { return; } this.errorList.Add(new GLSLError($"{text} expected", this.CurrentToken.Span)); SyntaxNode node = new SyntaxNode(this.tree, expected, this.snapshot.CreateTrackingSpan(this.CurrentToken.Span)); node.IsMissing = true; this.stack.Peek().AddChild(node); } }
public static ColoredString ToColoredString(this SyntaxType syntaxType) { string text = syntaxType.GetText(); if (!string.IsNullOrEmpty(text)) { return(ColoredString.Create(text, ColorType.Keyword)); } else { return(null); } }
internal static void LoadDefaultCompletions(IGlyphService glyphService, IClassificationFormatMapService formatMapService, IClassificationTypeRegistryService typeRegistry) { IClassificationFormatMap formatMap = formatMapService.GetClassificationFormatMap("text"); ImageSource keywordIcon = glyphService.GetGlyph(StandardGlyphGroup.GlyphKeyword, StandardGlyphItem.GlyphItemPublic); for (SyntaxType syntaxType = SyntaxType.AttributeKeyword; syntaxType <= SyntaxType.LinePreprocessorKeyword; syntaxType++) { string text = syntaxType.GetText(); TextBlock textBlock = new TextBlock(); if (syntaxType.IsPreprocessor()) { textBlock.Inlines.Add(text.ToRun(formatMap, typeRegistry.GetClassificationType(GLSLConstants.PreprocessorKeyword))); } else { textBlock.Inlines.Add(text.ToRun(formatMap, typeRegistry.GetClassificationType(GLSLConstants.Keyword))); } textBlock.Inlines.Add(new Run(" Keyword")); keywords.Add(new GLSLCompletion(textBlock, text, text + "Keyword", keywordIcon)); } for (int j = 1; j <= 32; j *= 2) { builtIn.Add((ShaderType)j, new List <Completion>()); } foreach (List <Definition> definitions in BuiltInData.Instance.Definitions.Values) { for (int i = 0; i < definitions.Count; i++) { GLSLCompletion completion = new GLSLCompletion(definitions[i].ToTextBlock(formatMap, typeRegistry, definitions.Count), definitions[i], definitions[i].GetImageSource(glyphService)); if (definitions[i].ShaderType.HasFlag <ShaderType>(ShaderType.Compute)) { builtIn[ShaderType.Compute].Add(completion); } if (definitions[i].ShaderType.HasFlag <ShaderType>(ShaderType.Vertex)) { builtIn[ShaderType.Vertex].Add(completion); } if (definitions[i].ShaderType.HasFlag <ShaderType>(ShaderType.Geometry)) { builtIn[ShaderType.Geometry].Add(completion); } if (definitions[i].ShaderType.HasFlag <ShaderType>(ShaderType.TessellationControl)) { builtIn[ShaderType.TessellationControl].Add(completion); } if (definitions[i].ShaderType.HasFlag <ShaderType>(ShaderType.TessellationEvaluation)) { builtIn[ShaderType.TessellationEvaluation].Add(completion); } if (definitions[i].ShaderType.HasFlag <ShaderType>(ShaderType.Fragment)) { builtIn[ShaderType.Fragment].Add(completion); } } } }