6
6
import com .intellij .codeInsight .lookup .LookupElementPresentation ;
7
7
import com .intellij .util .IconUtil ;
8
8
import org .jetbrains .annotations .NotNull ;
9
+ import org .jetbrains .annotations .Nullable ;
9
10
10
11
/**
11
12
* @author Daniel Espendiller <daniel@espendiller.net>
12
13
*/
13
14
public class SymfonyBundleFileLookupElement extends LookupElement {
14
-
15
+ private final @ NotNull String bundleName ;
15
16
private final BundleFile bundleFile ;
16
17
private InsertHandler <LookupElement > insertHandler = null ;
18
+ private final @ Nullable String shortcutName ;
17
19
18
20
public SymfonyBundleFileLookupElement (BundleFile bundleFile ) {
19
21
this .bundleFile = bundleFile ;
22
+ this .shortcutName = bundleFile .getShortcutPath ();
23
+ this .bundleName = bundleFile .getSymfonyBundle ().getName ();
20
24
}
21
25
22
26
public SymfonyBundleFileLookupElement (BundleFile bundleFile , InsertHandler <LookupElement > insertHandler ) {
@@ -27,23 +31,21 @@ public SymfonyBundleFileLookupElement(BundleFile bundleFile, InsertHandler<Looku
27
31
@ NotNull
28
32
@ Override
29
33
public String getLookupString () {
30
- String shortcutName = this .bundleFile .getShortcutPath ();
31
- if (shortcutName == null ) {
34
+ if (shortcutName == null ) {
32
35
return "" ;
33
36
}
34
37
35
38
// we strip any control char, so only use the pathname
36
- if (shortcutName .startsWith ("@" )) {
37
- shortcutName = shortcutName .substring (1 );
39
+ if (shortcutName .startsWith ("@" )) {
40
+ return shortcutName .substring (1 );
38
41
}
39
42
40
43
return shortcutName ;
41
44
}
42
45
43
46
@ Override
44
- public void handleInsert (InsertionContext context ) {
45
-
46
- if (this .insertHandler != null ) {
47
+ public void handleInsert (@ NotNull InsertionContext context ) {
48
+ if (this .insertHandler != null ) {
47
49
this .insertHandler .handleInsert (context , this );
48
50
return ;
49
51
}
@@ -53,10 +55,8 @@ public void handleInsert(InsertionContext context) {
53
55
54
56
public void renderElement (LookupElementPresentation presentation ) {
55
57
presentation .setItemText (getLookupString ());
56
- presentation .setTypeText (this . bundleFile . getSymfonyBundle (). getName () );
58
+ presentation .setTypeText (bundleName );
57
59
presentation .setTypeGrayed (true );
58
60
presentation .setIcon (IconUtil .getIcon (this .bundleFile .getVirtualFile (), 0 , this .bundleFile .getProject ()));
59
-
60
61
}
61
-
62
62
}
0 commit comments