@@ -136,7 +136,7 @@ public bool CanMoveToResource()
136136 var projectResources = new HashSet < ResourceEntity > ( GetResourceEntriesFromProject ( document , entities ) ) ;
137137
138138 // put resources from the same project on top
139- entities . RemoveAll ( entity => projectResources . Contains ( entity ) ) ;
139+ entities . RemoveAll ( projectResources . Contains ) ;
140140 entities . InsertRange ( 0 , projectResources ) ;
141141
142142 // put the last used entry on top, if it's in the same project, or the last access was cross-project.
@@ -197,7 +197,7 @@ private static IEnumerable<ResourceEntity> GetResourceEntriesFromProject(Documen
197197 }
198198 catch ( Exception )
199199 {
200- return Enumerable . Empty < ResourceEntity > ( ) ;
200+ return [ ] ;
201201 }
202202 }
203203
@@ -256,7 +256,7 @@ private static bool IsInProject(ResourceEntity entity, Project? project)
256256 if ( document is null )
257257 return null ;
258258
259- var textDocument = ( TextDocument ? ) document . Object ( @ "TextDocument") ;
259+ var textDocument = ( TextDocument ? ) document . Object ( "TextDocument" ) ;
260260 if ( textDocument is null )
261261 return null ;
262262
@@ -396,60 +396,46 @@ private sealed class GenericParser : IParser
396396 return locator . Locate ( @"""" ) ?? locator . Locate ( "'" ) ?? locator . Locate ( "`" ) ;
397397 }
398398
399- private sealed class Locator
399+ private sealed class Locator ( string line , int column , Selection ? selection )
400400 {
401- private readonly string _line ;
402- private readonly int _column ;
403- private readonly Selection ? _selection ;
404-
405- public Locator ( string line , int column , Selection ? selection )
406- {
407- _line = line ;
408- _column = column ;
409- _selection = selection ;
410- }
411-
412401 public string ? Locate ( string quote )
413402 {
414403 ThrowIfNotOnUIThread ( ) ;
415404
416405 var secondQuote = - 1 ;
417406
418- while ( secondQuote < _line . Length )
407+ while ( secondQuote < line . Length )
419408 {
420- var firstQuote = _line . IndexOf ( quote , secondQuote + 1 , StringComparison . Ordinal ) ;
409+ var firstQuote = line . IndexOf ( quote , secondQuote + 1 , StringComparison . Ordinal ) ;
421410 if ( firstQuote == - 1 )
422411 return null ;
423412
424- if ( _line . Length <= firstQuote + 1 )
413+ var startIndex = firstQuote + 1 ;
414+
415+ if ( line . Length <= startIndex )
425416 return null ;
426417
427- if ( _column < firstQuote )
418+ if ( column < firstQuote )
428419 return null ;
429420
430- secondQuote = _line . IndexOf ( quote , firstQuote + 1 , StringComparison . Ordinal ) ;
421+ secondQuote = line . IndexOf ( quote , startIndex , StringComparison . Ordinal ) ;
431422 if ( secondQuote == - 1 )
432423 return null ;
433424
434- if ( _column >= secondQuote )
435- continue ;
425+ var endIndex = secondQuote + 2 ;
436426
437- var startIndex = firstQuote + 1 ;
438- var length = secondQuote - firstQuote - 1 ;
427+ if ( column >= endIndex )
428+ continue ;
439429
440- if ( _selection != null )
441- {
442- var startColumn = firstQuote + 1 ;
443- var endColumn = secondQuote + 2 ;
430+ var length = secondQuote - startIndex ;
444431
445- _selection . MoveTo ( startColumn , endColumn ) ;
446- }
432+ selection ? . MoveTo ( startIndex , endIndex ) ;
447433
448- return _line . Substring ( startIndex , length ) ;
434+ return line . Substring ( startIndex , length ) ;
449435 }
450436
451437 return null ;
452438 }
453439 }
454440 }
455- }
441+ }
0 commit comments