66import com .intellij .codeInsight .lookup .LookupElementPresentation ;
77import com .intellij .util .IconUtil ;
88import org .jetbrains .annotations .NotNull ;
9+ import org .jetbrains .annotations .Nullable ;
910
1011/**
1112 * @author Daniel Espendiller <[email protected] > 1213 */
1314public class SymfonyBundleFileLookupElement extends LookupElement {
14-
15+ private final @ NotNull String bundleName ;
1516 private final BundleFile bundleFile ;
1617 private InsertHandler <LookupElement > insertHandler = null ;
18+ private final @ Nullable String shortcutName ;
1719
1820 public SymfonyBundleFileLookupElement (BundleFile bundleFile ) {
1921 this .bundleFile = bundleFile ;
22+ this .shortcutName = bundleFile .getShortcutPath ();
23+ this .bundleName = bundleFile .getSymfonyBundle ().getName ();
2024 }
2125
2226 public SymfonyBundleFileLookupElement (BundleFile bundleFile , InsertHandler <LookupElement > insertHandler ) {
@@ -27,23 +31,21 @@ public SymfonyBundleFileLookupElement(BundleFile bundleFile, InsertHandler<Looku
2731 @ NotNull
2832 @ Override
2933 public String getLookupString () {
30- String shortcutName = this .bundleFile .getShortcutPath ();
31- if (shortcutName == null ) {
34+ if (shortcutName == null ) {
3235 return "" ;
3336 }
3437
3538 // 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 );
3841 }
3942
4043 return shortcutName ;
4144 }
4245
4346 @ 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 ) {
4749 this .insertHandler .handleInsert (context , this );
4850 return ;
4951 }
@@ -53,10 +55,8 @@ public void handleInsert(InsertionContext context) {
5355
5456 public void renderElement (LookupElementPresentation presentation ) {
5557 presentation .setItemText (getLookupString ());
56- presentation .setTypeText (this . bundleFile . getSymfonyBundle (). getName () );
58+ presentation .setTypeText (bundleName );
5759 presentation .setTypeGrayed (true );
5860 presentation .setIcon (IconUtil .getIcon (this .bundleFile .getVirtualFile (), 0 , this .bundleFile .getProject ()));
59-
6061 }
61-
6262}
0 commit comments