Added public api changes for TagHelper project system
This commit is contained in:
parent
6cf78ceb1b
commit
9a2e3ceab6
|
|
@ -8,5 +8,6 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
||||||
Added,
|
Added,
|
||||||
Removed,
|
Removed,
|
||||||
Changed,
|
Changed,
|
||||||
|
TagHelpersChanged,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Microsoft.VisualStudio.Editor.Razor
|
||||||
|
{
|
||||||
|
public sealed class ContextChangeEventArgs : EventArgs
|
||||||
|
{
|
||||||
|
public ContextChangeEventArgs(ContextChangeKind kind)
|
||||||
|
{
|
||||||
|
Kind = kind;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ContextChangeKind Kind { get; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
namespace Microsoft.VisualStudio.Editor.Razor
|
||||||
|
{
|
||||||
|
public enum ContextChangeKind
|
||||||
|
{
|
||||||
|
ProjectChanged,
|
||||||
|
EditorSettingsChanged,
|
||||||
|
TagHelpersChanged,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
@ -133,7 +132,7 @@ namespace Microsoft.VisualStudio.Editor.Razor
|
||||||
}
|
}
|
||||||
|
|
||||||
// Internal for testing
|
// Internal for testing
|
||||||
internal void DocumentTracker_ContextChanged(object sender, EventArgs args)
|
internal void DocumentTracker_ContextChanged(object sender, ContextChangeEventArgs args)
|
||||||
{
|
{
|
||||||
_dispatcher.AssertForegroundThread();
|
_dispatcher.AssertForegroundThread();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Microsoft.AspNetCore.Razor.Language;
|
||||||
using Microsoft.CodeAnalysis;
|
using Microsoft.CodeAnalysis;
|
||||||
using Microsoft.CodeAnalysis.Razor.Editor;
|
using Microsoft.CodeAnalysis.Razor.Editor;
|
||||||
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
|
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
|
||||||
|
|
@ -13,12 +14,14 @@ namespace Microsoft.VisualStudio.Editor.Razor
|
||||||
{
|
{
|
||||||
public abstract class VisualStudioDocumentTracker
|
public abstract class VisualStudioDocumentTracker
|
||||||
{
|
{
|
||||||
public abstract event EventHandler ContextChanged;
|
public abstract event EventHandler<ContextChangeEventArgs> ContextChanged;
|
||||||
|
|
||||||
internal abstract ProjectExtensibilityConfiguration Configuration { get; }
|
internal abstract ProjectExtensibilityConfiguration Configuration { get; }
|
||||||
|
|
||||||
public abstract EditorSettings EditorSettings { get; }
|
public abstract EditorSettings EditorSettings { get; }
|
||||||
|
|
||||||
|
public abstract IReadOnlyList<TagHelperDescriptor> TagHelpers { get; }
|
||||||
|
|
||||||
public abstract bool IsSupportedProject { get; }
|
public abstract bool IsSupportedProject { get; }
|
||||||
|
|
||||||
public abstract string FilePath { get; }
|
public abstract string FilePath { get; }
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Microsoft.AspNetCore.Razor.Language;
|
||||||
using Microsoft.CodeAnalysis;
|
using Microsoft.CodeAnalysis;
|
||||||
using Microsoft.CodeAnalysis.Razor;
|
using Microsoft.CodeAnalysis.Razor;
|
||||||
using Microsoft.CodeAnalysis.Razor.Editor;
|
using Microsoft.CodeAnalysis.Razor.Editor;
|
||||||
|
|
@ -27,7 +28,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor
|
||||||
private ProjectSnapshot _project;
|
private ProjectSnapshot _project;
|
||||||
private string _projectPath;
|
private string _projectPath;
|
||||||
|
|
||||||
public override event EventHandler ContextChanged;
|
public override event EventHandler<ContextChangeEventArgs> ContextChanged;
|
||||||
|
|
||||||
public DefaultVisualStudioDocumentTracker(
|
public DefaultVisualStudioDocumentTracker(
|
||||||
string filePath,
|
string filePath,
|
||||||
|
|
@ -81,6 +82,8 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor
|
||||||
|
|
||||||
public override EditorSettings EditorSettings => _editorSettingsManager.Current;
|
public override EditorSettings EditorSettings => _editorSettingsManager.Current;
|
||||||
|
|
||||||
|
public override IReadOnlyList<TagHelperDescriptor> TagHelpers => Array.Empty<TagHelperDescriptor>();
|
||||||
|
|
||||||
public override bool IsSupportedProject => _isSupportedProject;
|
public override bool IsSupportedProject => _isSupportedProject;
|
||||||
|
|
||||||
public override Project Project => _workspace.CurrentSolution.GetProject(_project.UnderlyingProject.Id);
|
public override Project Project => _workspace.CurrentSolution.GetProject(_project.UnderlyingProject.Id);
|
||||||
|
|
@ -176,7 +179,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor
|
||||||
_projectManager.Changed += ProjectManager_Changed;
|
_projectManager.Changed += ProjectManager_Changed;
|
||||||
_editorSettingsManager.Changed += EditorSettingsManager_Changed;
|
_editorSettingsManager.Changed += EditorSettingsManager_Changed;
|
||||||
|
|
||||||
OnContextChanged(_project);
|
OnContextChanged(_project, ContextChangeKind.ProjectChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Unsubscribe()
|
private void Unsubscribe()
|
||||||
|
|
@ -187,17 +190,17 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor
|
||||||
// Detached from project.
|
// Detached from project.
|
||||||
_isSupportedProject = false;
|
_isSupportedProject = false;
|
||||||
_project = null;
|
_project = null;
|
||||||
OnContextChanged(project: null);
|
OnContextChanged(project: null, kind: ContextChangeKind.ProjectChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnContextChanged(ProjectSnapshot project)
|
private void OnContextChanged(ProjectSnapshot project, ContextChangeKind kind)
|
||||||
{
|
{
|
||||||
_project = project;
|
_project = project;
|
||||||
|
|
||||||
var handler = ContextChanged;
|
var handler = ContextChanged;
|
||||||
if (handler != null)
|
if (handler != null)
|
||||||
{
|
{
|
||||||
handler(this, EventArgs.Empty);
|
handler(this, new ContextChangeEventArgs(kind));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -206,14 +209,21 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor
|
||||||
if (_projectPath != null &&
|
if (_projectPath != null &&
|
||||||
string.Equals(_projectPath, e.Project.UnderlyingProject.FilePath, StringComparison.OrdinalIgnoreCase))
|
string.Equals(_projectPath, e.Project.UnderlyingProject.FilePath, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
OnContextChanged(e.Project);
|
if (e.Kind == ProjectChangeKind.TagHelpersChanged)
|
||||||
|
{
|
||||||
|
OnContextChanged(e.Project, ContextChangeKind.TagHelpersChanged);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OnContextChanged(e.Project, ContextChangeKind.ProjectChanged);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Internal for testing
|
// Internal for testing
|
||||||
internal void EditorSettingsManager_Changed(object sender, EditorSettingsChangedEventArgs args)
|
internal void EditorSettingsManager_Changed(object sender, EditorSettingsChangedEventArgs args)
|
||||||
{
|
{
|
||||||
OnContextChanged(_project);
|
OnContextChanged(_project, ContextChangeKind.EditorSettingsChanged);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue