コード例 #1
0
        public async Task <User> GetUser(string key)

        {
            List <UserHistory> userHistory = new List <UserHistory>();

            //throw new System.NotImplementedException();
            var scannerOptions = new ScannerOptions
            {
                TableName = "dewey_users",
                Filter    = new PrefixFilter(key)
            };

            using (IScanner scanner = await StargateApi.CreateScannerAsync(scannerOptions))
            {
                //     int count = scanner.Count();
                foreach (CellSet result in scanner)
                {
                    userHistory.AddRange(
                        result.GroupBy(a => a.Identifier.Row).Select(a =>
                                                                     new UserHistory(a.Key, new CellSet(a))
                                                                     ));
                }
            }
            return(User.CreateUser(userHistory));
        }
コード例 #2
0
ファイル: XmlTestCase.cs プロジェクト: VAllens/cvsi
        public void IncompleteXmlTagInsideXmlTagBreaksOutOfXmlTagWhenInIntelliSenseMode()
        {
            Scanner        scanner        = new Scanner(new ErrorHandler());
            ScannerOptions scannerOptions = new ScannerOptions();

            scannerOptions.EnableIntelliSenseTriggerTokens = true;
            scanner.Options = scannerOptions;

            scanner.SetSource(
                "<div>\n" +
                "    <a \n" +
                "</div>");

            AssertMatchToken(scanner, TokenType.XmlTagStart);
            AssertMatchToken(scanner, TokenType.XmlTagName, "div");
            AssertMatchToken(scanner, TokenType.XmlTagEnd);

            AssertMatchToken(scanner, TokenType.XmlText, "\n    ");
            AssertMatchToken(scanner, TokenType.XmlTagStart);
            AssertMatchToken(scanner, TokenType.XmlTagName, "a");
            AssertMatchToken(scanner, TokenType.XmlAttributeMemberSelect, " ");
            AssertMatchToken(scanner, TokenType.XmlAttributeMemberSelect, "\n");
            // When in IntelliSense mode the scanner should drop out of a tag if it finds a '<'

            AssertMatchToken(scanner, TokenType.XmlTagStart);
            AssertMatchToken(scanner, TokenType.XmlForwardSlash);
            AssertMatchToken(scanner, TokenType.XmlTagName, "div");
            AssertMatchToken(scanner, TokenType.XmlTagEnd);

            AssertEOF();
        }
コード例 #3
0
        public async Task <IEnumerable <User> > GetUsers(bool?isDelete = null)
        {
            List <UserHistory> userHistory = new List <UserHistory>();

            //throw new System.NotImplementedException();
            var scannerOptions = new ScannerOptions
            {
                TableName = "dewey_users",
                Filter    = new PrefixFilter(string.Empty)
            };

            using (IScanner scanner = await StargateApi.CreateScannerAsync(scannerOptions))
            {
                //     int count = scanner.Count();
                foreach (CellSet result in scanner)
                {
                    userHistory.AddRange(
                        result.GroupBy(a => a.Identifier.Row).Select(a =>
                                                                     new UserHistory(a.Key, new CellSet(a))
                                                                     ));
                }
            }

            IEnumerable <User> users =
                userHistory
                .GroupBy(a => a.UserKey)
                .Select(a => User.CreateUser(a.ToList()));

            if (isDelete.HasValue)
            {
                users = users.Where(a => a.IsDeleted == isDelete);
            }

            return(users);
        }
