Skip to content

Commit 3216ae3

Browse files
committed
Merge branch 'master' into 2.0
2 parents 3866725 + f4e3267 commit 3216ae3

23 files changed

Lines changed: 1366 additions & 708 deletions

Deltinteger/Deltinteger/Compiler/Syntax Tree/Syntax Tree.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ public StringExpression(Token localized, Token token)
396396
{
397397
Localized = localized;
398398
Token = token;
399-
Value = token.Text.StartsWith("\"") ? Extras.RemoveQuotes(token.Text) : token.Text.Trim('\'');
399+
Value = Extras.RemoveQuotes(token.Text);
400400
}
401401

402402
public StringExpression(Token localized, Token token, List<IParseExpression> formats) : this(localized, token)

Deltinteger/Deltinteger/Elements/Values.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -450,12 +450,12 @@ public override Element Optimize()
450450

451451
if (ParameterValues[0] is V_Number a && ParameterValues[1] is V_Number b)
452452
{
453-
double h = a.Value;
454-
double v = b.Value;
453+
double h = a.Value * (Math.PI / 180);
454+
double v = b.Value * (Math.PI / 180);
455455

456-
double x = Math.Sin(h * (Math.PI / 180));
457-
double y = -Math.Sin(v * (Math.PI / 180));
458-
double z = Math.Cos(h * (Math.PI / 180));
456+
double x = Math.Sin(h) * Math.Cos(v);
457+
double y = -Math.Sin(v);
458+
double z = Math.Cos(h) * Math.Cos(v);
459459

460460
if (y == -0)
461461
y = 0;
@@ -566,6 +566,7 @@ public override object GetConstant() =>
566566
}
567567

568568
[ElementData("Empty Array", ValueType.Any)]
569+
[HideElement]
569570
public class V_EmptyArray : Element { }
570571

571572
[ElementData("Entity Exists", ValueType.Boolean)]
@@ -601,6 +602,7 @@ public class V_EyePosition : Element { }
601602
public class V_FacingDirectionOf : Element { }
602603

603604
[ElementData("False", ValueType.Boolean)]
605+
[HideElement]
604606
public class V_False : Element
605607
{
606608
public override bool ConstantSupported<T>() =>
@@ -1117,9 +1119,11 @@ public override Element Optimize()
11171119
}
11181120

11191121
[ElementData("Null", ValueType.Any)]
1122+
[HideElement]
11201123
public class V_Null : Element { }
11211124

