Skip to content

Commit

Permalink
Roll back extra patch
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Apr 16, 2018
1 parent 9a8ce13 commit 92938cd
Showing 1 changed file with 14 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@
import org.codehaus.groovy.control.CompilePhase;
import org.codehaus.groovy.control.SourceUnit;
import org.codehaus.groovy.control.messages.SyntaxErrorMessage;
import org.codehaus.groovy.runtime.DefaultGroovyMethodsSupport;
import org.codehaus.groovy.runtime.StringGroovyMethods;
import org.codehaus.groovy.syntax.Numbers;
import org.codehaus.groovy.syntax.SyntaxException;
Expand Down Expand Up @@ -356,17 +355,7 @@ public AstBuilder(SourceUnit sourceUnit) {
this.sourceUnit = sourceUnit;
this.moduleNode = new ModuleNode(sourceUnit);

// GRECLIPSE edit
//CharStream charStream = createCharStream(sourceUnit);
CharStream charStream;
try {
sourceUnitReader = new BufferedReader(sourceUnit.getSource().getReader());
} catch (IOException e) {
throw new RuntimeException("Error occurred reading the source code.", e);
}
try {
charStream = CharStreams.fromReader(sourceUnitReader, sourceUnit.getName());
// GRECLIPSE end
CharStream charStream = createCharStream(sourceUnit);

this.lexer = new GroovyLangLexer(charStream);
this.parser = new GroovyLangParser(new CommonTokenStream(this.lexer));
Expand All @@ -376,24 +365,21 @@ public AstBuilder(SourceUnit sourceUnit) {
this.groovydocManager = GroovydocManager.getInstance();

// GRECLIPSE add
try (BufferedReader reader = new BufferedReader(sourceUnit.getSource().getReader())) {
// TODO: Can this be done without boxing/unboxing offsets or juggling temp arrays?
int chr, off = 0; List<Integer> ends = new ArrayList<>(32); ends.add(0);
while ((chr = reader.read()) != -1) { off += 1;
if (chr == '\n') ends.add(off);
}
ends.add(off);
try (BufferedReader reader = new BufferedReader(sourceUnit.getSource().getReader())) {
// TODO: Can this be done without boxing/unboxing offsets or juggling temp arrays?
int chr, off = 0; List<Integer> ends = new ArrayList<>(32); ends.add(0);
while ((chr = reader.read()) != -1) { off += 1;
if (chr == '\n') ends.add(off);
}
ends.add(off);

int[] arr = new int[ends.size()];
for (int i = 0, n = arr.length; i < n; i += 1) {
arr[i] = ends.get(i);
}
this.locationSupport = new LocationSupport(arr);
int[] arr = new int[ends.size()];
for (int i = 0, n = arr.length; i < n; i += 1) {
arr[i] = ends.get(i);
}
} catch (Throwable t) {
DefaultGroovyMethodsSupport.closeQuietly(sourceUnitReader);
if (t instanceof Error) throw (Error) t; // preserve error semantics
throw new RuntimeException("Error occurred reading the source code.", t);
this.locationSupport = new LocationSupport(arr);
} catch (Exception e) {
throw new RuntimeException("Error occurred reading the source code.", e);
}
// GRECLIPSE end
}
Expand Down Expand Up @@ -438,7 +424,6 @@ private <T extends ASTNode> T configureAST(T astNode, GroovyParser.GroovyParserR
}
// GRECLIPSE end

/* GRECLIPSE edit
private CharStream createCharStream(SourceUnit sourceUnit) {
CharStream charStream;

Expand All @@ -452,7 +437,6 @@ private CharStream createCharStream(SourceUnit sourceUnit) {

return charStream;
}
*/

private GroovyParserRuleContext buildCST() throws CompilationFailedException {
GroovyParserRuleContext result;
Expand Down Expand Up @@ -512,11 +496,6 @@ public ModuleNode buildAST() {
} catch (Throwable t) {
throw convertException(t);
}
// GRECLIPSE add
finally {
DefaultGroovyMethodsSupport.closeQuietly(sourceUnitReader);
}
// GRECLIPSE end
}

@Override
Expand Down Expand Up @@ -5186,7 +5165,6 @@ public List<DeclarationExpression> getDeclarationExpressions() {
private final GroovydocManager groovydocManager;
// GRECLIPSE add
private final LocationSupport locationSupport;
private final BufferedReader sourceUnitReader;
// GRECLIPSE add
private final List<ClassNode> classNodeList = new LinkedList<>();
private final Deque<ClassNode> classNodeStack = new ArrayDeque<>();
Expand Down

0 comments on commit 92938cd

Please sign in to comment.