phax / jcodemodel

A heavily extended fork of the com.sun.codemodel (from 2013/09)
Other
93 stars 34 forks source link

Add option for classes to never be imported #51

Closed WonderCsabo closed 7 years ago

WonderCsabo commented 7 years ago

In some cases, the convention for a certain class is to never be imported, but always use its fully qualified class name when referencing it or any of its members. In the Android world, such a class is the android.R class, which contains resource identifiers for the system, and it should not be confused with the project R class which gets imported. For example:

package example.my.project;

public class MyActivity extends Activity {

  void someMethod() {
    String system = getString(android.R.string.some_string);
  }
}

It would be nice to add an option to JCodeModel to support this.

phax commented 7 years ago

You can use JCodeModel.addDontImportClass in the latest 3.0.0 SNAPSHOT (Java 8!)

WonderCsabo commented 7 years ago

Thanks for this! I am looking forward for the stable release. :)

WonderCsabo commented 6 years ago

@phax thanks again, i finally integrated this and it works as expected! 🙏