use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.
the class IErlModuleTest method getIncludedFiles.
// Collection<ErlangIncludeFile> getIncludedFiles() throws
// ErlModelException;
@Test
public void getIncludedFiles() throws Exception {
// ErlideTestUtils.createInclude(project, "yy.hrl",
// "-define(A, hej).\n");
final IErlModule includeLibModule = ErlideTestUtils.createModule(project, "zz.erl", "-module(zz).\n-include_lib(\"kernel/include/file.hrl\").\nf(_) -> ok");
module.open(null);
includeLibModule.open(null);
final Collection<ErlangIncludeFile> includeFiles = module.getIncludeFiles();
final Collection<ErlangIncludeFile> includeFiles2 = includeLibModule.getIncludeFiles();
assertEquals(1, includeFiles.size());
assertEquals("yy.hrl", includeFiles.iterator().next().getFilenameLastPart());
assertEquals(1, includeFiles2.size());
assertEquals("file.hrl", includeFiles2.iterator().next().getFilenameLastPart());
}
use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.
the class IErlModuleTest method getPreprocessorDefs.
// public Collection<IErlPreprocessorDef> getPreprocessorDefs(final Kind
// kind);
@Test
public void getPreprocessorDefs() throws Exception {
final IErlModule preprocessorDefModule = ErlideTestUtils.createModule(project, "yy.erl", "-module(yy).\n-define(A, hej).\n-define(B(x), x).\n" + "-record(?MODULE, {a, b}).\nf(L) -> reverse(L).\n");
preprocessorDefModule.open(null);
final Collection<IErlPreprocessorDef> records = preprocessorDefModule.getPreprocessorDefs(ErlElementKind.RECORD_DEF);
final Collection<IErlPreprocessorDef> macros = preprocessorDefModule.getPreprocessorDefs(ErlElementKind.MACRO_DEF);
assertEquals(1, records.size());
assertEquals(2, macros.size());
final Iterator<IErlPreprocessorDef> iterator = macros.iterator();
assertEquals("A", iterator.next().getDefinedName());
assertEquals("B", iterator.next().getDefinedName());
}
use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.
the class IErlModuleTest method findAllIncludedFiles.
// void addComment(IErlComment c);
// List<IErlModule> findAllIncludedFiles() throws CoreException;
@Test
public void findAllIncludedFiles() throws Exception {
module.open(null);
final Collection<IErlModule> includedFiles = ErlangEngine.getInstance().getModelFindService().findAllIncludedFiles(module);
final String yyHrl = "yy.hrl";
final IErlModule include = ErlideTestUtils.createInclude(project, yyHrl, "-include(\"zz.hrl\").\n-define(A, hej).\n");
final IErlModule include2 = ErlideTestUtils.createInclude(project, "zz.hrl", "-define(B(X), lists:reverse(X)).\n");
module.open(null);
final List<IErlModule> includedFiles2 = Lists.newArrayList(ErlangEngine.getInstance().getModelFindService().findAllIncludedFiles(module));
assertEquals(0, includedFiles.size());
assertEquals(2, includedFiles2.size());
assertEquals(include, includedFiles2.get(0));
assertEquals(include2, includedFiles2.get(1));
}
use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.
the class IErlModuleTest method isOnSourcePath.
// boolean isOnSourcePath();
@Test
public void isOnSourcePath() throws Exception {
final IErlModule module2 = ErlideTestUtils.createInclude(project, "yy.erl", "-module(yy).\n");
assertTrue(module.isOnSourcePath());
assertFalse(module2.isOnSourcePath());
}
use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.
the class IErlProjectTest method getModule.
// IErlModule getModule(String name) throws ErlModelException;
@Test
public void getModule() throws Exception {
final IErlProject aProject = ErlModelTestBase.projects[0];
final Collection<IPath> sourceDirs = aProject.getProperties().getSourceDirs();
try {
// given
// an Erlang project and a module
final IErlModule aModule = ErlideTestUtils.createModule(aProject, "aa.erl", "-module(aa).\n");
final IPath srcxPath = new Path("srcx");
final List<IPath> srcxDirs = Lists.newArrayList(srcxPath);
aProject.open(null);
// when
// setting source dirs so the module is on source path
final IErlModule module2 = aProject.getModule("aa");
final IErlModule nullModule = aProject.getModule("aa.hrl");
final IErlModule nullModule2 = aProject.getModule("AA");
final IErlModule nullModule3 = aProject.getModule("aA");
final IErlModule nullModule4 = aProject.getModule("AA.erl");
final IErlModule module4 = aProject.getModule("aa.erl");
((ErlProject) aProject).setSourceDirs(srcxDirs);
aProject.open(null);
final IErlModule srcxModule = aProject.getModule("aa");
((ErlProject) aProject).setSourceDirs(sourceDirs);
aProject.open(null);
final IErlModule module3 = aProject.getModule("aa");
// then
// the it should be returned, but not otherwise
assertEquals(aModule, module2);
assertNull(srcxModule);
assertNull(nullModule);
assertNull(nullModule2);
assertNull(nullModule3);
assertNull(nullModule4);
assertEquals(aModule, module3);
assertEquals(aModule, module4);
} finally {
((ErlProject) aProject).setSourceDirs(sourceDirs);
}
}
Aggregations