Commit Graph

71 Commits

Author SHA1 Message Date
Ryan Nowak baa71375d0
Add and process notifications for Imports (#2656)
This builds support for tracking the effect of changes to imports on
other documents, and completes our model for being able to keep
generated code up to date.
2018-10-19 21:39:43 -07:00
N. Taylor Mullen 333989af7a Update to use latest completion APIs 2018-10-19 15:10:19 -07:00
N. Taylor Mullen c371fa29fe Make it so the RazorDirectiveCompletionProvider doesn't load extra assemblies in C#.
- Added a layer of indirection to allow for proper Lazy loading of Razor and future async completion specific assemblies.
2018-10-19 15:10:19 -07:00
N. Taylor Mullen 2b1bdb7342 Move RazorCompletionFactsService to CodeAnalysis.Workspaces.Razor.
- Also updated workspaces test project to also compile for netcoreapp2.2.
2018-09-18 17:34:45 -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 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
N. Taylor Mullen 572b55690d Refactor completion logic into standalone service.
- Migrated the completion item source provider and the legacy directive completion provider to use the new service.
- Cleaned up duplicate tests that were both verifying common completion functionality.
- Ensured that the legacy `RazorDirectiveCompletionProvider` did not result in additional Razor assembly loads when in C# scenarios.

#2530
2018-08-10 14:46:13 -07:00
N. Taylor Mullen aec88e3eba Change Razor directive completions to use new completions API.
- Kept the same behavior as we previously had with Razor directive completions.
- Attempted adding additional functionalities such as lighting up Razor directive completion when completion was invoked on top of Razor directives (non-C#) but ran into issues involving the core HTML editor not consuming the new completion APIs yet. That's something we'll have to re-visit once they move to the new completion APIs.
- Added tests to validate all aspects of new completion APIs.
- Made completion provider turn on and off based off of feature flag.

#1743
#1813
2018-08-10 11:37:47 -07:00
N. Taylor Mullen cb557cf771 Changed `GetDesiredIndentation` to be resilient to our SyntaxTree which occasionally has gaps.
- Added a test to cover the scenario.

#2489
2018-07-30 10:45:18 -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
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
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 b2ec939006 Make brace indenter smarter about making edits to non-valid content kinds.
- Prior to this change our brace smart indenter would indent JavaScript blocks incorrectly because it didn't take into account where in a Razor file the brace that it was indenting existed.
- Made it so the brace smart indenter only functions in code/metacode locations within the SyntaxTree.
- Updated and added tests to account for new behavior.

#2297
2018-06-11 10:34:26 -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
N. Taylor Mullen 59baad17da Merge branch 'rel/vs15.8' into dev 2018-05-21 10:48:16 -07:00
Ryan Nowak 4ac8b21978 Fix dispose logic for EditorDocument
This could throw when the document is disposed and wasn't open in the
editor.

Improved the tests to cover dispose as well for both cases.
2018-05-20 16:39:46 -07:00
N. Taylor Mullen 95d41507fc Add `ProjectPathProvider` abstract for document tracker creation.
- First iteration of live share replaced the document tracker factory entirely; however, this will be prone to breaking changes in the future when me make changes to document tracker to not rely on a file path. To pre-emptively prevent breaking changes I added a project path provider that can be overridden in the live share case. Note that one big difference here between old and new is that instead of being a MEF service implementation for the project path resolution we're bringing that to the Workspace service level.
- Added tests to validate the two flows of the default project path provider.
2018-05-17 15:28:20 -07:00
N. Taylor Mullen e8c8396298 Upgrade to VS 15.8 Preview 2 version of Roslyn. 2018-05-16 15:50:54 -07:00
N. Taylor Mullen 7c70207594 Made the Visual Studio parser smarter about overlapping reparse requests.
- Prior to this the parser would think that a non-latest reparse request was the latest because the only way we would check to see if a change reference was "latest" would be to do an equality check on the snapshot and `SourceChange`; the issue here was that `SourceChange` was null but the snapshots were the same. Problems could arise with this due to project context changes.
- Added tests to validate the new reparse behavior.
- Renamed `Edit` in the `BackgroundParser` to `ChangeReference` also refactored all the "edit" text in `BackgroundParser` to be `ChangerReference` like.
- Added a new event args to be the DTO between the internal and external parser implementations. This is how we could pas additional information in order to determine "latest" change reference.

#2336
2018-05-14 11:54:56 -07:00
Ryan Nowak fafdd7e3af Track the open/closed state of documents
This change intoduces content changes to our project snapshots. We now
know the open/closed state of documents that are initialized by the
Razor project system and listen to the correct data source based on
whether the file is open in the editor.

There are a few other random improvements in here as well like a
workaround for the upcoming name change to our OOP client type.
2018-05-11 08:18:08 -07:00
Ryan Nowak 1d5245c421 Reorganize file tracker
This is precursor to a much bigger change. Pushing out some of the
changes that have broad impact early to make it easier to review the
real change.
2018-05-08 16:27:51 -07:00
N. Taylor Mullen dbed73da32 Remove ProjectService requirements for Razor text buffer initialization.
- Now that we have our own content type the editor does the work of determining if a Razor file opened in a core project should flow to our code.
2018-05-03 11:13:36 -07:00
N. Taylor Mullen 2885b4b138 Make document tracker resilient to multiple subscribes.
- Added tests to verify new functionality.

#2314
2018-04-30 12:03:13 -07:00
Ryan Nowak e2edc280c5 Add documents, engine, tag helpers to snapshot
The project snapshot now maintains a RazorProjectEngine as well as set
of Tag Helpers that are known for that snapshot.

Pivoted some more services to be snapshot-centric.

Also added the ability to track .cshtml documents to the project system.
For now most components just ignore document changes.
2018-04-25 19:05:54 -04:00
Ajay Bhargav Baaskaran f8dc5c4702 Obsoleted IRazorEngineBuilder APIs 2018-04-13 12:35:53 -07:00
Kiran Challa 431a8e195a [Fixes #2144] Incorrect target element of nested tag helper 2018-03-20 15:25:07 -07:00
Ryan Nowak 2f79b90af5 Merge branch 'rel/vs15.7' into dev 2018-03-08 15:49:01 -08:00
Ryan Nowak 989a6c699f Don't add the tag helper provider by default
Since the default tag helper provider is used by MVC then MVC should
include it. Now that Blazor is in the mix we shouldn't include it for
all configurations.
2018-03-08 15:41:34 -08:00
N. Taylor Mullen 5c456fbd04 Merge branch 'rel/vs15.7' into dev
# Conflicts:
#	build/dependencies.props
#	src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshot.cs
#	src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotManager.cs
#	src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotWorker.cs
#	src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotWorkerFactory.cs
#	src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshot.cs
#	src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotUpdateContext.cs
#	src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioDocumentTracker.cs
#	src/Microsoft.VisualStudio.LanguageServices.Razor/Legacy/LegacyTagHelperResolver.cs
#	src/Microsoft.VisualStudio.LanguageServices.Razor/Microsoft.VisualStudio.LanguageServices.Razor.csproj
#	src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/Rules/RazorConfiguration.cs
#	src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/Rules/RazorExtension.cs
#	src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/Rules/RazorGeneral.cs
#	src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/Rules/RazorProjectProperties.cs
#	test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/DefaultProjectSnapshotTest.cs
#	test/Microsoft.VisualStudio.Editor.Razor.Test/Microsoft.VisualStudio.Editor.Razor.Test.csproj
2018-03-05 22:58:07 -08:00
N. Taylor Mullen c5e83c61f8 Changed AddDefaultImports to take strings instead of project items.
- Strings here was important because any import added to the system dynamically needs to eventually make its way back to being a project item. With strings we can state that they do exist (have content) but do not have any file paths associated.
- Updated all call sites to use the new AddDefaultImports string based api.

#2080
2018-02-21 09:42:40 -08:00
Ryan Nowak 0b777dad3f Decouple tooling from MVC assemblies 2018-02-19 14:39:19 -08:00
Ryan Nowak 5008c7803c Add a project system
Step 1: Add HostProject

This is a somewhat complex addition to the ProjectSnapshotManager. Now
that we accept updates from the underlying IDE project system we need to
coordinate those with the Workspace.

This means that ProjectSnapshot itself now also has a version concept.

Step 2: Introduce a new project system based on CPS

We use project capabilities defined by the Razor SDK to determine
whether to rely on MSBuild evaluation to detect the configuration or
whether to fallback to assembly-based detection.

Step 3: Flow RazorConfiguration everywhere

We use now expose the RazorConfiguration to the language service and
editor. This means that we no longer need to detect the project's
configuration asynchronously, it happens much faster now.
2018-02-19 14:39:19 -08:00
Nate McMaster 13824c418e Catch 15.7 up with dev
This change integrates most of the non-breaking work that we did in 2.1
including the updates to make Razor less coupled to MVC.
2018-02-19 10:46:16 -08:00
N. Taylor Mullen e200b69511 Change IImportProjectFeature to consume RazorProjectItems.
- Updated all implementations of `IImportProjectFeature`; for MVC I went ahead and made a single project item that's always returned for MVC scenarios. That project item is smart about returning its content in a light-weight stream fashion.
- Had to add a `RazorProjectItem` => `RazorSourceDocument` conversion mechanic into `DefaultRazorProjectEngine`.
- Added tests for `DefaultRazorProjectItem.ConvertToSourceDocument`.
- Removed the `ProjectEngine` API from `VisualStudioRazorParser`. This was unrelated but was missed feedback.

#2068
2018-02-15 11:31:18 -08:00
N. Taylor Mullen 133eff3119 Move to RazorProjectEngine.
- Instead of using Razor/Mvc TemplateEngine use `RazorProjectEngine`. This involved changing several locations (each of which used `RazorTemplateEngine` in an entirely different way) to use the RazorProjectEngine's two Process methods.
- Changed an unused public API `VisualStudioRazorParser.TemplateEngine` to `VisualStudioRazorParser.RazorProjectEngine`.
- Ported the remainder of `RazorEngineBuilder`'s extension methods over to `RazorProjectEngineBuilder`. These were used in tests and our `RazorGenerate` tool.
- Added a few test helper methods/classes to enable simple testing of the `RazorProjectEngine`.
- Resolved several test hacks that were working around little discrepancies each of the `RazorTemplateEngine` APIs.
- Changed the template engine factory service to be a project engine factory service.
2018-02-14 12:40:23 -08:00
N. Taylor Mullen 84bc74ea9f Move to RazorProjectFileSystem.
- Changed all existing APIs to utilize `RazorProjectFileSystem`. This was possible because `RazorProjectFileSystem` inherits from RazorProject.
- Renamed `FileSystemRazorProject` to `DefaultRazorProjectFileSystem`.
- Renamed FileSystemRazorProjectItem` to `DefaultRazorProjectItem`.
- Obsoleted `RazorProject.Create`

#1828
2018-02-09 11:49:31 -08:00
N. Taylor Mullen 4eea2f6992 Change DefaultTagHelperFactsService to not expect a primary workspace.
- Removed `TagHelperFactsServiceInternal` since we had no way of retrieving the internal Workspace service given the exposed public API. Not to mention I think the `TagHelperFactsService` made more sense as a MEF service anyhow.
- Moved `TagHelperFactsServiceInternal` tests to `Microsoft.VisualStudio.Editor.Razor.Test` project and changed them to utilize the non-"internal" version.
- Updated completion service API to rely on non-`TagHelperFactsServiceInternal` pieces.

#2004
2018-02-02 12:02:45 -08:00
N. Taylor Mullen 6d2460ae7f Update DefaultRazorEditorFactoryService to be per-workspace.
- Updated the a `VisualStudioWorkspaceAccessor` API in windows to enable the factory to retrieve a workspace given a text buffer.
- Added a way to add test services to `AdhocWorkspace` so we can test against services being retrieved from a `Workspace`. This will be much more common once we rely on services coming from `TextBuffer`s in our other tooling pieces.
- Added tests for the default workspace provider.

#1989
2018-02-01 14:51:23 -08:00
N. Taylor Mullen 99010aaea4 Change EditorSettingsManager to not be per-workspace.
- Lifted `DefaultEditorSettingsManagerInternal`s state / event handling functionality into its `DefaultEditorSettingsManager`.
- Re-purposed `EditorSettingsManagerInternal` into a less-API heavy middleman `WorkspaceEditorSettings` for any workspace services concerned with editor settings to consume.
- Moved `DefaultEditorSettingsManagerInternal` into the Editor.Razor assembly and renamed it to `DefaultWorkspaceEditorSettings` since it needed the `EditorSettingsManager` API to function properly. The contract still exists at the `CodeAnalysis.Razor.Workspace` level.

#1982
2018-01-30 16:01:55 -08:00
N. Taylor Mullen 80f943caef Flow RazorLanguageVersion to RazorEngine.
- Restructured RazorLanguageVersion to be a sealed concrete type to enable things like `RazorLanguageVersion.Latest`; it also allows us to make broader changes in the future. Also, in the future if we want to add support for overriding operators to enable greater than comparisons we can as well.
- Removed version validity checks because we restrict who can construct a `RazorLanguageVersion` now. This way we don't have to check for valid versions all throughout our code.
- Added a simple `ProjectExtensibilityConfiguration` => `RazorLanguageVersion` method in the `DefaultProjectExtensibilityConfigurationFactory` to temporarily enable letting the system operate on the `RazorLanguageVersion`. Eventually that entire class will change.

#1961
2018-01-29 16:08:17 -08:00
N. Taylor Mullen a01fa1c5b6 Flow RazorLanguageVersion to RazorEngine.
- Restructured RazorLanguageVersion to be a sealed concrete type to enable things like `RazorLanguageVersion.Latest`; it also allows us to make broader changes in the future. Also, in the future if we want to add support for overriding operators to enable greater than comparisons we can as well.
- Removed version validity checks because we restrict who can construct a `RazorLanguageVersion` now. This way we don't have to check for valid versions all throughout our code.
- Added a simple `ProjectExtensibilityConfiguration` => `RazorLanguageVersion` method in the `DefaultProjectExtensibilityConfigurationFactory` to temporarily enable letting the system operate on the `RazorLanguageVersion`. Eventually that entire class will change.

#1961
2018-01-25 09:17:37 -08:00
N. Taylor Mullen f025a27f04 Unify how AdhocWorkspace is constructed.
- Created a new `TestWorkspace` type to lock on `AdhocWorkspace` construction. This type can't be constructed/changed in parallel.
- Updated test usages of `AdhocWorkspace` to make use of `TestWorkspace`.
- Added a `Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common` project to have the `TestWorkspace` type.

#1913
2018-01-12 17:54:53 -08:00
N. Taylor Mullen 8d6b86c76a Add `RazorLanguage.CoreContentType`.
#1852
2018-01-09 14:59:01 -08:00
Ajay Bhargav Baaskaran 52a06e93bc Added test for DefaultRazorSyntaxFactsService 2017-12-29 17:02:35 -08:00
N. Taylor Mullen 66d244aafc Make unit test work on linux 2017-12-22 14:33:08 -08:00
N. Taylor Mullen d4994eb4a4 Added DefaultRazorIndentationFactsService unit tests.
- Already had a good variety of integration tests so refactored the service to properly unit test each piece.
- Found several pieces of unneeded code (wasn't being used) so removed it.
- Removed the `LocateOwner` logic that was embedded in the service. We already have an equivalent locate owner on our `SyntaxTreeNode` items.

#1698
2017-12-22 14:31:14 -08:00
N. Taylor Mullen 463e11b739 Make SyntaxTree mutations not leak.
- Prior to this when the partial parser would successfully parse a change we'd mutate the returned syntax tree so any data inquired about the tree would then be wrong. We now isolate mutations to copied versions of the syntax tree.
- Added copy tests to ensure that we were appropriately copying all the various syntax node types.

#1793
2017-12-18 11:50:07 -08:00
N. Taylor Mullen 4164821e4c Add VS agnostic non-OOP DefaultTagHelperResolver.
- Added tests for the VisualStudio.Editor tag helper resolver.

#1789
2017-12-14 11:28:30 -08:00
N. Taylor Mullen 1aff9d0031 Make RazorEditorFactoryService VS agnostic.
- Moved the editor factory service into the Editor dll. It did not have any windows specific functionality within it.

#1789
2017-12-13 17:11:48 -08:00