TypeChooser () { return new TypeChooser() { @Override public Type chooseType(final XmlTag tag) { return tag != null && tag.findFirstSubTag("foo") != null ? FooInterface.class : BarInterface.class; } @Override public void distinguishTag(final XmlTag tag, final Type aClass) throws IncorrectOperationException { if (FooInterface.class.equals(aClass) && tag.findFirstSubTag("foo") == null) { tag.add(XmlElementFactory.getInstance(getProject()).createTagFromText("<foo/>")); } } @Override public Type[] getChooserTypes() { return new Class[]{FooInterface.class, BarInterface.class}; } }; }