diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2013-03-20 16:09:04 +0100 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2013-04-27 15:33:20 +0200 |
commit | a8edefcef8905ed3487c7293056f6d0946e79dd7 (patch) | |
tree | 2bcf87b30a70492f4586d2e1dbb98a11bc626223 /src | |
parent | 403ba8938f115215700e677523d91710c20b6be4 (diff) | |
download | scala-a8edefcef8905ed3487c7293056f6d0946e79dd7.tar.gz scala-a8edefcef8905ed3487c7293056f6d0946e79dd7.tar.bz2 scala-a8edefcef8905ed3487c7293056f6d0946e79dd7.zip |
SI-7271 fixes positions of string interpolation parts
Positions of static parts are now set explicitly during parsing rather
than filled in wholesale during subsequent atPos after parsing.
I also had to change the offsets that scanner uses for initial static
parts of string interpolations so that they no longer point to the
opening double quote, but rather to the actual beginning of the part.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/parser/Parsers.scala | 4 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/parser/Scanners.scala | 2 |
2 files changed, 4 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index 6f79f639b9..9c936ea2c5 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -1152,7 +1152,7 @@ self => val exprBuf = new ListBuffer[Tree] in.nextToken() while (in.token == STRINGPART) { - partsBuf += literal() + partsBuf += atPos(in.offset)(literal()) exprBuf += { if (inPattern) dropAnyBraces(pattern()) else { @@ -1166,7 +1166,7 @@ self => } } } - if (in.token == STRINGLIT) partsBuf += literal() + if (in.token == STRINGLIT) partsBuf += atPos(in.offset)(literal()) val t1 = atPos(o2p(start)) { Ident(nme.StringContext) } val t2 = atPos(start) { Apply(t1, partsBuf.toList) } diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala index c05906c740..1aa50be83a 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala @@ -425,6 +425,7 @@ trait Scanners extends ScannersCommon { if (ch == '\"') { nextRawChar() if (ch == '\"') { + offset += 3 nextRawChar() getStringPart(multiLine = true) sepRegions = STRINGPART :: sepRegions // indicate string part @@ -434,6 +435,7 @@ trait Scanners extends ScannersCommon { strVal = "" } } else { + offset += 1 getStringPart(multiLine = false) sepRegions = STRINGLIT :: sepRegions // indicate single line string part } |