Skip to content

Commit 1c19167

Browse files
committed
Fix incomplete source section work.
1 parent bcda0cc commit 1c19167

File tree

6 files changed

+15
-18
lines changed

6 files changed

+15
-18
lines changed

core/src/main/java/org/jruby/lexer/yacc/ByteArrayLexerSource.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ public class ByteArrayLexerSource extends LexerSource {
1616
private Cursor mainCursor, pushbackCursor;
1717
private final boolean captureSource;
1818

19-
public ByteArrayLexerSource(String sourceName, byte[] in, List<String> list, int line, SourcePositionFactory sourcePositionFactory) {
20-
super(sourceName, list, line, sourcePositionFactory);
19+
public ByteArrayLexerSource(String sourceName, byte[] in, List<String> list, int line) {
20+
super(sourceName, list, line);
2121
this.readCursor = new ByteArrayCursor(in);
2222
this.mainCursor = readCursor;
2323
this.pushbackCursor = new PushbackCursor(mainCursor, new ByteList(128));

core/src/main/java/org/jruby/lexer/yacc/InputStreamLexerSource.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ public class InputStreamLexerSource extends LexerSource {
3535
* @param in is what represents the contents of file sourceName
3636
* @param line starting line number for source (used by eval)
3737
*/
38-
public InputStreamLexerSource(String sourceName, InputStream in, List<String> list, int line,
39-
SourcePositionFactory sourcePositionFactory) {
40-
super(sourceName, list, line, sourcePositionFactory);
38+
public InputStreamLexerSource(String sourceName, InputStream in, List<String> list, int line) {
39+
super(sourceName, list, line);
4140

4241
this.in = in;
4342
this.captureSource = list != null;

core/src/main/java/org/jruby/lexer/yacc/LexerSource.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ public abstract class LexerSource {
7979
*
8080
* @param sourceName is the file we are reading
8181
*/
82-
protected LexerSource(String sourceName, List<String> list, int lineOffset, SourcePositionFactory sourcePositionFactory) {
82+
protected LexerSource(String sourceName, List<String> list, int lineOffset) {
8383
this.sourceName = sourceName;
8484
this.lineOffset = lineOffset;
85-
positionFactory = sourcePositionFactory;
85+
positionFactory = new SimpleSourcePositionFactory(this, line);
8686
this.list = list;
8787
lineBuffer = new StringBuilder(160);
8888
sourceLine = new StringBuilder(160);
@@ -148,13 +148,13 @@ public ISourcePosition getPosition() {
148148
* @return the new source
149149
*/
150150
public static LexerSource getSource(String name, InputStream content, List<String> list,
151-
ParserConfiguration configuration, SourcePositionFactory sourcePositionFactory) {
152-
return new InputStreamLexerSource(name, content, list, configuration.getLineNumber(), sourcePositionFactory);
151+
ParserConfiguration configuration) {
152+
return new InputStreamLexerSource(name, content, list, configuration.getLineNumber());
153153
}
154154

155155
public static LexerSource getSource(String name, byte[] content, List<String> list,
156-
ParserConfiguration configuration, SourcePositionFactory sourcePositionFactory) {
157-
return new ByteArrayLexerSource(name, content, list, configuration.getLineNumber(), sourcePositionFactory);
156+
ParserConfiguration configuration) {
157+
return new ByteArrayLexerSource(name, content, list, configuration.getLineNumber());
158158
}
159159

160160
private void captureFeatureNewline() {

core/src/main/java/org/jruby/parser/Parser.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public Node parse(String file, ByteList content, DynamicScope blockScope,
7474
public Node parse(String file, byte[] content, DynamicScope blockScope,
7575
ParserConfiguration configuration) {
7676
RubyArray list = getLines(configuration, runtime, file);
77-
LexerSource lexerSource = LexerSource.getSource(file, content, list, configuration, new SimpleSourcePositionFactory.Factory());
77+
LexerSource lexerSource = LexerSource.getSource(file, content, list, configuration);
7878
return parse(file, lexerSource, blockScope, configuration);
7979
}
8080

@@ -85,7 +85,7 @@ public Node parse(String file, InputStream content, DynamicScope blockScope,
8585
if (content instanceof LoadServiceResourceInputStream) {
8686
return parse(file, ((LoadServiceResourceInputStream) content).getBytes(), blockScope, configuration);
8787
} else {
88-
LexerSource lexerSource = LexerSource.getSource(file, content, list, configuration, new SimpleSourcePositionFactory.Factory());
88+
LexerSource lexerSource = LexerSource.getSource(file, content, list, configuration);
8989
return parse(file, lexerSource, blockScope, configuration);
9090
}
9191
}

core/src/main/java/org/jruby/parser/ParserSupport.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,8 @@ public Node appendToBlock(Node head, Node tail) {
198198
if (tail == null) return head;
199199
if (head == null) return tail;
200200

201-
// Reduces overhead in interp by not set position every single line we encounter.
202-
if (!configuration.hasExtraPositionInformation()) {
203-
head = compactNewlines(head);
204-
}
201+
// Reduces overhead in interp by not set position every single line we encounter.
202+
head = compactNewlines(head);
205203

206204
if (!(head instanceof BlockNode)) {
207205
head = new BlockNode(head.getPosition()).add(head);

core/src/main/java/org/jruby/truffle/translator/TranslatorDriver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public RubyRootNode parse(RubyContext context, Source source, ParserContext pars
9393
}
9494
}
9595

96-
final org.jruby.parser.ParserConfiguration parserConfiguration = new org.jruby.parser.ParserConfiguration(context.getRuntime(), 0, false, false, parserContext == ParserContext.TOP_LEVEL, true);
96+
final org.jruby.parser.ParserConfiguration parserConfiguration = new org.jruby.parser.ParserConfiguration(context.getRuntime(), 0, false, parserContext == ParserContext.TOP_LEVEL, true);
9797

9898
// Parse to the JRuby AST
9999

0 commit comments

Comments
 (0)