public ParameterDefinition(IReadOnlyList <SyntaxType> typeQualifier, TypeDefinition type, string identifier, string documentation, IReadOnlyList <ColoredString> arraySpecifiers, Scope scope, TrackingSpan span) : base(ColoredString.Create(identifier, ColorType.Parameter), documentation, DefinitionKind.Parameter, scope, span) { this.TypeQualifiers = typeQualifier ?? new List <SyntaxType>(); this.Type = type; this.ArraySpecifiers = arraySpecifiers ?? new List <ColoredString>(); }
public FieldDefinition(IReadOnlyList <SyntaxType> typeQualifier, TypeDefinition type, string name, IReadOnlyList <ColoredString> arraySpecifiers, string documentation, Scope scope, TrackingSpan span) : base(ColoredString.Create(name, ColorType.Field), documentation, DefinitionKind.Field, scope, span) { this.TypeQualifiers = typeQualifier ?? new List <SyntaxType>(); this.Type = type; this.ArraySpecifiers = arraySpecifiers ?? new List <ColoredString>(); }
public override IReadOnlyList <ColoredString> GetColoredText() { List <ColoredString> list = new List <ColoredString>(); list.AddRange(this.ReturnType.GetColoredText()); list.Add(ColoredString.Space); list.Add(this.Name); list.Add(ColoredString.Create("(", ColorType.Punctuation)); for (int i = 0; i < this.Parameters.Count; i++) { if (i != 0) { list.Add(ColoredString.Create(",", ColorType.Punctuation)); list.Add(ColoredString.Space); } list.AddRange(this.Parameters[i].GetColoredText()); } list.Add(ColoredString.Create(")", ColorType.Punctuation)); return(list); }
public UserVariableDefinition(StructDeclaratorSyntax declarator, IdentifierSyntax identifier, string documentation, DefinitionKind kind, Scope scope) : base(documentation, kind, scope, identifier.Span) { if (kind == DefinitionKind.LocalVariable) { this.Name = ColoredString.Create(identifier.Identifier, ColorType.LocalVariable); } else { this.Name = ColoredString.Create(identifier.Identifier, ColorType.GlobalVariable); } InterfaceBlockSyntax block = declarator.Parent as InterfaceBlockSyntax; this.TypeQualifiers = block.TypeQualifier?.ToSyntaxTypes() ?? new List <SyntaxType>(); this.Type = new TypeDefinition(SyntaxType.TypeName); List <ColoredString> arraySpecifiers = new List <ColoredString>(); for (int i = 0; i < declarator.ArraySpecifiers.Count; i++) { arraySpecifiers.AddRange(declarator.ArraySpecifiers[i].ToColoredString()); } this.ArraySpecifiers = arraySpecifiers; }
protected virtual void GetColoredString(List <ColoredString> list) { if (this.SyntaxType == SyntaxType.WhiteSpaceTrivia) { list.Add(ColoredString.Create(this.text, ColorType.WhiteSpace)); } }
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 FieldDefinition Create(SyntaxType type, string name, bool isArray) { if (isArray) { return(new FieldDefinition(null, new TypeDefinition(type), name, new List <ColoredString> { ColoredString.Create("[", ColorType.Punctuation), ColoredString.Create("]", ColorType.Punctuation) }, string.Empty, Scope.BuiltIn, null)); } else { return(new FieldDefinition(null, new TypeDefinition(type), name, string.Empty, Scope.BuiltIn, null)); } }
public UserVariableDefinition(ConditionSyntax condition, IdentifierSyntax identifier, string documentation, DefinitionKind kind, Scope scope) : base(documentation, kind, scope, identifier.Span) { if (kind == DefinitionKind.LocalVariable) { this.Name = ColoredString.Create(identifier.Identifier, ColorType.LocalVariable); } else { this.Name = ColoredString.Create(identifier.Identifier, ColorType.GlobalVariable); } this.TypeQualifiers = condition.TypeQualifier?.ToSyntaxTypes() ?? new List <SyntaxType>(); this.Type = new TypeDefinition(condition.TypeSyntax); this.ArraySpecifiers = new List <ColoredString>(); }
public override IReadOnlyList <ColoredString> GetColoredText() { List <ColoredString> list = new List <ColoredString>(); if (this.TypeQualifiers.Count > 0) { list.AddRange(this.TypeQualifiers.ConvertList(text => text.ToColoredString(), ColoredString.Space, true)); } list.AddRange(this.Type.GetColoredText()); list.Add(ColoredString.Space); list.Add(this.Name); list.AddRange(this.ArraySpecifiers); list.Add(ColoredString.Create(";", ColorType.Punctuation)); return(list); }
public override IReadOnlyList <ColoredString> GetColoredText() { List <ColoredString> list = new List <ColoredString>(); list.Add(this.Name); if (this.Parameters.Count > 0) { list.Add(ColoredString.Create("(", ColorType.Punctuation)); list.AddRange(this.Parameters); list.Add(ColoredString.Create(")", ColorType.Punctuation)); } list.Add(ColoredString.Space); list.AddRange(this.TokenString); return(list); }
internal static ParameterDefinition[] Create(string type, string name, int arraySize) { string[] types; if (BuiltInData.GenTypes.TryGetValue(type, out types)) { ParameterDefinition[] parameters = new ParameterDefinition[types.Length]; for (int i = 0; i < types.Length; i++) { parameters[i] = new ParameterDefinition(null, new TypeDefinition(types[i].GetSyntaxType()), name, string.Empty, new List <ColoredString> { ColoredString.Create("[", ColorType.Punctuation), ColoredString.Create(arraySize.ToString(), ColorType.Number), ColoredString.Create("]", ColorType.Punctuation) }, Scope.BuiltIn, null); } return(parameters); } else { return(new ParameterDefinition[] { new ParameterDefinition(null, new TypeDefinition(type.GetSyntaxType()), name, string.Empty, new List <ColoredString> { ColoredString.Create("[", ColorType.Punctuation), ColoredString.Create(arraySize.ToString(), ColorType.Number), ColoredString.Create("]", ColorType.Punctuation) }, Scope.BuiltIn, null) }); } }
protected override void ToColoredString(List <ColoredString> list) { ColorType type = ColorType.Identifier; if (this.SyntaxType.IsPreprocessor()) { type = ColorType.PreprocessorKeyword; } else if (this?.IsExcludedCode() ?? false) { type = ColorType.ExcludedCode; } else if (this.SyntaxType.IsPunctuation()) { type = ColorType.Punctuation; } else if (this?.IsPreprocessorText() ?? false) { type = ColorType.PreprocessorText; } else if (this.SyntaxType.IsKeyword()) { type = ColorType.Keyword; } else if (this.SyntaxType.IsNumber()) { type = ColorType.Number; } list.Add(ColoredString.Create(this.Text, type)); if (this.HasTrailingTrivia) { this.TrailingTrivia.ToColoredString(list); } }
public InterfaceBlockDefinition(IReadOnlyList <SyntaxType> typeQualifier, string typeName, string documentation, List <FieldDefinition> fields, Scope scope, TrackingSpan span) : base(ColoredString.Create(typeName, ColorType.TypeName), documentation, DefinitionKind.InterfaceBlock, scope, span) { this.TypeQualifiers = typeQualifier ?? new List <SyntaxType>(); this.InternalFields = fields ?? new List <FieldDefinition>(); }
internal TypeNameDefinition(string name, string documentation, Scope scope, TrackingSpan span) : base(ColoredString.Create(name, ColorType.TypeName), documentation, DefinitionKind.TypeName, scope, span) { }
internal TypeNameDefinition(string name, string documentation, List <FieldDefinition> fields, Scope scope, TrackingSpan span) : base(ColoredString.Create(name, ColorType.TypeName), documentation, DefinitionKind.TypeName, scope, span) { this.InternalFields = fields; }
protected override void ToColoredString(List <ColoredString> list) { ColorType type = ColorType.Identifier; if (this.SyntaxType.IsPreprocessor()) { type = ColorType.PreprocessorKeyword; } if (this.Definition?.Kind == DefinitionKind.Macro) { type = ColorType.Macro; } if (this.IsExcludedCode()) { type = ColorType.ExcludedCode; } if (this.SyntaxType.IsPunctuation()) { type = ColorType.Punctuation; } if (this.IsPreprocessorText()) { type = ColorType.PreprocessorText; } if (this.SyntaxType.IsKeyword()) { type = ColorType.Keyword; } if (this.SyntaxType.IsNumber()) { type = ColorType.Number; } if (this.Definition != null) { switch (this.Definition.Kind) { case DefinitionKind.Field: type = ColorType.Field; break; case DefinitionKind.Function: type = ColorType.Function; break; case DefinitionKind.GlobalVariable: type = ColorType.GlobalVariable; break; case DefinitionKind.LocalVariable: type = ColorType.LocalVariable; break; case DefinitionKind.Macro: type = ColorType.Macro; break; case DefinitionKind.Parameter: type = ColorType.Parameter; break; case DefinitionKind.TypeName: case DefinitionKind.InterfaceBlock: type = ColorType.TypeName; break; } } list.Add(ColoredString.Create(this.Text, type)); if (this.HasTrailingTrivia) { this.TrailingTrivia.ToColoredString(list); } }
public MacroDefinition(string name, IReadOnlyList <ColoredString> parameters, IReadOnlyList <ColoredString> tokenString, string documentation, Scope scope, TrackingSpan span) : base(ColoredString.Create(name, ColorType.Macro), documentation, DefinitionKind.Macro, scope, span) { this.Parameters = parameters ?? new List <ColoredString>(); this.TokenString = tokenString ?? new List <ColoredString>(); }
public FunctionDefinition(TypeDefinition returnType, string identifier, List <ParameterDefinition> parameters, string documentation, Scope scope, TrackingSpan span) : base(ColoredString.Create(identifier, ColorType.Function), documentation, DefinitionKind.Function, scope, span) { this.ReturnType = returnType; this.InternalParameters = parameters; }