Beispiel #1
0
        public void TestTextCheckRestrictedSymbols()
        {
            const string AllChars = "abcdefghijklmnopqrstuvwxyz \n\t абвгдеёжзийклмнопрстуфхцчшщьыъэюя 1234567890 \\ \" .,;:~'`!? №@#$%^&_ []{}()<> /*-+=";
            var          value    = new TextElementValue {
                Raw = AllChars
            };
            var constraints = new PlainTextElementConstraints();

            var errorSpace = TestHelpers.MakeValidationCheck <TextElementValue, NonBreakingSpaceSymbolError>(
                value,
                constraints,
                PlainTextValidator.CheckRestrictedSymbols,
                val => val.Raw = "\x00A0");

            Assert.Equal(nameof(constraints.WithoutNonBreakingSpace), errorSpace.ErrorType);

            value.Raw = AllChars.ToUpper();
            var errorControlChars = TestHelpers.MakeValidationCheck <TextElementValue, ControlCharactersInTextError>(
                value,
                constraints,
                PlainTextValidator.CheckRestrictedSymbols,
                val => val.Raw = "\r");

            Assert.Equal(nameof(constraints.WithoutControlChars), errorControlChars.ErrorType);
        }
Beispiel #2
0
        public void TestFasCommentCheckRestrictedSymbols()
        {
            const string AllChars = "abcdefghijklmnopqrstuvwxyz \n\t абвгдеёжзийклмнопрстуфхцчшщьыъэюя 1234567890 \\ \" .,;:~'`!? №@#$%^&|_ []{}()<> /*-+=";
            var          value    = new FasElementValue {
                Raw = "custom", Text = AllChars
            };
            var constraints = new PlainTextElementConstraints();

            TestHelpers.MakeValidationCheck <FasElementValue, NonBreakingSpaceSymbolError>(value, constraints, PlainTextValidator.CheckRestrictedSymbols, val => val.Text = "\x00A0");

            value.Text = AllChars.ToUpper();
            TestHelpers.MakeValidationCheck <FasElementValue, ControlCharactersInTextError>(value, constraints, PlainTextValidator.CheckRestrictedSymbols, val => val.Text = "\r");
        }
        private async Task UpdateListCaches()
        {
            AllChars = await Task.Run(() => ActiveList.Concat(InactiveList).ToList());

            Allies = await Task.Run(() => AllChars.Where(x => x.PlayerControlled).ToList());

            Enemies = await Task.Run(() => AllChars.Where(x => !x.PlayerControlled).ToList());

            EventHandler handler = OnListUpdate;

            if (handler != null)
            {
                handler(this, EventArgs.Empty);
            }
        }
Beispiel #4
0
        public override void Initialize(GrammarData grammarData)
        {
            base.Initialize(grammarData);
            _allCharsSet = new CharHashSet(Grammar.CaseSensitive);
            _allCharsSet.UnionWith(AllChars.ToCharArray());

            //Adjust case restriction. We adjust only first chars; if first char is ok, we will scan the rest without restriction
            // and then check casing for entire identifier
            switch (CaseRestriction)
            {
            case CaseRestriction.AllLower:
            case CaseRestriction.FirstLower:
                _allFirstCharsSet = new CharHashSet(true);
                _allFirstCharsSet.UnionWith(AllFirstChars.ToLowerInvariant().ToCharArray());
                break;

            case CaseRestriction.AllUpper:
            case CaseRestriction.FirstUpper:
                _allFirstCharsSet = new CharHashSet(true);
                _allFirstCharsSet.UnionWith(AllFirstChars.ToUpperInvariant().ToCharArray());
                break;

            default:
                //None
                _allFirstCharsSet = new CharHashSet(Grammar.CaseSensitive);
                _allFirstCharsSet.UnionWith(AllFirstChars.ToCharArray());
                break;
            }
            //if there are "first" chars defined by categories, add the terminal to FallbackTerminals
            if (StartCharCategories.Count > 0)
            {
                grammarData.NoPrefixTerminals.Add(this);
            }

            if (EditorInfo == null)
            {
                EditorInfo = new TokenEditorInfo(TokenType.Identifier, TokenColor.Identifier, TokenTriggers.None);
            }
        }