|
2 | 2 | * Copyright © Magento, Inc. All rights reserved. |
3 | 3 | * See COPYING.txt for license details. |
4 | 4 | */ |
| 5 | + |
5 | 6 | package com.magento.idea.magento2plugin.completion.provider; |
6 | 7 |
|
7 | 8 | import com.intellij.codeInsight.completion.CompletionParameters; |
|
13 | 14 | import com.intellij.util.ProcessingContext; |
14 | 15 | import com.intellij.util.indexing.FileBasedIndex; |
15 | 16 | import com.magento.idea.magento2plugin.stubs.indexes.js.RequireJsIndex; |
16 | | -import org.jetbrains.annotations.NotNull; |
17 | 17 | import java.util.Collection; |
| 18 | +import org.jetbrains.annotations.NotNull; |
18 | 19 |
|
19 | 20 | public class RequireJsMappingCompletionProvider extends CompletionProvider<CompletionParameters> { |
20 | 21 |
|
21 | 22 | @Override |
22 | | - protected void addCompletions(@NotNull CompletionParameters parameters, |
23 | | - ProcessingContext context, |
24 | | - @NotNull CompletionResultSet result) { |
25 | | - PsiElement position = parameters.getPosition().getOriginalElement(); |
| 23 | + protected void addCompletions( |
| 24 | + final @NotNull CompletionParameters parameters, |
| 25 | + final ProcessingContext context, |
| 26 | + final @NotNull CompletionResultSet result |
| 27 | + ) { |
| 28 | + final PsiElement position = parameters.getPosition().getOriginalElement(); |
26 | 29 | if (position == null) { |
27 | 30 | return; |
28 | 31 | } |
29 | | - String prefix = result.getPrefixMatcher().getPrefix(); |
| 32 | + final String prefix = result.getPrefixMatcher().getPrefix(); |
30 | 33 |
|
31 | | - Collection<String> requireJsKeys |
32 | | - = FileBasedIndex.getInstance().getAllKeys(RequireJsIndex.KEY, position.getProject()); |
| 34 | + final Collection<String> requireJsKeys |
| 35 | + = FileBasedIndex.getInstance().getAllKeys( |
| 36 | + RequireJsIndex.KEY, position.getProject() |
| 37 | + ); |
33 | 38 |
|
34 | 39 | requireJsKeys.removeIf(m -> !m.startsWith(prefix)); |
35 | | - JavaScriptFileType jsFileType = new JavaScriptFileType(); |
36 | | - for (String requireJsKey : requireJsKeys) { |
| 40 | + final JavaScriptFileType jsFileType = JavaScriptFileType.INSTANCE; |
| 41 | + for (final String requireJsKey : requireJsKeys) { |
37 | 42 | result.addElement( |
38 | 43 | LookupElementBuilder |
39 | 44 | .create(requireJsKey) |
|
0 commit comments