コード例 #4
0
        public void Sync(IComponentSerializer ser)
        {
            if (ser.IsReader)
            {
                int option = 0;
                ser.Sync(nameof(_scannerOptions), ref option);
                _scannerOptions = (ScannerOptions)option;
            }
            else
            {
                int option = (int)_scannerOptions;
                ser.Sync(nameof(_scannerOptions), ref option);
            }

            ser.Sync(nameof(_isVBlank), ref _isVBlank);
            ser.Sync(nameof(_framebuffer), ref _framebuffer, false);
            ser.Sync(nameof(_isTextInversed), ref _isTextInversed);
            ser.Sync(nameof(_cyclesPerVBlank), ref _cyclesPerVBlank);
            ser.Sync(nameof(_cyclesPerVBlankPreset), ref _cyclesPerVBlankPreset);
            ser.Sync(nameof(_cyclesPerVSync), ref _cyclesPerVSync);
            ser.Sync(nameof(_cyclesPerFlash), ref _cyclesPerFlash);
            ser.Sync(nameof(_vCountPreset), ref _vCountPreset);
            ser.Sync(nameof(_vLineLeaveVBlank), ref _vLineLeaveVBlank);
            ser.Sync(nameof(_charSet), ref _charSet, false);
            ser.Sync(nameof(_isCellDirty), ref _isCellDirty, false);
            ser.Sync(nameof(_isMonochrome), ref _isMonochrome);
        }
コード例 #5
0
        public void ParseXmlElementWithSingleQuotesAroundAttribute()
        {
            ScannerOptions scannerOptions = new ScannerOptions();

            scannerOptions.EnableIntelliSenseTriggerTokens = true;

            Parser       parser   = GetNewParser(scannerOptions, "<tag attr='value'/>");
            TemplateNode template = parser.ParseTemplate();

            // Template has 1 XML Element
            XmlElement xmlElement = (XmlElement)template.Content[0];

            // Element has 1 Attribute
            Assert.AreEqual(1, xmlElement.Attributes.Count);
            XmlAttribute xmlAttribute = (XmlAttribute)xmlElement.Attributes[0];

            Assert.AreEqual("attr", xmlAttribute.Name);

            // Element has 1 XML text node
            Assert.AreEqual(1, xmlAttribute.Content.Count);
            XmlTextNode xmlTextNode = (XmlTextNode)xmlAttribute.Content[0];

            Assert.AreEqual("value", xmlTextNode.Text);

            AssertNoErrors(parser);
        }
コード例 #6
0
        public void ParsePartialNVReferenceWithDollarIdentDotIdentLParen()
        {
            ScannerOptions scannerOptions = new ScannerOptions();

            scannerOptions.EnableIntelliSenseTriggerTokens = true;

            Parser       parser   = GetNewParser(scannerOptions, "$Ajax.LinkToRemote(");
            TemplateNode template = parser.ParseTemplate();

            // Check errors
            Assert.AreEqual(2, parser.Errors.Count);
            AssertError("Expected expression, was 'Error'", new Position(1, 20, 1, 20), parser.Errors[0]);
            AssertError("Expected 'NVRParen' but was 'Error'", new Position(1, 20, 1, 20), parser.Errors[1]);

            // Check the TemplateNode
            Assert.AreEqual(1, template.Content.Count);
            NVReference nvReference = (NVReference)template.Content[0];

            Assert.AreEqual("Ajax", nvReference.Designator.Name);

            Assert.AreEqual(1, nvReference.Designator.Selectors.Count);
            NVSelector selector = nvReference.Designator.Selectors[0];

            Assert.AreEqual("LinkToRemote", selector.Name);
            Assert.AreEqual(0, selector.Actuals.Count);
        }
コード例 #7
0
 public ScannerFileEnumerator(string directory, ScannerOptions options)
     : base(directory, GetEnumerationOptions(options))
 {
     _options       = options;
     _shouldScan    = options.ShouldScanFilePredicate ?? s_truePredicate;
     _shouldRecurse = options.ShouldRecursePredicate ?? s_truePredicate;
 }
コード例 #8
0
        public void ParsePartialNVReferenceWithDollarIdentDotInXmlElement()
        {
            ScannerOptions scannerOptions = new ScannerOptions();

            scannerOptions.EnableIntelliSenseTriggerTokens = true;

            Parser parser = GetNewParser(
                "<tag>\n" +
                "  $Ajax.\n" +
                "</tag>");
            TemplateNode templateNode = parser.ParseTemplate();

            // Check the TemplateNode
            Assert.AreEqual(1, templateNode.Content.Count);
            XmlElement  xmlElement  = (XmlElement)templateNode.Content[0];
            NVReference nvReference = (NVReference)xmlElement.Content[1];

            Assert.AreEqual("Ajax", nvReference.Designator.Name);
            Assert.AreEqual(1, nvReference.Designator.Selectors.Count);

            AssertPosition(new Position(1, 1, 3, 7), xmlElement.Position);
            AssertPosition(new Position(2, 3, 2, 9), nvReference.Position);
            AssertPosition(new Position(2, 3, 2, 9), nvReference.Designator.Position);
            AssertPosition(new Position(2, 8, 2, 9), nvReference.Designator.Selectors[0].Position);
        }
