From 3426d318446dece541fe99bed24d9d0fd155f404 Mon Sep 17 00:00:00 2001 From: Oleg Sukhodolsky Date: Sat, 9 Feb 2013 17:03:57 +0400 Subject: [PATCH] RUBY-12161: special case to parse valid octal chars #RUBY-12161 fixed --- .../lang/regexp/psi/impl/RegExpCharImpl.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/RegExpSupport/src/org/intellij/lang/regexp/psi/impl/RegExpCharImpl.java b/RegExpSupport/src/org/intellij/lang/regexp/psi/impl/RegExpCharImpl.java index ccff8a4a0e12..5ebee1d74d22 100644 --- a/RegExpSupport/src/org/intellij/lang/regexp/psi/impl/RegExpCharImpl.java +++ b/RegExpSupport/src/org/intellij/lang/regexp/psi/impl/RegExpCharImpl.java @@ -57,7 +57,23 @@ public class RegExpCharImpl extends RegExpElementImpl implements RegExpChar { @Nullable public Character getValue() { final String s = getUnescapedText(); - if (s.equals("\\") && getType() == Type.CHAR) return '\\'; + if (s.equals("\\") && getType() == Type.CHAR) { + return '\\'; + } + // special case for valid octal escaped sequences (see RUBY-12161) + if (s.startsWith("\\") && s.length() > 1) { + final ASTNode child = getNode().getFirstChildNode(); + assert child != null; + final IElementType t = child.getElementType(); + if (t == RegExpTT.OCT_CHAR) { + try { + return (char) Integer.parseInt(s.substring(1), 8); + } + catch (NumberFormatException e) { + // do nothing + } + } + } return unescapeChar(s); }