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

Commit f549f2a

Browse files
committed
Use LINQ for IntelliSense
1 parent 6c941a0 commit f549f2a

File tree

2 files changed

+35
-45
lines changed

2 files changed

+35
-45
lines changed

App/AssemblyInfo1.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@
3333
#if (DEBUG)
3434
[assembly: AssemblyVersion("1.13.*")]
3535
#else
36-
[assembly: AssemblyVersion("1.3.0.0")]
36+
[assembly: AssemblyVersion("1.3.0.1")]
3737
#endif

UI/Components/IntelliSenseController.cs

+34-44
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Linq;
23
using System.Text.RegularExpressions;
34
using System.Windows;
45
using System.Windows.Input;
@@ -182,72 +183,61 @@ private void EvaluateIntelliSense()
182183
{
183184
var methodString = ISMatches[j].Groups["method"].Value;
184185
var found = false;
186+
185187
// Match for static methods.
186-
foreach (var methodMap in methodMaps)
188+
var staticMethodMap = methodMaps.FirstOrDefault(e => e.Name == classString);
189+
var staticMethod =
190+
staticMethodMap?.Methods.FirstOrDefault(e => e.Name == methodString);
191+
if (staticMethod != null)
187192
{
188-
if (classString == methodMap.Name)
189-
{
190-
foreach (var method in methodMap.Methods)
191-
{
192-
if (method.Name == methodString)
193-
{
194-
xPos = ISMatches[j].Groups["method"].Index +
195-
ISMatches[j].Groups["method"].Length;
196-
ForwardShowIS = true;
197-
ISFuncNameStr = method.FullName;
198-
ISFuncDescriptionStr = method.CommentString;
199-
ForceReSet = true;
200-
found = true;
201-
break;
202-
}
203-
}
204-
205-
break;
206-
}
193+
xPos = ISMatches[j].Groups["method"].Index +
194+
ISMatches[j].Groups["method"].Length;
195+
ForwardShowIS = true;
196+
ISFuncNameStr = staticMethod.FullName;
197+
ISFuncDescriptionStr = staticMethod.CommentString;
198+
ForceReSet = true;
199+
found = true;
207200
}
201+
208202
if (!found)
209203
{
210204
// Many any methodmap, since the ide is not aware of the types
211205
foreach (var methodMap in methodMaps)
212206
{
213-
Console.WriteLine(methodMap.Name);
214-
foreach (var method in methodMap.Methods)
207+
var method =
208+
methodMap.Methods.FirstOrDefault(e => e.Name == methodString);
209+
if (method != null)
215210
{
216-
if (method.Name == methodString)
217-
{
218-
xPos = ISMatches[j].Groups["method"].Index +
219-
ISMatches[j].Groups["method"].Length;
220-
ForwardShowIS = true;
221-
ISFuncNameStr = method.FullName;
222-
ISFuncDescriptionStr = method.CommentString;
223-
ForceReSet = true;
224-
found = true;
225-
break;
226-
}
211+
xPos = ISMatches[j].Groups["method"].Index +
212+
ISMatches[j].Groups["method"].Length;
213+
ForwardShowIS = true;
214+
ISFuncNameStr = method.FullName;
215+
ISFuncDescriptionStr = method.CommentString;
216+
ForceReSet = true;
227217
}
228218
}
229219
}
230220
}
231221
else
232222
{
233-
foreach (var func in funcs)
234-
if (testString == func.Name)
235-
{
236-
xPos = ISMatches[j].Groups["name"].Index +
237-
ISMatches[j].Groups["name"].Length;
238-
ForwardShowIS = true;
239-
ISFuncNameStr = func.FullName;
240-
ISFuncDescriptionStr = func.CommentString;
241-
ForceReSet = true;
242-
break;
243-
}
223+
var func = funcs.FirstOrDefault(e => e.Name == testString);
224+
if (func != null)
225+
{
226+
xPos = ISMatches[j].Groups["name"].Index +
227+
ISMatches[j].Groups["name"].Length;
228+
ForwardShowIS = true;
229+
ISFuncNameStr = func.FullName;
230+
ISFuncDescriptionStr = func.CommentString;
231+
ForceReSet = true;
232+
}
244233
}
245234

246235
break;
247236
}
248237

249238
if (FoundMatch)
250239
{
240+
// ReSharper disable once RedundantAssignment
251241
scopeLevel--; //i have no idea why this works...
252242
break;
253243
}

0 commit comments

Comments
 (0)