Commit Graph

30 Commits

Author SHA1 Message Date
Ajay Bhargav Baaskaran ed9068cef4 Replace RazorError with RazorDiagnostics in public API 2017-02-17 15:44:37 -08:00
Ajay Bhargav Baaskaran 4b2245eeb9 [Fixes #924] Correct RightShiftAssign operator 2017-02-15 16:31:40 -08:00
Ajay Bhargav Baaskaran 02675da467 Handle single line directives properly 2017-02-08 13:41:27 -08:00
Pranav K d293547f24 Adding more tests 2017-02-08 11:17:43 -08:00
Pranav K 8b764c57e4 Parse string directive tokens correctly 2017-02-08 11:17:43 -08:00
Pranav K 2eba53de1b Add support for optional directives 2017-02-07 19:20:49 -08:00
N. Taylor Mullen 3f5d1bb2d6 Remove literal directive tokens.
- Literal directive tokens acted as a way for a user to provide markup bits to be required when parsing a directive.
- Removed source implementations.
- Removed tests validating the feature.

#969
2017-02-03 12:02:16 -08:00
Ajay Bhargav Baaskaran 406522d14b [Fixes #958] Added support for AddTagHelper, RemoveTagHelper and TagHelperPrefix directives 2017-01-30 15:40:05 -08:00
Ryan Nowak d187edbd76 Use the TagHelperBinder to dedupe taghelpers
This change does deduplication of taghelpers during the binding/rewriting
phase. This is needed when a taghelper has multiple sets of html
attributes that are required (behaves like an OR). This is used lots in
MVC.

The old codebase used to do this in the codegen phase, but it seems
beneficial to do as early as possible.
2017-01-26 15:36:42 -08:00
Ryan Nowak 4a49ee2164 Adds support for imports to IR lowering
This change adds support for 'imports' - extra source files which contain
directives that can merged with 'main' source files. The purpose of course
is to support things like global usings or addTagHelpers, like
_ViewImports in MVC does today.

Instead of a one-off this is now a feature of the Razor langugage since
things like addTagHelper have an impact on the parsing behavior. Also,
having a standard imports concept keeps out feature creep, for instance
the 'global' usings we have today could really just be an import.

Imports allow single-line directives including the fundamental directives
like addTagHelper, using, and other friends. Code, content, and block
directives are not merged and will be ignored. We can consider making
these kinds of things warnings in the future.
2017-01-20 10:43:53 -08:00
Ryan Nowak 242ea0ee3f Add parsing of includes and imports
Also adds the source document to the RazorSyntaxTree and does some cleanup
related to this. This lets us verify which tree goes to which document and
that seems important.

Added basic tests to verify that parsing happens, though it's not being
used for anything right now.
2017-01-13 11:25:20 -08:00
Ryan Nowak 59b24fb724 Make TagHelperDescriptor public for tooling 2017-01-10 09:06:05 -08:00
Ryan Nowak e104451f79 Make SourceSpan public
Cleansup SourceSpan and makes it public where its used.
2017-01-03 12:46:56 -08:00
Ryan Nowak 6b075880ce Clean up SourceLocation
This change makes SourceLocation public and moves some of the undesirable
functions off of the class and into the .Legacy namespace.
2017-01-03 10:01:48 -08:00
Ryan Nowak f45afb6c19 Add a test for using with trailing newline
I couldn't find a test like this, but I've been debugging an issue in this
scenario.
2016-12-30 16:06:18 -08:00
Ryan Nowak 0835de17ec Adds stronger verification for spans
This change ensures that spans are contiguous and that all source is part
of a span. This means that a character can't be 'lost' and not a member of
any span.

And guess what? We have a bug like that. So now a few tests are skipped
due to that bug.

Also made some changes to tests that construct invalid spans or spans
without correct locations as their expected input. This allows us to add
the above verification to all parser tests.
2016-12-28 21:56:35 -08:00
Ryan Nowak f191cc62a2 Get rid of locations on Tokens. 2016-12-28 18:22:06 -08:00
N. Taylor Mullen 88d99b06b3 Skip Razor.Evolution tests on Linux and Mac.
- Source ranges currently aren't normalized when they're input into the system. Due to how we serialize pieces of the code this breaks cross plat because of newline differences.
- This is a temporary work around to get the build passing cross plat.
2016-12-19 15:03:32 -08:00
N. Taylor Mullen 5d4c4e1ccf Add Razor runtime code generation.
- Added TabSize,IsIndentingWithTabs and NamespaceImports to the RazorParser options. These are replacements for the existing RazorEngineHost abstraction.
- Added RazorParserOptions consumption pattern to more than just the parsing phase.
- Added a ChecksumIRNode to ensure Debugging can work.
- Updated tests to to react to new Checksum and Namespace nodes in the IR tree.
2016-12-14 11:18:30 -08:00
N. Taylor Mullen 2db4985c21 Modify functions, section and inherits to use extensible directives.
- Removed existing type names used to track `@functions`, `@section` and `@inherits`.
- Updated parsing logic to reflect existing directive behaviors.
- Added additional IR and syntax tree pass in order to fulfill the default directive expectations.
- Updated tests to to expect new extensible directives parse structure.

#894
2016-12-14 11:12:40 -08:00
Ryan Nowak 853c28e568 Add integration testing
This change adds a basic framework for doing baselined integration tests.
This is very similar to what we do elsewhere with generated files and
tests that read them from resources.

What's here now is the support to do this kind of baselining with IR in a
pretty readable serialization format.

This is a building block and the intent is that we'd do something similar
in the future for syntax nodes and C# source.

Looking at the code of the tests in particular, we'll also build the
ability to capture the documents at key points (such as before/after a
targeted phase) and then verify them in the same manner.
2016-12-06 11:25:04 -08:00
Ryan Nowak 9cefcdd450 Add legacy dependencies of C# lowering 2016-12-04 23:30:34 -08:00
Ryan Nowak 03549bb542 Add end-to-end support for extensible directives
This change adds a way to actually configure the RazorEngine to use
extensible directives (previously buried behind legacy API). As part of
this feature adds the RazorParserOptions class to encapsulate anything
else that becomes a parser options (ahem taghelpers).

Now we have a pattern for this when we get there.

Options are propagated as part of the RazorSyntaxTree for
testability/sanity and this was actually responsible for the bulk of the
changes.

Also added some extension methods for adding directives to the
IRazorEngineBuilder and an end to end integration test.
2016-12-03 18:44:54 -08:00
N. Taylor Mullen 518378f499 Add extensible directive abstractions
- Based generic directive implementation off of descriptors.
- Added parsing logic to consume descriptors and parse content that's expected.
- Added parsing errors to automagically detect unexpected directive pieces.
- Updated visitor implementations to understand the directive bits.
- Added a builder abstraction to easily create descriptors. Had to maintain the ability to manually construct a descriptor to enable convenient serialization/deserialization.
- Added tests/comparers to verify correctness of parsing.

#853
2016-11-23 19:56:40 -08:00
N. Taylor Mullen cf7489e600 Port WhiteSpaceRewriter and ConditionalAttributeCollapser.
- Add an `HtmlNodeOptimizationPass` that does all of the `RazorSyntaxTreeRewriting` that legacy used to achieve outside of `TagHelper`s.
- Add tests for `HtmlNodeOptimizationPass` to verify it's executing appropriate bits.

#849
2016-11-22 12:04:31 -08:00
N. Taylor Mullen 6c8ef157b4 Add TagHelper binding abstractions.
- Added a TagHelperFeature to hold TagHelper specific pieces that can be replaced.
- Built a syntax tree pass that applies the ported TagHelper bits.
- Updated tests that expected different RazorEngine defaults.
- Added new tests to verify binder pass.
2016-11-21 11:04:42 -08:00
N. Taylor Mullen 26a1cf3cff Port existing TagHelper infrastructure.
- Modified how tests are run to reflect our new test infrastructure.
- Added TagHelper assertion bits.
- Moved all classes to the Evolution.Legacy namespace.
- Copied Test.Sources bits to the Evolution.Test project.

#845
2016-11-21 11:01:10 -08:00
N. Taylor Mullen 51fb0c993b Add indexability to the RazorSourceDocument.
- Removed the `CreateReader` API in favor of a `CopyTo`, `Length`, `[index]` and `Encoding`.
- Updated existing APIs to react to the change.
- Added tests.
2016-11-21 10:58:09 -08:00
Ryan Nowak 49d3574677 Make tests public - xUnit requires this 2016-11-16 14:06:01 -08:00
N. Taylor Mullen d06e5b6002 Add legacy parser 2016-11-16 14:06:00 -08:00