tagging Groovy 1.7.9
git-svn-id: http://svn.codehaus.org/groovy/tags/GROOVY_1_7_9@21776 a5544e8c-8a19-0410-ba12-f9af4593a198
diff --git a/build.properties b/build.properties
index 8a98af0..eb83448 100644
--- a/build.properties
+++ b/build.properties
@@ -1,6 +1,6 @@
-groovyVersion = 1.7.9-SNAPSHOT
+groovyVersion = 1.7.9
# bundle version format: major('.'minor('.'micro('.'qualifier)?)?)? (first 3 only digits)
-groovyBundleVersion = 1.7.9-SNAPSHOT
+groovyBundleVersion = 1.7.9
# Many people have reported problems testing UberTestCaseGroovySourceSubPackages, others have no difficulties with the default
# values ant junit task uses. The decision has been taken to provide the values to try and cause the least
diff --git a/pom.xml b/pom.xml
index 0da8c03..952ce44 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,7 +8,7 @@
<name>Groovy</name>
<packaging>jar</packaging>
- <version>1.7.8</version>
+ <version>1.7.9</version>
<description>
Groovy: A powerful, dynamic language for the JVM
diff --git a/src/main/org/codehaus/groovy/antlr/AntlrParserPlugin.java b/src/main/org/codehaus/groovy/antlr/AntlrParserPlugin.java
index 92c2e05..de64394 100644
--- a/src/main/org/codehaus/groovy/antlr/AntlrParserPlugin.java
+++ b/src/main/org/codehaus/groovy/antlr/AntlrParserPlugin.java
@@ -113,7 +113,8 @@
// TODO find a way to inject any GroovyLexer/GroovyRecognizer
UnicodeEscapingReader unicodeReader = new UnicodeEscapingReader(reader, sourceBuffer);
- GroovyLexer lexer = new GroovyLexer(unicodeReader);
+ UnicodeLexerSharedInputState inputState = new UnicodeLexerSharedInputState(unicodeReader);
+ GroovyLexer lexer = new GroovyLexer(inputState);
unicodeReader.setLexer(lexer);
GroovyRecognizer parser = GroovyRecognizer.make(lexer);
parser.setSourceBuffer(sourceBuffer);
diff --git a/src/main/org/codehaus/groovy/antlr/UnicodeEscapingReader.java b/src/main/org/codehaus/groovy/antlr/UnicodeEscapingReader.java
index 3a2c4cf..fe486d3 100644
--- a/src/main/org/codehaus/groovy/antlr/UnicodeEscapingReader.java
+++ b/src/main/org/codehaus/groovy/antlr/UnicodeEscapingReader.java
@@ -21,12 +21,14 @@
import java.io.Reader;
import antlr.CharScanner;
+import antlr.Token;
+import antlr.TokenStreamException;
/**
* Translates GLS-defined unicode escapes into characters. Throws an exception
* in the event of an invalid unicode escape being detected.
*
- * <p>No attempt has been made to optimise this class for speed or
+ * <p>No attempt has been made to optimize this class for speed or
* space.</p>
*
* @version $Revision$
@@ -38,7 +40,27 @@
private boolean hasNextChar = false;
private int nextChar;
private final SourceBuffer sourceBuffer;
+ private int previousLine;
+ private int numUnicodeEscapesFound = 0;
+ private int numUnicodeEscapesFoundOnCurrentLine = 0;
+ private static class DummyLexer extends CharScanner{
+ final private Token t = new Token();
+ @Override
+ public Token nextToken() throws TokenStreamException {
+ return t;
+ }
+ @Override
+ public int getColumn() {
+ return 0;
+ }
+ @Override
+ public int getLine() {
+ return 0;
+ }
+
+ }
+
/**
* Constructor.
* @param reader The reader that this reader will filter over.
@@ -46,6 +68,7 @@
public UnicodeEscapingReader(Reader reader,SourceBuffer sourceBuffer) {
this.reader = reader;
this.sourceBuffer = sourceBuffer;
+ this.lexer = new DummyLexer();
}
/**
@@ -82,6 +105,12 @@
return nextChar;
}
+ if (previousLine != lexer.getLine()) {
+ // new line, so reset unicode escapes
+ numUnicodeEscapesFoundOnCurrentLine = 0;
+ previousLine = lexer.getLine();
+ }
+
int c = reader.read();
if (c != '\\') {
write(c);
@@ -98,7 +127,9 @@
}
// Swallow multiple 'u's
+ int numberOfUChars = 0;
do {
+ numberOfUChars++;
c = reader.read();
} while (c == 'u');
@@ -115,6 +146,10 @@
}
int rv = Integer.parseInt(charNum.toString(), 16);
write(rv);
+
+ numUnicodeEscapesFound += 4 + numberOfUChars;
+ numUnicodeEscapesFoundOnCurrentLine += 4 + numberOfUChars;
+
return rv;
}
private void write(int c) {
@@ -140,6 +175,14 @@
+ " line: " + lexer.getLine() + " col:" + lexer.getColumn());
}
+ public int getUnescapedUnicodeColumnCount() {
+ return numUnicodeEscapesFoundOnCurrentLine;
+ }
+
+ public int getUnescapedUnicodeOffsetCount() {
+ return numUnicodeEscapesFound;
+ }
+
/**
* Closes this reader by calling close on the underlying reader.
* @see java.io.Reader#close()
diff --git a/src/main/org/codehaus/groovy/antlr/UnicodeLexerSharedInputState.java b/src/main/org/codehaus/groovy/antlr/UnicodeLexerSharedInputState.java
new file mode 100644
index 0000000..b1ad16b
--- /dev/null
+++ b/src/main/org/codehaus/groovy/antlr/UnicodeLexerSharedInputState.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2011 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.codehaus.groovy.antlr;
+
+import antlr.LexerSharedInputState;
+
+/**
+ * GRECLIPSE-805 Support for unicode escape sequences
+ * @author Andrew Eisenberg
+ * @created Mar 3, 2011
+ */
+public class UnicodeLexerSharedInputState extends LexerSharedInputState {
+ private final UnicodeEscapingReader escapingReader;
+
+ private int prevUnescape;
+
+ public UnicodeLexerSharedInputState(UnicodeEscapingReader in) {
+ super(in);
+ escapingReader = in;
+ }
+
+ @Override
+ public int getColumn() {
+ prevUnescape = escapingReader.getUnescapedUnicodeColumnCount();
+ return super.getColumn() + prevUnescape;
+ }
+
+ @Override
+ public int getTokenStartColumn() {
+ if (line == tokenStartLine) {
+ return super.getTokenStartColumn() + escapingReader.getUnescapedUnicodeColumnCount();
+ } else {
+ return super.getTokenStartColumn() + prevUnescape;
+ }
+ }
+}
\ No newline at end of file