コード例 #9
0
        public async Task <IEnumerable <File> > GetUserFile(string userKey, bool?isDelete = null)
        {
            List <FileHistory> fileHistory = new List <FileHistory>();

            //throw new System.NotImplementedException();
            var scannerOptions = new ScannerOptions
            {
                TableName = "dewey_files",
                Filter    = new PrefixFilter(userKey),
            };

            using (IScanner scanner = await StargateApi.CreateScannerAsync(scannerOptions))
            {
                //     int count = scanner.Count();
                foreach (CellSet result in scanner)
                {
                    fileHistory.AddRange(
                        result.GroupBy(a => a.Identifier.Row).Select(a =>
                                                                     new FileHistory(a.Key, new CellSet(a))
                                                                     ));
                }
                IEnumerable <File> files =
                    fileHistory
                    .GroupBy(a => a.KeyUserFile)
                    .Select(a => File.CreateFile(a.ToList()));

                if (isDelete.HasValue)
                {
                    files = files.Where(a => a.IsDeleted == isDelete);
                }

                return(files);
            }
        }
コード例 #10
0
        /// <summary>
        ///    Converts the specified options to an XML document with
        ///    filter options as embedded JSON.
        /// </summary>
        /// <param name="options">The options.</param>
        public string Convert(ScannerOptions options)
        {
            var xml = new XElement(_scannerName);

            if (!string.IsNullOrEmpty(options.StartRow))
            {
                xml.Add(new XAttribute(_startRowName, _codec.Encode(options.StartRow)));
            }

            if (!string.IsNullOrEmpty(options.StopRow))
            {
                xml.Add(new XAttribute(_stopRowName, _codec.Encode(options.StopRow)));
            }

            if (options.BatchSize.HasValue)
            {
                xml.Add(new XAttribute(_batchSizeName, options.BatchSize));
            }

            if (options.Filter != null)
            {
                xml.Add(new XElement(_filterName)
                {
                    Value = options.Filter.ConvertToJson(_codec).ToString()
                });
            }

            return(xml.ToString());
        }
コード例 #11
0
ファイル: ParserTestBase.cs プロジェクト: jonorossi/cvsi
        protected static Parser GetNewParser(ScannerOptions scannerOptions, string template)
        {
            Scanner scanner = new Scanner(new ErrorHandler());
            scanner.Options = scannerOptions;
            scanner.SetSource(template);

            return new Parser(scanner, new ErrorHandler());
        }
コード例 #12
0
 private static EnumerationOptions GetEnumerationOptions(ScannerOptions options)
 {
     return(new EnumerationOptions
     {
         RecurseSubdirectories = options.RecurseSubdirectories,
         IgnoreInaccessible = true,
         ReturnSpecialDirectories = false,
     });
 }
コード例 #13
0
        protected static Parser GetNewParser(ScannerOptions scannerOptions, string template)
        {
            Scanner scanner = new Scanner(new ErrorHandler());

            scanner.Options = scannerOptions;
            scanner.SetSource(template);

            return(new Parser(scanner, new ErrorHandler()));
        }
コード例 #14
0
        public void DefaultScannersIncludeAllScanners()
        {
            var scanners = new ScannerOptions().Scanners.Select(t => t.GetType()).OrderBy(t => t.FullName).ToArray();

            var allScanners = typeof(ScannerOptions).Assembly.GetExportedTypes()
                              .Where(type => !type.IsAbstract && type.IsAssignableTo(typeof(DependencyScanner)) && type != typeof(RegexScanner))
                              .OrderBy(t => t.FullName)
                              .ToArray();

            Assert.NotEmpty(scanners);
            Assert.Equal(allScanners, scanners);
        }
