use of org.erlide.engine.model.root.IErlExternal in project erlide_eclipse by erlang.
the class ModelInternalUtils method getElementWithExternalName.
private IErlExternal getElementWithExternalName(final IParent parent, final String name) throws ErlModelException {
System.out.println(" ?? " + name);
for (final IErlElement e : parent.getChildrenOfKind(ErlElementKind.EXTERNAL_ROOT, ErlElementKind.EXTERNAL_APP, ErlElementKind.EXTERNAL_FOLDER)) {
final IErlExternal external = (IErlExternal) e;
final String externalName = external.getName();
System.out.println(" ? " + externalName);
if (externalName.equals(name)) {
return external;
}
}
return null;
}
use of org.erlide.engine.model.root.IErlExternal in project erlide_eclipse by erlang.
the class IErlElementTest method accept.
// void accept(IErlElementVisitor visitor, EnumSet<AcceptFlags> flags,
// IErlElement.Kind leafKind) throws ErlModelException;
@Test
public void accept() throws Exception {
project.open(null);
// ErlLogger.debug(project.getChildren().toString());
module.open(null);
final List<IErlElement> elements = Lists.newArrayList();
final IErlElementVisitor visitor = new IErlElementVisitor() {
@Override
public boolean visit(final IErlElement element) throws ErlModelException {
if (element instanceof IErlExternal) {
// avoid digging through otp
return false;
}
final String name = element.getName();
if ("ebin".equals(name)) {
// avoid possible beam-files
return false;
} else if (name.startsWith(".")) {
// avoid eclipse internals
return false;
}
elements.add(element);
return true;
}
};
final EnumSet<AcceptFlags> noneOf = EnumSet.noneOf(AcceptFlags.class);
project.accept(visitor, noneOf, ErlElementKind.MODULE);
final List<IErlElement> kindModuleElementsVisited = Lists.newArrayList(elements);
elements.clear();
project.accept(visitor, noneOf, ErlElementKind.FUNCTION);
final List<IErlElement> kindFunctionElementsVisited = Lists.newArrayList(elements);
elements.clear();
project.accept(visitor, EnumSet.of(AcceptFlags.CHILDREN_FIRST), ErlElementKind.MODULE);
final List<IErlElement> childrenFirst = Lists.newArrayList(elements);
elements.clear();
project.accept(visitor, EnumSet.of(AcceptFlags.LEAFS_ONLY), ErlElementKind.MODULE);
final List<IErlElement> leafsOnly = Lists.newArrayList(elements);
elements.clear();
// assertEquals(4, kindModuleElementsVisited.size());
assertEquals(project, kindModuleElementsVisited.get(0));
// ErlLogger.debug(kindModuleElementsVisited.toString());
assertEquals("include", kindModuleElementsVisited.get(1).getName());
assertEquals("src", kindModuleElementsVisited.get(2).getName());
assertEquals(module, kindModuleElementsVisited.get(3));
assertEquals(7, kindFunctionElementsVisited.size());
final int projectIndex = childrenFirst.indexOf(project);
final int moduleIndex = childrenFirst.indexOf(module);
assertTrue(moduleIndex < projectIndex);
assertFalse(leafsOnly.contains(project));
assertTrue(leafsOnly.contains(module));
}
use of org.erlide.engine.model.root.IErlExternal in project erlide_eclipse by erlang.
the class IErlElementTest method isStructureKnown.
// boolean isReadOnly();
// Empty method
// boolean isStructureKnown() throws ErlModelException;
@Test
public void isStructureKnown() throws Exception {
((ErlProject) project).setSourceDirs(project.getProperties().getSourceDirs());
// this sets structureKnown to false
final boolean structureKnown = project.isStructureKnown();
project.open(null);
final boolean structureKnown2 = project.isStructureKnown();
final boolean structureKnown3 = module.isStructureKnown();
module.open(null);
final boolean structureKnown4 = module.isStructureKnown();
final IErlElementLocator model = ErlangEngine.getInstance().getModel();
final IErlModule otpFile = model.findModuleFromProject(project, "file.erl", null, IErlElementLocator.Scope.PROJECT_ONLY);
final IErlExternal external = (IErlExternal) otpFile.getParent();
final boolean structureKnown5 = external.isStructureKnown();
final IErlModule module2 = ErlideTestUtils.createModule(project, "yy.erl", "-module(yy).\n% comment\n% same\nf(x) -> y.\n% last");
final boolean structureKnown6 = module2.isStructureKnown();
module2.open(null);
final boolean structureKnown7 = module2.isStructureKnown();
assertFalse(structureKnown);
assertTrue(structureKnown2);
assertFalse(structureKnown3);
assertTrue(structureKnown4);
assertTrue(structureKnown5);
assertFalse(structureKnown6);
assertTrue(structureKnown7);
}
use of org.erlide.engine.model.root.IErlExternal in project erlide_eclipse by erlang.
the class IErlExternalTest method isOTP.
// boolean isOTP();
@Test
public void isOTP() throws Exception {
final List<IErlElement> externals = project.getChildrenOfKind(ErlElementKind.EXTERNAL_ROOT);
final IErlExternal external = (IErlExternal) externals.get(0);
external.open(null);
assertFalse(external.isOTP());
final IErlExternal external2 = (IErlExternal) externals.get(1);
external2.open(null);
assertTrue(external2.isOTP());
final IErlExternal external3 = (IErlExternal) external.getChildren().get(0);
assertFalse(external3.isOTP());
final IErlExternal external4 = (IErlExternal) external2.getChildren().get(0);
assertTrue(external4.isOTP());
}
use of org.erlide.engine.model.root.IErlExternal in project erlide_eclipse by erlang.
the class IErlExternalTest method hasIncludes.
// boolean hasIncludes();
@Test
public void hasIncludes() throws Exception {
final List<IErlElement> externals = project.getChildrenOfKind(ErlElementKind.EXTERNAL_ROOT);
final IErlExternal external = (IErlExternal) externals.get(0);
external.open(null);
final IErlExternal externalOTP = (IErlExternal) externals.get(1);
externalOTP.open(null);
final IErlExternal externalDialyzer = (IErlExternal) externalOTP.getChildNamed("dialyzer");
assertTrue(external.hasIncludes());
assertTrue(externalOTP.hasIncludes());
assertFalse(externalDialyzer.hasIncludes());
}
Aggregations