use of org.erlide.engine.model.IErlElement in project erlide_eclipse by erlang.
the class IErlImportTest method getImportModule.
// public String getImportModule();
@Test
public void getImportModule() throws Exception {
final IErlModule module2 = ErlideTestUtils.createModule(project, "zz.erl", "-module(zz).\n" + "-import(lists, [foldl/3, reverse/1, reverse/2]).\n");
module2.open(null);
final List<IErlElement> imports = module2.getChildrenOfKind(ErlElementKind.IMPORT);
final IErlImport import1 = (IErlImport) imports.get(0);
final String importModule = import1.getImportModule();
assertEquals("lists", importModule);
}
use of org.erlide.engine.model.IErlElement in project erlide_eclipse by erlang.
the class IErlMemberTest method setNameRange.
// void setNameRange(int offset, int length);
@Test
public void setNameRange() throws Exception {
module.open(null);
final IErlElement element = module.getElementAt(1);
final IErlAttribute attribute = (IErlAttribute) element;
final int offset = 1;
final int length = 2;
attribute.setNameRange(offset, length);
final ISourceRange nameRange = attribute.getNameRange();
assertEquals(offset, nameRange.getOffset());
assertEquals(length, nameRange.getLength());
}
use of org.erlide.engine.model.IErlElement in project erlide_eclipse by erlang.
the class IErlMemberTest method getNameRange.
// ISourceRange getNameRange();
@Test
public void getNameRange() throws Exception {
module.open(null);
final IErlElement element = module.getElementAt(1);
final IErlAttribute attribute = (IErlAttribute) element;
final ISourceRange nameRange = attribute.getNameRange();
assertEquals(0, nameRange.getOffset());
assertEquals(12, nameRange.getLength());
}
use of org.erlide.engine.model.IErlElement in project erlide_eclipse by erlang.
the class IErlModelTest method findElement.
// IErlElement findElement(IResource resource);
@Test
public void findElement() throws Exception {
final IProject workspaceProject = project.getWorkspaceProject();
final IErlElement findElement = model.findElement(workspaceProject);
final IErlElement findElement2 = model.findElement(module.getCorrespondingResource());
final IErlElement findElement3 = model.findElement(workspaceProject.getFolder("no_way"));
final IErlElement findElement4 = model.findElement(workspaceProject.getParent());
final IErlElement parent = (IErlElement) module.getParent();
final IFolder folder = (IFolder) parent.getResource();
final IErlElement findElement5 = model.findElement(folder);
project.open(null);
final IErlElement srcFolder = project.getChildNamed("src");
assertEquals(project, findElement);
assertEquals(module, findElement2);
assertNull(findElement3);
assertNull(findElement4);
assertEquals(srcFolder, findElement5);
}
use of org.erlide.engine.model.IErlElement in project erlide_eclipse by erlang.
the class IErlModelTest method addModelChangeListener.
// void addModelChangeListener(IErlModelChangeListener listener);
// void removeModelChangeListener(IErlModelChangeListener listener);
@Test
public void addModelChangeListener() throws Exception {
final List<IErlElement> changed = Lists.newArrayList();
final IErlModelChangeListener listener = new IErlModelChangeListener() {
@Override
public void elementChanged(final IErlElement element) {
changed.add(element);
}
};
final IErlModule module2 = ErlideTestUtils.createModule(project, "zz.erl", "-module(zz).\n");
final IErlModule module3 = ErlideTestUtils.createModule(project, "tt.erl", "-module(tt).\n");
model.addModelChangeListener(listener);
module2.open(null);
model.removeModelChangeListener(listener);
module3.open(null);
final List<IErlElement> changed2 = Lists.newArrayList(changed);
changed.clear();
final List<IErlElement> changed3 = Lists.newArrayList(changed);
changed.clear();
assertEquals(1, changed2.size());
assertEquals(0, changed3.size());
}
Aggregations