public override SyntaxNode VisitField(FieldSyntax node) { PropertyValueSyntax fieldClass = node.GetPropertyValue("FieldClass"); if ((fieldClass == null) || (fieldClass.ToString().Equals("Normal", StringComparison.CurrentCultureIgnoreCase))) { PropertySyntax propertySyntax = node.GetProperty("DataClassification"); if (propertySyntax == null) { NoOfChanges++; return(node.AddPropertyListProperties( this.CreateDataClassificationProperty(node))); } else { string valueText = propertySyntax.Value.ToString(); if ((String.IsNullOrWhiteSpace(valueText)) || (valueText.Equals("ToBeClassified", StringComparison.CurrentCultureIgnoreCase))) { NoOfChanges++; return(node.ReplaceNode(propertySyntax, this.CreateDataClassificationProperty(node))); } } } return(base.VisitField(node)); }
public void ExecuteSimple() { var field = new FieldSyntax { Name = new NameSyntax { Value = "key" }, Value = new ListSyntax { new TextSyntax { Text = "value" } } }; var objectField = fieldInstruction.Evaluate(CompilerStateFixtures.Empty(), field); Assert.IsType <ObjectField>(objectField); var castedField = (ObjectField)objectField; Assert.Equal("key", castedField.Key); var resultArguments = (Argument[])castedField.Argument.Value; var paragraph = (Paragraph)resultArguments[0].Value; var leaf = (ITextLeaf)paragraph.Leaves[0]; Assert.Equal("value", leaf.Content); }
public static Argument Evaluate(CompilerState state, SyntaxNode node) { if (state is null) { throw new ArgumentNullException(nameof(state)); } if (node is null) { throw new ArgumentNullException(nameof(node)); } var result = node switch { TextSyntax text => textInstruction.Evaluate(state, text), QuoteSyntax quote => quoteInstruction.Evaluate(state, quote), StringLiteralSyntax stringLiteral => stringInstruction.Evaluate(state, stringLiteral), ArgumentSyntax argumentSyntax => argumentInstruction.Evaluate(state, argumentSyntax), CommandSyntax command => commandInstruction.Evaluate(state, command), ObjectSyntax objectSyntax => objectCreationInstruction.Evaluate(state, objectSyntax), FieldSyntax fieldSyntax => fieldInstruction.Evaluate(state, fieldSyntax), ArraySyntax arraySyntax => arrayInstruction.Evaluate(state, arraySyntax), PercentSyntax percentSyntax => percentInstruction.Evaluate(state, percentSyntax), ListSyntax list => blockInstruction.Evaluate(state, list), CommentSyntax _ => null, _ => throw new ArgumentException($"Evaluation of node type {node.GetType().Name} not implemented.", nameof(node)), }; return(new Argument(node, result)); }
public override SyntaxNode VisitField(FieldSyntax node) { if ((this.NodeInSpan(node)) && (node.Triggers != null) && (node.Triggers.Count > 0) && (!node.ContainsDiagnostics)) { node = node.WithTriggers(this.Sort(node.Triggers)); } return(base.VisitField(node)); }
public TableFieldTypeInformation(FieldSyntax fieldSyntax) : this(fieldSyntax.GetNameStringValue()) { PropertyValueSyntax propValue = fieldSyntax.GetPropertyValue("Caption"); if (propValue != null) { this.Caption = ALSyntaxHelper.DecodeString(propValue.ToString()); } this.DataType = fieldSyntax.Type.ToString(); }
public SyntaxTokenCollection Format(FieldSyntax syntax) { SyntaxTokenCollection tokens = new SyntaxTokenCollection(); tokens.AddRange(GetVisibility(syntax)); tokens.Add(Constants.Space); tokens.Add(GetType(syntax)); tokens.Add(Constants.Space); tokens.Add(new SyntaxToken(syntax.GetIdentifier(), SyntaxTokens.Text)); return(tokens); }
protected void ProcessFieldNode(ALSymbolInformation symbol, FieldSyntax syntax) { Type syntaxType = syntax.GetType(); if (syntax.No != null) { string idText = syntax.No.ToString(); int id = 0; if (Int32.TryParse(idText, out id)) { symbol.id = id; } } symbol.fullName = ALSyntaxHelper.EncodeName(symbol.name) + ": " + syntax.Type.ToFullString(); }
public void TestFieldCaptionPropertyValidation() { CancellationTokenSource source = new CancellationTokenSource(); CancellationToken token = source.Token; FieldSyntax fieldSyntax = null; IEnumerable <SyntaxNode> objectNodes = (SyntaxTree.ParseObjectText(GenerateFakeTableObject()).GetRoot(token) as ObjectCompilationUnitSyntax).Objects.FirstOrDefault().DescendantNodes(); foreach (SyntaxNode syntax in objectNodes) { if (syntax.Kind == SyntaxKind.Field) { fieldSyntax = syntax as FieldSyntax; } } SyntaxNodeAnalysisContext context = new SyntaxNodeAnalysisContext(); CaptionPropertyValidation.AnalyzeTableFieldsCaption(context); if (fieldSyntax != null) { CaptionPropertyValidation.AnalyzeTableFieldsCaptions(context, fieldSyntax); } }
public List <SyntaxToken> GetVisibility(FieldSyntax syntax) { return(FormatVisibility(syntax.GetVisibility())); }
public SyntaxToken GetType(FieldSyntax syntax) { return(FormatTypeName(syntax.GetType())); }
public static void AnalyzeTableFieldsCaption(SyntaxNodeAnalysisContext context) { FieldSyntax syntax = context.Node as FieldSyntax; AnalyzeTableFieldsCaptions(context, syntax); }
public virtual void Visit(FieldSyntax fieldSyntax) { if (fieldSyntax.Initializer != null) { Visit(fieldSyntax.Initializer); } }
public BoundField(string name, FieldSyntax syntax) : base(syntax) { Name = name; }
private static FieldSyntax?ParseField(ParserContext context) { var token = context.Tokens.Peek(); var span = token.Span; SkipWhitespaceTokens(context); var nextToken = context.Tokens.Peek(1); NameSyntax?name; if (nextToken.Type == TokenType.Colon) { name = ParseName(context); // Remove colon token here context.Tokens.Dequeue(2); token = context.Tokens.Peek(); } else { // In order to parse the next field correctly, we read the current field to the end. ParseBlock(context, TokenType.Semicolon, TokenType.CurlyClose); nextToken = context.Tokens.Peek(); span = span.WithEnd(nextToken.Span.End); context.Issues.Add(span, ParserIssueType.Error, "Field name and : expected."); return(null); } SkipWhitespaceTokens(context); var argument = new FieldSyntax { Name = name }; if (token.Type != TokenType.None) { argument.Value = ParseBlock(context, TokenType.Semicolon, TokenType.CurlyClose); } else { argument.Value = new ListSyntax(); } token = context.Tokens.Peek(); if (token.Type != TokenType.None) { if (token.Type == TokenType.Semicolon) { context.Tokens.Dequeue(); } else if (token.Type != TokenType.CurlyClose) { context.Issues.Add(token, ParserIssueType.Error, "Expected the end of a field via ; or }."); } } else { context.Issues.Add(argument, ParserIssueType.Error, "Expected the end of a field via ; or }."); } CleanText(argument.Value); argument.Span = span.WithEnd(token.Span.End); return(argument); }
public static void AnalyzeTableFieldsCaptions(SyntaxNodeAnalysisContext context, FieldSyntax syntax) { if (syntax == null) { return; } PropertyListSyntax propertyListSyntax = syntax.PropertyList; PropertySyntax propertySyntax = GetProperty(propertyListSyntax.Properties, "Caption"); if (propertySyntax == null) { ReportTableFieldsMustHaveCaptionProperty(context, propertyListSyntax.GetLocation(), syntax.Name.ToString(), syntax.Kind, syntax.Name); } }
public CSharpFieldFormatter(FieldSyntax syntax) { _syntax = syntax; }
public VBFieldFormatter(FieldSyntax syntax) { _syntax = syntax; }
private void BindField(BoundField field, FieldSyntax syntax) { var qualifier = GetQualifier(syntax.Qualifier.Type); field.Qualifier = qualifier; var boundExpression = BindExpression(syntax.Initializer); field.Initializer = boundExpression; field.Type = boundExpression.Type; }