Example #1
0
        public void Validate(DecoratorSyntax decoratorSyntax, TypeSymbol targetType, ITypeManager typeManager, IDiagnosticWriter diagnosticWriter)
        {
            if (targetType is ErrorType)
            {
                return;
            }

            this.validator?.Invoke(this.Overload.Name, decoratorSyntax, targetType, typeManager, diagnosticWriter);
        }
Example #2
0
        public ObjectSyntax?Evaluate(DecoratorSyntax decoratorSyntax, TypeSymbol targetType, ObjectSyntax?targetObject)
        {
            if (this.evaluator is null)
            {
                return(targetObject);
            }

            return(this.evaluator(decoratorSyntax, targetType, targetObject));
        }
Example #3
0
        public void Validate(DecoratorSyntax decoratorSyntax, TypeSymbol targetType, ITypeManager typeManager, IBinder binder, IDiagnosticWriter diagnosticWriter)
        {
            if (targetType is ErrorType)
            {
                return;
            }

            if (!this.CanAttachTo(targetType))
            {
                diagnosticWriter.Write(DiagnosticBuilder.ForPosition(decoratorSyntax).CannotAttachDecoratorToTarget(this.Overload.Name, attachableType, targetType));
            }

            // Invoke custom validator if provided.
            this.validator?.Invoke(this.Overload.Name, decoratorSyntax, targetType, typeManager, binder, diagnosticWriter);
        }
Example #4
0
        public void Validate(DecoratorSyntax decoratorSyntax, TypeSymbol targetType, ITypeManager typeManager, IDiagnosticWriter diagnosticWriter)
        {
            if (targetType is ErrorType)
            {
                return;
            }

            if (this.validator != null)
            {
                this.validator.Invoke(this.Overload.Name, decoratorSyntax, targetType, typeManager, diagnosticWriter);

                return;
            }

            // No custom validator provided. Just validate the target type.
            if (!this.CanAttachTo(targetType))
            {
                diagnosticWriter.Write(DiagnosticBuilder.ForPosition(decoratorSyntax).CannotAttacheDecoratorToTarget(this.Overload.Name, attachableType, targetType));
            }
        }
Example #5
0
 public override void VisitDecoratorSyntax(DecoratorSyntax syntax) =>
 this.BuildWithConcat(() => base.VisitDecoratorSyntax(syntax));
Example #6
0
 static SyntaxBase SingleArgumentSelector(DecoratorSyntax decoratorSyntax) => decoratorSyntax.Arguments.Single().Expression;
Example #7
0
 public override void VisitDecoratorSyntax(DecoratorSyntax syntax)
 {
     this.currentDecorator = syntax;
     base.VisitDecoratorSyntax(syntax);
     this.currentDecorator = null;
 }