public void ImplicitExpressionAcceptsDotAtEndOfNonWhitespaceCharacters() { var factory = new SpanFactory(); var changed = new StringTextSnapshot("@{" + Environment.NewLine + " @foo." + Environment.NewLine + "}"); var old = new StringTextSnapshot("@{" + Environment.NewLine + " @foo" + Environment.NewLine + "}"); RunPartialParseTest(new TestEdit(10 + Environment.NewLine.Length, 0, old, 1, changed, "."), new MarkupBlock( factory.EmptyHtml(), new StatementBlock( factory.CodeTransition(), factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), factory.Code(Environment.NewLine + " ") .AsStatement() .AutoCompleteWith(autoCompleteString: null), new ExpressionBlock( factory.CodeTransition(), factory.Code(@"foo.") .AsImplicitExpression(CSharpCodeParser.DefaultKeywords, acceptTrailingDot: true) .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), factory.Code(Environment.NewLine).AsStatement(), factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), factory.EmptyHtml())); }
public void ImplicitExpressionAcceptsInnerInsertionsInStatementBlock() { // Arrange SpanFactory factory = SpanFactory.CreateCsHtml(); StringTextBuffer changed = new StringTextBuffer("@{" + Environment.NewLine + " @DateTime..Now" + Environment.NewLine + "}"); StringTextBuffer old = new StringTextBuffer("@{" + Environment.NewLine + " @DateTime.Now" + Environment.NewLine + "}"); // Act and Assert RunPartialParseTest(new TextChange(17, 0, old, 1, changed), new MarkupBlock( factory.EmptyHtml(), new StatementBlock( factory.CodeTransition(), factory.MetaCode("{").Accepts(AcceptedCharacters.None), factory.Code("\r\n ").AsStatement(), new ExpressionBlock( factory.CodeTransition(), factory.Code("DateTime..Now") .AsImplicitExpression(CSharpCodeParser.DefaultKeywords, acceptTrailingDot: true) .Accepts(AcceptedCharacters.NonWhiteSpace)), factory.Code("\r\n").AsStatement(), factory.MetaCode("}").Accepts(AcceptedCharacters.None)), factory.EmptyHtml())); }
public void ImplicitExpressionAcceptsInnerInsertionsInStatementBlock() { // Arrange var factory = new SpanFactory(); var changed = new StringTextSnapshot("@{" + Environment.NewLine + " @DateTime..Now" + Environment.NewLine + "}"); var old = new StringTextSnapshot("@{" + Environment.NewLine + " @DateTime.Now" + Environment.NewLine + "}"); // Act and Assert RunPartialParseTest(new TestEdit(17, 0, old, 1, changed, "."), new MarkupBlock( factory.EmptyHtml(), new StatementBlock( factory.CodeTransition(), factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), factory.Code(Environment.NewLine + " ") .AsStatement() .AutoCompleteWith(autoCompleteString: null), new ExpressionBlock( factory.CodeTransition(), factory.Code("DateTime..Now") .AsImplicitExpression(CSharpCodeParser.DefaultKeywords, acceptTrailingDot: true) .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), factory.Code(Environment.NewLine).AsStatement(), factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), factory.EmptyHtml())); }
public void ImplicitExpressionAcceptsDotlessCommitInsertionsInStatementBlockAfterIdentifiers() { SpanFactory factory = SpanFactory.CreateCsHtml(); StringTextBuffer changed = new StringTextBuffer("@{" + Environment.NewLine + " @DateTime." + Environment.NewLine + "}"); StringTextBuffer old = new StringTextBuffer("@{" + Environment.NewLine + " @DateTime" + Environment.NewLine + "}"); var textChange = new TextChange(17, 0, old, 1, changed); using (TestParserManager manager = CreateParserManager()) { Action <TextChange, PartialParseResult, string> applyAndVerifyPartialChange = (changeToApply, expectedResult, expectedCode) => { PartialParseResult result = manager.CheckForStructureChangesAndWait(textChange); // Assert Assert.Equal(expectedResult, result); Assert.Equal(1, manager.ParseCount); ParserTestBase.EvaluateParseTree(manager.Parser.CurrentParseTree, new MarkupBlock( factory.EmptyHtml(), new StatementBlock( factory.CodeTransition(), factory.MetaCode("{").Accepts(AcceptedCharacters.None), factory.Code("\r\n ").AsStatement(), new ExpressionBlock( factory.CodeTransition(), factory.Code(expectedCode) .AsImplicitExpression(CSharpCodeParser.DefaultKeywords, acceptTrailingDot: true) .Accepts(AcceptedCharacters.NonWhiteSpace)), factory.Code("\r\n").AsStatement(), factory.MetaCode("}").Accepts(AcceptedCharacters.None)), factory.EmptyHtml())); }; manager.InitializeWithDocument(textChange.OldBuffer); // This is the process of a dotless commit when doing "." insertions to commit intellisense changes. applyAndVerifyPartialChange(textChange, PartialParseResult.Accepted, "DateTime."); old = changed; changed = new StringTextBuffer("@{" + Environment.NewLine + " @DateTime.." + Environment.NewLine + "}"); textChange = new TextChange(18, 0, old, 1, changed); applyAndVerifyPartialChange(textChange, PartialParseResult.Accepted, "DateTime.."); old = changed; changed = new StringTextBuffer("@{" + Environment.NewLine + " @DateTime.Now." + Environment.NewLine + "}"); textChange = new TextChange(18, 0, old, 3, changed); applyAndVerifyPartialChange(textChange, PartialParseResult.Accepted, "DateTime.Now."); } }
public async Task ImplicitExpressionAcceptsDotlessCommitInsertionsInStatementBlockAfterIdentifiers() { var factory = new SpanFactory(); var changed = new StringTextSnapshot("@{" + Environment.NewLine + " @DateTime." + Environment.NewLine + "}"); var original = new StringTextSnapshot("@{" + Environment.NewLine + " @DateTime" + Environment.NewLine + "}"); var edit = new TestEdit(15 + Environment.NewLine.Length, 0, original, 1, changed, "."); using (var manager = CreateParserManager(original)) { void ApplyAndVerifyPartialChange(TestEdit testEdit, string expectedCode) { manager.ApplyEdit(testEdit); Assert.Equal(1, manager.ParseCount); ParserTestBase.EvaluateParseTree(manager.PartialParsingSyntaxTreeRoot, new MarkupBlock( factory.EmptyHtml(), new StatementBlock( factory.CodeTransition(), factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), factory.Code(Environment.NewLine + " ") .AsStatement() .AutoCompleteWith(autoCompleteString: null), new ExpressionBlock( factory.CodeTransition(), factory.Code(expectedCode) .AsImplicitExpression(CSharpCodeParser.DefaultKeywords, acceptTrailingDot: true) .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), factory.Code(Environment.NewLine).AsStatement(), factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), factory.EmptyHtml())); }; await manager.InitializeWithDocumentAsync(edit.OldSnapshot); // This is the process of a dotless commit when doing "." insertions to commit intellisense changes. ApplyAndVerifyPartialChange(edit, "DateTime."); original = changed; changed = new StringTextSnapshot("@{" + Environment.NewLine + " @DateTime.." + Environment.NewLine + "}"); edit = new TestEdit(16 + Environment.NewLine.Length, 0, original, 1, changed, "."); ApplyAndVerifyPartialChange(edit, "DateTime.."); original = changed; changed = new StringTextSnapshot("@{" + Environment.NewLine + " @DateTime.Now." + Environment.NewLine + "}"); edit = new TestEdit(16 + Environment.NewLine.Length, 0, original, 3, changed, "Now"); ApplyAndVerifyPartialChange(edit, "DateTime.Now."); } }
public async Task ImplicitExpressionProvisionallyAcceptsDotlessCommitInsertionsAfterIdentifiers() { var factory = new SpanFactory(); var changed = new StringTextSnapshot("foo @DateTime. baz"); var original = new StringTextSnapshot("foo @DateTime baz"); var edit = new TestEdit(13, 0, original, 1, changed, "."); using (var manager = CreateParserManager(original)) { void ApplyAndVerifyPartialChange(TestEdit testEdit, string expectedCode) { manager.ApplyEdit(testEdit); Assert.Equal(1, manager.ParseCount); ParserTestBase.EvaluateParseTree(manager.PartialParsingSyntaxTreeRoot, new MarkupBlock( factory.Markup("foo "), new ExpressionBlock( factory.CodeTransition(), factory.Code(expectedCode).AsImplicitExpression(CSharpCodeParser.DefaultKeywords).Accepts(AcceptedCharactersInternal.NonWhiteSpace)), factory.Markup(" baz"))); }; await manager.InitializeWithDocumentAsync(edit.OldSnapshot); // This is the process of a dotless commit when doing "." insertions to commit intellisense changes. ApplyAndVerifyPartialChange(edit, "DateTime."); original = changed; changed = new StringTextSnapshot("foo @DateTime.. baz"); edit = new TestEdit(14, 0, original, 1, changed, "."); ApplyAndVerifyPartialChange(edit, "DateTime.."); original = changed; changed = new StringTextSnapshot("foo @DateTime.Now. baz"); edit = new TestEdit(14, 0, original, 3, changed, "Now"); ApplyAndVerifyPartialChange(edit, "DateTime.Now."); // Verify the reparse eventually happens await manager.WaitForReparseAsync(); Assert.Equal(2, manager.ParseCount); ParserTestBase.EvaluateParseTree(manager.CurrentSyntaxTree.Root, new MarkupBlock( factory.Markup("foo "), new ExpressionBlock( factory.CodeTransition(), factory.Code("DateTime.Now").AsImplicitExpression(CSharpCodeParser.DefaultKeywords).Accepts(AcceptedCharactersInternal.NonWhiteSpace)), factory.Markup(". baz"))); } }
public async Task AwaitPeriodInsertionAcceptedProvisionally() { // Arrange var original = new StringTextSnapshot("foo @await Html baz"); using (var manager = CreateParserManager(original)) { var factory = new SpanFactory(); var changed = new StringTextSnapshot("foo @await Html. baz"); var edit = new TestEdit(15, 0, original, 1, changed, "."); await manager.InitializeWithDocumentAsync(edit.OldSnapshot); // Act await manager.ApplyEditAndWaitForReparseAsync(edit); // Assert Assert.Equal(2, manager.ParseCount); ParserTestBase.EvaluateParseTree(manager.CurrentSyntaxTree.Root, new MarkupBlock( factory.Markup("foo "), new ExpressionBlock( factory.CodeTransition(), factory.Code("await Html").AsImplicitExpression(CSharpCodeParser.DefaultKeywords).Accepts(AcceptedCharactersInternal.WhiteSpace | AcceptedCharactersInternal.NonWhiteSpace)), factory.Markup(". baz"))); } }
public async Task ImplicitExpressionAcceptsIdentifierTypedAfterDotIfLastChangeWasProvisionalAcceptanceOfDot() { // Arrange var factory = new SpanFactory(); var dotTyped = new TestEdit(8, 0, new StringTextSnapshot("foo @foo bar"), 1, new StringTextSnapshot("foo @foo. bar"), "."); var charTyped = new TestEdit(9, 0, new StringTextSnapshot("foo @foo. bar"), 1, new StringTextSnapshot("foo @foo.b bar"), "b"); using (var manager = CreateParserManager(dotTyped.OldSnapshot)) { await manager.InitializeWithDocumentAsync(dotTyped.OldSnapshot); // Apply the dot change manager.ApplyEdit(dotTyped); // Act (apply the identifier start char change) manager.ApplyEdit(charTyped); // Assert Assert.Equal(1, manager.ParseCount); ParserTestBase.EvaluateParseTree(manager.PartialParsingSyntaxTreeRoot, new MarkupBlock( factory.Markup("foo "), new ExpressionBlock( factory.CodeTransition(), factory.Code("foo.b") .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), factory.Markup(" bar"))); } }
public async Task ImplicitExpression_AcceptsParenthesisAtEnd_TwoEdits() { // Arrange var factory = new SpanFactory(); var edit1 = new TestEdit(8, 0, new StringTextSnapshot("foo @foo bar"), 1, new StringTextSnapshot("foo @foo( bar"), "("); var edit2 = new TestEdit(9, 0, new StringTextSnapshot("foo @foo( bar"), 1, new StringTextSnapshot("foo @foo() bar"), ")"); using (var manager = CreateParserManager(edit1.OldSnapshot)) { await manager.InitializeWithDocumentAsync(edit1.OldSnapshot); // Apply the ( edit manager.ApplyEdit(edit1); // Apply the ) edit manager.ApplyEdit(edit2); // Assert Assert.Equal(1, manager.ParseCount); ParserTestBase.EvaluateParseTree( manager.PartialParsingSyntaxTreeRoot, new MarkupBlock( factory.Markup("foo "), new ExpressionBlock( factory.CodeTransition(), factory.Code("foo()") .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), factory.Markup(" bar"))); } }
public void ImplicitExpressionProvisionallyAcceptsDotlessCommitInsertions() { SpanFactory factory = SpanFactory.CreateCsHtml(); var changed = new StringTextBuffer("foo @DateT. baz"); var old = new StringTextBuffer("foo @DateT baz"); var textChange = new TextChange(10, 0, old, 1, changed); TestParserManager manager = CreateParserManager(); Action <TextChange, PartialParseResult, string> applyAndVerifyPartialChange = (changeToApply, expectedResult, expectedCode) => { PartialParseResult result = manager.CheckForStructureChangesAndWait(textChange); // Assert Assert.Equal(expectedResult, result); Assert.Equal(1, manager.ParseCount); ParserTestBase.EvaluateParseTree(manager.Parser.CurrentParseTree, new MarkupBlock( factory.Markup("foo "), new ExpressionBlock( factory.CodeTransition(), factory.Code(expectedCode).AsImplicitExpression(CSharpCodeParser.DefaultKeywords).Accepts(AcceptedCharacters.NonWhiteSpace)), factory.Markup(" baz"))); }; manager.InitializeWithDocument(textChange.OldBuffer); // This is the process of a dotless commit when doing "." insertions to commit intellisense changes. applyAndVerifyPartialChange(textChange, PartialParseResult.Accepted | PartialParseResult.Provisional, "DateT."); old = changed; changed = new StringTextBuffer("foo @DateTime. baz"); textChange = new TextChange(10, 0, old, 3, changed); applyAndVerifyPartialChange(textChange, PartialParseResult.Accepted | PartialParseResult.Provisional, "DateTime."); }
public void ImplicitExpressionAcceptsDeleteOfIdentifierPartsIfSomeOfIdentifierRemains() { var factory = new SpanFactory(); var changed = new StringTextSnapshot("foo @Us baz"); var old = new StringTextSnapshot("foo @User baz"); RunPartialParseTest(new TestEdit(7, 2, old, 0, changed, string.Empty), new MarkupBlock( factory.Markup("foo "), new ExpressionBlock( factory.CodeTransition(), factory.Code("Us").AsImplicitExpression(CSharpCodeParser.DefaultKeywords).Accepts(AcceptedCharactersInternal.NonWhiteSpace)), factory.Markup(" baz"))); }
public void ImplicitExpressionAcceptsMultipleInsertionIfItOnlyCausesIdentifierExpansion() { var factory = new SpanFactory(); var changed = new StringTextSnapshot("foo @barbiz baz"); var old = new StringTextSnapshot("foo @bar baz"); RunPartialParseTest(new TestEdit(8, 0, old, 3, changed, "biz"), new MarkupBlock( factory.Markup("foo "), new ExpressionBlock( factory.CodeTransition(), factory.Code("barbiz").AsImplicitExpression(CSharpCodeParser.DefaultKeywords).Accepts(AcceptedCharactersInternal.NonWhiteSpace)), factory.Markup(" baz"))); }
public void ImplicitExpressionProvisionallyAcceptsDeleteOfIdentifierPartsIfDotRemains() { SpanFactory factory = SpanFactory.CreateCsHtml(); StringTextBuffer changed = new StringTextBuffer("foo @User. baz"); StringTextBuffer old = new StringTextBuffer("foo @User.Name baz"); RunPartialParseTest(new TextChange(10, 4, old, 0, changed), new MarkupBlock( factory.Markup("foo "), new ExpressionBlock( factory.CodeTransition(), factory.Code("User.").AsImplicitExpression(CSharpCodeParser.DefaultKeywords).Accepts(AcceptedCharacters.NonWhiteSpace)), factory.Markup(" baz")), additionalFlags: PartialParseResult.Provisional); }
public void ImplicitExpressionProvisionallyAcceptsMultipleInsertionIfItCausesIdentifierExpansionAndTrailingDot() { var factory = new SpanFactory(); var changed = new StringTextSnapshot("foo @User. baz"); var old = new StringTextSnapshot("foo @U baz"); RunPartialParseTest(new TestEdit(6, 0, old, 4, changed, "ser."), new MarkupBlock( factory.Markup("foo "), new ExpressionBlock( factory.CodeTransition(), factory.Code("User.").AsImplicitExpression(CSharpCodeParser.DefaultKeywords).Accepts(AcceptedCharactersInternal.NonWhiteSpace)), factory.Markup(" baz")), additionalFlags: PartialParseResultInternal.Provisional); }
public void ImplicitExpressionProvisionallyAcceptsDeleteOfIdentifierPartsIfDotRemains() { var factory = new SpanFactory(); var changed = new StringTextSnapshot("foo @User. baz"); var old = new StringTextSnapshot("foo @User.Name baz"); RunPartialParseTest(new TestEdit(10, 4, old, 0, changed, string.Empty), new MarkupBlock( factory.Markup("foo "), new ExpressionBlock( factory.CodeTransition(), factory.Code("User.").AsImplicitExpression(CSharpCodeParser.DefaultKeywords).Accepts(AcceptedCharactersInternal.NonWhiteSpace)), factory.Markup(" baz")), additionalFlags: PartialParseResultInternal.Provisional); }
public async Task ImplicitExpressionRejectsChangeWhichWouldHaveBeenAcceptedIfLastChangeWasProvisionallyAcceptedOnDifferentSpan() { // Arrange var factory = new SpanFactory(); var dotTyped = new TestEdit(8, 0, new StringTextSnapshot("foo @foo @bar"), 1, new StringTextSnapshot("foo @foo. @bar"), "."); var charTyped = new TestEdit(14, 0, new StringTextSnapshot("foo @foo. @bar"), 1, new StringTextSnapshot("foo @foo. @barb"), "b"); using (var manager = CreateParserManager(dotTyped.OldSnapshot)) { await manager.InitializeWithDocumentAsync(dotTyped.OldSnapshot); // Apply the dot change await manager.ApplyEditAndWaitForReparseAsync(dotTyped); // Act (apply the identifier start char change) await manager.ApplyEditAndWaitForParseAsync(charTyped); // Assert Assert.Equal(2, manager.ParseCount); ParserTestBase.EvaluateParseTree(manager.PartialParsingSyntaxTreeRoot, new MarkupBlock( factory.Markup("foo "), new ExpressionBlock( factory.CodeTransition(), factory.Code("foo") .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), factory.Markup(". "), new ExpressionBlock( factory.CodeTransition(), factory.Code("barb") .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), factory.EmptyHtml())); } }
public void ImplicitExpressionAcceptsWholeIdentifierReplacement() { // Arrange SpanFactory factory = SpanFactory.CreateCsHtml(); StringTextBuffer old = new StringTextBuffer("foo @date baz"); StringTextBuffer changed = new StringTextBuffer("foo @DateTime baz"); // Act and Assert RunPartialParseTest(new TextChange(5, 4, old, 8, changed), new MarkupBlock( factory.Markup("foo "), new ExpressionBlock( factory.CodeTransition(), factory.Code("DateTime").AsImplicitExpression(CSharpCodeParser.DefaultKeywords).Accepts(AcceptedCharacters.NonWhiteSpace)), factory.Markup(" baz"))); }
public void ImplicitExpressionAcceptsPrefixIdentifierReplacements_SingleSymbol() { // Arrange var factory = new SpanFactory(); var old = new StringTextSnapshot("foo @dTime baz"); var changed = new StringTextSnapshot("foo @DateTime baz"); // Act and Assert RunPartialParseTest(new TestEdit(5, 1, old, 4, changed, "Date"), new MarkupBlock( factory.Markup("foo "), new ExpressionBlock( factory.CodeTransition(), factory.Code("DateTime").AsImplicitExpression(CSharpCodeParser.DefaultKeywords).Accepts(AcceptedCharactersInternal.NonWhiteSpace)), factory.Markup(" baz"))); }
public void ImplicitExpressionAcceptsAdditionalIdentifierCharactersIfEndOfSpanIsIdentifier() { var factory = new SpanFactory(); var changed = new StringTextSnapshot("foo @foob bar"); var old = new StringTextSnapshot("foo @foo bar"); RunPartialParseTest(new TestEdit(8, 0, old, 1, changed, "b"), new MarkupBlock( factory.Markup("foo "), new ExpressionBlock( factory.CodeTransition(), factory.Code("foob") .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), factory.Markup(" bar"))); }
public void ImplicitExpressionAcceptsInnerInsertions() { // Arrange var factory = new SpanFactory(); var changed = new StringTextSnapshot("foo @DateTime..Now baz"); var old = new StringTextSnapshot("foo @DateTime.Now baz"); // Act and Assert RunPartialParseTest(new TestEdit(13, 0, old, 1, changed, "."), new MarkupBlock( factory.Markup("foo "), new ExpressionBlock( factory.CodeTransition(), factory.Code("DateTime..Now").AsImplicitExpression(CSharpCodeParser.DefaultKeywords).Accepts(AcceptedCharactersInternal.NonWhiteSpace)), factory.Markup(" baz")), additionalFlags: PartialParseResultInternal.Provisional); }
public void ImplicitExpressionAcceptsSurroundedIdentifierReplacements() { // Arrange var factory = new SpanFactory(); var old = new StringTextSnapshot("foo @DateTime.n.ToString() baz"); var changed = new StringTextSnapshot("foo @DateTime.Now.ToString() baz"); // Act and Assert RunPartialParseTest(new TestEdit(14, 1, old, 3, changed, "Now"), new MarkupBlock( factory.Markup("foo "), new ExpressionBlock( factory.CodeTransition(), factory.Code("DateTime.Now.ToString()").AsImplicitExpression(CSharpCodeParser.DefaultKeywords).Accepts(AcceptedCharactersInternal.NonWhiteSpace)), factory.Markup(" baz"))); }
public void ImplicitExpressionAcceptsInnerInsertions() { // Arrange SpanFactory factory = SpanFactory.CreateCsHtml(); StringTextBuffer changed = new StringTextBuffer("foo @DateTime..Now baz"); StringTextBuffer old = new StringTextBuffer("foo @DateTime.Now baz"); // Act and Assert RunPartialParseTest(new TextChange(13, 0, old, 1, changed), new MarkupBlock( factory.Markup("foo "), new ExpressionBlock( factory.CodeTransition(), factory.Code("DateTime..Now").AsImplicitExpression(CSharpCodeParser.DefaultKeywords).Accepts(AcceptedCharacters.NonWhiteSpace)), factory.Markup(" baz")), additionalFlags: PartialParseResult.Provisional); }
public void ImplicitExpressionProvisionallyAcceptsDotAfterIdentifierInMarkup() { var factory = new SpanFactory(); var changed = new StringTextSnapshot("foo @foo. bar"); var old = new StringTextSnapshot("foo @foo bar"); RunPartialParseTest(new TestEdit(8, 0, old, 1, changed, "."), new MarkupBlock( factory.Markup("foo "), new ExpressionBlock( factory.CodeTransition(), factory.Code("foo.") .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), factory.Markup(" bar")), additionalFlags: PartialParseResultInternal.Provisional); }
public void ImplicitExpressionAcceptsDotIfTrailingDotsAreAllowed() { var factory = new SpanFactory(); var changed = new StringTextSnapshot("@{@foo.}"); var old = new StringTextSnapshot("@{@foo}"); RunPartialParseTest(new TestEdit(6, 0, old, 1, changed, "."), new MarkupBlock( factory.EmptyHtml(), new StatementBlock( factory.CodeTransition(), factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), factory.EmptyCSharp() .AsStatement() .AutoCompleteWith(autoCompleteString: null), new ExpressionBlock( factory.CodeTransition(), factory.Code("foo.") .AsImplicitExpression(CSharpCodeParser.DefaultKeywords, acceptTrailingDot: true) .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), factory.EmptyCSharp().AsStatement(), factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), factory.EmptyHtml())); }
// [Fact] Silent skip to avoid warnings. Skipping until we can control the parser more directly. private void ImplicitExpressionProvisionallyAcceptsCaseInsensitiveDotlessCommitInsertions_NewRoslynIntegration() { var factory = new SpanFactory(); var original = new StringTextSnapshot("foo @date baz"); var changed = new StringTextSnapshot("foo @date. baz"); var edit = new TestEdit(9, 0, original, 1, changed, "."); using (var manager = CreateParserManager(original)) { void ApplyAndVerifyPartialChange(Action applyEdit, string expectedCode) { applyEdit(); Assert.Equal(1, manager.ParseCount); ParserTestBase.EvaluateParseTree(manager.CurrentSyntaxTree.Root, new MarkupBlock( factory.Markup("foo "), new ExpressionBlock( factory.CodeTransition(), factory.Code(expectedCode).AsImplicitExpression(CSharpCodeParser.DefaultKeywords).Accepts(AcceptedCharactersInternal.NonWhiteSpace)), factory.Markup(" baz"))); }; manager.InitializeWithDocument(edit.OldSnapshot); // This is the process of a dotless commit when doing "." insertions to commit intellisense changes. // @date => @date. ApplyAndVerifyPartialChange(() => manager.ApplyEdit(edit), "date."); original = changed; changed = new StringTextSnapshot("foo @date baz"); edit = new TestEdit(9, 1, original, 0, changed, ""); // @date. => @date ApplyAndVerifyPartialChange(() => manager.ApplyEdit(edit), "date"); original = changed; changed = new StringTextSnapshot("foo @DateTime baz"); edit = new TestEdit(5, 4, original, 8, changed, "DateTime"); // @date => @DateTime ApplyAndVerifyPartialChange(() => manager.ApplyEdit(edit), "DateTime"); original = changed; changed = new StringTextSnapshot("foo @DateTime. baz"); edit = new TestEdit(13, 0, original, 1, changed, "."); // @DateTime => @DateTime. ApplyAndVerifyPartialChange(() => manager.ApplyEdit(edit), "DateTime."); // Verify the reparse eventually happens manager.WaitForReparse(); Assert.Equal(2, manager.ParseCount); ParserTestBase.EvaluateParseTree(manager.CurrentSyntaxTree.Root, new MarkupBlock( factory.Markup("foo "), new ExpressionBlock( factory.CodeTransition(), factory.Code("DateTime").AsImplicitExpression(CSharpCodeParser.DefaultKeywords).Accepts(AcceptedCharactersInternal.NonWhiteSpace)), factory.Markup(". baz"))); } }