use of org.erlide.engine.services.parsing.ScannerService in project erlide_eclipse by erlang.
the class ModelUtilsTest method findExternalTypeTest.
@Test
public void findExternalTypeTest() throws Exception {
// given
// an Erlang module with typedef
final IErlModule moduleB = ErlideTestUtils.createModule(ModelUtilsTest.projects[0], "bx.erl", "-module(bx).\n-type concat_thing() :: atom() | integer() | float() | string().\n");
// final IErlModule moduleC =
// ErlideTestUtils.createErlModule(projects[1],
// "c.erl", "-module(c).\n-type cc() :: b:concat_thing().\n");
final ScannerService scanner = moduleB.getScanner();
try {
moduleB.open(null);
ModelUtilsTest.projects[0].open(null);
// moduleC.open(null);
// when
// looking for it
// within project
final IErlElementLocator model = ErlangEngine.getInstance().getModel();
final IErlElement element1 = modelFindService.findTypeDef(model, ModelUtilsTest.projects[0], moduleB, "bx", "concat_thing", moduleB.getResource().getLocation().toPortableString(), IErlElementLocator.Scope.PROJECT_ONLY);
// in other project but path given
final IErlElement element2 = modelFindService.findTypeDef(model, ModelUtilsTest.projects[1], moduleB, "bx", "concat_thing", moduleB.getResource().getLocation().toPortableString(), IErlElementLocator.Scope.PROJECT_ONLY);
// in other project no path given, search all projects true
final IErlElement element3 = modelFindService.findTypeDef(model, ModelUtilsTest.projects[1], moduleB, "bx", "concat_thing", null, IErlElementLocator.Scope.ALL_PROJECTS);
// in other project no path given, search all projects false, ->
// null
final IErlElement element4 = modelFindService.findTypeDef(model, ModelUtilsTest.projects[1], moduleB, "bx", "concat_thing", null, IErlElementLocator.Scope.PROJECT_ONLY);
// then
// it should be returned if found
assertTrue(element1 instanceof IErlTypespec);
assertNull(element2);
assertTrue(element3 instanceof IErlTypespec);
assertNull(element4);
} finally {
scanner.dispose();
}
}
use of org.erlide.engine.services.parsing.ScannerService in project erlide_eclipse by erlang.
the class IErlModuleTest method reconcileText.
// void initialReconcile();
// Empty method
// void reconcileText(int offset, int removeLength, String newText,
// IProgressMonitor mon);
// void postReconcile(IProgressMonitor mon);
@Test
public void reconcileText() throws Exception {
final ErlangFunction f_1 = new ErlangFunction("f", 1);
final ErlangFunction abc_1 = new ErlangFunction("abc", 1);
final ScannerService scanner = module.getScanner();
try {
module.open(null);
final IErlFunction function = module.findFunction(f_1);
final IErlFunction function2 = module.findFunction(abc_1);
module.reconcileText(33, 1, "abc", null);
final IErlFunction function3 = module.findFunction(f_1);
final IErlFunction function4 = module.findFunction(abc_1);
module.postReconcile(null);
final IErlFunction function5 = module.findFunction(f_1);
final IErlFunction function6 = module.findFunction(abc_1);
assertNotNull(function);
assertNull(function2);
assertNotNull(function3);
assertNull(function4);
assertNull(function5);
assertNotNull(function6);
} finally {
scanner.dispose();
}
}
Aggregations