mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-68196 XPath 2: double literal in scientific notation is red
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -30,11 +30,22 @@ public class XPathNumberImpl extends XPathElementImpl implements XPathNumber {
|
||||
|
||||
@NotNull
|
||||
public XPathType getType() {
|
||||
return getXPathVersion() == XPathVersion.V1 ? XPathType.NUMBER :
|
||||
(textContains('.') ? XPath2Type.DOUBLE : XPath2Type.INTEGER);
|
||||
if (getXPathVersion() == XPathVersion.V1) {
|
||||
return XPathType.NUMBER;
|
||||
} else {
|
||||
if (textContains('.')) {
|
||||
return isScientificNotation() ? XPath2Type.DOUBLE : XPath2Type.DECIMAL;
|
||||
} else {
|
||||
return XPath2Type.INTEGER;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public double getValue() {
|
||||
public boolean isScientificNotation() {
|
||||
return textContains('e') || textContains('E');
|
||||
}
|
||||
|
||||
public double getValue() {
|
||||
return Double.parseDouble(getText());
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ import org.intellij.lang.xpath.context.functions.Parameter;
|
||||
import org.intellij.lang.xpath.psi.*;
|
||||
import org.intellij.lang.xpath.psi.impl.PrefixedNameImpl;
|
||||
import org.intellij.lang.xpath.psi.impl.XPathChangeUtil;
|
||||
import org.intellij.lang.xpath.psi.impl.XPathNumberImpl;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
@@ -146,6 +147,10 @@ public final class XPathAnnotator extends XPath2ElementVisitor implements Annota
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (((XPathNumberImpl)number).isScientificNotation()) {
|
||||
myHolder.createErrorAnnotation(number, "Number literals in scientific notation are not allowed in XPath 1.0");
|
||||
}
|
||||
}
|
||||
|
||||
super.visitXPathNumber(number);
|
||||
|
||||
@@ -44,7 +44,7 @@ QName=({NCName} ":")? {NCName}
|
||||
|
||||
STRING_LITERAL= "\"" ([^\"]|"\"\"")* "\""? | "'" ([^\']|"''")* "'"?
|
||||
DIGITS=[:digit:]+
|
||||
NUMBER= {DIGITS} ("." {DIGITS}?)? | "." {DIGITS}
|
||||
NUMBER= ({DIGITS} ("." {DIGITS}?)? | "." {DIGITS}) ([eE] [+-]? {DIGITS})?
|
||||
|
||||
AXIS= "ancestor"
|
||||
| "ancestor-or-self"
|
||||
|
||||
@@ -63,6 +63,10 @@ public class XPath2ParsingTest extends TestBase {
|
||||
doXPathHighlighting();
|
||||
}
|
||||
|
||||
public void testDoubleLiterals() throws Throwable {
|
||||
doXPathHighlighting();
|
||||
}
|
||||
|
||||
private void doXPathHighlighting(String... moreFiles) throws Throwable {
|
||||
final String name = getTestFileName();
|
||||
myFixture.testHighlighting(false, false, false, ArrayUtil.append(moreFiles, name + ".xpath2"));
|
||||
|
||||
@@ -60,6 +60,10 @@ public class XPathHighlightingTest extends TestBase {
|
||||
doXPathHighlighting();
|
||||
}
|
||||
|
||||
public void testScientificNotationNumber() throws Throwable {
|
||||
doXPathHighlighting();
|
||||
}
|
||||
|
||||
private void doXPathHighlighting(String... moreFiles) throws Throwable {
|
||||
final String name = getTestFileName();
|
||||
myFixture.testHighlighting(true, false, false, ArrayUtil.append(moreFiles, name + ".xpath"));
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<error descr="Number literals in scientific notation are not allowed in XPath 1.0">1.1e2</error>
|
||||
@@ -0,0 +1 @@
|
||||
+1.2E-1 + -1.2E+1 + .12E1
|
||||
Reference in New Issue
Block a user