ribot / SublimeAndroidImport

A Sublime Text 2/3 plugin which automatically adds imports from the Android SDK.
30 stars 6 forks source link

Prevent android imports for existing compatibility library (i.e. actionbarsherlock) imports #8

Closed owjhart closed 10 years ago

owjhart commented 11 years ago

Scenario: If I have already imported com.actionbarsherlock.view.MenuItem, then if I run Cmd+Shift+O, I expect android.view.MenuItem to not be imported.

Solution: Compare class names at the end of the package paths instead of comparing full package paths.

matt-oakes commented 11 years ago

Great! Thanks! I've been meaning to fix this for a while now.

There is a slight regression. If you've included the AlertDialog class then then had this piece of code:

    new AlertDialog.Builder(getActivity())
            .setMessage(toastString)
            .setNeutralButton(R.string.profile_error_dismiss, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            })
            .create()
            .show();

your new code will ask you which Builder you want to import. Ideally I'd like it so if you've already imported a class then you can use its inner-classes without having to import them as well.

If you could fix this small problem then I'll merge your pull request right away! If you don't have time let me know and I'll give it a go myself.

Thanks again :+1:

owjsub commented 11 years ago

Good find! I won't have time this week. If you could give it a go that'd be great. Thanks~!

matt-oakes commented 11 years ago

I'll see if I can find some time tomorrow :-)

On 11 November 2013 15:54, owjsub notifications@github.com wrote:

Good find! I won't have time this week. If you could give it a go that'd be great. Thanks~!

— Reply to this email directly or view it on GitHubhttps://github.com/ribot/SublimeAndroidImport/pull/8#issuecomment-28211186 .

matt-oakes commented 10 years ago

I've fixed this issue using your commit with a patch on top of it. Thank you for the contribution!