Examples of DetailedSourcePosition


Examples of org.jruby.lexer.yacc.DetailedSourcePosition

        assertEquals(5, position.getOffset());
        // assertEquals(18, position.getLength());
    }

    public void testMultiLineDef() {
        final DetailedSourcePosition position = detailedSource(find(parse("true\ndef foo\n  true\nend\nfalse\n"), DefnNode.class));
        assertEquals("test", position.getFile());
        assertEquals(1, position.getLine());
        assertEquals(5, position.getOffset());
        // assertEquals(18, position.getLength());
    }
View Full Code Here

Examples of org.jruby.lexer.yacc.DetailedSourcePosition

        assertEquals(5, position.getOffset());
        // assertEquals(18, position.getLength());
    }

    public void testSingleLineCall() {
        final DetailedSourcePosition position = detailedSource(find(parse("true\nFoo.bar(true, false)\nfalse\n"), CallNode.class));
        assertEquals("test", position.getFile());
        assertEquals(1, position.getLine());
        assertEquals(8, position.getOffset()); // we would like this to be 5, but 8 is a good start
        // assertEquals(21, position.getLength());
    }
View Full Code Here

Examples of org.jruby.lexer.yacc.DetailedSourcePosition

        assertEquals(8, position.getOffset()); // we would like this to be 5, but 8 is a good start
        // assertEquals(21, position.getLength());
    }

    public void testMultiLineCall() {
        final DetailedSourcePosition position = detailedSource(find(parse("true\nFoo.bar(\n  true,\n  false\n)\nfalse\n"), CallNode.class));
        assertEquals("test", position.getFile());
        assertEquals(1, position.getLine());
        assertEquals(8, position.getOffset()); // we would like this to be 5, but 8 is a good start
        // assertEquals(28, position.getLength());
    }
View Full Code Here

Examples of org.jruby.lexer.yacc.DetailedSourcePosition

    }

    // This is the test case which motivated the need for the new detailed source position implementation

    public void testRegression1() {
        final DetailedSourcePosition position = detailedSource(find(parse("p 42\n\n3.hello\n"), CallNode.class));
        assertEquals("test", position.getFile());
        assertEquals(2, position.getLine());
        assertEquals(6, position.getOffset());
        // assertEquals(7, position.getLength());
    }
View Full Code Here

Examples of org.jruby.lexer.yacc.DetailedSourcePosition

    }

    // Found during testing

    public void testRegression2() {
        final DetailedSourcePosition position = detailedSource(find(parse("__FILE__"), FileNode.class));
        assertEquals("test", position.getFile());
        assertEquals(0, position.getLine());
        assertEquals(8, position.getOffset()); // should be 0 - this is the central problem with the parser at the moment - asks the lexer for position after the token's parsed
        // assertEquals(8, position.getLength());
    }
View Full Code Here

Examples of org.jruby.lexer.yacc.DetailedSourcePosition

                throw new UnsupportedOperationException("Truffle doesn't want invalid positions - find a way to give me a real position!");
            } else {
                return parentSourceSection;
            }
        } else if (sourcePosition instanceof DetailedSourcePosition) {
            final DetailedSourcePosition detailedSourcePosition = (DetailedSourcePosition) sourcePosition;

            try {
                return source.createSection(getIdentifier(), detailedSourcePosition.getOffset(), detailedSourcePosition.getLength());
            } catch (IllegalArgumentException e) {
                // In some cases we still get bad offsets with the detailed source positions
                return source.createSection(getIdentifier(), sourcePosition.getLine() + 1);
            }
        } else if (Options.TRUFFLE_ALLOW_SIMPLE_SOURCE_SECTIONS.load()) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.