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

Lsp internal #71

Open
wants to merge 14 commits into
base: language-server-protocol
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file modified .nuget/NuGet.exe
Binary file not shown.
3 changes: 0 additions & 3 deletions Nitra.TestsLauncher/Nitra.TestsLauncher.nproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@
<ItemGroup>
<Compile Include="Main.n" />
<Compile Include="Properties\AssemblyInfo.n" />
<Compile Include="SerializationHelper.n">
<SubType>Code</SubType>
</Compile>
<Compile Include="Utils.n">
<SubType>Code</SubType>
</Compile>
Expand Down
5 changes: 2 additions & 3 deletions Nitra.TestsLauncher/Utils.n
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Xml.Linq;
using Nitra.Visualizer.Serialization;
using Messages = Nitra.ClientServer.Messages;

namespace Nitra.Visualizer
Expand Down Expand Up @@ -93,7 +92,7 @@ namespace Nitra.Visualizer

public MakeXml(config : Messages.Config) : string
{
SerializationHelper.Serialize(config)
Messages.SerializationHelper.Serialize(config)
}

public Escape(str: string): string
Expand All @@ -109,4 +108,4 @@ namespace Nitra.Visualizer
</Span>"
}
}
}
}
5 changes: 2 additions & 3 deletions Nitra.TestsLauncher/ViewModels/SuiteVm.n
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Xml.Linq;
using Nitra.Visualizer.Serialization;
using System.Reflection;
using File = System.IO.File;
using Messages = Nitra.ClientServer.Messages;
Expand Down Expand Up @@ -52,7 +51,7 @@ namespace Nitra.ViewModels
try
{
def config = if (File.Exists(_configPath))
SerializationHelper.Deserialize(_configPath);
Messages.SerializationHelper.Deserialize(_configPath);
else
Messages.Config.InitNew();
Config = config;
Expand Down Expand Up @@ -127,7 +126,7 @@ namespace Nitra.ViewModels

public Save() : void
{
File.WriteAllText(_configPath, SerializationHelper.Serialize(Config));
File.WriteAllText(_configPath, Messages.SerializationHelper.Serialize(Config));
}

public GetConfigWithFullPaths() : Messages.Config
Expand Down
11 changes: 7 additions & 4 deletions Nitra/ClientServer/Nitra.ClientServer.Client/StringManager.n
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,19 @@ namespace Nitra.ClientServer.Client

public GetId(path : string) : int
{
if (string.IsNullOrEmpty(path))
def unesc = Uri.UnescapeDataString(path);
def uri = Uri(unesc).ToString();

if (string.IsNullOrEmpty(uri))
0
else
{
mutable id;
unless (_pathToId.TryGetValue(path, out id))
unless (_pathToId.TryGetValue(uri, out id))
{
id = _idToPaths.Count;
_pathToId.Add(path, id);
_idToPaths.Add(path);
_pathToId.Add(uri, id);
_idToPaths.Add(uri);
}
id
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
<ItemGroup>
<Compile Include="Messages.n" />
<Compile Include="Properties\AssemblyInfo.n" />
<Compile Include="SerializationHelper.n">
<SubType>Code</SubType>
</Compile>
<Compile Include="Utils\StringPatternMatching.n">
<SubType>Code</SubType>
</Compile>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,75 +1,70 @@
using Nemerle;
using Nemerle.Collections;
using Nemerle.Extensions;
using Nemerle.Text;
using Nemerle.Utility;

using Nitra.ClientServer.Client;
using Nitra.ViewModels;

using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Xml.Serialization;

using Messages = Nitra.ClientServer.Messages;

namespace Nitra.Visualizer.Serialization
{
public sealed class Language
{
[XmlAttribute] public Name: string { get; set }
[XmlAttribute] public Path: string { get; set }
public DynamicExtensions: array[DynamicExtension] { get; set }
public Libs: array[string] { get; set }
}

public sealed class DynamicExtension
{
[XmlAttribute] public Name : string { get; set }
[XmlAttribute] public Path : string { get; set }

public ToDynamicExtensionInfo(rootPath : string) : Messages.DynamicExtensionInfo
{
Messages.DynamicExtensionInfo(Name, Path.GetFullPath(Path.Combine(rootPath, Path)))
}
}

public module SerializationHelper
{
_configXmlSerializer : XmlSerializer = XmlSerializer(typeof(Messages.Config));
_languageXmlSerializer : XmlSerializer = XmlSerializer(typeof(Language));

public Serialize(config : Messages.Config) : string
{
def writer = StringWriter();
_configXmlSerializer.Serialize(writer, config);
writer.ToString()
}

public Deserialize(configPath : string) : Messages.Config
{
def text = File.ReadAllText(configPath);
def reader = StringReader(text);

def result =
try _configXmlSerializer.Deserialize(reader) :> Messages.Config
catch
{ | _e is InvalidOperationException =>
// Try interpret config as old version. Try to read "Language" type
def reader = StringReader(text);
def lang = _languageXmlSerializer.Deserialize(reader) :> Language;
// Convert it to new format (Messages.Config type)
def dynExt = lang.DynamicExtensions?.Select(e => Messages.DynamicExtensionInfo(e.Name, e.Path))?.ToArray();
def langInfo = Messages.LanguageInfo(lang.Name, lang.Path, dynExt ?? array(0));
def result = Messages.Config(Messages.ProjectSupport("", "", ""), array[langInfo], lang.Libs?.ToArray() ?? array(0));
File.WriteAllText(configPath, Serialize(result));
Deserialize(configPath)
};
result
}
}
}
using Nemerle;
using Nemerle.Collections;
using Nemerle.Extensions;
using Nemerle.Text;
using Nemerle.Utility;

using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Xml.Serialization;

namespace Nitra.ClientServer.Messages
{
public sealed class Language
{
[XmlAttribute] public Name: string { get; set }
[XmlAttribute] public Path: string { get; set }
public DynamicExtensions: array[DynamicExtension] { get; set }
public Libs: array[string] { get; set }
}

public sealed class DynamicExtension
{
[XmlAttribute] public Name : string { get; set }
[XmlAttribute] public Path : string { get; set }

public ToDynamicExtensionInfo(rootPath : string) : Messages.DynamicExtensionInfo
{
Messages.DynamicExtensionInfo(Name, Path.GetFullPath(Path.Combine(rootPath, Path)))
}
}

public module SerializationHelper
{
_configXmlSerializer : XmlSerializer = XmlSerializer(typeof(Messages.Config));
_languageXmlSerializer : XmlSerializer = XmlSerializer(typeof(Language));

public Serialize(config : Messages.Config) : string
{
def writer = StringWriter();
_configXmlSerializer.Serialize(writer, config);
writer.ToString()
}

public Deserialize(configPath : string) : Messages.Config
{
def text = File.ReadAllText(configPath);
def reader = StringReader(text);

def result =
try _configXmlSerializer.Deserialize(reader) :> Messages.Config
catch
{ | _e is InvalidOperationException =>
// Try interpret config as old version. Try to read "Language" type
def reader = StringReader(text);
def lang = _languageXmlSerializer.Deserialize(reader) :> Language;
// Convert it to new format (Messages.Config type)
def dynExt = lang.DynamicExtensions?.Select(e => Messages.DynamicExtensionInfo(e.Name, e.Path))?.ToArray();
def langInfo = Messages.LanguageInfo(lang.Name, lang.Path, dynExt ?? array(0));
def result = Messages.Config(Messages.ProjectSupport("", "", ""), array[langInfo], lang.Libs?.ToArray() ?? array(0));
File.WriteAllText(configPath, Serialize(result));
Deserialize(configPath)
};
result
}
}
}
Loading