Commit Graph

231 Commits

Author SHA1 Message Date
Ryan Nowak bafe1b27ff Add line numbers for design time directives
Addresses a blocking issue for FAR of types when used in user-code in a
directive. The FAR infrastructure is skipping over the directive code
because it's mapped to `#hidden`. As you can see in the code, the token
provided by the user is already included in the projection mappings.

I think we didn't do this before because we didn't expect this code to
need line numbers - it's not really debuggable, and design-time codegen
doesn't happen when you build the project.

I think it's OK for now that we don't line-map (or include) directives
based on view imports. If you trigger FAR on an `@inject ...` in an
import for instance, you'll find the reference for the view import file.
That seems pretty good, and the only cases I can really imagine it being
broken would be for go-to-definition (within a Razor view). Lets revisit
in the future based on feedback.
2018-10-18 13:46:24 -07:00
Ryan Nowak fb9a02ef5a Merge branch 'release/2.2' 2018-10-01 17:05:44 -07:00
Ryan Nowak f425134ffe Fix #2265 - Port Blazor testing improvements
The Blazor test infrastructure made a copy of the code in Razor and then
added some more features. This change backports the features needed for
the style of test we're using in Blazor.

I updated the MVC integration tests to use the new style, but I think
there's limited value in trying to rev all of the old tests.