コード例 #15
0
        public void XmlElementsHaveParentElements()
        {
            ScannerOptions scannerOptions = new ScannerOptions();

            scannerOptions.EnableIntelliSenseTriggerTokens = true;

            Parser       parser       = GetNewParser(scannerOptions, "<outer><inner></inner></outer>");
            TemplateNode templateNode = parser.ParseTemplate();

            Assert.AreEqual(
                templateNode.Content[0],
                ((XmlElement)((XmlElement)templateNode.Content[0]).Content[0]).Parent);

            AssertNoErrors(parser);
        }
コード例 #16
0
        public void ParseForeachDirectiveWithStartOfReference()
        {
            ScannerOptions scannerOptions = new ScannerOptions();

            scannerOptions.EnableIntelliSenseTriggerTokens = true;

            Parser parser = GetNewParser(scannerOptions,
                                         "text #foreach($item in $collection) $  #end text");
            TemplateNode templateNode = parser.ParseTemplate();

            // Check Position, it should get to just after the '$'
            AssertPosition(new Position(1, 6, 1, 38), templateNode.Content[1].Position);

            Assert.AreEqual(2, parser.Errors.Count);
        }
コード例 #17
0
        public void ReferenceFollowedByReference()
        {
            ScannerOptions scannerOptions = new ScannerOptions();

            scannerOptions.EnableIntelliSenseTriggerTokens = true;
            Parser parser = GetNewParser(scannerOptions,
                                         "$Ajax.InstallScripts()\n$Form.");
            //                                 ^
            TemplateNode templateNode = parser.ParseTemplate();

            // Designator
            NVSelector designator = (NVSelector)templateNode.GetNodeAt(2, 7);

            AssertPosition(new Position(2, 6, 2, 7), designator.Position);
        }
コード例 #18
0
        public void AtEndOfUnclosedXmlElementWithAtLeastOneAttribute()
        {
            ScannerOptions scannerOptions = new ScannerOptions();

            scannerOptions.EnableIntelliSenseTriggerTokens = true;
            Parser parser = GetNewParser(scannerOptions,
                                         "<a name=\"\"     ");
            //               ^
            TemplateNode templateNode = parser.ParseTemplate();

            AstNode astNode = templateNode.GetNodeAt(1, 11);

            Assert.IsAssignableFrom(typeof(XmlElement), astNode);
            AssertPosition(new Position(1, 1, 1, 16), astNode.Position);
        }
コード例 #19
0
        public void ParseDirectiveStartWithNoNameFollowedByWhitespace()
        {
            ScannerOptions scannerOptions = new ScannerOptions();
            scannerOptions.EnableIntelliSenseTriggerTokens = true;

            Parser parser = GetNewParser(scannerOptions,
                "# ");
            TemplateNode templateNode = parser.ParseTemplate();

            // Ensure the whole directive is included
            AssertPosition(new Position(1, 1, 1, 3), templateNode.GetNodeAt(1, 1).Position);

            Assert.AreEqual(1, parser.Errors.Count);
            AssertError("Expected directive name", new Position(1, 3, 1, 3), parser.Errors[0]);
        }
コード例 #20
0
        public void ParseDirectiveStartWithNoNameFollowedByWhitespace()
        {
            ScannerOptions scannerOptions = new ScannerOptions();

            scannerOptions.EnableIntelliSenseTriggerTokens = true;

            Parser parser = GetNewParser(scannerOptions,
                                         "# ");
            TemplateNode templateNode = parser.ParseTemplate();

            // Ensure the whole directive is included
            AssertPosition(new Position(1, 1, 1, 3), templateNode.GetNodeAt(1, 1).Position);

            Assert.AreEqual(1, parser.Errors.Count);
            AssertError("Expected directive name", new Position(1, 3, 1, 3), parser.Errors[0]);
        }
