@@ -176,102 +176,14 @@ public async Task CancelIfRunningAsync()
176176 }
177177 await ProjectHelper . HideProgressAsync ( ) ;
178178 }
179- private void HandleKeyCollision ( string existingKey , string newValue )
180- {
181- if ( _queryDict [ existingKey ] . Equals ( newValue ) )
182- {
183- return ;
184- }
185- StringBuilder replacementKey = new StringBuilder ( ) ;
186- StringBuilder newValueKey = new StringBuilder ( ) ;
187- List < string > existingValueParts = _queryDict [ existingKey ] . Split ( '/' ) . ToList ( ) ;
188- List < string > newValueParts = newValue . Split ( '/' ) . ToList ( ) ;
189- while ( ( existingValueParts . Count > 0 && newValueParts . Count > 0 ) &&
190- existingValueParts . Last ( ) . Equals ( newValueParts . Last ( ) ) )
191- {
192- replacementKey . Insert ( 0 , "/" + existingValueParts . Last ( ) ) ;
193- existingValueParts . RemoveAt ( existingValueParts . Count - 1 ) ;
194- newValueKey . Insert ( 0 , "/" + newValueParts . Last ( ) ) ;
195- newValueParts . RemoveAt ( newValueParts . Count - 1 ) ;
196- }
197-
198- // add remaining unique value
199- if ( newValueParts . Count > 0 && existingValueParts . Count > 0 ) {
200- newValueKey . Insert ( 0 , newValueParts . Last ( ) ) ;
201- replacementKey . Insert ( 0 , existingValueParts . Last ( ) ) ;
202-
203- // if at a version, try to get the qlpack for it which should be the preceding two segments
204- if ( Version . TryParse ( newValueParts . Last ( ) , out _ ) && newValueParts . Count > 2 )
205- {
206- newValueKey . Insert ( 0 , newValueParts . ElementAt ( newValueParts . Count - 3 ) + "/" +
207- newValueParts . ElementAt ( newValueParts . Count - 2 ) + "/" ) ;
208- }
209- if ( Version . TryParse ( existingValueParts . Last ( ) , out _ ) && existingValueParts . Count > 2 )
210- {
211- replacementKey . Insert ( 0 , existingValueParts . ElementAt ( existingValueParts . Count - 2 ) + "/" +
212- existingValueParts . ElementAt ( existingValueParts . Count - 2 ) + "/" ) ;
213- }
214- }
215- else
216- {
217- throw new Exception ( "Unable to find new key" ) ;
218- }
219-
220- if ( newValueKey . ToString ( ) . Equals ( replacementKey . ToString ( ) ) )
221- {
222- throw new Exception ( "Unable to find new key" ) ;
223- }
224- _queryDict . Remove ( existingKey ) ;
225- if ( ! _queryDict . ContainsKey ( replacementKey . ToString ( ) ) )
226- {
227- _queryDict . Add ( replacementKey . ToString ( ) , string . Join ( "/" , existingValueParts ) ) ;
228- }
229- if ( ! _queryDict . ContainsKey ( replacementKey . ToString ( ) ) )
230- {
231- _queryDict . Add ( newValueKey . ToString ( ) , newValue ) ;
232- }
233- }
234-
179+
235180 public async Task < ObservableCollection < string > > FindAvailableQueriesAsync ( )
236181 {
237182 List < string > packList = await CodeQLRunner . Instance . FindPacksAsync ( CodeQLGeneralOptions . Instance . AdditionalQueryLocations ) ;
238183 List < string > queryList = await CodeQLRunner . Instance . FindQueriesAsync ( packList , queriesNSuites : false ) ;
239- foreach ( string query in queryList )
240- {
241- string key = query . Replace ( "\\ " , "/" ) . Split ( '/' ) . Last ( ) ;
242- if ( _queryDict . ContainsKey ( key ) )
243- {
244- HandleKeyCollision ( key , query ) ;
245- }
246- else
247- {
248- _queryDict . Add ( key , query . Replace ( "\\ " , "/" ) ) ;
249- }
250- }
251-
252- return new ObservableCollection < string > ( _queryDict . Keys ) ;
184+ return new ObservableCollection < string > ( queryList . ToHashSet ( ) ) ;
253185 }
254186
255- public void AddAdditionalQueries ( List < string > queries )
256- {
257- foreach ( string query in queries )
258- {
259- string key = query . Replace ( "\\ " , "/" ) . Split ( '/' ) . Last ( ) ;
260- if ( ! _queryDict . ContainsKey ( key ) )
261- {
262- _queryDict . Add ( key , query . Replace ( "\\ " , "/" ) ) ;
263- }
264- }
265- }
266-
267- public void RemoveQuery ( string query )
268- {
269- string key = query . Replace ( "\\ " , "/" ) . Split ( '/' ) . Last ( ) ;
270- if ( _queryDict . ContainsKey ( key ) )
271- {
272- _queryDict . Remove ( key ) ;
273- }
274- }
275187
276188 public async Task UpdateDatabaseBuildInfoAsync ( )
277189 {
0 commit comments