Lines 54-59
Link Here
|
54 |
import org.eclipse.jdt.core.dom.CharacterLiteral; |
54 |
import org.eclipse.jdt.core.dom.CharacterLiteral; |
55 |
import org.eclipse.jdt.core.dom.ClassInstanceCreation; |
55 |
import org.eclipse.jdt.core.dom.ClassInstanceCreation; |
56 |
import org.eclipse.jdt.core.dom.CompilationUnit; |
56 |
import org.eclipse.jdt.core.dom.CompilationUnit; |
|
|
57 |
import org.eclipse.jdt.core.dom.ConditionalExpression; |
57 |
import org.eclipse.jdt.core.dom.ConstructorInvocation; |
58 |
import org.eclipse.jdt.core.dom.ConstructorInvocation; |
58 |
import org.eclipse.jdt.core.dom.EnumDeclaration; |
59 |
import org.eclipse.jdt.core.dom.EnumDeclaration; |
59 |
import org.eclipse.jdt.core.dom.Expression; |
60 |
import org.eclipse.jdt.core.dom.Expression; |
Lines 117-123
Link Here
|
117 |
static { |
118 |
static { |
118 |
// TESTS_NAMES = new String[] {"test0602"}; |
119 |
// TESTS_NAMES = new String[] {"test0602"}; |
119 |
// TESTS_RANGE = new int[] { 670, -1 }; |
120 |
// TESTS_RANGE = new int[] { 670, -1 }; |
120 |
// TESTS_NUMBERS = new int[] { 677 }; |
121 |
// TESTS_NUMBERS = new int[] { 678 }; |
121 |
} |
122 |
} |
122 |
public static Test suite() { |
123 |
public static Test suite() { |
123 |
return buildModelTestSuite(ASTConverterTestAST3_2.class); |
124 |
return buildModelTestSuite(ASTConverterTestAST3_2.class); |
Lines 9229-9232
Link Here
|
9229 |
assertNotNull("No fields", fields); |
9230 |
assertNotNull("No fields", fields); |
9230 |
assertTrue("Empty", fields.length != 0); |
9231 |
assertTrue("Empty", fields.length != 0); |
9231 |
} |
9232 |
} |
|
|
9233 |
|
9234 |
/* |
9235 |
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=193979 |
9236 |
*/ |
9237 |
public void test0678() throws JavaModelException { |
9238 |
ICompilationUnit workingCopy = null; |
9239 |
try { |
9240 |
String contents = |
9241 |
"public class X {\n" + |
9242 |
" public String foo() {\n" + |
9243 |
" return((true ? \"\" : (\"Hello\" + \" World\") + \"!\"));\n" + |
9244 |
" }\n" + |
9245 |
"}"; |
9246 |
workingCopy = getWorkingCopy("/Converter/src/X.java", true/*resolve*/); |
9247 |
ASTNode node = buildAST( |
9248 |
contents, |
9249 |
workingCopy); |
9250 |
assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType()); |
9251 |
CompilationUnit unit = (CompilationUnit) node; |
9252 |
assertProblemsSize(unit, 0); |
9253 |
node = getASTNode(unit, 0, 0, 0); |
9254 |
assertEquals("Not a return statement", ASTNode.RETURN_STATEMENT, node.getNodeType()); |
9255 |
ReturnStatement returnStatement = (ReturnStatement) node; |
9256 |
Expression expression = returnStatement.getExpression(); |
9257 |
assertNotNull("No expression", expression); |
9258 |
assertEquals("Not a parenthesized expression", ASTNode.PARENTHESIZED_EXPRESSION, expression.getNodeType()); |
9259 |
expression = ((ParenthesizedExpression) expression).getExpression(); |
9260 |
assertEquals("Not a parenthesized expression", ASTNode.PARENTHESIZED_EXPRESSION, expression.getNodeType()); |
9261 |
expression = ((ParenthesizedExpression) expression).getExpression(); |
9262 |
assertEquals("Not a conditional expression", ASTNode.CONDITIONAL_EXPRESSION, expression.getNodeType()); |
9263 |
ConditionalExpression conditionalExpression = (ConditionalExpression) expression; |
9264 |
final Expression elseExpression = conditionalExpression.getElseExpression(); |
9265 |
assertEquals("Not an infix expression", ASTNode.INFIX_EXPRESSION, elseExpression.getNodeType()); |
9266 |
InfixExpression infixExpression = (InfixExpression) elseExpression; |
9267 |
List extendedOperands = infixExpression.extendedOperands(); |
9268 |
assertEquals("wrong size", 0, extendedOperands.size()); |
9269 |
Expression leftOperand = infixExpression.getLeftOperand(); |
9270 |
assertEquals("Not a parenthesized expression", ASTNode.PARENTHESIZED_EXPRESSION, leftOperand.getNodeType()); |
9271 |
ParenthesizedExpression parenthesizedExpression = (ParenthesizedExpression) leftOperand; |
9272 |
assertEquals("Not an infix expression", ASTNode.INFIX_EXPRESSION, parenthesizedExpression.getExpression().getNodeType()); |
9273 |
Expression rightOperand = infixExpression.getRightOperand(); |
9274 |
assertEquals("Not a string literal", ASTNode.STRING_LITERAL, rightOperand.getNodeType()); |
9275 |
StringLiteral stringLiteral = (StringLiteral) rightOperand; |
9276 |
assertEquals("wrong value", "!", stringLiteral.getLiteralValue()); |
9277 |
infixExpression = (InfixExpression) parenthesizedExpression.getExpression(); |
9278 |
leftOperand = infixExpression.getLeftOperand(); |
9279 |
assertEquals("Not a string literal", ASTNode.STRING_LITERAL, leftOperand.getNodeType()); |
9280 |
stringLiteral = (StringLiteral) leftOperand; |
9281 |
assertEquals("wrong value", "Hello", stringLiteral.getLiteralValue()); |
9282 |
rightOperand = infixExpression.getRightOperand(); |
9283 |
assertEquals("Not a string literal", ASTNode.STRING_LITERAL, rightOperand.getNodeType()); |
9284 |
stringLiteral = (StringLiteral) rightOperand; |
9285 |
assertEquals("wrong value", " World", stringLiteral.getLiteralValue()); |
9286 |
assertEquals("Wrong size", 0, infixExpression.extendedOperands().size()); |
9287 |
} finally { |
9288 |
if (workingCopy != null) |
9289 |
workingCopy.discardWorkingCopy(); |
9290 |
} |
9291 |
} |
9232 |
} |
9292 |
} |