+30
-7
lines changedFilter options
+30
-7
lines changed Original file line number Diff line number Diff line change
@@ -1599,18 +1599,22 @@ public Void visitMemberSelect(MemberSelectTree node, Void unused) {
1599
1599
public Void visitLiteral(LiteralTree node, Void unused) {
1600
1600
sync(node);
1601
1601
String sourceForNode = getSourceForNode(node, getCurrentPath());
1602
-
// A negative numeric literal -n is usually represented as unary minus on n,
1603
-
// but that doesn't work for integer or long MIN_VALUE. The parser works
1604
-
// around that by representing it directly as a signed literal (with no
1605
-
// unary minus), but the lexer still expects two tokens.
1606
-
if (sourceForNode.startsWith("-")) {
1602
+
if (isUnaryMinusLiteral(sourceForNode)) {
1607
1603
token("-");
1608
1604
sourceForNode = sourceForNode.substring(1).trim();
1609
1605
}
1610
1606
token(sourceForNode);
1611
1607
return null;
1612
1608
}
1613
1609
1610
+
// A negative numeric literal -n is usually represented as unary minus on n,
1611
+
// but that doesn't work for integer or long MIN_VALUE. The parser works
1612
+
// around that by representing it directly as a signed literal (with no
1613
+
// unary minus), but the lexer still expects two tokens.
1614
+
private static boolean isUnaryMinusLiteral(String literalTreeSource) {
1615
+
return literalTreeSource.startsWith("-");
1616
+
}
1617
+
1614
1618
private void visitPackage(
1615
1619
ExpressionTree packageName, List<? extends AnnotationTree> packageAnnotations) {
1616
1620
if (!packageAnnotations.isEmpty()) {
@@ -1696,10 +1700,10 @@ private boolean ambiguousUnaryOperator(UnaryTree node, String operatorName) {
1696
1700
default:
1697
1701
return false;
1698
1702
}
1699
-
if (!(node.getExpression() instanceof UnaryTree)) {
1703
+
JCTree.Tag tag = unaryTag(node.getExpression());
1704
+
if (tag == null) {
1700
1705
return false;
1701
1706
}
1702
-
JCTree.Tag tag = ((JCTree) node.getExpression()).getTag();
1703
1707
if (tag.isPostUnaryOp()) {
1704
1708
return false;
1705
1709
}
@@ -1709,6 +1713,17 @@ private boolean ambiguousUnaryOperator(UnaryTree node, String operatorName) {
1709
1713
return true;
1710
1714
}
1711
1715
1716
+
private JCTree.Tag unaryTag(ExpressionTree expression) {
1717
+
if (expression instanceof UnaryTree) {
1718
+
return ((JCTree) expression).getTag();
1719
+
}
1720
+
if (expression instanceof LiteralTree
1721
+
&& isUnaryMinusLiteral(getSourceForNode(expression, getCurrentPath()))) {
1722
+
return JCTree.Tag.MINUS;
1723
+
}
1724
+
return null;
1725
+
}
1726
+
1712
1727
@Override
1713
1728
public Void visitPrimitiveType(PrimitiveTypeTree node, Void unused) {
1714
1729
sync(node);
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
1
+
class B183431894 {
2
+
int a = - -1;
3
+
int d = + +1;
4
+
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
1
+
class B183431894 {
2
+
int a = - -1;
3
+
int d = + +1;
4
+
}
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4