コード例 #21
0
        public void SecondDesignatorSelector()
        {
            ScannerOptions scannerOptions = new ScannerOptions();

            scannerOptions.EnableIntelliSenseTriggerTokens = true;
            Parser parser = GetNewParser(scannerOptions,
                                         "$Ajax.InstallScripts.");
            //                        ^
            TemplateNode templateNode = parser.ParseTemplate();

            // Get node at position
            AstNode astNode = templateNode.GetNodeAt(1, 22);

            Assert.AreEqual(typeof(NVSelector), astNode.GetType());
            AssertPosition(new Position(1, 21, 1, 22), astNode.Position); // selectors include '.'
        }
コード例 #22
0
        public void ParseXmlElementWithEmptyAttributeValue()
        {
            ScannerOptions scannerOptions = new ScannerOptions();

            scannerOptions.EnableIntelliSenseTriggerTokens = true;

            Parser       parser       = GetNewParser(scannerOptions, "<tag attr=\"\" />");
            TemplateNode templateNode = parser.ParseTemplate();

            // Element has 1 attribute with no content nodes
            XmlAttribute xmlAttribute = ((XmlAttribute)((XmlElement)templateNode.Content[0]).Attributes[0]);

            Assert.AreEqual(0, xmlAttribute.Content.Count);

            AssertNoErrors(parser);
        }
コード例 #23
0
        public void ReferenceFollowedByText()
        {
            ScannerOptions scannerOptions = new ScannerOptions();

            scannerOptions.EnableIntelliSenseTriggerTokens = true;
            Parser parser = GetNewParser(scannerOptions,
                                         "$Ajax.InstallScripts() text\n        text");
            //                          ^      ^
            TemplateNode templateNode = parser.ParseTemplate();

            // XmlTextNode, it is only one text node
            XmlTextNode point1 = (XmlTextNode)templateNode.GetNodeAt(1, 24);
            XmlTextNode point2 = (XmlTextNode)templateNode.GetNodeAt(2, 2);

            AssertPosition(new Position(1, 23, 2, 13), point1.Position);
            AssertPosition(new Position(1, 23, 2, 13), point2.Position);
        }
コード例 #24
0
        public void AtEndOfUnclosedXmlTagWithOneAttributeInsideXmlContent()
        {
            ScannerOptions scannerOptions = new ScannerOptions();

            scannerOptions.EnableIntelliSenseTriggerTokens = true;
            Parser parser = GetNewParser(scannerOptions,
                                         "<div>\n" +
                                         "    <a name=\"\" \n" +
                                         //                ^
                                         "</div>");
            TemplateNode templateNode = parser.ParseTemplate();

            AstNode astNode = templateNode.GetNodeAt(2, 16);

            Assert.IsAssignableFrom(typeof(XmlElement), astNode);
            AssertPosition(new Position(2, 5, 2, 16), astNode.Position);
        }
コード例 #25
0
        public void InsideStringLiteralInReference()
        {
            ScannerOptions scannerOptions = new ScannerOptions();

            scannerOptions.EnableIntelliSenseTriggerTokens = true;
            Parser parser = GetNewParser(scannerOptions,
                                         "$obj.Method(\"");
            //                 ^
            TemplateNode templateNode = parser.ParseTemplate();

            // Get node at position
            AstNode astNode = templateNode.GetNodeAt(1, 14);

            //TODO finish
            //NVStringExpression stringExpr = (NVStringExpression)astNode;
            //Assert.AreEqual("", stringExpr.Value);
            //AssertPosition(new Position(1, 14, 1, 14), stringExpr.Position);
        }
コード例 #26
0
        public void IncompleteDirectiveFollowedByAnotherDirectiveBreaksOutOfFirstDirectiveParams()
        {
            ScannerOptions scannerOptions = new ScannerOptions();
            scannerOptions.EnableIntelliSenseTriggerTokens = true;
            Parser parser = GetNewParser(scannerOptions,
                "#component(\n" +
                "#component(MyComponent)");
            TemplateNode templateNode = parser.ParseTemplate();

            // Ensure that both directives have been parsed as separate directives
            Assert.AreEqual(2, templateNode.Content.Count);
            Assert.IsInstanceOfType(typeof(NVDirective), templateNode.Content[0]);
            Assert.IsInstanceOfType(typeof(NVDirective), templateNode.Content[1]);

            // Check the error about the incomplete directive
            Assert.AreEqual(1, parser.Errors.Count);
            AssertError("Incomplete directive.", new Position(2, 2, 2, 2), parser.Errors[0]);
        }
