bool Conflict(VariableComponentCollection collection, AttributeType attributeType, string message)
 {
     if (collection.IsAttribute(attributeType))
     {
         collection.Diagnostics.Error(message, Range);
         WasRejected = true;
         return(false);
     }
     return(true);
 }
 public void Validate(VariableComponentCollection componentCollection)
 {
     switch (Attribute)
     {
     // Ref variables cannot be used alongside initial values.
     case AttributeType.Ref:
         if (componentCollection.TryGetComponent(out InitialValueComponent initialValueComponent))
         {
             componentCollection.Diagnostics.Error("'ref' variables cannot have an initial value", initialValueComponent.Range);
             initialValueComponent.WasRejected = true;
         }
         break;
     }
 }
        public bool CheckConflicts(VariableComponentCollection collection)
        {
            switch (Attribute)
            {
            // globalvar conflicting with playervar
            case AttributeType.GlobalVar:
                return(Conflict(collection, AttributeType.PlayerVar, "The 'globalvar' attribute cannot be used alongside the 'playervar' attribute"));

            // playervar conflicting with globalvar
            case AttributeType.PlayerVar:
                return(Conflict(collection, AttributeType.GlobalVar, "The 'playervar' attribute cannot be used alongside the 'globalvar' attribute"));

            // in conflicting with ref
            case AttributeType.In:
                return(Conflict(collection, AttributeType.Ref, "The 'in' attribute cannot be used alongside the 'ref' attribute"));

            // ref conflicting with in
            case AttributeType.Ref:
                return(Conflict(collection, AttributeType.In, "The 'ref' attribute cannot be used alongside the 'in' attribute"));
            }
            return(true);
        }
 public bool CheckConflicts(VariableComponentCollection componentCollection) => true;
 public void Validate(VariableComponentCollection componentCollection)
 {
 }