Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Classified items in quick info #52

Merged
merged 52 commits into from
Mar 20, 2019
Merged
Show file tree
Hide file tree
Changes from 51 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
ccef4fa
Start implementing the custom IToolTipPresenter.
GeorgeAlexandria Dec 22, 2018
2001c98
Append tool tip control.
GeorgeAlexandria Jan 26, 2019
cef6173
Improve colors and margins for tool tip.
GeorgeAlexandria Jan 26, 2019
e7fb5c8
Fixed popup position which must be relative to cursor.
GeorgeAlexandria Jan 27, 2019
da84c09
Fixed subscription on mouse moving.
GeorgeAlexandria Jan 29, 2019
74d93de
Fixed popup's dismissing.
GeorgeAlexandria Jan 30, 2019
f5325ba
Moved mouse tool tip to separate file.
GeorgeAlexandria Feb 2, 2019
6956677
Start implementing the custom quick info source.
GeorgeAlexandria Feb 2, 2019
9c1dd4a
Append dummy custom quick info item and it's provider.
GeorgeAlexandria Feb 13, 2019
2f11b13
Append a prototype of a base semantic provider.
GeorgeAlexandria Feb 24, 2019
c11d75a
Append a prototype of symbols description provider.
GeorgeAlexandria Feb 24, 2019
7854514
Append captured variables by lambda
GeorgeAlexandria Feb 25, 2019
012d8f2
Linked quick info and symbol description providers for C#
GeorgeAlexandria Feb 27, 2019
2021a82
Linked semantic provider to quick info source. Small refactoring.
GeorgeAlexandria Mar 1, 2019
e5c239f
Append CoCo classifications to quick info item.
GeorgeAlexandria Mar 1, 2019
8591352
Small fixes.
GeorgeAlexandria Mar 1, 2019
08c10cb
Mapped to quick info item.
GeorgeAlexandria Mar 2, 2019
b572f11
Reorganized structure of files.
GeorgeAlexandria Mar 2, 2019
1327232
Append image to quick info.
GeorgeAlexandria Mar 2, 2019
7590693
Fixed classifications for a couple of access syntax. Append dynamic p…
GeorgeAlexandria Mar 3, 2019
c1ee8a3
Fixed classification of object creation in quick info.
GeorgeAlexandria Mar 3, 2019
984db79
Fixed overload count.
GeorgeAlexandria Mar 3, 2019
e75a25d
Append range variable prefix.
GeorgeAlexandria Mar 3, 2019
8095e2d
Fixed node classification inside a object creation.
GeorgeAlexandria Mar 3, 2019
2853bee
Append type parameters in quick info for closed generic type. Append …
GeorgeAlexandria Mar 3, 2019
2a4067a
Append prototype of xml doc comment collector.
GeorgeAlexandria Mar 5, 2019
0af097c
Normalize text (trim whitespaces).
GeorgeAlexandria Mar 5, 2019
baa1d5e
Handle `para` element in description.
GeorgeAlexandria Mar 6, 2019
6f661f6
Handle `exception` element in description.
GeorgeAlexandria Mar 6, 2019
d287e02
Improved indentions.
GeorgeAlexandria Mar 8, 2019
424d62d
Append an evaluated initializer's value to quick info.
GeorgeAlexandria Mar 8, 2019
e4b2577
Collapsed anonymous type references and append them to the correspond…
GeorgeAlexandria Mar 8, 2019
e36b98a
Fixed indent for exception child nodes. Improved classification for p…
GeorgeAlexandria Mar 9, 2019
d225dd9
Small cleanup code.
GeorgeAlexandria Mar 9, 2019
2d18552
Skip empty quick info.
GeorgeAlexandria Mar 9, 2019
05fd569
Storing quick info settings.
GeorgeAlexandria Mar 10, 2019
5d7546c
Fixed saving only a quick info options.
GeorgeAlexandria Mar 10, 2019
e3cfc1b
Append usages of the loaded quick info options.
GeorgeAlexandria Mar 12, 2019
9cccc40
Small fixes.
GeorgeAlexandria Mar 12, 2019
d3c1d50
Supported overriding the default quick info.
GeorgeAlexandria Mar 15, 2019
0d8bd29
Reorganized files structure.
GeorgeAlexandria Mar 15, 2019
e58f88d
Small refactoring.
GeorgeAlexandria Mar 15, 2019
3af7915
Append fallback classification types to description.
GeorgeAlexandria Mar 16, 2019
b30a6db
Fixed a couple build errors for vs14.
GeorgeAlexandria Mar 16, 2019
dbf8d26
Shared quick info analysis code with vs14.
GeorgeAlexandria Mar 16, 2019
115ae09
Append quick info source provider to vs14.
GeorgeAlexandria Mar 16, 2019
c17c348
Cast quick info to UIElements in vs14.
GeorgeAlexandria Mar 17, 2019
3b4ab83
Append image.
GeorgeAlexandria Mar 17, 2019
2c27230
Fixed redundant items for type parameters in quick info. Small fixes.
GeorgeAlexandria Mar 19, 2019
33b8bc1
Avoid classification item in quick info when it's disabled.
GeorgeAlexandria Mar 19, 2019
b12bac3
Fixed classifications for alias.
GeorgeAlexandria Mar 19, 2019
e244ec3
Small fixes.
GeorgeAlexandria Mar 20, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace CoCo.Settings
{
[DebuggerDisplay("{Name}")]
public struct LanguageSettings
public struct EditorLanguageSettings
{
public string Name { get; set; }

Expand Down
9 changes: 9 additions & 0 deletions src/common/CoCo.Settings/EditorSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Collections.Generic;

namespace CoCo.Settings
{
public struct EditorSettings
{
public ICollection<EditorLanguageSettings> Languages { get; set; }
}
}
12 changes: 12 additions & 0 deletions src/common/CoCo.Settings/QuickInfoLanguageSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System.Diagnostics;

namespace CoCo.Settings
{
[DebuggerDisplay("{Name}")]
public struct QuickInfoLanguageSettings
{
public string Name { get; set; }

public int? State { get; set; }
}
}
9 changes: 9 additions & 0 deletions src/common/CoCo.Settings/QuickInfoSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Collections.Generic;

namespace CoCo.Settings
{
public struct QuickInfoSettings
{
public ICollection<QuickInfoLanguageSettings> Languages { get; set; }
}
}
12 changes: 8 additions & 4 deletions src/common/CoCo.Settings/Settings.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
using System.Collections.Generic;

namespace CoCo.Settings
namespace CoCo.Settings
{
public struct Settings
{
public ICollection<LanguageSettings> Languages { get; set; }
public EditorSettings Editor { get; set; }

public string EditorPath { get; set; }

public QuickInfoSettings QuickInfo { get; set; }

public string QuickInfoPath { get; set; }
}
}
90 changes: 76 additions & 14 deletions src/common/CoCo.Settings/SettingsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,23 @@ public static class SettingsManager

private const string CurrentClassificationsName = "current";

public static void SaveSettings(Settings settings, string path)
public static void SaveSettings(QuickInfoSettings settings, string path)
{
var jSettings = new JObject();
foreach (var language in settings.Languages)
{
var jLanguage = new JObject();
if (language.State.HasValue)
{
jLanguage.Add(nameof(QuickInfoLanguageSettings.State), new JValue(language.State));
}
jSettings.Add(language.Name, jLanguage);
}

WriteToFile(jSettings, path);
}

public static void SaveSettings(EditorSettings settings, string path)
{
JArray ToJArray(ICollection<ClassificationSettings> classificationSettings)
{
Expand All @@ -40,25 +56,55 @@ JArray ToJArray(ICollection<ClassificationSettings> classificationSettings)
jSettings.Add(language.Name, jLanguage);
}

var info = new FileInfo(path);
if (!info.Directory.Exists)
WriteToFile(jSettings, path);
}

public static QuickInfoSettings LoadQuickInfoSettings(string path)
{
if (!File.Exists(path))
{
info.Directory.Create();
return new QuickInfoSettings { Languages = new List<QuickInfoLanguageSettings>() };
}

using (var writer = !info.Exists ? info.CreateText() : new StreamWriter(path))
using (var jsonWriter = new JsonTextWriter(writer))
JObject jSettings;
using (var reader = File.OpenText(path))
using (var jsonReader = new JsonTextReader(reader))
{
jsonWriter.Formatting = Formatting.Indented;
jSettings.WriteTo(jsonWriter);
try
{
jSettings = (JObject)JToken.ReadFrom(jsonReader);
}
catch (JsonReaderException)
{
return new QuickInfoSettings { Languages = new List<QuickInfoLanguageSettings>() };
}
}

var languages = new List<QuickInfoLanguageSettings>();
foreach (var jSetting in jSettings)
{
if (!(jSetting.Value is JObject jLanguageSettings)) continue;

var language = new QuickInfoLanguageSettings
{
Name = jSetting.Key,
};

if (jLanguageSettings[nameof(QuickInfoLanguageSettings.State)] is JValue jValue && jValue.Value is long state)
{
language.State = (int)state;
}
languages.Add(language);
}

return new QuickInfoSettings { Languages = languages };
}

public static Settings LoadSettings(string path, IMigrationService service = null)
public static EditorSettings LoadEditorSettings(string path, IMigrationService service = null)
{
if (!File.Exists(path))
{
return new Settings { Languages = new List<LanguageSettings>() };
return new EditorSettings { Languages = new List<EditorLanguageSettings>() };
}

JObject jSettings;
Expand All @@ -71,16 +117,16 @@ public static Settings LoadSettings(string path, IMigrationService service = nul
}
catch (JsonReaderException)
{
return new Settings { Languages = new List<LanguageSettings>() };
return new EditorSettings { Languages = new List<EditorLanguageSettings>() };
}
}

var languages = new List<LanguageSettings>();
var languages = new List<EditorLanguageSettings>();
foreach (var jSetting in jSettings)
{
if (!(jSetting.Value is JObject jLanguageSettings)) continue;

var language = new LanguageSettings
var language = new EditorLanguageSettings
{
Name = jSetting.Key,
CurrentClassifications = new List<ClassificationSettings>(),
Expand Down Expand Up @@ -126,7 +172,23 @@ public static Settings LoadSettings(string path, IMigrationService service = nul

languages.Add(language);
}
return new Settings { Languages = languages };
return new EditorSettings { Languages = languages };
}

private static void WriteToFile(JObject jSettings, string path)
{
var info = new FileInfo(path);
if (!info.Directory.Exists)
{
info.Directory.Create();
}

using (var writer = !info.Exists ? info.CreateText() : new StreamWriter(path))
using (var jsonWriter = new JsonTextWriter(writer))
{
jsonWriter.Formatting = Formatting.Indented;
jSettings.WriteTo(jsonWriter);
}
}

private static bool TryParseClassification(
Expand Down
14 changes: 14 additions & 0 deletions src/common/CoCo.UI/CoCo.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,18 @@
</ItemGroup>
<ItemGroup>
<Compile Include="..\AssemblyInfoCommon.cs" Link="Properties\AssemblyInfoCommon.cs" />
<Compile Update="UI\QuickInfoControl.xaml.cs">
<DependentUpon>QuickInfoControl.xaml</DependentUpon>
</Compile>
<Compile Update="UI\ClassificationsControl.xaml.cs">
<DependentUpon>ClassificationsControl.xaml</DependentUpon>
</Compile>
<Compile Update="UI\PresetsControl.xaml.cs">
<DependentUpon>PresetsControl.xaml</DependentUpon>
</Compile>
<Compile Update="UI\VsToolTipControl.xaml.cs">
<DependentUpon>VsToolTipControl.xaml</DependentUpon>
</Compile>
<Page Include="UI\Resources\Templates\Buttons.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down Expand Up @@ -60,6 +66,14 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UI\VsToolTipControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UI\QuickInfoControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<None Update="UI\Resources\Styles\Controls.xaml">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace CoCo.UI.Data
{
public class Option
public sealed class EditorOption
{
public ICollection<Language> Languages { get; } = new List<Language>();
}
Expand Down
2 changes: 1 addition & 1 deletion src/common/CoCo.UI/Data/Language.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace CoCo.UI.Data
{
[DebuggerDisplay("{Name}")]
public class Language
public sealed class Language
{
public Language(string name)
{
Expand Down
2 changes: 1 addition & 1 deletion src/common/CoCo.UI/Data/Preset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace CoCo.UI.Data
{
[DebuggerDisplay("{Name}")]
public class Preset
public sealed class Preset
{
public Preset(string name)
{
Expand Down
17 changes: 17 additions & 0 deletions src/common/CoCo.UI/Data/QuickInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Diagnostics;

namespace CoCo.UI.Data
{
[DebuggerDisplay("{Language}")]
public sealed class QuickInfo
{
public QuickInfo(string language)
{
Language = language;
}

public string Language { get; }

public int State { get; set; }
}
}
9 changes: 9 additions & 0 deletions src/common/CoCo.UI/Data/QuickInfoOption.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Collections.Generic;

namespace CoCo.UI.Data
{
public sealed class QuickInfoOption
{
public ICollection<QuickInfo> Languages { get; } = new List<QuickInfo>();
}
}
21 changes: 21 additions & 0 deletions src/common/CoCo.UI/QuickInfoStateService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.Collections.Generic;

namespace CoCo.UI
{
public static class QuickInfoStateService
{
public static readonly Dictionary<string, int> SupportedStateByNames = new Dictionary<string, int>
{
["Disable"] = 0,
["Extend"] = 1,
["Override"] = 2,
};

public static readonly Dictionary<int, string> SupportedState = new Dictionary<int, string>
{
[0] = "Disable",
[1] = "Extend",
[2] = "Override",
};
}
}
61 changes: 61 additions & 0 deletions src/common/CoCo.UI/UI/QuickInfoControl.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<UserControl
x:Class="CoCo.UI.QuickInfoControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewModels="clr-namespace:CoCo.UI.ViewModels"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/ResourceDictionary.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="5*" />
</Grid.RowDefinitions>
<StackPanel
Grid.Row="0"
Width="Auto"
HorizontalAlignment="Left"
Orientation="Horizontal">
<Label
Margin="5,0,0,5"
Content="Language:"
FontSize="14"
Style="{StaticResource labelStyle}" />
<ComboBox
Width="100"
Margin="5,0,0,5"
DisplayMemberPath="Language"
ItemsSource="{Binding Languages}"
SelectedItem="{Binding SelectedLanguage}"
Style="{StaticResource comboBoxFlatStyle}" />
</StackPanel>
<StackPanel Grid.Row="1">
<StackPanel
Width="Auto"
Height="26"
Margin="0,0,0,4"
HorizontalAlignment="Left"
DataContext="{Binding SelectedLanguage}"
Orientation="Horizontal">
<Label
Content="Quic info state:"
FontSize="12"
Style="{StaticResource labelStyle}" />
<ComboBox
Width="100"
ItemsSource="{Binding States}"
SelectedItem="{Binding SelectedState}"
Style="{StaticResource comboBoxFlatStyle}" />
</StackPanel>
</StackPanel>
</Grid>
</UserControl>
Loading