Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix incomplete source section work.
  • Loading branch information
chrisseaton committed Oct 26, 2014
1 parent bcda0cc commit 1c19167
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 18 deletions.
Expand Up @@ -16,8 +16,8 @@ public class ByteArrayLexerSource extends LexerSource {
private Cursor mainCursor, pushbackCursor;
private final boolean captureSource;

public ByteArrayLexerSource(String sourceName, byte[] in, List<String> list, int line, SourcePositionFactory sourcePositionFactory) {
super(sourceName, list, line, sourcePositionFactory);
public ByteArrayLexerSource(String sourceName, byte[] in, List<String> list, int line) {
super(sourceName, list, line);
this.readCursor = new ByteArrayCursor(in);
this.mainCursor = readCursor;
this.pushbackCursor = new PushbackCursor(mainCursor, new ByteList(128));
Expand Down
Expand Up @@ -35,9 +35,8 @@ public class InputStreamLexerSource extends LexerSource {
* @param in is what represents the contents of file sourceName
* @param line starting line number for source (used by eval)
*/
public InputStreamLexerSource(String sourceName, InputStream in, List<String> list, int line,
SourcePositionFactory sourcePositionFactory) {
super(sourceName, list, line, sourcePositionFactory);
public InputStreamLexerSource(String sourceName, InputStream in, List<String> list, int line) {
super(sourceName, list, line);

this.in = in;
this.captureSource = list != null;
Expand Down
12 changes: 6 additions & 6 deletions core/src/main/java/org/jruby/lexer/yacc/LexerSource.java
Expand Up @@ -79,10 +79,10 @@ public abstract class LexerSource {
*
* @param sourceName is the file we are reading
*/
protected LexerSource(String sourceName, List<String> list, int lineOffset, SourcePositionFactory sourcePositionFactory) {
protected LexerSource(String sourceName, List<String> list, int lineOffset) {
this.sourceName = sourceName;
this.lineOffset = lineOffset;
positionFactory = sourcePositionFactory;
positionFactory = new SimpleSourcePositionFactory(this, line);
this.list = list;
lineBuffer = new StringBuilder(160);
sourceLine = new StringBuilder(160);
Expand Down Expand Up @@ -148,13 +148,13 @@ public ISourcePosition getPosition() {
* @return the new source
*/
public static LexerSource getSource(String name, InputStream content, List<String> list,
ParserConfiguration configuration, SourcePositionFactory sourcePositionFactory) {
return new InputStreamLexerSource(name, content, list, configuration.getLineNumber(), sourcePositionFactory);
ParserConfiguration configuration) {
return new InputStreamLexerSource(name, content, list, configuration.getLineNumber());
}

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

private void captureFeatureNewline() {
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/parser/Parser.java
Expand Up @@ -74,7 +74,7 @@ public Node parse(String file, ByteList content, DynamicScope blockScope,
public Node parse(String file, byte[] content, DynamicScope blockScope,
ParserConfiguration configuration) {
RubyArray list = getLines(configuration, runtime, file);
LexerSource lexerSource = LexerSource.getSource(file, content, list, configuration, new SimpleSourcePositionFactory.Factory());
LexerSource lexerSource = LexerSource.getSource(file, content, list, configuration);
return parse(file, lexerSource, blockScope, configuration);
}

Expand All @@ -85,7 +85,7 @@ public Node parse(String file, InputStream content, DynamicScope blockScope,
if (content instanceof LoadServiceResourceInputStream) {
return parse(file, ((LoadServiceResourceInputStream) content).getBytes(), blockScope, configuration);
} else {
LexerSource lexerSource = LexerSource.getSource(file, content, list, configuration, new SimpleSourcePositionFactory.Factory());
LexerSource lexerSource = LexerSource.getSource(file, content, list, configuration);
return parse(file, lexerSource, blockScope, configuration);
}
}
Expand Down
6 changes: 2 additions & 4 deletions core/src/main/java/org/jruby/parser/ParserSupport.java
Expand Up @@ -198,10 +198,8 @@ public Node appendToBlock(Node head, Node tail) {
if (tail == null) return head;
if (head == null) return tail;

// Reduces overhead in interp by not set position every single line we encounter.
if (!configuration.hasExtraPositionInformation()) {
head = compactNewlines(head);
}
// Reduces overhead in interp by not set position every single line we encounter.
head = compactNewlines(head);

if (!(head instanceof BlockNode)) {
head = new BlockNode(head.getPosition()).add(head);
Expand Down
Expand Up @@ -93,7 +93,7 @@ public RubyRootNode parse(RubyContext context, Source source, ParserContext pars
}
}

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

// Parse to the JRuby AST

Expand Down

0 comments on commit 1c19167

Please sign in to comment.