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

Commit bf8cfea

Browse files
committed
Fix variables intellisense
1 parent 65b6912 commit bf8cfea

File tree

4 files changed

+94
-96
lines changed

4 files changed

+94
-96
lines changed

SourcepawnCondenser/SourcepawnCondenser/Condenser.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ public partial class Condenser
1515
private readonly Token[] t;
1616
private int position;
1717

18-
public Condenser(string sourceCode, string fileName, bool isSP = false)
18+
public Condenser(string sourceCode, string fileName)
1919
{
2020
t = Tokenizer.Tokenizer.TokenizeString(sourceCode, true).ToArray();
2121
position = 0;
2222
length = t.Length;
23-
def = new SMDefinition(isSP);
23+
def = new SMDefinition();
2424
source = sourceCode;
2525
if (fileName.EndsWith(".inc", StringComparison.InvariantCultureIgnoreCase))
2626
fileName = fileName.Substring(0, fileName.Length - 4);

SourcepawnCondenser/SourcepawnCondenser/SMDefinition/SMDefinition.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ public string[]
2727

2828
/* Other */
2929
public string[] FunctionStrings = new string[0];
30-
private bool isSP;
3130
public List<SMMethodmap> Methodmaps = new List<SMMethodmap>();
3231

3332

@@ -41,13 +40,7 @@ public string[]
4140
public string[] TypeStrings = new string[0];
4241
public List<SMVariable> Variables = new List<SMVariable>();
4342
public string[] VariableStrings = new string[0];
44-
45-
public SMDefinition(bool sp = false)
46-
{
47-
isSP = sp;
48-
}
49-
50-
43+
5144
public void Sort()
5245
{
5346
try

UI/MainWindowBackgroundParser.cs

Lines changed: 90 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,103 @@
11
using System.Diagnostics;
2-
using SourcepawnCondenser;
3-
using SourcepawnCondenser.SourcemodDefinition;
2+
using System.IO;
43
using System.Threading;
54
using System.Timers;
6-
using System.IO;
5+
using SourcepawnCondenser;
6+
using SourcepawnCondenser.SourcemodDefinition;
77
using Spedit.UI.Components;
8+
using Timer = System.Timers.Timer;
89

910
namespace Spedit.UI
1011
{
11-
public partial class MainWindow
12-
{
13-
private ulong currentSMDefUID;
14-
Thread backgroundParserThread;
15-
SMDefinition currentSMDef;
16-
System.Timers.Timer parseDistributorTimer;
12+
public partial class MainWindow
13+
{
14+
private Thread backgroundParserThread;
15+
private ACNode[] currentACNodes;
16+
private ISNode[] currentISNodes;
17+
private SMDefinition currentSMDef;
18+
private ulong currentSMDefUID;
19+
20+
private SMFunction[] currentSMFunctions;
21+
private Timer parseDistributorTimer;
22+
23+
private void StartBackgroundParserThread()
24+
{
25+
backgroundParserThread = new Thread(BackgroundParser_Worker);
26+
backgroundParserThread.Start();
27+
parseDistributorTimer = new Timer(500.0);
28+
parseDistributorTimer.Elapsed += ParseDistributorTimer_Elapsed;
29+
parseDistributorTimer.Start();
30+
}
31+
32+
private void ParseDistributorTimer_Elapsed(object sender, ElapsedEventArgs args)
33+
{
34+
if (currentSMDefUID == 0) return;
35+
36+
EditorElement[] ee = null;
37+
EditorElement ce = null;
38+
Dispatcher?.Invoke(() =>
39+
{
40+
ee = GetAllEditorElements();
41+
ce = GetCurrentEditorElement();
42+
});
43+
if (ee == null || ce == null) return;
1744

18-
private void StartBackgroundParserThread()
19-
{
20-
backgroundParserThread = new Thread(BackgroundParser_Worker);
21-
backgroundParserThread.Start();
22-
parseDistributorTimer = new System.Timers.Timer(500.0);
23-
parseDistributorTimer.Elapsed += ParseDistributorTimer_Elapsed;
24-
parseDistributorTimer.Start();
25-
}
45+
Debug.Assert(ee != null, nameof(ee) + " != null");
46+
foreach (var e in ee)
47+
if (e.LastSMDefUpdateUID < currentSMDefUID) //wants an update of the SMDefinition
48+
{
49+
if (e == ce)
50+
{
51+
Debug.Assert(ce != null, nameof(ce) + " != null");
52+
if (ce.ISAC_Open) continue;
53+
}
2654

27-
private void ParseDistributorTimer_Elapsed(object sender, ElapsedEventArgs args)
28-
{
29-
if (currentSMDefUID == 0) { return; }
30-
EditorElement[] ee = null;
31-
EditorElement ce = null;
32-
Dispatcher?.Invoke(() =>
33-
{
34-
ee = GetAllEditorElements();
35-
ce = GetCurrentEditorElement();
36-
});
37-
if (ee == null || ce == null) { return; } //this can happen!
55+
e.InterruptLoadAutoCompletes(currentSMDef.FunctionStrings, currentSMFunctions, currentACNodes,
56+
currentISNodes);
57+
e.LastSMDefUpdateUID = currentSMDefUID;
58+
}
59+
}
3860

39-
Debug.Assert(ee != null, nameof(ee) + " != null");
40-
foreach (var e in ee)
41-
{
42-
if (e.LastSMDefUpdateUID < currentSMDefUID) //wants an update of the SMDefinition
43-
{
44-
if (e == ce)
45-
{
46-
Debug.Assert(ce != null, nameof(ce) + " != null");
47-
if (ce.ISAC_Open)
48-
{
49-
continue;
50-
}
51-
}
52-
e.InterruptLoadAutoCompletes(currentSMDef.FunctionStrings, currentSMFunctions, currentACNodes, currentISNodes);
53-
e.LastSMDefUpdateUID = currentSMDefUID;
54-
}
55-
}
56-
}
61+
private void BackgroundParser_Worker()
62+
{
63+
while (true)
64+
while (Program.OptionsObject.Program_DynamicISAC)
65+
{
66+
Thread.Sleep(5000);
67+
var ee = GetAllEditorElements();
68+
if (ee != null)
69+
{
70+
var definitions = new SMDefinition[ee.Length];
71+
for (var i = 0; i < ee.Length; ++i)
72+
{
73+
var fInfo = new FileInfo(ee[i].FullFilePath);
74+
if (fInfo.Extension.Trim('.').ToLowerInvariant() == "inc")
75+
definitions[i] =
76+
new Condenser(File.ReadAllText(fInfo.FullName), fInfo.Name).Condense();
5777

58-
private SMFunction[] currentSMFunctions;
59-
private ACNode[] currentACNodes;
60-
private ISNode[] currentISNodes;
78+
if (fInfo.Extension.Trim('.').ToLowerInvariant() == "sp")
79+
{
80+
var i1 = i;
81+
Dispatcher.Invoke(() =>
82+
{
83+
if (ee[i1].IsLoaded)
84+
definitions[i1] =
85+
new Condenser(File.ReadAllText(fInfo.FullName), fInfo.Name)
86+
.Condense();
87+
});
88+
}
89+
}
6190

62-
private void BackgroundParser_Worker()
63-
{
64-
while (true)
65-
{
66-
while (Program.OptionsObject.Program_DynamicISAC)
67-
{
68-
Thread.Sleep(5000);
69-
var ee = GetAllEditorElements();
70-
if (ee != null)
71-
{
72-
SMDefinition[] definitions = new SMDefinition[ee.Length];
73-
for (int i = 0; i < ee.Length; ++i)
74-
{
75-
FileInfo fInfo = new FileInfo(ee[i].FullFilePath);
76-
if (fInfo.Extension.Trim('.').ToLowerInvariant() == "inc")
77-
{
78-
definitions[i] = (new Condenser(File.ReadAllText(fInfo.FullName), fInfo.Name).Condense());
79-
}
91+
currentSMDef = Program.Configs[Program.SelectedConfig].GetSMDef()
92+
.ProduceTemporaryExpandedDefinition(definitions);
93+
currentSMFunctions = currentSMDef.Functions.ToArray();
94+
currentACNodes = currentSMDef.ProduceACNodes();
95+
currentISNodes = currentSMDef.ProduceISNodes();
96+
++currentSMDefUID;
97+
}
98+
}
8099

81-
if (fInfo.Extension.Trim('.').ToLowerInvariant() == "sp")
82-
{
83-
definitions[i] = (new Condenser(File.ReadAllText(fInfo.FullName), fInfo.Name, true).Condense());
84-
}
85-
}
86-
currentSMDef = Program.Configs[Program.SelectedConfig].GetSMDef().ProduceTemporaryExpandedDefinition(definitions);
87-
currentSMFunctions = currentSMDef.Functions.ToArray();
88-
currentACNodes = currentSMDef.ProduceACNodes();
89-
currentISNodes = currentSMDef.ProduceISNodes();
90-
++currentSMDefUID;
91-
}
92-
}
93-
Thread.Sleep(5000);
94-
}
95-
// ReSharper disable once FunctionNeverReturns
96-
}
97-
}
98-
}
100+
// ReSharper disable once FunctionNeverReturns
101+
}
102+
}
103+
}

UI/MainWindowCommands.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Spedit.UI
1212
{
1313
public partial class MainWindow
1414
{
15-
private EditorElement GetCurrentEditorElement()
15+
public EditorElement GetCurrentEditorElement()
1616
{
1717
EditorElement outElement = null;
1818
if (DockingPane.SelectedContent?.Content != null)

0 commit comments

Comments
 (0)