Package org.erlide.engine.services.parsing

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


    private IHyperlink[] detectHyperlinks(final IDocument doc, final int offset) {
        final AbstractErlangEditor editor = (AbstractErlangEditor) getAdapter(AbstractErlangEditor.class);
        if (editor == null) {
            return null;
        }
        final ErlToken token = editor.getScanner().getTokenAt(offset);
        if (token == null) {
            return null;
        }
        final int tokenKind = token.getKind();
        if (tokenKind != ErlToken.KIND_ATOM && tokenKind != ErlToken.KIND_STRING
                && tokenKind != ErlToken.KIND_MACRO && tokenKind != ErlToken.KIND_VAR) {
            return null;
        }
        try {
            final ITypedRegion partition = doc.getPartition(offset);
            final ErlRegion region = new ErlRegion(token.getOffset(), token.getLength(),
                    partition.getType());
            if (!IDocument.DEFAULT_CONTENT_TYPE.equals(region.getType())) {
                return null;
            }
            return new IHyperlink[] { new ErlangHyperlink(editor, region) };
View Full Code Here


        final OtpErlangTuple t1 = (OtpErlangTuple) r1;
        if (Util.isOk(t1)) {
            final OtpErlangObject ot = t1.elementAt(1);
            if (ot instanceof OtpErlangTuple) {
                final OtpErlangTuple tt = (OtpErlangTuple) ot;
                return new ErlToken(tt);
            }
        }
        return null;
    }
View Full Code Here

            if (t1.elementAt(1) instanceof OtpErlangBinary) {
                final OtpErlangBinary b = (OtpErlangBinary) t1.elementAt(1);
                final byte[] bytes = b.binaryValue();
                toks = new ArrayList<ErlToken>(bytes.length / 10);
                for (int i = 0; i < bytes.length; i += 10) {
                    final ErlToken tk = new ErlToken(bytes, i, offset);
                    toks.add(tk);
                }
                return toks;
            }
            throw new ScannerException("unexpected token format");
View Full Code Here

        }

        final IErlModule module = editor.getModule();

        final int offset = invocationContext.getOffset();
        final ErlToken token = module.getScanner().getTokenAt(offset);
        if (token == null || token.getKind() != ErlToken.KIND_STRING) {
            return false;
        }
        final IDocument doc = viewer.getDocument();
        String text;
        try {
            text = doc.get(token.getOffset(), token.getLength());
            if (text.contains("\n")) {
                return true;
            }
        } catch (final BadLocationException e) {
        }
View Full Code Here

            final AbstractErlangEditor editor) {
        if (editor == null) {
            return null;
        }
        editor.reconcileNow();
        final ErlToken token = editor.getScanner().getTokenAt(offset);
        if (token == null) {
            return null;
        }
        return new Region(token.getOffset(), token.getLength());
    }
View Full Code Here

        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

        }
    }

    @Override
    public IToken nextToken() {
        final ErlToken nextErlToken = nextErlToken();
        return convert(nextErlToken);
    }
View Full Code Here

        if (fCrtToken >= fTokens.size()) {
            return 0;
        }

        final ErlToken tk = fTokens.get(fCrtToken);
        return tk.getOffset();
    }
View Full Code Here

        if (fCrtToken >= fTokens.size()) {
            return 0;
        }

        final ErlToken tk = fTokens.get(fCrtToken);
        return tk.getLength();
    }
View Full Code Here

        fCrtToken++;
        if (fCrtToken >= fTokens.size()) {
            return ErlToken.EOF;
        }

        final ErlToken tk = fTokens.get(fCrtToken);
        if (tk.getOffset() >= rangeOffset + rangeLength) {
            return ErlToken.EOF;
        }
        return fTokens.get(fCrtToken);
    }
View Full Code Here

TOP

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

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.