コード例 #27
0
        public void ParseXmlElementWithTwoAttributes()
        {
            ScannerOptions scannerOptions = new ScannerOptions();

            scannerOptions.EnableIntelliSenseTriggerTokens = true;

            Parser       parser       = GetNewParser(scannerOptions, "<tag attr1=\"\" attr2=\"\" />");
            TemplateNode templateNode = parser.ParseTemplate();

            // XML Element has 2 attributes
            XmlElement xmlElement = (XmlElement)templateNode.Content[0];

            Assert.AreEqual(2, xmlElement.Attributes.Count);
            Assert.AreEqual("attr1", ((XmlAttribute)xmlElement.Attributes[0]).Name);
            Assert.AreEqual("attr2", ((XmlAttribute)xmlElement.Attributes[1]).Name);

            AssertNoErrors(parser);
        }
コード例 #28
0
        public void ParsePartialNVReferenceOnlyWithDollar()
        {
            ScannerOptions scannerOptions = new ScannerOptions();
            scannerOptions.EnableIntelliSenseTriggerTokens = true;

            Parser parser = GetNewParser(scannerOptions, "$");
            TemplateNode template = parser.ParseTemplate();

            // Check errors
            Assert.AreEqual(1, parser.Errors.Count);
            Error error0 = parser.Errors[0];
            Assert.AreEqual("Expected reference identifier", error0.Description);
            AssertPosition(new Position(1, 2, 1, 2), error0.Position);
            Assert.AreEqual(ErrorSeverity.Error, error0.Severity);

            // Check the TemplateNode
            Assert.AreEqual(1, template.Content.Count);
            Assert.AreEqual(typeof(NVReference), template.Content[0].GetType());
        }
コード例 #29
0
        public void IncompleteDirectiveFollowedByAnotherDirectiveBreaksOutOfFirstDirectiveParams()
        {
            ScannerOptions scannerOptions = new ScannerOptions();

            scannerOptions.EnableIntelliSenseTriggerTokens = true;
            Parser parser = GetNewParser(scannerOptions,
                                         "#component(\n" +
                                         "#component(MyComponent)");
            TemplateNode templateNode = parser.ParseTemplate();

            // Ensure that both directives have been parsed as separate directives
            Assert.AreEqual(2, templateNode.Content.Count);
            Assert.IsInstanceOfType(typeof(NVDirective), templateNode.Content[0]);
            Assert.IsInstanceOfType(typeof(NVDirective), templateNode.Content[1]);

            // Check the error about the incomplete directive
            Assert.AreEqual(1, parser.Errors.Count);
            AssertError("Incomplete directive.", new Position(2, 2, 2, 2), parser.Errors[0]);
        }
コード例 #30
0
        public void StartOfDesignator()
        {
            ScannerOptions scannerOptions = new ScannerOptions();

            scannerOptions.EnableIntelliSenseTriggerTokens = true;
            Parser parser = GetNewParser(scannerOptions,
                                         "$");
            //    ^
            TemplateNode templateNode = parser.ParseTemplate();

            // Check template
            Assert.AreEqual(1, templateNode.Content.Count);
            Assert.AreEqual(typeof(NVReference), templateNode.Content[0].GetType());

            // Get node at position
            AstNode astNode = templateNode.GetNodeAt(1, 2);

            Assert.AreEqual(typeof(NVDesignator), astNode.GetType());
            AssertPosition(new Position(1, 1, 1, 2), astNode.Position);
        }
コード例 #31
0
        public void ScanTest_MultiLineComment()
        {
            string content =
                @"/* comment */";

            string vocabulary = @"
                \s WHITE_SPACE
                \$ NEW_LINE
                /\*(\.|\$)*\*/ MULTI_LINE_COMMENT";

            var table   = TransitionTable.FromVocabularyString(vocabulary);
            var options = new ScannerOptions {
                Transitions = table, BlackList = Empty <TokenTag> .Array
            };
            var tokens = Scanner.Scan(content, options);

            tokens.Should().Be(new[] {
                MULTI_LINE_COMMENT("/* comment */"),
            });
        }
