// Private protected virtual for testing private protected virtual bool ProjectSupportsLSPEditor(string documentFilePath, DotNetProject?project) { if (project is null) { project = _textBufferProjectService.GetHostProject(documentFilePath) as DotNetProject; if (project is null) { return(false); } } // We alow projects to specifically opt-out of the legacy Razor editor because there are legacy scenarios which would rely on behind-the-scenes // opt-out mechanics to enable the .NET Core editor in non-.NET Core scenarios. Therefore, we need a similar mechanic to continue supporting // those types of scenarios for the new .NET Core Razor editor. if (_projectCapabilityResolver.HasCapability(documentFilePath, project, LegacyRazorEditorProjectCapability)) { // CPS project that requires the legacy editor return(false); } if (_projectCapabilityResolver.HasCapability(documentFilePath, project, DotNetCoreCSharpProjectCapability)) { // .NET Core project that supports C# return(true); } // Not a C# .NET Core project. This typically happens for legacy Razor scenarios return(false); }
internal virtual bool TryGetWorkspaceFromHostProject(ITextBuffer textBuffer, out Workspace workspace) { var project = _projectService.GetHostProject(textBuffer); if (project is null) { // Could not locate a project for the given text buffer. workspace = null; return(false); } // We have a host project, assume default workspace. workspace = _defaultWorkspace; return(true); }