One feature in particular that I removed from the old infrastructure was
the automatic inference of imports based on the file system. This
feature was wierd and doesn't parallel how these features work in
actuality. It's easy and more natural to test imports in new style
tests.
2018-10-01 13:00:44 -07:00
Ajay Bhargav Baaskaran dc70687f0e Test tag helper directives correctly 2018-09-27 16:37:28 -07:00
Ajay Bhargav Baaskaran 93e7e735a4 Test Directives correctly 2018-09-27 15:47:21 -07:00
Ajay Bhargav Baaskaran 9e4c4079f2
Renamed HtmlTextSyntax to HtmlTextLiteralSyntax for consistency (#2560)
* Renamed HtmlTextSyntax to HtmlTextLiteralSyntax for consistency

* Generated baselines
2018-08-28 14:00:32 -07:00
Ajay Bhargav Baaskaran f4808b50b5 Renamed WhiteSpace to Whitespace 2018-08-24 15:45:55 -07:00
Ajay Bhargav Baaskaran 27a9991f21
Auto generate CSharp syntax tree nodes (#2550)
* Auto generate CSharp syntax tree nodes
- Auto generated syntax nodes, visitors and factories
- Renamed RazorComment to RazorCommentLiteral to avoid a conflict
- Modified the Visit() contract
- Added new SyntaxKinds
- Regenerated baselines
2018-08-21 14:20:33 -07:00
Ajay Bhargav Baaskaran db2a142132
Updated the tokenizer and parser to operate on SyntaxTokens directly (#2540)
* Updated the tokenizer and parser to operate on SyntaxTokens directly
- The tokenizer and parser now operates directly on SyntaxTokens (Green)
- The SyntaxToken(Red) is now created when the Span is built with the correct parent and position
- All other passes that run after the parsing is complete(TagHelperRewriter etc) will operate on the Red tokens.
- There is now only one type for all SyntaxTokens. They are differentiated by their SyntaxKind.
- Added equivalence checking for tokens
- Updated test code to react
- Regenerated baselines
2018-08-16 16:11:01 -07:00
Ajay Bhargav Baaskaran 9a9931d59f
Initial infrastrucure for a better html parser (#2522)
Initial infrastrucure for a better html parser
- Added new syntax node types that follow Roslyn's red/green pattern
- Modified the html text node in the current syntax tree to use the new
nodes
- Updated test infrastructure
- Generated baselines
2018-08-13 11:26:24 -07:00
Artak 692e09b017
Fixes #2491: Treating RazorCommentTransition-s similar to Transitions in tag content (#2531)
* Treating RazorCommentTransition-s similar to Transitions in tag content
2018-08-10 14:46:58 -07:00
Ajay Bhargav Baaskaran eb6faf1754 Redo baselines 2018-07-19 15:29:30 -07:00
Ajay Bhargav Baaskaran 8e667ba730 Rename parser tests to have shorter names 2018-07-19 15:22:30 -07:00
Ajay Bhargav Baaskaran 7f6b05149d Generate deterministic unique ids for tag helpers 2018-07-17 14:01:42 -07:00
Ajay Bhargav Baaskaran 21f2edce16 Generate and verify baselines for ClassifiedSpans and TagHelperSpans
- Moved GetClassifiedSpans and GetTagHelperSpans logic to Razor.Language
2018-07-17 10:54:42 -07:00
N. Taylor Mullen cfd63e1e2e Change HTML splitting logic to not split on surrogate pairs.
- When a surrogate pair is about to be split down the middle we reduce the size of our split by 1 character. This way we split right before a surrogate pair. In the case of zero width joiners, if we split on a zero width joiner we still render valid bytes because the zero width joiner by itself can stand alone.
- Added tests for the various split cases.

#2470
2018-07-13 17:18:56 -07:00
Ajay Bhargav Baaskaran ce4780a830 Renamed symbol to token everywhere
- Updated Resources
- Updated test code
- Regenerated baselines
- Added exclusions for apicheck (See https://github.com/aspnet/BuildTools/issues/704)
2018-07-06 16:29:36 -07:00
Ajay Bhargav Baaskaran ed7c4e8f5c Parser tests clean up 2018-07-06 16:24:39 -07:00
Ajay Bhargav Baaskaran f9a09372b7 Converted TagHelperBlockRewriterTest 2018-06-29 15:33:21 -07:00
Ajay Bhargav Baaskaran 984e7826d6 Converted TagHelperParseTreeRewriterTest 2018-06-29 12:23:52 -07:00
Ajay Bhargav Baaskaran b232a1103a Prereq for converting tag helper tests 2018-06-29 12:15:13 -07:00
Ryan Nowak 942d4d194c Convert HtmlToCodeSwitchTest 2018-06-28 13:30:52 -07:00
N. Taylor Mullen 42e8f4abc8 Convert HtmlTagsTest to use baselines.
#2263
2018-06-28 10:49:15 -07:00
N. Taylor Mullen 8211dfff9c Convert HtmlErrorTest to use baselines.
#2263
2018-06-28 10:49:15 -07:00
Ryan Nowak ea96c50dce Convert WhitespaceRewriterTest 2018-06-27 17:02:03 -07:00
Ajay Bhargav Baaskaran 8eef4a4bb3 Convert HtmlDocumentTest 2018-06-27 15:47:57 -07:00
N. Taylor Mullen 67b5588185 Convert CSharpWhitespaceHandlingTest to use baselines.
#2263
2018-06-27 15:09:33 -07:00
Ajay Bhargav Baaskaran 048a6ec3ea Converted HtmlAttributeTest 2018-06-27 14:47:44 -07:00
N. Taylor Mullen 5950928baa Convert CSharpSpecialBlockTest to use baselines.
#2263
2018-06-27 14:35:22 -07:00
Ajay Bhargav Baaskaran a7fd53b3a3 Convert CSharpNestedStatementsTest 2018-06-27 13:43:51 -07:00
Ajay Bhargav Baaskaran df22392996 Convert CSharpImplicitExpressionTest 2018-06-27 13:43:51 -07:00
Ajay Bhargav Baaskaran d48946c2e0 Convert CSharpExplicitExpressionTest 2018-06-27 13:43:50 -07:00
Ryan Nowak 363be73a00 Convert more tests
CSharpRazorCommentsTest
CSharpReservedKeyWordsTest
CSharpToMarkupSwitchTest
2018-06-27 13:14:58 -07:00
Ryan Nowak 4fda468f06 Convert CSharpSectionTest 2018-06-27 13:14:58 -07:00
Ajay Bhargav Baaskaran c0929a9002 Convert CSharpErrorTest 2018-06-27 12:53:52 -07:00
N. Taylor Mullen 69cfb95b90 Convert CSharpStatementTest to use baselines.
#2263
2018-06-27 12:24:52 -07:00
N. Taylor Mullen 25547e80d1 Convert CSharpTemplateTest to use baselines.
#2263
2018-06-27 12:24:52 -07:00
Ajay Bhargav Baaskaran ab27e0bd52 Converted CSharpBlockTest to use baselines 2018-06-26 18:02:50 -07:00
Ajay Bhargav Baaskaran 1e58748f59 Converted HtmlBlockTest to use baselines 2018-06-26 16:09:05 -07:00
Ajay Bhargav Baaskaran a92089d2f9 Converted CSharpDirectivesTest to use baselines 2018-06-26 15:17:36 -07:00
Ajay Bhargav Baaskaran 999c24d78d Converted more parser tests to baselines
- Converted CSharpAutoCompleteTest
2018-06-25 11:43:17 -07:00
Ajay Bhargav Baaskaran b821ce8b8e First step in converting parser tests to use baselines
- Added the necessary infrastructure to serialize and verify the syntax
tree
- Updated ParserVisitor to be overrideable
- Made CSharpVerbatimBlockTest to use baselines
2018-06-19 15:57:05 -07:00
N. Taylor Mullen 41fad8a33a Don't smart indent code inside of Razor block constructs.
- Prior to this change we weren't strict enough with where our smart indenter ran. We made the assumption that every code block could be smart indented and then Roslyn would "do the right thing". However, in nested code block scenarios we found that Roslyn and us would both indent resulting in extra newlines. These changes make the criteria for applying smart indentation a little stricter.
- Updated directive code block parsing to add a C# marker symbol in cases of an empty code block directive.
- Added unit tests to verify new smart indenter behavior.
- Updated existing tests to expect new syntax tree marker symbol for empty directive bits.
- Regenerated baselines.

#2410
2018-06-18 20:38:01 -07:00
N. Taylor Mullen 1aa15374b5 Add partial parsing of `@functions` directive body.
- Added ability to understand valid inserts, deletes and replacements for the `@functions` directive (and any other directive that uses our extensible code block bits).
- Added unit tests.
- Updated existing tests.
- Found an issue when completing some C# items the auto-completions would impact the underlying snapshot after we'd captured the change. Fixed this by forcing a reparse when we detect that our understanding of the latest snapshot and the actual latest snapshot diverge.

#2408
2018-06-18 17:11:40 -07:00
N. Taylor Mullen d6f3a1bd22 Enable using directive IntelliSense auto-completion.
- Allow identical `@using` directives in the primary document. This means that if a user types `@using System` twice in the primary document (i.e. `Index.cshtml`) then we'll generate that using statement twice; this enables proper C# IntelliSense to light up on both using statements and allows auto-completion to work because there's no more magical distinction logic for Razor code that is in the current document.
- Prior to this change if you had two identical using statements in the same document one would be in no-mans land mapped to nothing (not C#, not HTML) and the other would be mapped to C#; the second a user differentiated the two statements (i.e. adding a `.`) we'd distinctify the using statements resulting in an invalid completion.
- This PR has an end-user impact where they will now receive the normal C# warning about having duplicate using. I treated this prior behavior more as a bug because we threw away the first using directive instance which impacted editing and in general was a silly thing to correct for the user.
- Added new integration test showing how using directives are not de-duplicated in the primary document.

#1255
2018-06-15 13:17:09 -07:00
Ryan Nowak af63afdae7 Add partial parsing for parenthesis
- This is part of a fix for #1255 - this change enables signature help in implicit expressions by improving the partial parsing. We're now smart enough about the contents of an implicit expression and attempt to balance parenthesis to determine if we should not full parse.

#1255
2018-06-15 11:22:03 -07:00
N. Taylor Mullen dc76027a7a Generate line pragmas even for whitespace.
- We need to pre-emptively generate line pragmas to handle C# scenarios which are session based. For instance, if a C# completion session starts at a location without a pragma they capture the origination point; at which point if a user keeps typing we generate a line pragma drastically changing where the copmletion started resulting in a broken C# completion experience.
- Updated test files to reflect new behavior.

#2299
2018-06-11 14:48:38 -07:00
Ajay Bhargav Baaskaran f9d4fba39d Added a taghelpers and imports overload to Process and ProcessDesignTime
We want to have a way to specify the taghelper descriptors and imports to use while
processing a specific document.
- Added an overload to Process and ProcessDesignTime to take in a list
TagHelperDescriptors and a list of imports
- Added the corresponding CreateCodeDocumentCore overload
- Added GetTagHelpers and SetTagHelpers extension methods for
CodeDocument
- Added the necessary plumbing to use the taghelpers from the
CodeDocument when available and fallback logic.
- Added DocumentImportsTracker and updated background code generation
logic to use the new overload
- Added/updated tests
2018-05-22 11:40:21 -07:00
Ryan Brandenburg efaaec6546 Upgrade to netcoreapp22 2018-05-08 15:22:54 -07:00
Ajay Bhargav Baaskaran f8dc5c4702 Obsoleted IRazorEngineBuilder APIs 2018-04-13 12:35:53 -07:00