Search in sources :

Example 6 with ScannerService

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();
    }
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) IErlTypespec(org.erlide.engine.model.erlang.IErlTypespec) IErlModule(org.erlide.engine.model.root.IErlModule) IErlElementLocator(org.erlide.engine.model.root.IErlElementLocator) ScannerService(org.erlide.engine.services.parsing.ScannerService) Test(org.junit.Test)

Example 7 with ScannerService

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();
    }
}
Also used : ScannerService(org.erlide.engine.services.parsing.ScannerService) Test(org.junit.Test)

Aggregations

ScannerService (org.erlide.engine.services.parsing.ScannerService)7 Test (org.junit.Test)4 IErlElement (org.erlide.engine.model.IErlElement)3 IErlModule (org.erlide.engine.model.root.IErlModule)3 CoreException (org.eclipse.core.runtime.CoreException)2 IFile (org.eclipse.core.resources.IFile)1 ErlModelException (org.erlide.engine.model.ErlModelException)1 IErlAttribute (org.erlide.engine.model.erlang.IErlAttribute)1 IErlTypespec (org.erlide.engine.model.erlang.IErlTypespec)1 IErlElementLocator (org.erlide.engine.model.root.IErlElementLocator)1 IErlModel (org.erlide.engine.model.root.IErlModel)1 IErlProject (org.erlide.engine.model.root.IErlProject)1 ErlToken (org.erlide.engine.services.parsing.ErlToken)1 OpenResult (org.erlide.engine.services.search.OpenResult)1