@Test
public void testBasic() throws Exception { testBasic$(); }
public void testBasic$() throws Exception {
ISourceModule srcModule = getSourceModule(TR_SAMPLE_SRC1, "sampledefs.d");
final IType topLevelElement = srcModule.getType("sampledefs");
new SampleModelElementsVisitor(srcModule) {
@Override
public void visitAllModelElements(
IType _Module,
IField _Variable,
IField _Variable2,
IField _VarExtended,
IField _VarExtended2,
IField _AutoVar,
IField _AutoVar2,
IMethod _Function,
IMethod _AutoFunction,
IType _Struct,
IType _Union,
IType _Class,
IType _Interface,
IType _Template,
IType _Enum,
IField _Enum_memberA,
IField _Enum_memberB,
IType _Mixin,
IType _AliasVarDecl,
IType _AliasFunctionDecl,
IType _AliasFrag,
IType _AliasFrag2,
IField _OtherClass_fieldA,
IMethod _OtherClass_methodB,
IMethod _OtherClass_this,
IType _OtherTemplate_TplNestedClass,
IMethod tplFunc
) {
runCheckElementExists( _Module, EArcheType.Module, "module sampledefs;");
runCheckElementExists(_Variable, EArcheType.Variable, "int Variable");
runCheckElementExists(_Variable2, EArcheType.Variable, "Variable2");
runCheckElementExists(_VarExtended, EArcheType.Variable, "/** DDOC */\r\nstatic ");
runCheckElementExists(_VarExtended2, EArcheType.Variable, "VarExtended2");
runCheckElementExists(_AutoVar, EArcheType.Variable, "auto AutoVar =");
runCheckElementExists(_AutoVar2, EArcheType.Variable, "AutoVar2");
runCheckElementExists(_Function, EArcheType.Function, "void Function(int fooParam)");
runCheckElementExists(_AutoFunction, EArcheType.Function, "static AutoFunction(int fooParam)");
runCheckElementExists(_Struct, EArcheType.Struct, "struct Struct { }");
runCheckElementExists(_Union, EArcheType.Union, "union Union { }");
runCheckElementExists(_Class, EArcheType.Class, "class Class {");
runCheckElementExists(_Interface, EArcheType.Interface, "interface Interface { }");
runCheckElementExists(_Template, EArcheType.Template, "template Template(");
runCheckElementExists(_Enum, EArcheType.Enum, "enum Enum {");
runCheckElementExists(_Enum_memberA, EArcheType.EnumMember, "EnumMemberA");
runCheckElementExists(_Enum_memberB, EArcheType.EnumMember, "EnumMemberB");
runCheckElementExists(_Mixin, EArcheType.Mixin, "mixin foo!() Mixin;");
runCheckElementExists(_AliasVarDecl, EArcheType.Alias, "alias TargetFoo AliasVarDecl;");
runCheckElementExists(_AliasFunctionDecl, EArcheType.Alias, "alias TargetFoo AliasFunctionDecl(");
runCheckElementExists(_AliasFrag, EArcheType.Alias, "alias AliasFrag = int");
runCheckElementExists(_AliasFrag2, EArcheType.Alias, "AliasFrag2 = char");
runCheckElementExists(_OtherClass_fieldA, EArcheType.Variable, "int fieldA;");
runCheckElementExists(_OtherClass_methodB, EArcheType.Function, "void methodB() { }");
runCheckElementExists(_OtherClass_this,
EArcheType.Constructor, "/*this*/ ", "this(int ctorParam)");
runCheckElementExists(_OtherTemplate_TplNestedClass, EArcheType.Class, "class TplNestedClass {");
runCheckElementExists(tplFunc, EArcheType.Function, "void tplFunc(asdf.qwer parameter) {");
}
protected void runCheckElementExists(IMember element, EArcheType archeType, String code) {
runCheckElementExists(element, archeType, null, code);
}
protected void runCheckElementExists(IMember element, EArcheType archeType, String nameKey, String code) {
try {
doCheckElementExists(srcModule, element, archeType, nameKey, code);
} catch(ModelException e) {
throw melnorme.utilbox.core.ExceptionAdapter.unchecked(e);
}
}
}.visitAll();
assertTrue(topLevelElement.getMethod("OtherFunction").exists());
// TODO: need to re-enable this test, but need to complete search engine tests first
if(false) {
assertTrue(topLevelElement.getMethod("OtherFunction").getChildren().length == 0);
}
}