11221125
[ElementData("Number", ValueType.Number)]
1126+
[HideElement]
11231127
public class V_Number : Element
11241128
{
11251129
public static readonly V_Number LargeArbitraryNumber = new V_Number(9999);
@@ -1476,6 +1480,7 @@ public override Element Optimize()
14761480
[Parameter("{0}", ValueType.Any, typeof(V_Null))]
14771481
[Parameter("{1}", ValueType.Any, typeof(V_Null))]
14781482
[Parameter("{2}", ValueType.Any, typeof(V_Null))]
1483+
[HideElement]
14791484
public class V_String : Element
14801485
{
14811486
public V_String(string text, params Element[] stringValues) : base(NullifyEmptyValues(stringValues))
@@ -1510,6 +1515,7 @@ protected override bool OverrideEquals(IWorkshopTree other)
15101515
[Parameter("{0}", ValueType.Any, typeof(V_Null))]
15111516
[Parameter("{1}", ValueType.Any, typeof(V_Null))]
15121517
[Parameter("{2}", ValueType.Any, typeof(V_Null))]
1518+
[HideElement]
15131519
public class V_CustomString : Element
15141520
{
15151521
public string Text { get; }
@@ -1630,6 +1636,7 @@ public class V_ThrottleOf : Element { }
16301636
public class V_TotalTimeElapsed : Element { }
16311637

16321638
[ElementData("True", ValueType.Boolean)]
1639+
[HideElement]
16331640
public class V_True : Element
16341641
{
16351642
public override bool ConstantSupported<T>() =>

Deltinteger/Deltinteger/Extras.cs

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
using System.Text;
33
using System.Collections.Generic;
44
using System.IO;
5-
using System.Xml.Serialization;
65
using Deltin.Deltinteger.Parse;
76
using StringOrMarkupContent = OmniSharp.Extensions.LanguageServer.Protocol.Models.StringOrMarkupContent;
87
using MarkupContent = OmniSharp.Extensions.LanguageServer.Protocol.Models.MarkupContent;
98
using MarkupKind = OmniSharp.Extensions.LanguageServer.Protocol.Models.MarkupKind;
9+
using DocumentUri = OmniSharp.Extensions.LanguageServer.Protocol.DocumentUri;
1010

1111
namespace Deltin.Deltinteger
1212
{
@@ -55,9 +55,6 @@ public static string CombinePathWithDotNotation(string referenceDirectory, strin
5555
{
5656
string directory = Path.GetDirectoryName(referenceDirectory);
5757
string combined = Path.Combine(directory, file);
58-
if (file == "") combined += Path.DirectorySeparatorChar;
59-
if (!System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows))
60-
combined = "/" + combined;
6158
return Path.GetFullPath(combined);
6259
}
6360
catch (Exception)
@@ -66,40 +63,22 @@ public static string CombinePathWithDotNotation(string referenceDirectory, strin
6663
}
6764
}
6865

69-
public static string Lines(params string[] lines)
70-
{
71-
return string.Join("\n", lines);
72-
}
73-
74-
public static string RemoveQuotes(this string str) => str.Length >= 2 && str[0] == '"' && str[str.Length - 1] == '"' ? str.Substring(1, str.Length - 2) : str;
75-
76-
public static string FilePath(this Uri uri)
77-
{
78-
var path = uri.LocalPath.TrimStart('\\').TrimStart('/');
79-
if(!System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows))
80-
return "/" + path.Replace('\\', '/');
81-
else
82-
return path;
83-
}
66+
public static string RemoveQuotes(this string str) => str.Length >= 2 &&
67+
((str[0] == '"' && str[str.Length - 1] == '"') || (str[0] == '\'' && str[str.Length - 1] == '\'')) ? str.Substring(1, str.Length - 2) : str;
8468

85-
public static Uri Clean(this Uri uri)
69+
public static string FilePath(this Uri uri) => uri.LocalPath;
70+
public static bool Compare(this Uri uri, Uri other) => uri.LocalPath == other.LocalPath;
71+
public static DocumentUri ToDefinition(this Uri uri)
8672
{
87-
return new Uri(uri.FilePath());
73+
string enc = uri.LocalPath.Replace('\\', '/').Replace(" ", "%20").Replace(":", "%3A");
74+
return DocumentUri.File(uri.LocalPath);
8875
}
8976

90-
public static bool Compare(this Uri uri, Uri other) => uri.Clean().FilePath() == other.Clean().FilePath();
91-
9277
public static string GetNameOrDefine(this CodeType type) => type?.GetName() ?? "define";
9378

9479
public static bool CodeTypeParameterInvalid(this CodeType parameterType, CodeType valueType) =>
9580
parameterType != null && ((parameterType.IsConstant() && valueType == null) || (valueType != null && !valueType.Implements(parameterType)));
9681

97-
public static Uri Definition(string path)
98-
{
99-
string enc = "file:///" + path.Replace('\\', '/').Replace(" ", "%20").Replace(":", "%3A");
100-
return new Uri(enc);
101-
}
102-
10382
public static StringOrMarkupContent GetMarkupContent(string text) => new StringOrMarkupContent(new MarkupContent()
10483
{
10584
Kind = MarkupKind.Markdown,

Deltinteger/Deltinteger/Parse/Import/ImportedFile.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public ImportedFile(Uri uri)
2626
}
2727
}
2828

29-
private FileStream GetStream() => new FileStream(Uri.FilePath(), FileMode.Open, FileAccess.Read);
29+
private FileStream GetStream() => new FileStream(Uri.LocalPath, FileMode.Open, FileAccess.Read);
3030

3131
private byte[] GetFileHash(FileStream stream)
3232
{

Deltinteger/Deltinteger/Parse/Import/Importer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,15 +204,15 @@ class ImportResult
204204

205205
public ImportResult(FileImporter fileImporter, DocRange importRange, string relativePath, Uri referencingFile)
206206
{
207-
string resultingPath = Extras.CombinePathWithDotNotation(referencingFile.FilePath(), relativePath);
207+
string resultingPath = Extras.CombinePathWithDotNotation(referencingFile.LocalPath, relativePath);
208208

209209
// Syntax error if the filename has invalid characters.
210210
if (resultingPath == null)
211211
{
212212
fileImporter.Diagnostics.Error("File path contains invalid characters.", importRange);
213213
return;
214214
}
215-
Uri = Extras.Definition(resultingPath);
215+
Uri = new Uri(resultingPath);
216216
Directory = Path.GetDirectoryName(resultingPath);
217217
FilePath = resultingPath;
218218
FileType = Path.GetExtension(FilePath).ToLower();

Deltinteger/Deltinteger/Parse/Parameters/AlternateParameterTypes.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public override object Validate(ParseInfo parseInfo, IExpression value, DocRange
179179
return null;
180180
}
181181

182-
string resultingPath = Extras.CombinePathWithDotNotation(parseInfo.Script.Uri.FilePath(), str.Value);
182+
string resultingPath = Extras.CombinePathWithDotNotation(parseInfo.Script.Uri.LocalPath, str.Value);
183183

184184
if (resultingPath == null)
185185
{
@@ -203,7 +203,7 @@ public override object Validate(ParseInfo parseInfo, IExpression value, DocRange
203203
return null;
204204
}
205205

206-
parseInfo.Script.AddDefinitionLink(valueRange, new Location(Extras.Definition(resultingPath), DocRange.Zero));
206+
parseInfo.Script.AddDefinitionLink(valueRange, new Location(new Uri(resultingPath), DocRange.Zero));
207207
parseInfo.Script.AddHover(valueRange, resultingPath);
208208

209209
return resultingPath;

Deltinteger/Deltinteger/Parse/ScriptFile.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public void AddDefinitionLink(DocRange callRange, Location definedAt)
5959
callLinks.Add(new LocationLink()
6060
{
6161
OriginSelectionRange = callRange,
62-
TargetUri = definedAt.uri,
62+
TargetUri = definedAt.uri.ToDefinition(),
6363
TargetRange = definedAt.range,
6464
TargetSelectionRange = definedAt.range
6565
});

Deltinteger/Deltinteger/Parse/Variables/Var.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ public Var(VarInfo varInfo)
5555
DefinedAt = varInfo.DefinedAt;
5656
parseInfo = varInfo.ParseInfo;
5757
AccessLevel = varInfo.AccessLevel;
58-
DefinedAt = varInfo.DefinedAt;
5958
WholeContext = varInfo.WholeContext;
6059
CodeType = varInfo.Type;
6160
VariableType = varInfo.VariableType;

Deltinteger/Deltinteger/Program.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ static void Main(string[] args)
4242
return;
4343
}
4444

45+
if (args.Contains("--waitfordebugger") && !WaitForDebugger())
46+
return;
47+
4548
Program.args = args;
4649
CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US");
4750
ElementList.InitElements();
@@ -63,9 +66,19 @@ static void Main(string[] args)
6366
}
6467
}
6568

66-
static void WaitForDebugger()
69+
static bool WaitForDebugger()
6770
{
68-
while (!System.Diagnostics.Debugger.IsAttached) Thread.Sleep(100);
71+
var stopwatch = new System.Diagnostics.Stopwatch();
72+
stopwatch.Start();
73+
74+
while (!System.Diagnostics.Debugger.IsAttached)
75+
{
76+
Thread.Sleep(100);
77+
78+
if (stopwatch.ElapsedMilliseconds > 30000)
79+
return false;
80+
}
81+
return true;
6982
}
7083

7184
public static void Script(string parseFile)

Deltinteger/Deltinteger/packages.config

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)