Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.

Commit 995a27f

Browse files
committed
Add Handle as a Methodmap
1 parent 9c7f977 commit 995a27f

File tree

3 files changed

+28
-10
lines changed

3 files changed

+28
-10
lines changed

SourcepawnCondenser/SourcepawnCondenser/SourcemodDefinition/SMDefinition.cs

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,34 @@
22
using System.Collections.Generic;
33
using System.IO;
44
using System.Linq;
5+
56
// ReSharper disable NonReadonlyMemberInGetHashCode
67

78
namespace SourcepawnCondenser.SourcemodDefinition
89
{
910
public class SMDefinition
1011
{
12+
public SMDefinition()
13+
{
14+
if (Methodmaps.Count == 0)
15+
Methodmaps.Add(new SMMethodmap()
16+
{
17+
Name = "Handle",
18+
Methods =
19+
{
20+
new SMMethodmapMethod()
21+
{
22+
FullName = "(external) void Close()",
23+
ClassName = "Name",
24+
Name = "Close",
25+
CommentString =
26+
"Clones a Handle.\nWhen passing handles in between plugins, caching handles can result in accidental invalidation when one plugin releases the Handle,\nor is its owner is unloaded from memory.\nTo prevent this, the Handle may be \"cloned\" with a new owner.",
27+
ReturnType = "void"
28+
}
29+
}
30+
});
31+
}
32+
1133
// This contains Enum values, Constant variables, Defines.
1234
public List<string> Constants;
1335

@@ -30,6 +52,7 @@ public class SMDefinition
3052

3153
// This contains method map and enum structs' methods.
3254
public List<string> ObjectMethods;
55+
3356
// This contains method map and enum structs' fields.
3457
public List<string> ObjectFields;
3558

@@ -46,7 +69,7 @@ public void Sort()
4669
{
4770
Functions = Functions.Distinct(new SMFunctionComparer()).ToList();
4871
Functions.Sort((a, b) => string.CompareOrdinal(a.Name, b.Name));
49-
//Enums = Enums.Distinct(new SMEnumComparer()).ToList(); //enums can have the same name but not be the same...
72+
//Enums = Enums.Distinct(new SMEnumComparer()).ToList(); //enums can have the same name but not be the same values
5073
Enums.Sort((a, b) => string.CompareOrdinal(a.Name, b.Name));
5174
Structs = Structs.Distinct(new SMStructComparer()).ToList();
5275
Structs.Sort((a, b) => string.CompareOrdinal(a.Name, b.Name));
@@ -170,13 +193,13 @@ public List<ACNode> ProduceACNodes()
170193
// nodes.AddRange(ACNode.ConvertFromStringList(EnumStructs.Select(e => e.Name), false, "↩ "));
171194
nodes.AddRange(ACNode.ConvertFromStringList(Variables.Select(e => e.Name), false, "• "));
172195
nodes.AddRange(ACNode.ConvertFromStringList(_functionVariableStrings, false, "• "));
173-
196+
174197
//nodes = nodes.Distinct(new ACNodeEqualityComparer()).ToList(); Methodmaps and Functions can and will be the same.
175198
nodes.Sort((a, b) => string.CompareOrdinal(a.EntryName, b.EntryName));
176199

177200
return nodes;
178201
}
179-
202+
180203
public void MergeDefinitions(SMDefinition def)
181204
{
182205
try

UI/Components/EditorElement/EditorElementGoToDefinition.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,7 @@ private string GetWordAtMousePosition(MouseEventArgs e)
187187

188188
var currentChar = editor.TextArea.Document.GetText(offset, 1);
189189

190-
if (string.IsNullOrWhiteSpace(currentChar))
191-
{
192-
return string.Empty;
193-
}
194-
195-
return editor.TextArea.Document.GetText(offsetStart, offsetEnd - offsetStart);
190+
return string.IsNullOrWhiteSpace(currentChar) ? string.Empty : editor.TextArea.Document.GetText(offsetStart, offsetEnd - offsetStart);
196191
}
197192
}
198193
}

UI/Components/EditorElement/EditorElementIntellisenseController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ bool ComputeIntelliSense(string text, int lineOffset)
348348
{
349349
return null;
350350
}
351-
351+
352352
// If we found the declaration get the Variable Type and look for a method-map matching its type.
353353

354354
return (SMClasslike)_smDef.Methodmaps.FirstOrDefault(e => e.Name == varDecl.Type) ??

0 commit comments

Comments
 (0)