Package org.erlide.engine.services.parsing

Examples of org.erlide.engine.services.parsing.ScannerService


    public IErlModule getModule() {
        if (fModule == null) {
            try {
                fModule = ErlModelUtils.getModule(getEditorInput());
                fModule.createScanner();
                final ScannerService erlScanner = fModule.getScanner();
                erlScanner.dispose();
            } catch (final CoreException e) {
            }
        }
        return fModule;
    }
View Full Code Here


        try {
            final String filePath = file.getLocation().toPortableString();
            String initialText;
            initialText = Util.getInputStreamAsString(file.getContents(),
                    file.getCharset());
            final ScannerService scanner = ErlangEngine.getInstance()
                    .getScannerProviderService().get(getScannerName());
            scanner.initialScan(initialText, filePath, false);
            return scanner;
        } catch (final CoreException e) {
            ErlLogger.warn(e);
        }
        return null;
View Full Code Here

        final IErlProject project = projects[0];
        final IErlModule moduleE = createModule(
                project,
                "e.erl",
                "-module(e).\n-export([f/0]).\nf() ->\n    lists:reverse([1, 0]),\n    lists:reverse([1, 0], [2]).\n");
        final ScannerService scanner = moduleE.getScanner();
        try {
            moduleE.open(null);
            // when
            // looking for lists:reverse/2 and lists:reverse/1
            final IErlModel model = ErlangEngine.getInstance().getModel();
            final OpenResult res = ErlangEngine
                    .getInstance()
                    .getService(OpenService.class)
                    .open(moduleE.getScannerName(),
                            49,
                            ErlangEngine.getInstance().getModelUtilService()
                                    .getImportsAsList(moduleE),
                            project.getProperties().getExternalModules(),
                            model.getPathVars(project.getWorkspaceProject()));
            assertTrue(res instanceof ExternalCallOpenResult);
            final ExternalCallOpenResult eres = (ExternalCallOpenResult) res;
            final IErlFunction function = ErlangEngine
                    .getInstance()
                    .getModelFindService()
                    .findFunction(model, project, moduleE, eres.getMod(), eres.getPath(),
                            new ErlangFunction(eres.getFun(), eres.getArity()),
                            IErlElementLocator.Scope.PROJECT_ONLY);
            assertNotNull(function);

            final IErlElement module = model.findModuleFromProject(project,
                    function.getModuleName(), eres.getPath(),
                    IErlElementLocator.Scope.PROJECT_ONLY);
            // then
            // the function should be returned and the module, in External Files
            assertNotNull(module);
            assertEquals(function.getParent(), module);
            assertEquals(
                    ErlangEngine.getInstance().getModelUtilService().getProject(function),
                    project);
        } finally {
            scanner.dispose();
        }
    }
View Full Code Here

    public void reconcileText() throws Exception {
        module = createModule(project, "xy.erl",
                "-module(xy). -include(\"yy.hrl\"). f(A) ->     lists:reverse(A). ");
        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);
            IErlFunction function1 = module.findFunction(f_1);
            IErlFunction function2 = module.findFunction(abc_1);
            assertNotNull(function1);
            assertNull(function2);

            module.reconcileText(33, 1, "abc", null);
            function1 = module.findFunction(f_1);
            function2 = module.findFunction(abc_1);
            assertNotNull(function1);
            assertNull(function2);

            module.postReconcile(null);
            function1 = module.findFunction(f_1);
            function2 = module.findFunction(abc_1);
            assertNull(function1);
            assertNotNull(function2);
        } finally {
            scanner.dispose();
        }
    }
View Full Code Here

    // ErlToken getScannerTokenAt(int offset);
    @Test
    public void getScannerTokenAt() throws Exception {
        final String text = "-module(xyz). -include(\"yy.hrl\"). f(A) -> lists:reverse(A).";
        module = createModule(project, "xyz.erl", text);
        final ScannerService scanner = module.getScanner();

        try {
            module.open(null);
            final ErlToken token = scanner.getTokenAt(-1);
            assertNull(token);
            final ErlToken token2 = scanner.getTokenAt(0);
            assertNotNull(token2);
            assertEquals(ErlToken.KIND_OTHER, token2.getKind());
            final ErlToken token3 = scanner.getTokenAt(1);
            assertNotNull(token3);
            assertEquals(ErlToken.KIND_ATOM, token3.getKind());
            final ErlToken token4 = scanner.getTokenAt(12);
            assertNotNull(token4);
            assertEquals(ErlToken.KIND_OTHER, token4.getKind());
            final ErlToken token5 = scanner.getTokenAt(24);
            assertNotNull(token5);
            assertEquals(ErlToken.KIND_STRING, token5.getKind());
            final ErlToken token6 = scanner.getTokenAt(text.length() - 1);
            assertNotNull(token6);
            assertEquals(ErlToken.KIND_OTHER, token6.getKind());
            final ErlToken token7 = scanner.getTokenAt(text.length());
            assertNull(token7);
        } finally {
            scanner.dispose();
        }
    }
View Full Code Here

        final IErlModule moduleB = createModule(project1, "bx.erl",
                "-module(bx).\n-type concat_thing() :: atom() | integer() | float() | string().\n");
        // final IErlModule moduleC =
        // createErlModule(projects[1],
        // "c.erl", "-module(c).\n-type cc() :: b:concat_thing().\n");
        final ScannerService scanner = moduleB.getScanner();
        try {
            moduleB.open(null);
            project1.open(null);
            // moduleC.open(null);
            // when
            // looking for it
            // within project
            final IErlElementLocator model = ErlangEngine.getInstance().getModel();

            final IErlElement element1 = modelFindService.findTypeDef(model, project1,
                    moduleB, "bx", "concat_thing", moduleB.getResource().getLocation()
                            .toPortableString(), IErlElementLocator.Scope.PROJECT_ONLY);
            // in other project but path given
            final IErlElement element2 = modelFindService.findTypeDef(model, project2,
                    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, project2,
                    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, project2,
                    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();
        }
    }
View Full Code Here

    private RefacType checkType(final String callbackModule) {

        try {
            final IErlModule module = ErlangEngine.getInstance().getModel()
                    .findModule(callbackModule);
            final ScannerService scanner = module.getScanner();
            try {
                module.resetAndCacheScannerAndParser(null);
            } finally {
                scanner.dispose();
            }

            for (final IErlElement el : module
                    .getChildrenOfKind(ErlElementKind.ATTRIBUTE)) {
                final IErlAttribute attr = (IErlAttribute) el;
View Full Code Here

TOP

Related Classes of org.erlide.engine.services.parsing.ScannerService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.