1111import com .intellij .util .ProcessingContext ;
1212import org .jetbrains .annotations .NotNull ;
1313
14+ import java .util .ArrayList ;
15+ import java .util .Comparator ;
1416import java .util .HashMap ;
1517import java .util .HashSet ;
18+ import java .util .LinkedHashMap ;
19+ import java .util .List ;
1620import java .util .Map ;
21+ import java .util .stream .Collectors ;
1722
1823public class JALInstructionNameCompletionProvider extends CompletionProvider <CompletionParameters >
1924{
@@ -22,7 +27,7 @@ public class JALInstructionNameCompletionProvider extends CompletionProvider<Com
2227
2328 static
2429 {
25- HashMap <String , String > instructions = new HashMap <>();
30+ HashMap <String , String > instructions = new LinkedHashMap <>();
2631 // <editor-fold desc="Instruction Definitions">
2732 instructions .putAll (Map .ofEntries (
2833 Map .entry ("aaload" , "Reference: Array Load" ),
@@ -265,7 +270,17 @@ public class JALInstructionNameCompletionProvider extends CompletionProvider<Com
265270 )
266271 );
267272 // </editor-fold>
268- INSTRUCTIONS = instructions ;
273+ // Value のほうで昇順にソートする。
274+
275+ INSTRUCTIONS = instructions .entrySet ()
276+ .stream ()
277+ .sorted (Map .Entry .comparingByValue ()) // 昇順
278+ .collect (Collectors .toMap (
279+ Map .Entry ::getKey ,
280+ Map .Entry ::getValue ,
281+ (e1 , e2 ) -> e1 , // マージ関数は無視
282+ LinkedHashMap ::new // LinkedHashMap に詰める
283+ ));
269284 }
270285
271286 static
@@ -333,7 +348,6 @@ public class JALInstructionNameCompletionProvider extends CompletionProvider<Com
333348 // </editor-fold>
334349 }
335350
336-
337351 @ Override
338352 protected void addCompletions (@ NotNull CompletionParameters parameters , @ NotNull ProcessingContext context ,
339353 @ NotNull CompletionResultSet result )
@@ -348,7 +362,6 @@ protected void addCompletions(@NotNull CompletionParameters parameters, @NotNull
348362 instructionName ))
349363 .withCaseSensitivity (true );
350364 result .addElement (lookupElement );
351-
352365 }
353366 }
354367
0 commit comments