コード例 #32
0
        public void InsideWhitespacePrecededByXmlElement()
        {
            ScannerOptions scannerOptions = new ScannerOptions();

            scannerOptions.EnableIntelliSenseTriggerTokens = true;
            Parser parser = GetNewParser(scannerOptions,
                                         "  <p>inside</p>  ");
            //    ^              ^
            TemplateNode templateNode = parser.ParseTemplate();

            AstNode astNode;

            // Get the first XmlTextNode
            astNode = templateNode.GetNodeAt(1, 2);
            Assert.AreEqual("  ", ((XmlTextNode)astNode).Text);

            // Get the second XmlTextNode
            astNode = templateNode.GetNodeAt(1, 17);
            Assert.AreEqual("  ", ((XmlTextNode)astNode).Text);
        }
コード例 #33
0
        public void ParsePartialNVReferenceOnlyWithDollar()
        {
            ScannerOptions scannerOptions = new ScannerOptions();

            scannerOptions.EnableIntelliSenseTriggerTokens = true;

            Parser       parser   = GetNewParser(scannerOptions, "$");
            TemplateNode template = parser.ParseTemplate();

            // Check errors
            Assert.AreEqual(1, parser.Errors.Count);
            Error error0 = parser.Errors[0];

            Assert.AreEqual("Expected reference identifier", error0.Description);
            AssertPosition(new Position(1, 2, 1, 2), error0.Position);
            Assert.AreEqual(ErrorSeverity.Error, error0.Severity);

            // Check the TemplateNode
            Assert.AreEqual(1, template.Content.Count);
            Assert.AreEqual(typeof(NVReference), template.Content[0].GetType());
        }
コード例 #34
0
        public void InsideComponent()
        {
            ScannerOptions scannerOptions = new ScannerOptions();

            scannerOptions.EnableIntelliSenseTriggerTokens = true;
            Parser parser = GetNewParser(scannerOptions,
                                         "#component(");
            //              ^
            TemplateNode templateNode = parser.ParseTemplate();

            // Check template
            NVDirective nvDirective = (NVDirective)templateNode.Content[0];

            Assert.AreEqual("component", nvDirective.Name);

            // Get node at position
            AstNode astNode = templateNode.GetNodeAt(1, 12);

            Assert.AreEqual(typeof(NVDirective), astNode.GetType());
            AssertPosition(new Position(1, 1, 1, 12), astNode.Position);
        }
コード例 #35
0
        public void ParsePartialNVReferenceWithDollarIdentDot()
        {
            ScannerOptions scannerOptions = new ScannerOptions();
            scannerOptions.EnableIntelliSenseTriggerTokens = true;

            Parser parser = GetNewParser(scannerOptions, "$Ajax.");
            TemplateNode template = parser.ParseTemplate();

            // Check errors
            Assert.AreEqual(1, parser.Errors.Count);
            Error error0 = parser.Errors[0];
            Assert.AreEqual("Expected identifier", error0.Description);
            AssertPosition(new Position(1, 7, 1, 7), error0.Position);

            // Check the TemplateNode
            Assert.AreEqual(1, template.Content.Count);
            NVReference nvReference = (NVReference)template.Content[0];
            Assert.AreEqual("Ajax", nvReference.Designator.Name);
            Assert.AreEqual(1, nvReference.Designator.Selectors.Count);
            AssertPosition(new Position(1, 6, 1, 7), nvReference.Designator.Selectors[0].Position);
        }
