File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed
src/Razor/src/Microsoft.VisualStudioCode.RazorExtension/Services Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change 1+ // Copyright (c) .NET Foundation. All rights reserved.
2+ // Licensed under the MIT license. See License.txt in the project root for license information.
3+
4+ using System ;
5+ using System . Composition ;
6+ using Microsoft . CodeAnalysis . ExternalAccess . Razor ;
7+ using Microsoft . CodeAnalysis . Razor . Workspaces ;
8+
9+ namespace Microsoft . CodeAnalysis . Remote . Razor ;
10+
11+ [ Export ( typeof ( IFilePathService ) ) , Shared ]
12+ [ method: ImportingConstructor ]
13+ internal sealed class VSCodeFilePathService ( LanguageServerFeatureOptions options ) : AbstractFilePathService ( options )
14+ {
15+ private readonly LanguageServerFeatureOptions _options = options ;
16+
17+ public override Uri GetRazorDocumentUri ( Uri virtualDocumentUri )
18+ {
19+ if ( _options . UseRazorCohostServer && IsVirtualCSharpFile ( virtualDocumentUri ) )
20+ {
21+ throw new InvalidOperationException ( "Can not get a Razor document from a generated document Uri in cohosting" ) ;
22+ }
23+
24+ if ( virtualDocumentUri . Scheme == "razor-html" )
25+ {
26+ var builder = new UriBuilder ( virtualDocumentUri ) ;
27+ builder . Scheme = "file" ;
28+ return base . GetRazorDocumentUri ( builder . Uri ) ;
29+ }
30+
31+ return base . GetRazorDocumentUri ( virtualDocumentUri ) ;
32+ }
33+
34+ public override bool IsVirtualCSharpFile ( Uri uri )
35+ {
36+ if ( _options . UseRazorCohostServer )
37+ {
38+ return RazorUri . IsGeneratedDocumentUri ( uri ) ;
39+ }
40+
41+ return base . IsVirtualCSharpFile ( uri ) ;
42+ }
43+ }
You can’t perform that action at this time.
0 commit comments