コード例 #36
0
        public void ParsePartialNVReferenceWithDollarIdentDotIdentLParen()
        {
            ScannerOptions scannerOptions = new ScannerOptions();
            scannerOptions.EnableIntelliSenseTriggerTokens = true;

            Parser parser = GetNewParser(scannerOptions, "$Ajax.LinkToRemote(");
            TemplateNode template = parser.ParseTemplate();

            // Check errors
            Assert.AreEqual(2, parser.Errors.Count);
            AssertError("Expected expression, was 'Error'", new Position(1, 20, 1, 20), parser.Errors[0]);
            AssertError("Expected 'NVRParen' but was 'Error'", new Position(1, 20, 1, 20), parser.Errors[1]);

            // Check the TemplateNode
            Assert.AreEqual(1, template.Content.Count);
            NVReference nvReference = (NVReference)template.Content[0];
            Assert.AreEqual("Ajax", nvReference.Designator.Name);

            Assert.AreEqual(1, nvReference.Designator.Selectors.Count);
            NVSelector selector = nvReference.Designator.Selectors[0];
            Assert.AreEqual("LinkToRemote", selector.Name);
            Assert.AreEqual(0, selector.Actuals.Count);
        }
コード例 #37
0
ファイル: XmlTestCase.cs プロジェクト: jonorossi/cvsi
        public void IncompleteXmlTagWithNoNameInsideXmlTagBreaksOutOfXmlTagWhenInIntelliSenseMode()
        {
            Scanner scanner = new Scanner(new ErrorHandler());
            ScannerOptions scannerOptions = new ScannerOptions();
            scannerOptions.EnableIntelliSenseTriggerTokens = true;
            scanner.Options = scannerOptions;

            scanner.SetSource(
                "<div>\n" +
                "    < \n" +
                "</div>");

            AssertMatchToken(scanner, TokenType.XmlTagStart);
            AssertMatchToken(scanner, TokenType.XmlTagName, "div");
            AssertMatchToken(scanner, TokenType.XmlTagEnd);

            AssertMatchToken(scanner, TokenType.XmlText, "\n    ");
            AssertMatchToken(scanner, TokenType.XmlTagStart);
            AssertMatchToken(scanner, TokenType.XmlAttributeMemberSelect, " ");
            AssertMatchToken(scanner, TokenType.XmlAttributeMemberSelect, "\n");
            // When in IntelliSense mode the scanner should drop out of a tag if it finds a '<'

            AssertMatchToken(scanner, TokenType.XmlTagStart);
            AssertMatchToken(scanner, TokenType.XmlForwardSlash);
            AssertMatchToken(scanner, TokenType.XmlTagName, "div");
            AssertMatchToken(scanner, TokenType.XmlTagEnd);

            AssertEOF();
        }
コード例 #38
0
        public void ParseForeachDirectiveWithStartOfReference()
        {
            ScannerOptions scannerOptions = new ScannerOptions();
            scannerOptions.EnableIntelliSenseTriggerTokens = true;

            Parser parser = GetNewParser(scannerOptions,
                "text #foreach($item in $collection) $  #end text");
            TemplateNode templateNode = parser.ParseTemplate();

            // Check Position, it should get to just after the '$'
            AssertPosition(new Position(1, 6, 1, 38), templateNode.Content[1].Position);

            Assert.AreEqual(2, parser.Errors.Count);
        }
コード例 #39
0
        public void ParsePartialNVReferenceWithDollarIdentDotInXmlElement()
        {
            ScannerOptions scannerOptions = new ScannerOptions();
            scannerOptions.EnableIntelliSenseTriggerTokens = true;

            Parser parser = GetNewParser(
                "<tag>\n" +
                "  $Ajax.\n" +
                "</tag>");
            TemplateNode templateNode = parser.ParseTemplate();

            // Check the TemplateNode
            Assert.AreEqual(1, templateNode.Content.Count);
            XmlElement xmlElement = (XmlElement)templateNode.Content[0];
            NVReference nvReference = (NVReference)xmlElement.Content[1];
            Assert.AreEqual("Ajax", nvReference.Designator.Name);
            Assert.AreEqual(1, nvReference.Designator.Selectors.Count);

            AssertPosition(new Position(1, 1, 3, 7), xmlElement.Position);
            AssertPosition(new Position(2, 3, 2, 9), nvReference.Position);
            AssertPosition(new Position(2, 3, 2, 9), nvReference.Designator.Position);
            AssertPosition(new Position(2, 8, 2, 9), nvReference.Designator.Selectors[0].Position);
        }